-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'openiked:master' into master
- Loading branch information
Showing
39 changed files
with
695 additions
and
383 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/* $OpenBSD: arc4random.c,v 1.55 2019/03/24 17:56:54 deraadt Exp $ */ | ||
/* $OpenBSD: arc4random.c,v 1.58 2022/07/31 13:41:45 tb Exp $ */ | ||
|
||
/* | ||
* Copyright (c) 1996, David Mazieres <[email protected]> | ||
|
@@ -49,6 +49,8 @@ | |
#define BLOCKSZ 64 | ||
#define RSBUFSZ (16*BLOCKSZ) | ||
|
||
#define REKEY_BASE (1024*1024) /* NB. should be a power of 2 */ | ||
|
||
/* Marked MAP_INHERIT_ZERO, so zero'd out in fork children. */ | ||
static struct _rs { | ||
size_t rs_have; /* valid bytes at end of rs_buf */ | ||
|
@@ -78,14 +80,15 @@ _rs_init(u_char *buf, size_t n) | |
_exit(1); | ||
} | ||
|
||
chacha_keysetup(&rsx->rs_chacha, buf, KEYSZ * 8, 0); | ||
chacha_keysetup(&rsx->rs_chacha, buf, KEYSZ * 8); | ||
chacha_ivsetup(&rsx->rs_chacha, buf + KEYSZ); | ||
} | ||
|
||
static void | ||
_rs_stir(void) | ||
{ | ||
u_char rnd[KEYSZ + IVSZ]; | ||
uint32_t rekey_fuzz = 0; | ||
|
||
if (getentropy(rnd, sizeof rnd) == -1) | ||
_getentropy_fail(); | ||
|
@@ -100,7 +103,10 @@ _rs_stir(void) | |
rs->rs_have = 0; | ||
memset(rsx->rs_buf, 0, sizeof(rsx->rs_buf)); | ||
|
||
rs->rs_count = 1600000; | ||
/* rekey interval should not be predictable */ | ||
chacha_encrypt_bytes(&rsx->rs_chacha, (uint8_t *)&rekey_fuzz, | ||
(uint8_t *)&rekey_fuzz, sizeof(rekey_fuzz)); | ||
rs->rs_count = REKEY_BASE + (rekey_fuzz % REKEY_BASE); | ||
} | ||
|
||
static inline void | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
/* $OpenBSD: getopt_long.c,v 1.25 2011/03/05 22:10:11 guenther Exp $ */ | ||
/* $OpenBSD: getopt_long.c,v 1.32 2020/05/27 22:25:09 schwarze Exp $ */ | ||
/* $NetBSD: getopt_long.c,v 1.15 2002/01/31 22:43:40 tv Exp $ */ | ||
|
||
/* | ||
* Copyright (c) 2002 Todd C. Miller <[email protected]> | ||
* Copyright (c) 2002 Todd C. Miller <[email protected]> | ||
* | ||
* Permission to use, copy, modify, and distribute this software for any | ||
* purpose with or without fee is hereby granted, provided that the above | ||
|
@@ -55,11 +55,10 @@ | |
#if !defined(HAVE_GETOPT) | ||
|
||
#include <err.h> | ||
#include <getopt.h> | ||
#include <errno.h> | ||
#include <getopt.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <stdarg.h> | ||
|
||
int opterr = 1; /* if error message should be printed */ | ||
int optind = 1; /* index into parent argv vector */ | ||
|
@@ -83,7 +82,7 @@ char *optarg; /* argument associated with option */ | |
static int getopt_internal(int, char * const *, const char *, | ||
const struct option *, int *, int); | ||
static int parse_long_options(char * const *, const char *, | ||
const struct option *, int *, int); | ||
const struct option *, int *, int, int); | ||
static int gcd(int, int); | ||
static void permute_args(int, int, int, char * const *); | ||
|
||
|
@@ -148,9 +147,7 @@ permute_args(int panonopt_start, int panonopt_end, int opt_end, | |
else | ||
pos += nopts; | ||
swap = nargv[pos]; | ||
/* LINTED const cast */ | ||
((char **) nargv)[pos] = nargv[cstart]; | ||
/* LINTED const cast */ | ||
((char **)nargv)[pos] = nargv[cstart]; | ||
((char **)nargv)[cstart] = swap; | ||
} | ||
} | ||
|
@@ -163,14 +160,16 @@ permute_args(int panonopt_start, int panonopt_end, int opt_end, | |
*/ | ||
static int | ||
parse_long_options(char * const *nargv, const char *options, | ||
const struct option *long_options, int *idx, int short_too) | ||
const struct option *long_options, int *idx, int short_too, int flags) | ||
{ | ||
char *current_argv, *has_equal; | ||
size_t current_argv_len; | ||
int i, match; | ||
int i, match, exact_match, second_partial_match; | ||
|
||
current_argv = place; | ||
match = -1; | ||
exact_match = 0; | ||
second_partial_match = 0; | ||
|
||
optind++; | ||
|
||
|
@@ -190,6 +189,7 @@ parse_long_options(char * const *nargv, const char *options, | |
if (strlen(long_options[i].name) == current_argv_len) { | ||
/* exact match */ | ||
match = i; | ||
exact_match = 1; | ||
break; | ||
} | ||
/* | ||
|
@@ -199,16 +199,20 @@ parse_long_options(char * const *nargv, const char *options, | |
if (short_too && current_argv_len == 1) | ||
continue; | ||
|
||
if (match == -1) /* partial match */ | ||
if (match == -1) /* first partial match */ | ||
match = i; | ||
else { | ||
/* ambiguous abbreviation */ | ||
if (PRINT_ERROR) | ||
warnx(ambig, (int)current_argv_len, | ||
current_argv); | ||
optopt = 0; | ||
return (BADCH); | ||
} | ||
else if ((flags & FLAG_LONGONLY) || | ||
long_options[i].has_arg != long_options[match].has_arg || | ||
long_options[i].flag != long_options[match].flag || | ||
long_options[i].val != long_options[match].val) | ||
second_partial_match = 1; | ||
} | ||
if (!exact_match && second_partial_match) { | ||
/* ambiguous abbreviation */ | ||
if (PRINT_ERROR) | ||
warnx(ambig, (int)current_argv_len, current_argv); | ||
optopt = 0; | ||
return (BADCH); | ||
} | ||
if (match != -1) { /* option found */ | ||
if (long_options[match].has_arg == no_argument | ||
|
@@ -404,23 +408,15 @@ getopt_internal(int nargc, char * const *nargv, const char *options, | |
short_too = 1; /* could be short option too */ | ||
|
||
optchar = parse_long_options(nargv, options, long_options, | ||
idx, short_too); | ||
idx, short_too, flags); | ||
if (optchar != -1) { | ||
place = EMSG; | ||
return (optchar); | ||
} | ||
} | ||
|
||
if ((optchar = (int)*place++) == (int)':' || | ||
(optchar == (int)'-' && *place != '\0') || | ||
(oli = strchr(options, optchar)) == NULL) { | ||
/* | ||
* If the user specified "-" and '-' isn't listed in | ||
* options, return -1 (non-option) as per POSIX. | ||
* Otherwise, it is an unknown option character (or ':'). | ||
*/ | ||
if (optchar == (int)'-' && *place == '\0') | ||
return (-1); | ||
if (!*place) | ||
++optind; | ||
if (PRINT_ERROR) | ||
|
@@ -441,7 +437,7 @@ getopt_internal(int nargc, char * const *nargv, const char *options, | |
} else /* white space */ | ||
place = nargv[optind]; | ||
optchar = parse_long_options(nargv, options, long_options, | ||
idx, 0); | ||
idx, 0, flags); | ||
place = EMSG; | ||
return (optchar); | ||
} | ||
|
@@ -472,8 +468,6 @@ getopt_internal(int nargc, char * const *nargv, const char *options, | |
/* | ||
* getopt -- | ||
* Parse argc/argv argument vector. | ||
* | ||
* [eventually this will replace the BSD getopt] | ||
*/ | ||
int | ||
getopt(int nargc, char * const *nargv, const char *options) | ||
|
Oops, something went wrong.