Changeset View
Changeset View
Standalone View
Standalone View
head/contrib/ntp/util/ntp-keygen.c
Show First 20 Lines • Show All 636 Lines • ▼ Show 20 Lines | gen_md5( | ||||
int i, j; | int i, j; | ||||
fprintf(stderr, "Generating MD5 keys...\n"); | fprintf(stderr, "Generating MD5 keys...\n"); | ||||
str = fheader("MD5key", hostname); | str = fheader("MD5key", hostname); | ||||
ntp_srandom(epoch); | ntp_srandom(epoch); | ||||
for (i = 1; i <= MD5KEYS; i++) { | for (i = 1; i <= MD5KEYS; i++) { | ||||
for (j = 0; j < 16; j++) { | for (j = 0; j < 16; j++) { | ||||
while (1) { | while (1) { | ||||
temp = ntp_random() & 0xff; | temp = arc4random() & 0xff; | ||||
if (temp == '#') | if (temp == '#') | ||||
continue; | continue; | ||||
if (temp > 0x20 && temp < 0x7f) | if (temp > 0x20 && temp < 0x7f) | ||||
break; | break; | ||||
} | } | ||||
md5key[j] = (u_char)temp; | md5key[j] = (u_char)temp; | ||||
} | } | ||||
md5key[15] = '\0'; | md5key[15] = '\0'; | ||||
Show All 16 Lines | gen_rsa( | ||||
char *id /* file name id */ | char *id /* file name id */ | ||||
) | ) | ||||
{ | { | ||||
EVP_PKEY *pkey; /* private key */ | EVP_PKEY *pkey; /* private key */ | ||||
RSA *rsa; /* RSA parameters and key pair */ | RSA *rsa; /* RSA parameters and key pair */ | ||||
FILE *str; | FILE *str; | ||||
fprintf(stderr, "Generating RSA keys (%d bits)...\n", modulus); | fprintf(stderr, "Generating RSA keys (%d bits)...\n", modulus); | ||||
rsa = RSA_generate_key(modulus, 3, cb, "RSA"); | rsa = RSA_generate_key(modulus, 65537, cb, "RSA"); | ||||
fprintf(stderr, "\n"); | fprintf(stderr, "\n"); | ||||
if (rsa == NULL) { | if (rsa == NULL) { | ||||
fprintf(stderr, "RSA generate keys fails\n%s\n", | fprintf(stderr, "RSA generate keys fails\n%s\n", | ||||
ERR_error_string(ERR_get_error(), NULL)); | ERR_error_string(ERR_get_error(), NULL)); | ||||
rval = -1; | rval = -1; | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 262 Lines • ▼ Show 20 Lines | gen_gqpar( | ||||
BN_CTX *ctx; /* BN working space */ | BN_CTX *ctx; /* BN working space */ | ||||
FILE *str; | FILE *str; | ||||
/* | /* | ||||
* Generate RSA parameters for use as GQ parameters. | * Generate RSA parameters for use as GQ parameters. | ||||
*/ | */ | ||||
fprintf(stderr, | fprintf(stderr, | ||||
"Generating GQ parameters (%d bits)...\n", modulus); | "Generating GQ parameters (%d bits)...\n", modulus); | ||||
rsa = RSA_generate_key(modulus, 3, cb, "GQ"); | rsa = RSA_generate_key(modulus, 65537, cb, "GQ"); | ||||
fprintf(stderr, "\n"); | fprintf(stderr, "\n"); | ||||
if (rsa == NULL) { | if (rsa == NULL) { | ||||
fprintf(stderr, "RSA generate keys fails\n%s\n", | fprintf(stderr, "RSA generate keys fails\n%s\n", | ||||
ERR_error_string(ERR_get_error(), NULL)); | ERR_error_string(ERR_get_error(), NULL)); | ||||
rval = -1; | rval = -1; | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 925 Lines • Show Last 20 Lines |