Version bump
This commit is contained in:
+37
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2004-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2004-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -11,7 +11,7 @@
|
||||
* This file is dual-licensed and is also available under the following
|
||||
* terms:
|
||||
*
|
||||
* Copyright (c) 2004, Richard Levitte <richard@levitte.org>
|
||||
* Copyright (c) 2004, 2018, Richard Levitte <richard@levitte.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -46,6 +46,9 @@
|
||||
#ifndef LPDIR_H
|
||||
# include "LPdir.h"
|
||||
#endif
|
||||
#ifdef __VMS
|
||||
# include <ctype.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The POSIXly macro for the maximum number of characters in a file path is
|
||||
@@ -73,6 +76,10 @@
|
||||
struct LP_dir_context_st {
|
||||
DIR *dir;
|
||||
char entry_name[LP_ENTRY_SIZE + 1];
|
||||
#ifdef __VMS
|
||||
int expect_file_generations;
|
||||
char previous_entry_name[LP_ENTRY_SIZE + 1];
|
||||
#endif
|
||||
};
|
||||
|
||||
const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory)
|
||||
@@ -93,6 +100,15 @@ const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory)
|
||||
}
|
||||
memset(*ctx, 0, sizeof(**ctx));
|
||||
|
||||
#ifdef __VMS
|
||||
{
|
||||
char c = directory[strlen(directory) - 1];
|
||||
|
||||
if (c == ']' || c == '>' || c == ':')
|
||||
(*ctx)->expect_file_generations = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
(*ctx)->dir = opendir(directory);
|
||||
if ((*ctx)->dir == NULL) {
|
||||
int save_errno = errno; /* Probably not needed, but I'm paranoid */
|
||||
@@ -103,6 +119,13 @@ const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __VMS
|
||||
strncpy((*ctx)->previous_entry_name, (*ctx)->entry_name,
|
||||
sizeof((*ctx)->previous_entry_name));
|
||||
|
||||
again:
|
||||
#endif
|
||||
|
||||
direntry = readdir((*ctx)->dir);
|
||||
if (direntry == NULL) {
|
||||
return 0;
|
||||
@@ -111,6 +134,18 @@ const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory)
|
||||
strncpy((*ctx)->entry_name, direntry->d_name,
|
||||
sizeof((*ctx)->entry_name) - 1);
|
||||
(*ctx)->entry_name[sizeof((*ctx)->entry_name) - 1] = '\0';
|
||||
#ifdef __VMS
|
||||
if ((*ctx)->expect_file_generations) {
|
||||
char *p = (*ctx)->entry_name + strlen((*ctx)->entry_name);
|
||||
|
||||
while(p > (*ctx)->entry_name && isdigit(p[-1]))
|
||||
p--;
|
||||
if (p > (*ctx)->entry_name && p[-1] == ';')
|
||||
p[-1] = '\0';
|
||||
if (strcasecmp((*ctx)->entry_name, (*ctx)->previous_entry_name) == 0)
|
||||
goto again;
|
||||
}
|
||||
#endif
|
||||
return (*ctx)->entry_name;
|
||||
}
|
||||
|
||||
|
||||
Executable → Regular
@@ -203,7 +203,7 @@ AES_encrypt:
|
||||
adr r3,.
|
||||
#endif
|
||||
stmdb sp!,{r1,r4-r12,lr}
|
||||
#ifdef __APPLE__
|
||||
#if defined(__thumb2__) || defined(__APPLE__)
|
||||
adr $tbl,AES_Te
|
||||
#else
|
||||
sub $tbl,r3,#AES_encrypt-AES_Te @ Te
|
||||
@@ -481,7 +481,7 @@ _armv4_AES_set_encrypt_key:
|
||||
mov lr,r1 @ bits
|
||||
mov $key,r2 @ key
|
||||
|
||||
#ifdef __APPLE__
|
||||
#if defined(__thumb2__) || defined(__APPLE__)
|
||||
adr $tbl,AES_Te+1024 @ Te4
|
||||
#else
|
||||
sub $tbl,r3,#_armv4_AES_set_encrypt_key-AES_Te-1024 @ Te4
|
||||
@@ -979,7 +979,7 @@ AES_decrypt:
|
||||
adr r3,.
|
||||
#endif
|
||||
stmdb sp!,{r1,r4-r12,lr}
|
||||
#ifdef __APPLE__
|
||||
#if defined(__thumb2__) || defined(__APPLE__)
|
||||
adr $tbl,AES_Td
|
||||
#else
|
||||
sub $tbl,r3,#AES_decrypt-AES_Td @ Td
|
||||
|
||||
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
@@ -742,7 +742,7 @@ $code.=<<___;
|
||||
_bsaes_decrypt8:
|
||||
adr $const,.
|
||||
vldmia $key!, {@XMM[9]} @ round 0 key
|
||||
#ifdef __APPLE__
|
||||
#if defined(__thumb2__) || defined(__APPLE__)
|
||||
adr $const,.LM0ISR
|
||||
#else
|
||||
add $const,$const,#.LM0ISR-_bsaes_decrypt8
|
||||
@@ -841,7 +841,7 @@ _bsaes_const:
|
||||
_bsaes_encrypt8:
|
||||
adr $const,.
|
||||
vldmia $key!, {@XMM[9]} @ round 0 key
|
||||
#ifdef __APPLE__
|
||||
#if defined(__thumb2__) || defined(__APPLE__)
|
||||
adr $const,.LM0SR
|
||||
#else
|
||||
sub $const,$const,#_bsaes_encrypt8-.LM0SR
|
||||
@@ -949,7 +949,7 @@ $code.=<<___;
|
||||
_bsaes_key_convert:
|
||||
adr $const,.
|
||||
vld1.8 {@XMM[7]}, [$inp]! @ load round 0 key
|
||||
#ifdef __APPLE__
|
||||
#if defined(__thumb2__) || defined(__APPLE__)
|
||||
adr $const,.LM0
|
||||
#else
|
||||
sub $const,$const,#_bsaes_key_convert-.LM0
|
||||
|
||||
Executable → Regular
Executable → Regular
+1
-1
@@ -191,7 +191,7 @@ void OPENSSL_cpuid_setup(void)
|
||||
_armv8_sha256_probe();
|
||||
OPENSSL_armcap_P |= ARMV8_SHA256;
|
||||
}
|
||||
# ifdef __aarch64__
|
||||
# if defined(__aarch64__) && !defined(__APPLE__)
|
||||
if (sigsetjmp(ill_jmp, 1) == 0) {
|
||||
_armv8_sha512_probe();
|
||||
OPENSSL_armcap_P |= ARMV8_SHA512;
|
||||
|
||||
@@ -42,6 +42,7 @@ static const EVP_PKEY_ASN1_METHOD *standard_methods[] = {
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_EC
|
||||
&ecx25519_asn1_meth,
|
||||
&ecx448_asn1_meth,
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_POLY1305
|
||||
&poly1305_asn1_meth,
|
||||
@@ -51,6 +52,7 @@ static const EVP_PKEY_ASN1_METHOD *standard_methods[] = {
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_EC
|
||||
&ed25519_asn1_meth,
|
||||
&ed448_asn1_meth,
|
||||
#endif
|
||||
};
|
||||
|
||||
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
+4
-6
@@ -112,7 +112,7 @@ int BN_priv_rand(BIGNUM *rnd, int bits, int top, int bottom)
|
||||
/* random number r: 0 <= r < range */
|
||||
static int bnrand_range(BNRAND_FLAG flag, BIGNUM *r, const BIGNUM *range)
|
||||
{
|
||||
int b, n;
|
||||
int n;
|
||||
int count = 100;
|
||||
|
||||
if (range->neg || BN_is_zero(range)) {
|
||||
@@ -132,11 +132,9 @@ static int bnrand_range(BNRAND_FLAG flag, BIGNUM *r, const BIGNUM *range)
|
||||
* than range
|
||||
*/
|
||||
do {
|
||||
b = flag == NORMAL
|
||||
? BN_rand(r, n + 1, BN_RAND_TOP_ANY, BN_RAND_BOTTOM_ANY)
|
||||
: BN_priv_rand(r, n + 1, BN_RAND_TOP_ANY, BN_RAND_BOTTOM_ANY);
|
||||
if (!b)
|
||||
if (!bnrand(flag, r, n + 1, BN_RAND_TOP_ANY, BN_RAND_BOTTOM_ANY))
|
||||
return 0;
|
||||
|
||||
/*
|
||||
* If r < 3*range, use r := r MOD range (which is either r, r -
|
||||
* range, or r - 2*range). Otherwise, iterate once more. Since
|
||||
@@ -161,7 +159,7 @@ static int bnrand_range(BNRAND_FLAG flag, BIGNUM *r, const BIGNUM *range)
|
||||
} else {
|
||||
do {
|
||||
/* range = 11..._2 or range = 101..._2 */
|
||||
if (!BN_rand(r, n, BN_RAND_TOP_ANY, BN_RAND_BOTTOM_ANY))
|
||||
if (!bnrand(flag, r, n, BN_RAND_TOP_ANY, BN_RAND_BOTTOM_ANY))
|
||||
return 0;
|
||||
|
||||
if (!--count) {
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ EXTRA= ../ms/uplink-x86.pl ../ms/uplink.c ../ms/applink.c \
|
||||
ppccpuid.pl pariscid.pl alphacpuid.pl arm64cpuid.pl armv4cpuid.pl
|
||||
|
||||
DEPEND[cversion.o]=buildinf.h
|
||||
GENERATE[buildinf.h]=../util/mkbuildinf.pl "$(CC) $(CFLAGS) $(CPPFLAGS_Q)" "$(PLATFORM)"
|
||||
GENERATE[buildinf.h]=../util/mkbuildinf.pl "$(CC) $(LIB_CFLAGS) $(CPPFLAGS_Q)" "$(PLATFORM)"
|
||||
DEPEND[buildinf.h]=../configdata.pm
|
||||
|
||||
GENERATE[uplink-x86.s]=../ms/uplink-x86.pl $(PERLASM_SCHEME)
|
||||
|
||||
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
+204
-14
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -12,12 +12,20 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "internal/cryptlib.h"
|
||||
#include "internal/o_dir.h"
|
||||
#include <openssl/lhash.h>
|
||||
#include <openssl/conf.h>
|
||||
#include <openssl/conf_api.h>
|
||||
#include "conf_def.h"
|
||||
#include <openssl/buffer.h>
|
||||
#include <openssl/err.h>
|
||||
#ifndef OPENSSL_NO_POSIX_IO
|
||||
# include <sys/stat.h>
|
||||
# ifdef _WIN32
|
||||
# define stat _stat
|
||||
# define strcasecmp _stricmp
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The maximum length we can grow a value to after variable expansion. 64k
|
||||
@@ -26,12 +34,18 @@
|
||||
#define MAX_CONF_VALUE_LENGTH 65536
|
||||
|
||||
static char *eat_ws(CONF *conf, char *p);
|
||||
static void trim_ws(CONF *conf, char *start);
|
||||
static char *eat_alpha_numeric(CONF *conf, char *p);
|
||||
static void clear_comments(CONF *conf, char *p);
|
||||
static int str_copy(CONF *conf, char *section, char **to, char *from);
|
||||
static char *scan_quote(CONF *conf, char *p);
|
||||
static char *scan_dquote(CONF *conf, char *p);
|
||||
#define scan_esc(conf,p) (((IS_EOF((conf),(p)[1]))?((p)+1):((p)+2)))
|
||||
#ifndef OPENSSL_NO_POSIX_IO
|
||||
static BIO *process_include(char *include, OPENSSL_DIR_CTX **dirctx,
|
||||
char **dirpath);
|
||||
static BIO *get_next_file(const char *path, OPENSSL_DIR_CTX **dirctx);
|
||||
#endif
|
||||
|
||||
static CONF *def_create(CONF_METHOD *meth);
|
||||
static int def_init_default(CONF *conf);
|
||||
@@ -173,6 +187,11 @@ static int def_load_bio(CONF *conf, BIO *in, long *line)
|
||||
char *section = NULL, *buf;
|
||||
char *start, *psection, *pname;
|
||||
void *h = (void *)(conf->data);
|
||||
STACK_OF(BIO) *biosk = NULL;
|
||||
#ifndef OPENSSL_NO_POSIX_IO
|
||||
char *dirpath = NULL;
|
||||
OPENSSL_DIR_CTX *dirctx = NULL;
|
||||
#endif
|
||||
|
||||
if ((buff = BUF_MEM_new()) == NULL) {
|
||||
CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_BUF_LIB);
|
||||
@@ -205,11 +224,39 @@ static int def_load_bio(CONF *conf, BIO *in, long *line)
|
||||
}
|
||||
p = &(buff->data[bufnum]);
|
||||
*p = '\0';
|
||||
read_retry:
|
||||
BIO_gets(in, p, CONFBUFSIZE - 1);
|
||||
p[CONFBUFSIZE - 1] = '\0';
|
||||
ii = i = strlen(p);
|
||||
if (i == 0 && !again)
|
||||
break;
|
||||
if (i == 0 && !again) {
|
||||
/* the currently processed BIO is at EOF */
|
||||
BIO *parent;
|
||||
|
||||
#ifndef OPENSSL_NO_POSIX_IO
|
||||
/* continue processing with the next file from directory */
|
||||
if (dirctx != NULL) {
|
||||
BIO *next;
|
||||
|
||||
if ((next = get_next_file(dirpath, &dirctx)) != NULL) {
|
||||
BIO_vfree(in);
|
||||
in = next;
|
||||
goto read_retry;
|
||||
} else {
|
||||
OPENSSL_free(dirpath);
|
||||
dirpath = NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
/* no more files in directory, continue with processing parent */
|
||||
if ((parent = sk_BIO_pop(biosk)) == NULL) {
|
||||
/* everything processed get out of the loop */
|
||||
break;
|
||||
} else {
|
||||
BIO_vfree(in);
|
||||
in = parent;
|
||||
goto read_retry;
|
||||
}
|
||||
}
|
||||
again = 0;
|
||||
while (i > 0) {
|
||||
if ((p[i - 1] != '\r') && (p[i - 1] != '\n'))
|
||||
@@ -285,7 +332,6 @@ static int def_load_bio(CONF *conf, BIO *in, long *line)
|
||||
continue;
|
||||
} else {
|
||||
pname = s;
|
||||
psection = NULL;
|
||||
end = eat_alpha_numeric(conf, s);
|
||||
if ((end[0] == ':') && (end[1] == ':')) {
|
||||
*end = '\0';
|
||||
@@ -293,29 +339,57 @@ static int def_load_bio(CONF *conf, BIO *in, long *line)
|
||||
psection = pname;
|
||||
pname = end;
|
||||
end = eat_alpha_numeric(conf, end);
|
||||
} else {
|
||||
psection = section;
|
||||
}
|
||||
p = eat_ws(conf, end);
|
||||
if (*p != '=') {
|
||||
if (strncmp(pname, ".include", 8) == 0 && p != pname + 8) {
|
||||
char *include = NULL;
|
||||
BIO *next;
|
||||
|
||||
trim_ws(conf, p);
|
||||
if (!str_copy(conf, psection, &include, p))
|
||||
goto err;
|
||||
/* get the BIO of the included file */
|
||||
#ifndef OPENSSL_NO_POSIX_IO
|
||||
next = process_include(include, &dirctx, &dirpath);
|
||||
if (include != dirpath) {
|
||||
/* dirpath will contain include in case of a directory */
|
||||
OPENSSL_free(include);
|
||||
}
|
||||
#else
|
||||
next = BIO_new_file(include, "r");
|
||||
OPENSSL_free(include);
|
||||
#endif
|
||||
if (next != NULL) {
|
||||
/* push the currently processing BIO onto stack */
|
||||
if (biosk == NULL) {
|
||||
if ((biosk = sk_BIO_new_null()) == NULL) {
|
||||
CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
if (!sk_BIO_push(biosk, in)) {
|
||||
CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
/* continue with reading from the included BIO */
|
||||
in = next;
|
||||
}
|
||||
continue;
|
||||
} else if (*p != '=') {
|
||||
CONFerr(CONF_F_DEF_LOAD_BIO, CONF_R_MISSING_EQUAL_SIGN);
|
||||
goto err;
|
||||
}
|
||||
*end = '\0';
|
||||
p++;
|
||||
start = eat_ws(conf, p);
|
||||
while (!IS_EOF(conf, *p))
|
||||
p++;
|
||||
p--;
|
||||
while ((p != start) && (IS_WS(conf, *p)))
|
||||
p--;
|
||||
p++;
|
||||
*p = '\0';
|
||||
trim_ws(conf, start);
|
||||
|
||||
if ((v = OPENSSL_malloc(sizeof(*v))) == NULL) {
|
||||
CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
if (psection == NULL)
|
||||
psection = section;
|
||||
v->name = OPENSSL_strdup(pname);
|
||||
v->value = NULL;
|
||||
if (v->name == NULL) {
|
||||
@@ -345,10 +419,17 @@ static int def_load_bio(CONF *conf, BIO *in, long *line)
|
||||
}
|
||||
BUF_MEM_free(buff);
|
||||
OPENSSL_free(section);
|
||||
sk_BIO_pop_free(biosk, BIO_vfree);
|
||||
return 1;
|
||||
err:
|
||||
BUF_MEM_free(buff);
|
||||
OPENSSL_free(section);
|
||||
sk_BIO_pop_free(biosk, BIO_vfree);
|
||||
#ifndef OPENSSL_NO_POSIX_IO
|
||||
OPENSSL_free(dirpath);
|
||||
if (dirctx != NULL)
|
||||
OPENSSL_DIR_end(&dirctx);
|
||||
#endif
|
||||
if (line != NULL)
|
||||
*line = eline;
|
||||
BIO_snprintf(btmp, sizeof(btmp), "%ld", eline);
|
||||
@@ -555,6 +636,102 @@ static int str_copy(CONF *conf, char *section, char **pto, char *from)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef OPENSSL_NO_POSIX_IO
|
||||
/*
|
||||
* Check whether included path is a directory.
|
||||
* Returns next BIO to process and in case of a directory
|
||||
* also an opened directory context and the include path.
|
||||
*/
|
||||
static BIO *process_include(char *include, OPENSSL_DIR_CTX **dirctx,
|
||||
char **dirpath)
|
||||
{
|
||||
struct stat st = { 0 };
|
||||
BIO *next;
|
||||
|
||||
if (stat(include, &st) < 0) {
|
||||
SYSerr(SYS_F_STAT, errno);
|
||||
ERR_add_error_data(1, include);
|
||||
/* missing include file is not fatal error */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((st.st_mode & S_IFDIR) == S_IFDIR) {
|
||||
if (*dirctx != NULL) {
|
||||
CONFerr(CONF_F_PROCESS_INCLUDE,
|
||||
CONF_R_RECURSIVE_DIRECTORY_INCLUDE);
|
||||
ERR_add_error_data(1, include);
|
||||
return NULL;
|
||||
}
|
||||
/* a directory, load its contents */
|
||||
if ((next = get_next_file(include, dirctx)) != NULL)
|
||||
*dirpath = include;
|
||||
return next;
|
||||
}
|
||||
|
||||
next = BIO_new_file(include, "r");
|
||||
return next;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get next file from the directory path.
|
||||
* Returns BIO of the next file to read and updates dirctx.
|
||||
*/
|
||||
static BIO *get_next_file(const char *path, OPENSSL_DIR_CTX **dirctx)
|
||||
{
|
||||
const char *filename;
|
||||
|
||||
while ((filename = OPENSSL_DIR_read(dirctx, path)) != NULL) {
|
||||
size_t namelen;
|
||||
|
||||
namelen = strlen(filename);
|
||||
|
||||
|
||||
if ((namelen > 5 && strcasecmp(filename + namelen - 5, ".conf") == 0)
|
||||
|| (namelen > 4 && strcasecmp(filename + namelen - 4, ".cnf") == 0)) {
|
||||
size_t newlen;
|
||||
char *newpath;
|
||||
BIO *bio;
|
||||
|
||||
newlen = strlen(path) + namelen + 2;
|
||||
newpath = OPENSSL_zalloc(newlen);
|
||||
if (newpath == NULL) {
|
||||
CONFerr(CONF_F_GET_NEXT_FILE, ERR_R_MALLOC_FAILURE);
|
||||
break;
|
||||
}
|
||||
#ifdef OPENSSL_SYS_VMS
|
||||
/*
|
||||
* If the given path isn't clear VMS syntax,
|
||||
* we treat it as on Unix.
|
||||
*/
|
||||
{
|
||||
size_t pathlen = strlen(path);
|
||||
|
||||
if (path[pathlen - 1] == ']' || path[pathlen - 1] == '>'
|
||||
|| path[pathlen - 1] == ':') {
|
||||
/* Clear VMS directory syntax, just copy as is */
|
||||
OPENSSL_strlcpy(newpath, path, newlen);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (newpath[0] == '\0') {
|
||||
OPENSSL_strlcpy(newpath, path, newlen);
|
||||
OPENSSL_strlcat(newpath, "/", newlen);
|
||||
}
|
||||
OPENSSL_strlcat(newpath, filename, newlen);
|
||||
|
||||
bio = BIO_new_file(newpath, "r");
|
||||
OPENSSL_free(newpath);
|
||||
/* Errors when opening files are non-fatal. */
|
||||
if (bio != NULL)
|
||||
return bio;
|
||||
}
|
||||
}
|
||||
OPENSSL_DIR_end(dirctx);
|
||||
*dirctx = NULL;
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
static char *eat_ws(CONF *conf, char *p)
|
||||
{
|
||||
while (IS_WS(conf, *p) && (!IS_EOF(conf, *p)))
|
||||
@@ -562,6 +739,19 @@ static char *eat_ws(CONF *conf, char *p)
|
||||
return p;
|
||||
}
|
||||
|
||||
static void trim_ws(CONF *conf, char *start)
|
||||
{
|
||||
char *p = start;
|
||||
|
||||
while (!IS_EOF(conf, *p))
|
||||
p++;
|
||||
p--;
|
||||
while ((p >= start) && IS_WS(conf, *p))
|
||||
p--;
|
||||
p++;
|
||||
*p = '\0';
|
||||
}
|
||||
|
||||
static char *eat_alpha_numeric(CONF *conf, char *p)
|
||||
{
|
||||
for (;;) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Generated by util/mkerr.pl DO NOT EDIT
|
||||
* Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -20,6 +20,7 @@ static const ERR_STRING_DATA CONF_str_functs[] = {
|
||||
{ERR_PACK(ERR_LIB_CONF, CONF_F_CONF_PARSE_LIST, 0), "CONF_parse_list"},
|
||||
{ERR_PACK(ERR_LIB_CONF, CONF_F_DEF_LOAD, 0), "def_load"},
|
||||
{ERR_PACK(ERR_LIB_CONF, CONF_F_DEF_LOAD_BIO, 0), "def_load_bio"},
|
||||
{ERR_PACK(ERR_LIB_CONF, CONF_F_GET_NEXT_FILE, 0), "get_next_file"},
|
||||
{ERR_PACK(ERR_LIB_CONF, CONF_F_MODULE_INIT, 0), "module_init"},
|
||||
{ERR_PACK(ERR_LIB_CONF, CONF_F_MODULE_LOAD_DSO, 0), "module_load_dso"},
|
||||
{ERR_PACK(ERR_LIB_CONF, CONF_F_MODULE_RUN, 0), "module_run"},
|
||||
@@ -33,6 +34,7 @@ static const ERR_STRING_DATA CONF_str_functs[] = {
|
||||
{ERR_PACK(ERR_LIB_CONF, CONF_F_NCONF_LOAD_BIO, 0), "NCONF_load_bio"},
|
||||
{ERR_PACK(ERR_LIB_CONF, CONF_F_NCONF_LOAD_FP, 0), "NCONF_load_fp"},
|
||||
{ERR_PACK(ERR_LIB_CONF, CONF_F_NCONF_NEW, 0), "NCONF_new"},
|
||||
{ERR_PACK(ERR_LIB_CONF, CONF_F_PROCESS_INCLUDE, 0), "process_include"},
|
||||
{ERR_PACK(ERR_LIB_CONF, CONF_F_STR_COPY, 0), "str_copy"},
|
||||
{0, NULL}
|
||||
};
|
||||
@@ -56,6 +58,8 @@ static const ERR_STRING_DATA CONF_str_reasons[] = {
|
||||
{ERR_PACK(ERR_LIB_CONF, 0, CONF_R_NO_SECTION), "no section"},
|
||||
{ERR_PACK(ERR_LIB_CONF, 0, CONF_R_NO_SUCH_FILE), "no such file"},
|
||||
{ERR_PACK(ERR_LIB_CONF, 0, CONF_R_NO_VALUE), "no value"},
|
||||
{ERR_PACK(ERR_LIB_CONF, 0, CONF_R_RECURSIVE_DIRECTORY_INCLUDE),
|
||||
"recursive directory include"},
|
||||
{ERR_PACK(ERR_LIB_CONF, 0, CONF_R_UNABLE_TO_CREATE_NEW_SECTION),
|
||||
"unable to create new section"},
|
||||
{ERR_PACK(ERR_LIB_CONF, 0, CONF_R_UNKNOWN_MODULE_NAME),
|
||||
|
||||
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
+7
-16
@@ -40,12 +40,12 @@
|
||||
# P4 +22% +40%
|
||||
# Sandy Bridge -3% +11%
|
||||
# Haswell -1% +13%
|
||||
# Broadwell(***) +26% +30%
|
||||
# Skylake(***) +30% +47%
|
||||
# Broadwell(***) +30% +35%
|
||||
# Skylake(***) +33% +47%
|
||||
# Silvermont +20% +26%
|
||||
# Goldmont +40% +50%
|
||||
# Bulldozer +20% +9%
|
||||
# Ryzen(***) +35% +32%
|
||||
# Ryzen(***) +43% +40%
|
||||
# VIA +170% +120%
|
||||
#
|
||||
# (*) amd64-51 is popular assembly implementation with 2^51 radix,
|
||||
@@ -631,13 +631,10 @@ x25519_fe64_sqr:
|
||||
and \$38,%rax
|
||||
|
||||
add %rax,$acc0
|
||||
adc \$0,$acc1
|
||||
mov $acc0,8*0(%rdi)
|
||||
adc \$0,$acc2
|
||||
mov $acc1,8*1(%rdi)
|
||||
adc \$0,$acc3
|
||||
mov $acc2,8*2(%rdi)
|
||||
mov $acc3,8*3(%rdi)
|
||||
mov $acc0,8*0(%rdi)
|
||||
|
||||
mov 8*3(%rsp),%r15
|
||||
mov 8*4(%rsp),%r14
|
||||
@@ -674,13 +671,10 @@ x25519_fe64_mul121666:
|
||||
and \$38,%rax
|
||||
|
||||
add %rax,$acc0
|
||||
adc \$0,$acc1
|
||||
mov $acc0,8*0(%rdi)
|
||||
adc \$0,$acc2
|
||||
mov $acc1,8*1(%rdi)
|
||||
adc \$0,$acc3
|
||||
mov $acc2,8*2(%rdi)
|
||||
mov $acc3,8*3(%rdi)
|
||||
mov $acc0,8*0(%rdi)
|
||||
|
||||
ret
|
||||
.size x25519_fe64_mul121666,.-x25519_fe64_mul121666
|
||||
@@ -769,14 +763,11 @@ x25519_fe64_tobytes:
|
||||
and \$19,%rax
|
||||
|
||||
add %rax,$acc0
|
||||
adc \$0,$acc1
|
||||
adc \$0,$acc2
|
||||
adc \$0,$acc3
|
||||
|
||||
mov $acc0,8*0(%rdi)
|
||||
mov $acc1,8*1(%rdi)
|
||||
mov $acc2,8*2(%rdi)
|
||||
mov $acc3,8*3(%rdi)
|
||||
mov $acc0,8*0(%rdi)
|
||||
|
||||
ret
|
||||
.size x25519_fe64_tobytes,.-x25519_fe64_tobytes
|
||||
@@ -815,4 +806,4 @@ ___
|
||||
|
||||
$code =~ s/\`([^\`]*)\`/eval $1/gem;
|
||||
print $code;
|
||||
close $STDOUT;
|
||||
close STDOUT;
|
||||
@@ -13,7 +13,8 @@
|
||||
|
||||
#if defined(X25519_ASM) \
|
||||
|| ( (defined(__SIZEOF_INT128__) && __SIZEOF_INT128__ == 16) \
|
||||
&& !defined(__sparc__) )
|
||||
&& !defined(__sparc__) \
|
||||
&& !(defined(__ANDROID__) && !defined(__clang__)) )
|
||||
/*
|
||||
* Base 2^51 implementation.
|
||||
*/
|
||||
|
||||
@@ -579,7 +579,7 @@ static int recode_wnaf(struct smvt_control *control,
|
||||
assert(position >= 0);
|
||||
if (odd & (1 << (table_bits + 1)))
|
||||
delta -= (1 << (table_bits + 1));
|
||||
current -= delta << pos;
|
||||
current -= delta * (1 << pos);
|
||||
control[position].power = pos + 16 * (w - 1);
|
||||
control[position].addend = delta;
|
||||
position--;
|
||||
|
||||
@@ -122,7 +122,7 @@ void gf_strong_reduce(gf a)
|
||||
* it was < p, so now scarry = -1 and this = x - p + 2^255 so let's add
|
||||
* back in p. will carry back off the top for 2^255.
|
||||
*/
|
||||
assert(word_is_zero(scarry) | word_is_zero(scarry + 1));
|
||||
assert(scarry == 0 || scarry == -1);
|
||||
|
||||
scarry_0 = (word_t)scarry;
|
||||
|
||||
@@ -135,7 +135,7 @@ void gf_strong_reduce(gf a)
|
||||
carry >>= LIMB_PLACE_VALUE(LIMBPERM(i));
|
||||
}
|
||||
|
||||
assert(word_is_zero(carry + scarry_0));
|
||||
assert(carry < 2 && ((word_t)carry + scarry_0) == 0);
|
||||
}
|
||||
|
||||
/* Subtract two gf elements d=a-b */
|
||||
|
||||
@@ -135,9 +135,9 @@ void curve448_scalar_add(curve448_scalar_t out, const curve448_scalar_t a,
|
||||
|
||||
static ossl_inline void scalar_decode_short(curve448_scalar_t s,
|
||||
const unsigned char *ser,
|
||||
unsigned int nbytes)
|
||||
size_t nbytes)
|
||||
{
|
||||
unsigned int i, j, k = 0;
|
||||
size_t i, j, k = 0;
|
||||
|
||||
for (i = 0; i < C448_SCALAR_LIMBS; i++) {
|
||||
c448_word_t out = 0;
|
||||
|
||||
@@ -242,6 +242,10 @@ static const ERR_STRING_DATA EC_str_functs[] = {
|
||||
"ossl_ecdsa_verify_sig"},
|
||||
{ERR_PACK(ERR_LIB_EC, EC_F_PKEY_ECD_CTRL, 0), "pkey_ecd_ctrl"},
|
||||
{ERR_PACK(ERR_LIB_EC, EC_F_PKEY_ECD_DIGESTSIGN, 0), "pkey_ecd_digestsign"},
|
||||
{ERR_PACK(ERR_LIB_EC, EC_F_PKEY_ECD_DIGESTSIGN25519, 0),
|
||||
"pkey_ecd_digestsign25519"},
|
||||
{ERR_PACK(ERR_LIB_EC, EC_F_PKEY_ECD_DIGESTSIGN448, 0),
|
||||
"pkey_ecd_digestsign448"},
|
||||
{ERR_PACK(ERR_LIB_EC, EC_F_PKEY_ECX_DERIVE, 0), "pkey_ecx_derive"},
|
||||
{ERR_PACK(ERR_LIB_EC, EC_F_PKEY_EC_CTRL, 0), "pkey_ec_ctrl"},
|
||||
{ERR_PACK(ERR_LIB_EC, EC_F_PKEY_EC_CTRL_STR, 0), "pkey_ec_ctrl_str"},
|
||||
@@ -249,6 +253,7 @@ static const ERR_STRING_DATA EC_str_functs[] = {
|
||||
{ERR_PACK(ERR_LIB_EC, EC_F_PKEY_EC_KEYGEN, 0), "pkey_ec_keygen"},
|
||||
{ERR_PACK(ERR_LIB_EC, EC_F_PKEY_EC_PARAMGEN, 0), "pkey_ec_paramgen"},
|
||||
{ERR_PACK(ERR_LIB_EC, EC_F_PKEY_EC_SIGN, 0), "pkey_ec_sign"},
|
||||
{ERR_PACK(ERR_LIB_EC, EC_F_VALIDATE_ECX_DERIVE, 0), "validate_ecx_derive"},
|
||||
{0, NULL}
|
||||
};
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <openssl/ec.h>
|
||||
#include <openssl/bn.h>
|
||||
#include "internal/refcount.h"
|
||||
#include "curve448/curve448_lcl.h"
|
||||
|
||||
#if defined(__SUNPRO_C)
|
||||
# if __SUNPRO_C >= 0x520
|
||||
|
||||
+314
-104
@@ -16,30 +16,39 @@
|
||||
#include "internal/evp_int.h"
|
||||
#include "ec_lcl.h"
|
||||
|
||||
#define X25519_KEYLEN 32
|
||||
#define X25519_BITS 253
|
||||
#define X25519_SECURITY_BITS 128
|
||||
|
||||
#define ED25519_SIGSIZE 64
|
||||
|
||||
typedef struct {
|
||||
unsigned char pubkey[X25519_KEYLEN];
|
||||
unsigned char *privkey;
|
||||
} X25519_KEY;
|
||||
#define X448_BITS 448
|
||||
#define ED448_BITS 456
|
||||
#define X448_SECURITY_BITS 224
|
||||
|
||||
#define ED448_SIGSIZE 114
|
||||
|
||||
#define ISX448(id) ((id) == EVP_PKEY_X448)
|
||||
#define IS25519(id) ((id) == EVP_PKEY_X25519 || (id) == EVP_PKEY_ED25519)
|
||||
#define KEYLENID(id) (IS25519(id) ? X25519_KEYLEN \
|
||||
: ((id) == EVP_PKEY_X448 ? X448_KEYLEN \
|
||||
: ED448_KEYLEN))
|
||||
#define KEYLEN(p) KEYLENID((p)->ameth->pkey_id)
|
||||
|
||||
|
||||
typedef enum {
|
||||
X25519_PUBLIC,
|
||||
X25519_PRIVATE,
|
||||
X25519_KEYGEN
|
||||
KEY_OP_PUBLIC,
|
||||
KEY_OP_PRIVATE,
|
||||
KEY_OP_KEYGEN
|
||||
} ecx_key_op_t;
|
||||
|
||||
/* Setup EVP_PKEY using public, private or generation */
|
||||
static int ecx_key_op(EVP_PKEY *pkey, int id, const X509_ALGOR *palg,
|
||||
const unsigned char *p, int plen, ecx_key_op_t op)
|
||||
{
|
||||
X25519_KEY *xkey;
|
||||
ECX_KEY *key = NULL;
|
||||
unsigned char *privkey, *pubkey;
|
||||
|
||||
if (op != X25519_KEYGEN) {
|
||||
if (op != KEY_OP_KEYGEN) {
|
||||
if (palg != NULL) {
|
||||
int ptype;
|
||||
|
||||
@@ -51,69 +60,85 @@ static int ecx_key_op(EVP_PKEY *pkey, int id, const X509_ALGOR *palg,
|
||||
}
|
||||
}
|
||||
|
||||
if (p == NULL || plen != X25519_KEYLEN) {
|
||||
if (p == NULL || plen != KEYLENID(id)) {
|
||||
ECerr(EC_F_ECX_KEY_OP, EC_R_INVALID_ENCODING);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
xkey = OPENSSL_zalloc(sizeof(*xkey));
|
||||
if (xkey == NULL) {
|
||||
key = OPENSSL_zalloc(sizeof(*key));
|
||||
if (key == NULL) {
|
||||
ECerr(EC_F_ECX_KEY_OP, ERR_R_MALLOC_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
pubkey = key->pubkey;
|
||||
|
||||
if (op == X25519_PUBLIC) {
|
||||
memcpy(xkey->pubkey, p, plen);
|
||||
if (op == KEY_OP_PUBLIC) {
|
||||
memcpy(pubkey, p, plen);
|
||||
} else {
|
||||
xkey->privkey = OPENSSL_secure_malloc(X25519_KEYLEN);
|
||||
if (xkey->privkey == NULL) {
|
||||
privkey = key->privkey = OPENSSL_secure_malloc(KEYLENID(id));
|
||||
if (privkey == NULL) {
|
||||
ECerr(EC_F_ECX_KEY_OP, ERR_R_MALLOC_FAILURE);
|
||||
OPENSSL_free(xkey);
|
||||
return 0;
|
||||
goto err;
|
||||
}
|
||||
if (op == X25519_KEYGEN) {
|
||||
if (RAND_bytes(xkey->privkey, X25519_KEYLEN) <= 0) {
|
||||
OPENSSL_secure_free(xkey->privkey);
|
||||
OPENSSL_free(xkey);
|
||||
return 0;
|
||||
if (op == KEY_OP_KEYGEN) {
|
||||
if (RAND_priv_bytes(privkey, KEYLENID(id)) <= 0) {
|
||||
OPENSSL_secure_free(privkey);
|
||||
key->privkey = NULL;
|
||||
goto err;
|
||||
}
|
||||
if (id == EVP_PKEY_X25519) {
|
||||
xkey->privkey[0] &= 248;
|
||||
xkey->privkey[31] &= 127;
|
||||
xkey->privkey[31] |= 64;
|
||||
privkey[0] &= 248;
|
||||
privkey[X25519_KEYLEN - 1] &= 127;
|
||||
privkey[X25519_KEYLEN - 1] |= 64;
|
||||
} else if (id == EVP_PKEY_X448) {
|
||||
privkey[0] &= 252;
|
||||
privkey[X448_KEYLEN - 1] |= 128;
|
||||
}
|
||||
} else {
|
||||
memcpy(xkey->privkey, p, X25519_KEYLEN);
|
||||
memcpy(privkey, p, KEYLENID(id));
|
||||
}
|
||||
switch (id) {
|
||||
case EVP_PKEY_X25519:
|
||||
X25519_public_from_private(pubkey, privkey);
|
||||
break;
|
||||
case EVP_PKEY_ED25519:
|
||||
ED25519_public_from_private(pubkey, privkey);
|
||||
break;
|
||||
case EVP_PKEY_X448:
|
||||
X448_public_from_private(pubkey, privkey);
|
||||
break;
|
||||
case EVP_PKEY_ED448:
|
||||
ED448_public_from_private(pubkey, privkey);
|
||||
break;
|
||||
}
|
||||
if (id == EVP_PKEY_X25519)
|
||||
X25519_public_from_private(xkey->pubkey, xkey->privkey);
|
||||
else
|
||||
ED25519_public_from_private(xkey->pubkey, xkey->privkey);
|
||||
}
|
||||
|
||||
EVP_PKEY_assign(pkey, id, xkey);
|
||||
EVP_PKEY_assign(pkey, id, key);
|
||||
return 1;
|
||||
err:
|
||||
OPENSSL_free(key);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ecx_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey)
|
||||
{
|
||||
const X25519_KEY *xkey = pkey->pkey.ptr;
|
||||
const ECX_KEY *ecxkey = pkey->pkey.ecx;
|
||||
unsigned char *penc;
|
||||
|
||||
if (xkey == NULL) {
|
||||
if (ecxkey == NULL) {
|
||||
ECerr(EC_F_ECX_PUB_ENCODE, EC_R_INVALID_KEY);
|
||||
return 0;
|
||||
}
|
||||
|
||||
penc = OPENSSL_memdup(xkey->pubkey, X25519_KEYLEN);
|
||||
penc = OPENSSL_memdup(ecxkey->pubkey, KEYLEN(pkey));
|
||||
if (penc == NULL) {
|
||||
ECerr(EC_F_ECX_PUB_ENCODE, ERR_R_MALLOC_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!X509_PUBKEY_set0_param(pk, OBJ_nid2obj(pkey->ameth->pkey_id),
|
||||
V_ASN1_UNDEF, NULL, penc, X25519_KEYLEN)) {
|
||||
V_ASN1_UNDEF, NULL, penc, KEYLEN(pkey))) {
|
||||
OPENSSL_free(penc);
|
||||
ECerr(EC_F_ECX_PUB_ENCODE, ERR_R_MALLOC_FAILURE);
|
||||
return 0;
|
||||
@@ -130,17 +155,18 @@ static int ecx_pub_decode(EVP_PKEY *pkey, X509_PUBKEY *pubkey)
|
||||
if (!X509_PUBKEY_get0_param(NULL, &p, &pklen, &palg, pubkey))
|
||||
return 0;
|
||||
return ecx_key_op(pkey, pkey->ameth->pkey_id, palg, p, pklen,
|
||||
X25519_PUBLIC);
|
||||
KEY_OP_PUBLIC);
|
||||
}
|
||||
|
||||
static int ecx_pub_cmp(const EVP_PKEY *a, const EVP_PKEY *b)
|
||||
{
|
||||
const X25519_KEY *akey = a->pkey.ptr;
|
||||
const X25519_KEY *bkey = b->pkey.ptr;
|
||||
const ECX_KEY *akey = a->pkey.ecx;
|
||||
const ECX_KEY *bkey = b->pkey.ecx;
|
||||
|
||||
if (akey == NULL || bkey == NULL)
|
||||
return -2;
|
||||
return !CRYPTO_memcmp(akey->pubkey, bkey->pubkey, X25519_KEYLEN);
|
||||
|
||||
return CRYPTO_memcmp(akey->pubkey, bkey->pubkey, KEYLEN(a)) == 0;
|
||||
}
|
||||
|
||||
static int ecx_priv_decode(EVP_PKEY *pkey, const PKCS8_PRIV_KEY_INFO *p8)
|
||||
@@ -163,25 +189,25 @@ static int ecx_priv_decode(EVP_PKEY *pkey, const PKCS8_PRIV_KEY_INFO *p8)
|
||||
plen = ASN1_STRING_length(oct);
|
||||
}
|
||||
|
||||
rv = ecx_key_op(pkey, pkey->ameth->pkey_id, palg, p, plen, X25519_PRIVATE);
|
||||
rv = ecx_key_op(pkey, pkey->ameth->pkey_id, palg, p, plen, KEY_OP_PRIVATE);
|
||||
ASN1_OCTET_STRING_free(oct);
|
||||
return rv;
|
||||
}
|
||||
|
||||
static int ecx_priv_encode(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pkey)
|
||||
{
|
||||
const X25519_KEY *xkey = pkey->pkey.ptr;
|
||||
const ECX_KEY *ecxkey = pkey->pkey.ecx;
|
||||
ASN1_OCTET_STRING oct;
|
||||
unsigned char *penc = NULL;
|
||||
int penclen;
|
||||
|
||||
if (xkey == NULL || xkey->privkey == NULL) {
|
||||
if (ecxkey == NULL || ecxkey->privkey == NULL) {
|
||||
ECerr(EC_F_ECX_PRIV_ENCODE, EC_R_INVALID_PRIVATE_KEY);
|
||||
return 0;
|
||||
}
|
||||
|
||||
oct.data = xkey->privkey;
|
||||
oct.length = X25519_KEYLEN;
|
||||
oct.data = ecxkey->privkey;
|
||||
oct.length = KEYLEN(pkey);
|
||||
oct.flags = 0;
|
||||
|
||||
penclen = i2d_ASN1_OCTET_STRING(&oct, &penc);
|
||||
@@ -202,26 +228,34 @@ static int ecx_priv_encode(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pkey)
|
||||
|
||||
static int ecx_size(const EVP_PKEY *pkey)
|
||||
{
|
||||
return X25519_KEYLEN;
|
||||
return KEYLEN(pkey);
|
||||
}
|
||||
|
||||
static int ecx_bits(const EVP_PKEY *pkey)
|
||||
{
|
||||
return X25519_BITS;
|
||||
if (IS25519(pkey->ameth->pkey_id)) {
|
||||
return X25519_BITS;
|
||||
} else if(ISX448(pkey->ameth->pkey_id)) {
|
||||
return X448_BITS;
|
||||
} else {
|
||||
return ED448_BITS;
|
||||
}
|
||||
}
|
||||
|
||||
static int ecx_security_bits(const EVP_PKEY *pkey)
|
||||
{
|
||||
return X25519_SECURITY_BITS;
|
||||
if (IS25519(pkey->ameth->pkey_id)) {
|
||||
return X25519_SECURITY_BITS;
|
||||
} else {
|
||||
return X448_SECURITY_BITS;
|
||||
}
|
||||
}
|
||||
|
||||
static void ecx_free(EVP_PKEY *pkey)
|
||||
{
|
||||
X25519_KEY *xkey = pkey->pkey.ptr;
|
||||
|
||||
if (xkey)
|
||||
OPENSSL_secure_clear_free(xkey->privkey, X25519_KEYLEN);
|
||||
OPENSSL_free(xkey);
|
||||
if (pkey->pkey.ecx != NULL)
|
||||
OPENSSL_secure_clear_free(pkey->pkey.ecx->privkey, KEYLEN(pkey));
|
||||
OPENSSL_free(pkey->pkey.ecx);
|
||||
}
|
||||
|
||||
/* "parameters" are always equal */
|
||||
@@ -233,12 +267,11 @@ static int ecx_cmp_parameters(const EVP_PKEY *a, const EVP_PKEY *b)
|
||||
static int ecx_key_print(BIO *bp, const EVP_PKEY *pkey, int indent,
|
||||
ASN1_PCTX *ctx, ecx_key_op_t op)
|
||||
{
|
||||
const X25519_KEY *xkey = pkey->pkey.ptr;
|
||||
|
||||
const ECX_KEY *ecxkey = pkey->pkey.ecx;
|
||||
const char *nm = OBJ_nid2ln(pkey->ameth->pkey_id);
|
||||
|
||||
if (op == X25519_PRIVATE) {
|
||||
if (xkey == NULL || xkey->privkey == NULL) {
|
||||
if (op == KEY_OP_PRIVATE) {
|
||||
if (ecxkey == NULL || ecxkey->privkey == NULL) {
|
||||
if (BIO_printf(bp, "%*s<INVALID PRIVATE KEY>\n", indent, "") <= 0)
|
||||
return 0;
|
||||
return 1;
|
||||
@@ -247,10 +280,11 @@ static int ecx_key_print(BIO *bp, const EVP_PKEY *pkey, int indent,
|
||||
return 0;
|
||||
if (BIO_printf(bp, "%*spriv:\n", indent, "") <= 0)
|
||||
return 0;
|
||||
if (ASN1_buf_print(bp, xkey->privkey, X25519_KEYLEN, indent + 4) == 0)
|
||||
if (ASN1_buf_print(bp, ecxkey->privkey, KEYLEN(pkey),
|
||||
indent + 4) == 0)
|
||||
return 0;
|
||||
} else {
|
||||
if (xkey == NULL) {
|
||||
if (ecxkey == NULL) {
|
||||
if (BIO_printf(bp, "%*s<INVALID PUBLIC KEY>\n", indent, "") <= 0)
|
||||
return 0;
|
||||
return 1;
|
||||
@@ -260,7 +294,9 @@ static int ecx_key_print(BIO *bp, const EVP_PKEY *pkey, int indent,
|
||||
}
|
||||
if (BIO_printf(bp, "%*spub:\n", indent, "") <= 0)
|
||||
return 0;
|
||||
if (ASN1_buf_print(bp, xkey->pubkey, X25519_KEYLEN, indent + 4) == 0)
|
||||
|
||||
if (ASN1_buf_print(bp, ecxkey->pubkey, KEYLEN(pkey),
|
||||
indent + 4) == 0)
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
@@ -268,13 +304,13 @@ static int ecx_key_print(BIO *bp, const EVP_PKEY *pkey, int indent,
|
||||
static int ecx_priv_print(BIO *bp, const EVP_PKEY *pkey, int indent,
|
||||
ASN1_PCTX *ctx)
|
||||
{
|
||||
return ecx_key_print(bp, pkey, indent, ctx, X25519_PRIVATE);
|
||||
return ecx_key_print(bp, pkey, indent, ctx, KEY_OP_PRIVATE);
|
||||
}
|
||||
|
||||
static int ecx_pub_print(BIO *bp, const EVP_PKEY *pkey, int indent,
|
||||
ASN1_PCTX *ctx)
|
||||
{
|
||||
return ecx_key_print(bp, pkey, indent, ctx, X25519_PUBLIC);
|
||||
return ecx_key_print(bp, pkey, indent, ctx, KEY_OP_PUBLIC);
|
||||
}
|
||||
|
||||
static int ecx_ctrl(EVP_PKEY *pkey, int op, long arg1, void *arg2)
|
||||
@@ -282,16 +318,16 @@ static int ecx_ctrl(EVP_PKEY *pkey, int op, long arg1, void *arg2)
|
||||
switch (op) {
|
||||
|
||||
case ASN1_PKEY_CTRL_SET1_TLS_ENCPT:
|
||||
return ecx_key_op(pkey, EVP_PKEY_X25519, NULL, arg2, arg1,
|
||||
X25519_PUBLIC);
|
||||
return ecx_key_op(pkey, pkey->ameth->pkey_id, NULL, arg2, arg1,
|
||||
KEY_OP_PUBLIC);
|
||||
|
||||
case ASN1_PKEY_CTRL_GET1_TLS_ENCPT:
|
||||
if (pkey->pkey.ptr != NULL) {
|
||||
const X25519_KEY *xkey = pkey->pkey.ptr;
|
||||
if (pkey->pkey.ecx != NULL) {
|
||||
unsigned char **ppt = arg2;
|
||||
*ppt = OPENSSL_memdup(xkey->pubkey, X25519_KEYLEN);
|
||||
|
||||
*ppt = OPENSSL_memdup(pkey->pkey.ecx->pubkey, KEYLEN(pkey));
|
||||
if (*ppt != NULL)
|
||||
return X25519_KEYLEN;
|
||||
return KEYLEN(pkey);
|
||||
}
|
||||
return 0;
|
||||
|
||||
@@ -335,21 +371,58 @@ const EVP_PKEY_ASN1_METHOD ecx25519_asn1_meth = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int ecd_size(const EVP_PKEY *pkey)
|
||||
const EVP_PKEY_ASN1_METHOD ecx448_asn1_meth = {
|
||||
EVP_PKEY_X448,
|
||||
EVP_PKEY_X448,
|
||||
0,
|
||||
"X448",
|
||||
"OpenSSL X448 algorithm",
|
||||
|
||||
ecx_pub_decode,
|
||||
ecx_pub_encode,
|
||||
ecx_pub_cmp,
|
||||
ecx_pub_print,
|
||||
|
||||
ecx_priv_decode,
|
||||
ecx_priv_encode,
|
||||
ecx_priv_print,
|
||||
|
||||
ecx_size,
|
||||
ecx_bits,
|
||||
ecx_security_bits,
|
||||
|
||||
0, 0, 0, 0,
|
||||
ecx_cmp_parameters,
|
||||
0, 0,
|
||||
|
||||
ecx_free,
|
||||
ecx_ctrl,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
static int ecd_size25519(const EVP_PKEY *pkey)
|
||||
{
|
||||
return ED25519_SIGSIZE;
|
||||
}
|
||||
|
||||
static int ecd_size448(const EVP_PKEY *pkey)
|
||||
{
|
||||
return ED448_SIGSIZE;
|
||||
}
|
||||
|
||||
static int ecd_item_verify(EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn,
|
||||
X509_ALGOR *sigalg, ASN1_BIT_STRING *str,
|
||||
EVP_PKEY *pkey)
|
||||
{
|
||||
const ASN1_OBJECT *obj;
|
||||
int ptype;
|
||||
int nid;
|
||||
|
||||
/* Sanity check: make sure it is ED25519/ED448 with absent parameters */
|
||||
X509_ALGOR_get0(&obj, &ptype, NULL, sigalg);
|
||||
/* Sanity check: make sure it is ED25519 with absent parameters */
|
||||
if (OBJ_obj2nid(obj) != NID_ED25519 || ptype != V_ASN1_UNDEF) {
|
||||
nid = OBJ_obj2nid(obj);
|
||||
if ((nid != NID_ED25519 && nid != NID_ED448) || ptype != V_ASN1_UNDEF) {
|
||||
ECerr(EC_F_ECD_ITEM_VERIFY, EC_R_INVALID_ENCODING);
|
||||
return 0;
|
||||
}
|
||||
@@ -360,9 +433,9 @@ static int ecd_item_verify(EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn,
|
||||
return 2;
|
||||
}
|
||||
|
||||
static int ecd_item_sign(EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn,
|
||||
X509_ALGOR *alg1, X509_ALGOR *alg2,
|
||||
ASN1_BIT_STRING *str)
|
||||
static int ecd_item_sign25519(EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn,
|
||||
X509_ALGOR *alg1, X509_ALGOR *alg2,
|
||||
ASN1_BIT_STRING *str)
|
||||
{
|
||||
/* Set algorithms identifiers */
|
||||
X509_ALGOR_set0(alg1, OBJ_nid2obj(NID_ED25519), V_ASN1_UNDEF, NULL);
|
||||
@@ -372,14 +445,35 @@ static int ecd_item_sign(EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn,
|
||||
return 3;
|
||||
}
|
||||
|
||||
static int ecd_sig_info_set(X509_SIG_INFO *siginf, const X509_ALGOR *alg,
|
||||
const ASN1_STRING *sig)
|
||||
static int ecd_sig_info_set25519(X509_SIG_INFO *siginf, const X509_ALGOR *alg,
|
||||
const ASN1_STRING *sig)
|
||||
{
|
||||
X509_SIG_INFO_set(siginf, NID_undef, NID_ED25519, X25519_SECURITY_BITS,
|
||||
X509_SIG_INFO_TLS);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int ecd_item_sign448(EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn,
|
||||
X509_ALGOR *alg1, X509_ALGOR *alg2,
|
||||
ASN1_BIT_STRING *str)
|
||||
{
|
||||
/* Set algorithm identifier */
|
||||
X509_ALGOR_set0(alg1, OBJ_nid2obj(NID_ED448), V_ASN1_UNDEF, NULL);
|
||||
if (alg2 != NULL)
|
||||
X509_ALGOR_set0(alg2, OBJ_nid2obj(NID_ED448), V_ASN1_UNDEF, NULL);
|
||||
/* Algorithm identifier set: carry on as normal */
|
||||
return 3;
|
||||
}
|
||||
|
||||
static int ecd_sig_info_set448(X509_SIG_INFO *siginf, const X509_ALGOR *alg,
|
||||
const ASN1_STRING *sig)
|
||||
{
|
||||
X509_SIG_INFO_set(siginf, NID_undef, NID_ED448, X448_SECURITY_BITS,
|
||||
X509_SIG_INFO_TLS);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
const EVP_PKEY_ASN1_METHOD ed25519_asn1_meth = {
|
||||
EVP_PKEY_ED25519,
|
||||
EVP_PKEY_ED25519,
|
||||
@@ -396,7 +490,7 @@ const EVP_PKEY_ASN1_METHOD ed25519_asn1_meth = {
|
||||
ecx_priv_encode,
|
||||
ecx_priv_print,
|
||||
|
||||
ecd_size,
|
||||
ecd_size25519,
|
||||
ecx_bits,
|
||||
ecx_security_bits,
|
||||
|
||||
@@ -409,37 +503,98 @@ const EVP_PKEY_ASN1_METHOD ed25519_asn1_meth = {
|
||||
NULL,
|
||||
NULL,
|
||||
ecd_item_verify,
|
||||
ecd_item_sign,
|
||||
ecd_sig_info_set
|
||||
ecd_item_sign25519,
|
||||
ecd_sig_info_set25519
|
||||
};
|
||||
|
||||
const EVP_PKEY_ASN1_METHOD ed448_asn1_meth = {
|
||||
EVP_PKEY_ED448,
|
||||
EVP_PKEY_ED448,
|
||||
0,
|
||||
"ED448",
|
||||
"OpenSSL ED448 algorithm",
|
||||
|
||||
ecx_pub_decode,
|
||||
ecx_pub_encode,
|
||||
ecx_pub_cmp,
|
||||
ecx_pub_print,
|
||||
|
||||
ecx_priv_decode,
|
||||
ecx_priv_encode,
|
||||
ecx_priv_print,
|
||||
|
||||
ecd_size448,
|
||||
ecx_bits,
|
||||
ecx_security_bits,
|
||||
|
||||
0, 0, 0, 0,
|
||||
ecx_cmp_parameters,
|
||||
0, 0,
|
||||
|
||||
ecx_free,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
ecd_item_verify,
|
||||
ecd_item_sign448,
|
||||
ecd_sig_info_set448
|
||||
};
|
||||
|
||||
static int pkey_ecx_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
|
||||
{
|
||||
return ecx_key_op(pkey, ctx->pmeth->pkey_id, NULL, NULL, 0, X25519_KEYGEN);
|
||||
return ecx_key_op(pkey, ctx->pmeth->pkey_id, NULL, NULL, 0, KEY_OP_KEYGEN);
|
||||
}
|
||||
|
||||
static int pkey_ecx_derive(EVP_PKEY_CTX *ctx, unsigned char *key,
|
||||
size_t *keylen)
|
||||
static int validate_ecx_derive(EVP_PKEY_CTX *ctx, unsigned char *key,
|
||||
size_t *keylen,
|
||||
const unsigned char **privkey,
|
||||
const unsigned char **pubkey)
|
||||
{
|
||||
const X25519_KEY *pkey, *peerkey;
|
||||
const ECX_KEY *ecxkey, *peerkey;
|
||||
|
||||
if (ctx->pkey == NULL || ctx->peerkey == NULL) {
|
||||
ECerr(EC_F_PKEY_ECX_DERIVE, EC_R_KEYS_NOT_SET);
|
||||
ECerr(EC_F_VALIDATE_ECX_DERIVE, EC_R_KEYS_NOT_SET);
|
||||
return 0;
|
||||
}
|
||||
pkey = ctx->pkey->pkey.ptr;
|
||||
peerkey = ctx->peerkey->pkey.ptr;
|
||||
if (pkey == NULL || pkey->privkey == NULL) {
|
||||
ECerr(EC_F_PKEY_ECX_DERIVE, EC_R_INVALID_PRIVATE_KEY);
|
||||
ecxkey = ctx->pkey->pkey.ecx;
|
||||
peerkey = ctx->peerkey->pkey.ecx;
|
||||
if (ecxkey == NULL || ecxkey->privkey == NULL) {
|
||||
ECerr(EC_F_VALIDATE_ECX_DERIVE, EC_R_INVALID_PRIVATE_KEY);
|
||||
return 0;
|
||||
}
|
||||
if (peerkey == NULL) {
|
||||
ECerr(EC_F_PKEY_ECX_DERIVE, EC_R_INVALID_PEER_KEY);
|
||||
ECerr(EC_F_VALIDATE_ECX_DERIVE, EC_R_INVALID_PEER_KEY);
|
||||
return 0;
|
||||
}
|
||||
*keylen = X25519_KEYLEN;
|
||||
if (key != NULL && X25519(key, pkey->privkey, peerkey->pubkey) == 0)
|
||||
*privkey = ecxkey->privkey;
|
||||
*pubkey = peerkey->pubkey;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int pkey_ecx_derive25519(EVP_PKEY_CTX *ctx, unsigned char *key,
|
||||
size_t *keylen)
|
||||
{
|
||||
const unsigned char *privkey, *pubkey;
|
||||
|
||||
if (!validate_ecx_derive(ctx, key, keylen, &privkey, &pubkey)
|
||||
|| (key != NULL
|
||||
&& X25519(key, privkey, pubkey) == 0))
|
||||
return 0;
|
||||
*keylen = X25519_KEYLEN;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int pkey_ecx_derive448(EVP_PKEY_CTX *ctx, unsigned char *key,
|
||||
size_t *keylen)
|
||||
{
|
||||
const unsigned char *privkey, *pubkey;
|
||||
|
||||
if (!validate_ecx_derive(ctx, key, keylen, &privkey, &pubkey)
|
||||
|| (key != NULL
|
||||
&& X448(key, privkey, pubkey) == 0))
|
||||
return 0;
|
||||
*keylen = X448_KEYLEN;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -456,23 +611,33 @@ const EVP_PKEY_METHOD ecx25519_pkey_meth = {
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
pkey_ecx_keygen,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
pkey_ecx_derive,
|
||||
pkey_ecx_derive25519,
|
||||
pkey_ecx_ctrl,
|
||||
0
|
||||
};
|
||||
|
||||
static int pkey_ecd_digestsign(EVP_MD_CTX *ctx, unsigned char *sig,
|
||||
size_t *siglen, const unsigned char *tbs,
|
||||
size_t tbslen)
|
||||
const EVP_PKEY_METHOD ecx448_pkey_meth = {
|
||||
EVP_PKEY_X448,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
pkey_ecx_keygen,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
pkey_ecx_derive448,
|
||||
pkey_ecx_ctrl,
|
||||
0
|
||||
};
|
||||
|
||||
static int pkey_ecd_digestsign25519(EVP_MD_CTX *ctx, unsigned char *sig,
|
||||
size_t *siglen, const unsigned char *tbs,
|
||||
size_t tbslen)
|
||||
{
|
||||
const X25519_KEY *edkey = EVP_MD_CTX_pkey_ctx(ctx)->pkey->pkey.ptr;
|
||||
const ECX_KEY *edkey = EVP_MD_CTX_pkey_ctx(ctx)->pkey->pkey.ecx;
|
||||
|
||||
if (sig == NULL) {
|
||||
*siglen = ED25519_SIGSIZE;
|
||||
return 1;
|
||||
}
|
||||
if (*siglen < ED25519_SIGSIZE) {
|
||||
ECerr(EC_F_PKEY_ECD_DIGESTSIGN, EC_R_BUFFER_TOO_SMALL);
|
||||
ECerr(EC_F_PKEY_ECD_DIGESTSIGN25519, EC_R_BUFFER_TOO_SMALL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -482,11 +647,33 @@ static int pkey_ecd_digestsign(EVP_MD_CTX *ctx, unsigned char *sig,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int pkey_ecd_digestverify(EVP_MD_CTX *ctx, const unsigned char *sig,
|
||||
size_t siglen, const unsigned char *tbs,
|
||||
size_t tbslen)
|
||||
static int pkey_ecd_digestsign448(EVP_MD_CTX *ctx, unsigned char *sig,
|
||||
size_t *siglen, const unsigned char *tbs,
|
||||
size_t tbslen)
|
||||
{
|
||||
const X25519_KEY *edkey = EVP_MD_CTX_pkey_ctx(ctx)->pkey->pkey.ptr;
|
||||
const ECX_KEY *edkey = EVP_MD_CTX_pkey_ctx(ctx)->pkey->pkey.ecx;
|
||||
|
||||
if (sig == NULL) {
|
||||
*siglen = ED448_SIGSIZE;
|
||||
return 1;
|
||||
}
|
||||
if (*siglen < ED448_SIGSIZE) {
|
||||
ECerr(EC_F_PKEY_ECD_DIGESTSIGN448, EC_R_BUFFER_TOO_SMALL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ED448_sign(sig, tbs, tbslen, edkey->pubkey, edkey->privkey, NULL,
|
||||
0) == 0)
|
||||
return 0;
|
||||
*siglen = ED448_SIGSIZE;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int pkey_ecd_digestverify25519(EVP_MD_CTX *ctx, const unsigned char *sig,
|
||||
size_t siglen, const unsigned char *tbs,
|
||||
size_t tbslen)
|
||||
{
|
||||
const ECX_KEY *edkey = EVP_MD_CTX_pkey_ctx(ctx)->pkey->pkey.ecx;
|
||||
|
||||
if (siglen != ED25519_SIGSIZE)
|
||||
return 0;
|
||||
@@ -494,6 +681,18 @@ static int pkey_ecd_digestverify(EVP_MD_CTX *ctx, const unsigned char *sig,
|
||||
return ED25519_verify(tbs, tbslen, sig, edkey->pubkey);
|
||||
}
|
||||
|
||||
static int pkey_ecd_digestverify448(EVP_MD_CTX *ctx, const unsigned char *sig,
|
||||
size_t siglen, const unsigned char *tbs,
|
||||
size_t tbslen)
|
||||
{
|
||||
const ECX_KEY *edkey = EVP_MD_CTX_pkey_ctx(ctx)->pkey->pkey.ecx;
|
||||
|
||||
if (siglen != ED448_SIGSIZE)
|
||||
return 0;
|
||||
|
||||
return ED448_verify(tbs, tbslen, sig, edkey->pubkey, NULL, 0);
|
||||
}
|
||||
|
||||
static int pkey_ecd_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2)
|
||||
{
|
||||
switch (type) {
|
||||
@@ -517,6 +716,17 @@ const EVP_PKEY_METHOD ed25519_pkey_meth = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
pkey_ecd_ctrl,
|
||||
0,
|
||||
pkey_ecd_digestsign,
|
||||
pkey_ecd_digestverify
|
||||
pkey_ecd_digestsign25519,
|
||||
pkey_ecd_digestverify25519
|
||||
};
|
||||
|
||||
const EVP_PKEY_METHOD ed448_pkey_meth = {
|
||||
EVP_PKEY_ED448, EVP_PKEY_FLAG_SIGCTX_CUSTOM,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
pkey_ecx_keygen,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
pkey_ecd_ctrl,
|
||||
0,
|
||||
pkey_ecd_digestsign448,
|
||||
pkey_ecd_digestverify448
|
||||
};
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2011-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2011-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -20,28 +20,15 @@
|
||||
defined(__x86_64) || defined(__x86_64__) || \
|
||||
defined(_M_AMD64) || defined (_M_X64)) && defined(OPENSSL_CPUID_OBJ)
|
||||
|
||||
size_t OPENSSL_ia32_rdrand(void);
|
||||
size_t OPENSSL_ia32_rdrand_bytes(unsigned char *buf, size_t len);
|
||||
|
||||
static int get_random_bytes(unsigned char *buf, int num)
|
||||
{
|
||||
size_t rnd;
|
||||
|
||||
while (num >= (int)sizeof(size_t)) {
|
||||
if ((rnd = OPENSSL_ia32_rdrand()) == 0)
|
||||
return 0;
|
||||
|
||||
*((size_t *)buf) = rnd;
|
||||
buf += sizeof(size_t);
|
||||
num -= sizeof(size_t);
|
||||
}
|
||||
if (num) {
|
||||
if ((rnd = OPENSSL_ia32_rdrand()) == 0)
|
||||
return 0;
|
||||
|
||||
memcpy(buf, &rnd, num);
|
||||
if (num < 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
return (size_t)num == OPENSSL_ia32_rdrand_bytes(buf, (size_t)num);
|
||||
}
|
||||
|
||||
static int random_status(void)
|
||||
|
||||
@@ -109,6 +109,11 @@ int engine_table_register(ENGINE_TABLE **table, ENGINE_CLEANUP_CB *cleanup,
|
||||
}
|
||||
fnd->funct = NULL;
|
||||
(void)lh_ENGINE_PILE_insert(&(*table)->piles, fnd);
|
||||
if (lh_ENGINE_PILE_retrieve(&(*table)->piles, &tmplate) != fnd) {
|
||||
sk_ENGINE_free(fnd->sk);
|
||||
OPENSSL_free(fnd);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
/* A registration shouldn't add duplicate entries */
|
||||
(void)sk_ENGINE_delete_ptr(fnd->sk, e);
|
||||
|
||||
@@ -89,6 +89,7 @@ static ERR_STRING_DATA ERR_str_functs[] = {
|
||||
{ERR_PACK(0, SYS_F_IOCTL, 0), "ioctl"},
|
||||
{ERR_PACK(0, SYS_F_STAT, 0), "stat"},
|
||||
{ERR_PACK(0, SYS_F_FCNTL, 0), "fcntl"},
|
||||
{ERR_PACK(0, SYS_F_FSTAT, 0), "fstat"},
|
||||
{0, NULL},
|
||||
};
|
||||
|
||||
|
||||
@@ -299,6 +299,7 @@ CONF_F_CONF_LOAD_FP:103:CONF_load_fp
|
||||
CONF_F_CONF_PARSE_LIST:119:CONF_parse_list
|
||||
CONF_F_DEF_LOAD:120:def_load
|
||||
CONF_F_DEF_LOAD_BIO:121:def_load_bio
|
||||
CONF_F_GET_NEXT_FILE:107:get_next_file
|
||||
CONF_F_MODULE_INIT:115:module_init
|
||||
CONF_F_MODULE_LOAD_DSO:117:module_load_dso
|
||||
CONF_F_MODULE_RUN:118:module_run
|
||||
@@ -311,6 +312,7 @@ CONF_F_NCONF_LOAD:113:NCONF_load
|
||||
CONF_F_NCONF_LOAD_BIO:110:NCONF_load_bio
|
||||
CONF_F_NCONF_LOAD_FP:114:NCONF_load_fp
|
||||
CONF_F_NCONF_NEW:111:NCONF_new
|
||||
CONF_F_PROCESS_INCLUDE:116:process_include
|
||||
CONF_F_STR_COPY:101:str_copy
|
||||
CRYPTO_F_CRYPTO_DUP_EX_DATA:110:CRYPTO_dup_ex_data
|
||||
CRYPTO_F_CRYPTO_FREE_EX_DATA:111:CRYPTO_free_ex_data
|
||||
@@ -594,6 +596,8 @@ EC_F_OSSL_ECDSA_SIGN_SIG:249:ossl_ecdsa_sign_sig
|
||||
EC_F_OSSL_ECDSA_VERIFY_SIG:250:ossl_ecdsa_verify_sig
|
||||
EC_F_PKEY_ECD_CTRL:271:pkey_ecd_ctrl
|
||||
EC_F_PKEY_ECD_DIGESTSIGN:272:pkey_ecd_digestsign
|
||||
EC_F_PKEY_ECD_DIGESTSIGN25519:276:pkey_ecd_digestsign25519
|
||||
EC_F_PKEY_ECD_DIGESTSIGN448:277:pkey_ecd_digestsign448
|
||||
EC_F_PKEY_ECX_DERIVE:269:pkey_ecx_derive
|
||||
EC_F_PKEY_EC_CTRL:197:pkey_ec_ctrl
|
||||
EC_F_PKEY_EC_CTRL_STR:198:pkey_ec_ctrl_str
|
||||
@@ -601,6 +605,7 @@ EC_F_PKEY_EC_DERIVE:217:pkey_ec_derive
|
||||
EC_F_PKEY_EC_KEYGEN:199:pkey_ec_keygen
|
||||
EC_F_PKEY_EC_PARAMGEN:219:pkey_ec_paramgen
|
||||
EC_F_PKEY_EC_SIGN:218:pkey_ec_sign
|
||||
EC_F_VALIDATE_ECX_DERIVE:278:validate_ecx_derive
|
||||
ENGINE_F_DIGEST_UPDATE:198:digest_update
|
||||
ENGINE_F_DYNAMIC_CTRL:180:dynamic_ctrl
|
||||
ENGINE_F_DYNAMIC_GET_DATA_CTX:181:dynamic_get_data_ctx
|
||||
@@ -902,6 +907,7 @@ RAND_F_GET_ENTROPY:106:get_entropy
|
||||
RAND_F_RAND_BYTES:100:RAND_bytes
|
||||
RAND_F_RAND_DRBG_ENABLE_LOCKING:119:rand_drbg_enable_locking
|
||||
RAND_F_RAND_DRBG_GENERATE:107:RAND_DRBG_generate
|
||||
RAND_F_RAND_DRBG_GET_ENTROPY:120:rand_drbg_get_entropy
|
||||
RAND_F_RAND_DRBG_INSTANTIATE:108:RAND_DRBG_instantiate
|
||||
RAND_F_RAND_DRBG_NEW:109:RAND_DRBG_new
|
||||
RAND_F_RAND_DRBG_RESEED:110:RAND_DRBG_reseed
|
||||
@@ -1177,6 +1183,7 @@ SSL_F_SSL_SESSION_SET1_ID:423:SSL_SESSION_set1_id
|
||||
SSL_F_SSL_SESSION_SET1_ID_CONTEXT:312:SSL_SESSION_set1_id_context
|
||||
SSL_F_SSL_SET_ALPN_PROTOS:344:SSL_set_alpn_protos
|
||||
SSL_F_SSL_SET_CERT:191:ssl_set_cert
|
||||
SSL_F_SSL_SET_CERT_AND_KEY:621:ssl_set_cert_and_key
|
||||
SSL_F_SSL_SET_CIPHER_LIST:271:SSL_set_cipher_list
|
||||
SSL_F_SSL_SET_CT_VALIDATION_CALLBACK:399:SSL_set_ct_validation_callback
|
||||
SSL_F_SSL_SET_FD:192:SSL_set_fd
|
||||
@@ -1869,6 +1876,7 @@ CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE:106:no conf or environment variable
|
||||
CONF_R_NO_SECTION:107:no section
|
||||
CONF_R_NO_SUCH_FILE:114:no such file
|
||||
CONF_R_NO_VALUE:108:no value
|
||||
CONF_R_RECURSIVE_DIRECTORY_INCLUDE:111:recursive directory include
|
||||
CONF_R_UNABLE_TO_CREATE_NEW_SECTION:103:unable to create new section
|
||||
CONF_R_UNKNOWN_MODULE_NAME:113:unknown module name
|
||||
CONF_R_VARIABLE_EXPANSION_TOO_LONG:116:variable expansion too long
|
||||
@@ -2294,6 +2302,7 @@ RAND_R_NOT_A_REGULAR_FILE:122:Not a regular file
|
||||
RAND_R_NOT_INSTANTIATED:115:not instantiated
|
||||
RAND_R_NO_DRBG_IMPLEMENTATION_SELECTED:128:no drbg implementation selected
|
||||
RAND_R_PARENT_LOCKING_NOT_ENABLED:130:parent locking not enabled
|
||||
RAND_R_PARENT_STRENGTH_TOO_WEAK:131:parent strength too weak
|
||||
RAND_R_PERSONALISATION_STRING_TOO_LONG:116:personalisation string too long
|
||||
RAND_R_PRNG_NOT_SEEDED:100:PRNG not seeded
|
||||
RAND_R_RANDOM_POOL_OVERFLOW:125:random pool overflow
|
||||
@@ -2517,6 +2526,7 @@ SSL_R_LIBRARY_HAS_NO_CIPHERS:161:library has no ciphers
|
||||
SSL_R_MISSING_DSA_SIGNING_CERT:165:missing dsa signing cert
|
||||
SSL_R_MISSING_ECDSA_SIGNING_CERT:381:missing ecdsa signing cert
|
||||
SSL_R_MISSING_FATAL:256:missing fatal
|
||||
SSL_R_MISSING_PARAMETERS:290:missing parameters
|
||||
SSL_R_MISSING_RSA_CERTIFICATE:168:missing rsa certificate
|
||||
SSL_R_MISSING_RSA_ENCRYPTING_CERT:169:missing rsa encrypting cert
|
||||
SSL_R_MISSING_RSA_SIGNING_CERT:170:missing rsa signing cert
|
||||
@@ -2527,6 +2537,7 @@ SSL_R_MISSING_SUPPORTED_GROUPS_EXTENSION:209:missing supported groups extension
|
||||
SSL_R_MISSING_TMP_DH_KEY:171:missing tmp dh key
|
||||
SSL_R_MISSING_TMP_ECDH_KEY:311:missing tmp ecdh key
|
||||
SSL_R_NOT_ON_RECORD_BOUNDARY:182:not on record boundary
|
||||
SSL_R_NOT_REPLACING_CERTIFICATE:289:not replacing certificate
|
||||
SSL_R_NOT_SERVER:284:not server
|
||||
SSL_R_NO_APPLICATION_PROTOCOL:235:no application protocol
|
||||
SSL_R_NO_CERTIFICATES_RETURNED:176:no certificates returned
|
||||
@@ -2538,6 +2549,7 @@ SSL_R_NO_CIPHERS_SPECIFIED:183:no ciphers specified
|
||||
SSL_R_NO_CIPHER_MATCH:185:no cipher match
|
||||
SSL_R_NO_CLIENT_CERT_METHOD:331:no client cert method
|
||||
SSL_R_NO_COMPRESSION_SPECIFIED:187:no compression specified
|
||||
SSL_R_NO_COOKIE_CALLBACK_SET:287:no cookie callback set
|
||||
SSL_R_NO_GOST_CERTIFICATE_SENT_BY_PEER:330:\
|
||||
Peer haven't sent GOST certificate, required for selected ciphersuite
|
||||
SSL_R_NO_METHOD_SPECIFIED:188:no method specified
|
||||
@@ -2568,6 +2580,7 @@ SSL_R_PEM_NAME_BAD_PREFIX:391:pem name bad prefix
|
||||
SSL_R_PEM_NAME_TOO_SHORT:392:pem name too short
|
||||
SSL_R_PIPELINE_FAILURE:406:pipeline failure
|
||||
SSL_R_POST_HANDSHAKE_AUTH_ENCODING_ERR:278:post handshake auth encoding err
|
||||
SSL_R_PRIVATE_KEY_MISMATCH:288:private key mismatch
|
||||
SSL_R_PROTOCOL_IS_SHUTDOWN:207:protocol is shutdown
|
||||
SSL_R_PSK_IDENTITY_NOT_FOUND:223:psk identity not found
|
||||
SSL_R_PSK_NO_CLIENT_CB:224:psk no client cb
|
||||
|
||||
@@ -289,6 +289,14 @@ static int b64_read(BIO *b, char *out, int outl)
|
||||
(unsigned char *)ctx->tmp, i);
|
||||
ctx->tmp_len = 0;
|
||||
}
|
||||
/*
|
||||
* If eof or an error was signalled, then the condition
|
||||
* 'ctx->cont <= 0' will prevent b64_read() from reading
|
||||
* more data on subsequent calls. This assignment was
|
||||
* deleted accidentally in commit 5562cfaca4f3.
|
||||
*/
|
||||
ctx->cont = i;
|
||||
|
||||
ctx->buf_off = 0;
|
||||
if (i < 0) {
|
||||
ret_code = 0;
|
||||
|
||||
+17
-5
@@ -17,6 +17,7 @@
|
||||
#include "internal/evp_int.h"
|
||||
#include "modes_lcl.h"
|
||||
#include <openssl/rand.h>
|
||||
#include <internal/rand.h>
|
||||
#include "evp_locl.h"
|
||||
|
||||
typedef struct {
|
||||
@@ -1404,8 +1405,14 @@ static int s390x_aes_gcm_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr)
|
||||
memcpy(gctx->iv, ptr, arg);
|
||||
|
||||
enc = EVP_CIPHER_CTX_encrypting(c);
|
||||
if (enc && RAND_bytes(gctx->iv + arg, gctx->ivlen - arg) <= 0)
|
||||
return 0;
|
||||
if (enc) {
|
||||
if (c->drbg != NULL) {
|
||||
if (RAND_DRBG_bytes(c->drbg, gctx->iv + arg, gctx->ivlen - arg) == 0)
|
||||
return 0;
|
||||
} else if (RAND_bytes(gctx->iv + arg, gctx->ivlen - arg) <= 0) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
gctx->iv_gen = 1;
|
||||
return 1;
|
||||
@@ -2632,9 +2639,14 @@ static int aes_gcm_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr)
|
||||
return 0;
|
||||
if (arg)
|
||||
memcpy(gctx->iv, ptr, arg);
|
||||
if (EVP_CIPHER_CTX_encrypting(c)
|
||||
&& RAND_bytes(gctx->iv + arg, gctx->ivlen - arg) <= 0)
|
||||
return 0;
|
||||
if (EVP_CIPHER_CTX_encrypting(c)) {
|
||||
if (c->drbg != NULL) {
|
||||
if (RAND_DRBG_bytes(c->drbg, gctx->iv + arg, gctx->ivlen - arg) == 0)
|
||||
return 0;
|
||||
} else if (RAND_bytes(gctx->iv + arg, gctx->ivlen - arg) <= 0) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
gctx->iv_gen = 1;
|
||||
return 1;
|
||||
|
||||
|
||||
@@ -17,9 +17,11 @@
|
||||
#include <openssl/aes.h>
|
||||
#include <openssl/sha.h>
|
||||
#include <openssl/rand.h>
|
||||
#include <internal/rand.h>
|
||||
#include "modes_lcl.h"
|
||||
#include "internal/evp_int.h"
|
||||
#include "internal/constant_time_locl.h"
|
||||
#include "evp_locl.h"
|
||||
|
||||
typedef struct {
|
||||
AES_KEY ks;
|
||||
@@ -154,7 +156,8 @@ void aesni_multi_cbc_encrypt(CIPH_DESC *, void *, int);
|
||||
static size_t tls1_1_multi_block_encrypt(EVP_AES_HMAC_SHA1 *key,
|
||||
unsigned char *out,
|
||||
const unsigned char *inp,
|
||||
size_t inp_len, int n4x)
|
||||
size_t inp_len, int n4x,
|
||||
RAND_DRBG *drbg)
|
||||
{ /* n4x is 1 or 2 */
|
||||
HASH_DESC hash_d[8], edges[8];
|
||||
CIPH_DESC ciph_d[8];
|
||||
@@ -174,8 +177,13 @@ static size_t tls1_1_multi_block_encrypt(EVP_AES_HMAC_SHA1 *key,
|
||||
# endif
|
||||
|
||||
/* ask for IVs in bulk */
|
||||
if (RAND_bytes((IVs = blocks[0].c), 16 * x4) <= 0)
|
||||
IVs = blocks[0].c;
|
||||
if (drbg != NULL) {
|
||||
if (RAND_DRBG_bytes(drbg, IVs, 16 * x4) == 0)
|
||||
return 0;
|
||||
} else if (RAND_bytes(IVs, 16 * x4) <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
ctx = (SHA1_MB_CTX *) (storage + 32 - ((size_t)storage % 32)); /* align */
|
||||
|
||||
@@ -893,7 +901,8 @@ static int aesni_cbc_hmac_sha1_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg,
|
||||
|
||||
return (int)tls1_1_multi_block_encrypt(key, param->out,
|
||||
param->inp, param->len,
|
||||
param->interleave / 4);
|
||||
param->interleave / 4,
|
||||
ctx->drbg);
|
||||
}
|
||||
case EVP_CTRL_TLS1_1_MULTIBLOCK_DECRYPT:
|
||||
# endif
|
||||
|
||||
@@ -18,9 +18,11 @@
|
||||
#include <openssl/aes.h>
|
||||
#include <openssl/sha.h>
|
||||
#include <openssl/rand.h>
|
||||
#include <internal/rand.h>
|
||||
#include "modes_lcl.h"
|
||||
#include "internal/constant_time_locl.h"
|
||||
#include "internal/evp_int.h"
|
||||
#include "evp_locl.h"
|
||||
|
||||
typedef struct {
|
||||
AES_KEY ks;
|
||||
@@ -150,7 +152,8 @@ void aesni_multi_cbc_encrypt(CIPH_DESC *, void *, int);
|
||||
static size_t tls1_1_multi_block_encrypt(EVP_AES_HMAC_SHA256 *key,
|
||||
unsigned char *out,
|
||||
const unsigned char *inp,
|
||||
size_t inp_len, int n4x)
|
||||
size_t inp_len, int n4x,
|
||||
RAND_DRBG *drbg)
|
||||
{ /* n4x is 1 or 2 */
|
||||
HASH_DESC hash_d[8], edges[8];
|
||||
CIPH_DESC ciph_d[8];
|
||||
@@ -170,8 +173,13 @@ static size_t tls1_1_multi_block_encrypt(EVP_AES_HMAC_SHA256 *key,
|
||||
# endif
|
||||
|
||||
/* ask for IVs in bulk */
|
||||
if (RAND_bytes((IVs = blocks[0].c), 16 * x4) <= 0)
|
||||
IVs = blocks[0].c;
|
||||
if (drbg != NULL) {
|
||||
if (RAND_DRBG_bytes(drbg, IVs, 16 * x4) == 0)
|
||||
return 0;
|
||||
} else if (RAND_bytes(IVs, 16 * x4) <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* align */
|
||||
ctx = (SHA256_MB_CTX *) (storage + 32 - ((size_t)storage % 32));
|
||||
@@ -877,7 +885,8 @@ static int aesni_cbc_hmac_sha256_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg,
|
||||
|
||||
return (int)tls1_1_multi_block_encrypt(key, param->out,
|
||||
param->inp, param->len,
|
||||
param->interleave / 4);
|
||||
param->interleave / 4,
|
||||
ctx->drbg);
|
||||
}
|
||||
case EVP_CTRL_TLS1_1_MULTIBLOCK_DECRYPT:
|
||||
# endif
|
||||
|
||||
+9
-3
@@ -15,6 +15,7 @@
|
||||
# include <openssl/rand.h>
|
||||
# include "internal/aria.h"
|
||||
# include "internal/evp_int.h"
|
||||
# include "internal/rand.h"
|
||||
# include "modes_lcl.h"
|
||||
# include "evp_locl.h"
|
||||
|
||||
@@ -301,9 +302,14 @@ static int aria_gcm_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr)
|
||||
return 0;
|
||||
if (arg)
|
||||
memcpy(gctx->iv, ptr, arg);
|
||||
if (EVP_CIPHER_CTX_encrypting(c)
|
||||
&& RAND_bytes(gctx->iv + arg, gctx->ivlen - arg) <= 0)
|
||||
return 0;
|
||||
if (EVP_CIPHER_CTX_encrypting(c)) {
|
||||
if (c->drbg != NULL) {
|
||||
if (RAND_DRBG_bytes(c->drbg, gctx->iv + arg, gctx->ivlen - arg) == 0)
|
||||
return 0;
|
||||
} else if (RAND_bytes(gctx->iv + arg, gctx->ivlen - arg) <= 0) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
gctx->iv_gen = 1;
|
||||
return 1;
|
||||
|
||||
|
||||
+7
-1
@@ -15,6 +15,8 @@
|
||||
# include "internal/evp_int.h"
|
||||
# include <openssl/des.h>
|
||||
# include <openssl/rand.h>
|
||||
# include <internal/rand.h>
|
||||
# include "evp_locl.h"
|
||||
|
||||
typedef struct {
|
||||
union {
|
||||
@@ -229,8 +231,12 @@ static int des_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr)
|
||||
|
||||
switch (type) {
|
||||
case EVP_CTRL_RAND_KEY:
|
||||
if (RAND_bytes(ptr, 8) <= 0)
|
||||
if (c->drbg != NULL) {
|
||||
if (RAND_DRBG_bytes(c->drbg, ptr, 8) == 0)
|
||||
return 0;
|
||||
} else if (RAND_bytes(ptr, 8) <= 0) {
|
||||
return 0;
|
||||
}
|
||||
DES_set_odd_parity((DES_cblock *)ptr);
|
||||
return 1;
|
||||
|
||||
|
||||
+11
-2
@@ -15,6 +15,7 @@
|
||||
# include "internal/evp_int.h"
|
||||
# include <openssl/des.h>
|
||||
# include <openssl/rand.h>
|
||||
# include <internal/rand.h>
|
||||
# include "evp_locl.h"
|
||||
|
||||
typedef struct {
|
||||
@@ -283,8 +284,12 @@ static int des3_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr)
|
||||
|
||||
switch (type) {
|
||||
case EVP_CTRL_RAND_KEY:
|
||||
if (RAND_bytes(ptr, EVP_CIPHER_CTX_key_length(ctx)) <= 0)
|
||||
if (ctx->drbg != NULL) {
|
||||
if (RAND_DRBG_bytes(ctx->drbg, ptr, EVP_CIPHER_CTX_key_length(ctx)) == 0)
|
||||
return 0;
|
||||
} else if (RAND_bytes(ptr, EVP_CIPHER_CTX_key_length(ctx)) <= 0) {
|
||||
return 0;
|
||||
}
|
||||
DES_set_odd_parity(deskey);
|
||||
if (EVP_CIPHER_CTX_key_length(ctx) >= 16)
|
||||
DES_set_odd_parity(deskey + 1);
|
||||
@@ -372,8 +377,12 @@ static int des_ede3_wrap(EVP_CIPHER_CTX *ctx, unsigned char *out,
|
||||
memcpy(out + inl + 8, sha1tmp, 8);
|
||||
OPENSSL_cleanse(sha1tmp, SHA_DIGEST_LENGTH);
|
||||
/* Generate random IV */
|
||||
if (RAND_bytes(EVP_CIPHER_CTX_iv_noconst(ctx), 8) <= 0)
|
||||
if (ctx->drbg != NULL) {
|
||||
if (RAND_DRBG_bytes(ctx->drbg, EVP_CIPHER_CTX_iv_noconst(ctx), 8) == 0)
|
||||
return -1;
|
||||
} else if (RAND_bytes(EVP_CIPHER_CTX_iv_noconst(ctx), 8) <= 0) {
|
||||
return -1;
|
||||
}
|
||||
memcpy(out, EVP_CIPHER_CTX_iv_noconst(ctx), 8);
|
||||
/* Encrypt everything after IV in place */
|
||||
des_ede_cbc_cipher(ctx, out + 8, out + 8, inl + 8);
|
||||
|
||||
+15
-1
@@ -15,6 +15,7 @@
|
||||
#include <openssl/rand.h>
|
||||
#include <openssl/engine.h>
|
||||
#include "internal/evp_int.h"
|
||||
#include "internal/rand.h"
|
||||
#include "evp_locl.h"
|
||||
|
||||
int EVP_CIPHER_CTX_reset(EVP_CIPHER_CTX *c)
|
||||
@@ -577,6 +578,15 @@ int EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *ctx, int pad)
|
||||
int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (type == EVP_CTRL_GET_DRBG) {
|
||||
*(RAND_DRBG **)ptr = ctx->drbg;
|
||||
return 1;
|
||||
}
|
||||
if (type == EVP_CTRL_SET_DRBG) {
|
||||
ctx->drbg = ptr;
|
||||
return 1;
|
||||
}
|
||||
if (!ctx->cipher) {
|
||||
EVPerr(EVP_F_EVP_CIPHER_CTX_CTRL, EVP_R_NO_CIPHER_SET);
|
||||
return 0;
|
||||
@@ -600,8 +610,12 @@ int EVP_CIPHER_CTX_rand_key(EVP_CIPHER_CTX *ctx, unsigned char *key)
|
||||
{
|
||||
if (ctx->cipher->flags & EVP_CIPH_RAND_KEY)
|
||||
return EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_RAND_KEY, 0, key);
|
||||
if (RAND_bytes(key, ctx->key_len) <= 0)
|
||||
if (ctx->drbg) {
|
||||
if (RAND_DRBG_bytes(ctx->drbg, key, ctx->key_len) == 0)
|
||||
return 0;
|
||||
} else if (RAND_bytes(key, ctx->key_len) <= 0) {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ struct evp_cipher_ctx_st {
|
||||
int final_used;
|
||||
int block_mask;
|
||||
unsigned char final[EVP_MAX_BLOCK_LENGTH]; /* possible final block */
|
||||
RAND_DRBG *drbg;
|
||||
} /* EVP_CIPHER_CTX */ ;
|
||||
|
||||
int PKCS5_v2_PBKDF2_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass,
|
||||
|
||||
+10
-3
@@ -14,6 +14,8 @@
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/objects.h>
|
||||
#include <openssl/x509.h>
|
||||
#include <internal/rand.h>
|
||||
#include "evp_locl.h"
|
||||
|
||||
int EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
|
||||
unsigned char **ek, int *ekl, unsigned char *iv,
|
||||
@@ -31,9 +33,14 @@ int EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
|
||||
return 1;
|
||||
if (EVP_CIPHER_CTX_rand_key(ctx, key) <= 0)
|
||||
return 0;
|
||||
if (EVP_CIPHER_CTX_iv_length(ctx)
|
||||
&& RAND_bytes(iv, EVP_CIPHER_CTX_iv_length(ctx)) <= 0)
|
||||
return 0;
|
||||
if (EVP_CIPHER_CTX_iv_length(ctx)) {
|
||||
if (ctx->drbg) {
|
||||
if (RAND_DRBG_bytes(ctx->drbg, iv, EVP_CIPHER_CTX_iv_length(ctx)) == 0)
|
||||
return 0;
|
||||
} else if (RAND_bytes(iv, EVP_CIPHER_CTX_iv_length(ctx)) <= 0) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!EVP_EncryptInit_ex(ctx, NULL, NULL, key, iv))
|
||||
return 0;
|
||||
|
||||
@@ -51,6 +51,7 @@ static const EVP_PKEY_METHOD *standard_methods[] = {
|
||||
&tls1_prf_pkey_meth,
|
||||
#ifndef OPENSSL_NO_EC
|
||||
&ecx25519_pkey_meth,
|
||||
&ecx448_pkey_meth,
|
||||
#endif
|
||||
&hkdf_pkey_meth,
|
||||
#ifndef OPENSSL_NO_POLY1305
|
||||
@@ -61,6 +62,7 @@ static const EVP_PKEY_METHOD *standard_methods[] = {
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_EC
|
||||
&ed25519_pkey_meth,
|
||||
&ed448_pkey_meth,
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
@@ -68,7 +68,9 @@ extern const EVP_PKEY_ASN1_METHOD dhx_asn1_meth;
|
||||
extern const EVP_PKEY_ASN1_METHOD dsa_asn1_meths[5];
|
||||
extern const EVP_PKEY_ASN1_METHOD eckey_asn1_meth;
|
||||
extern const EVP_PKEY_ASN1_METHOD ecx25519_asn1_meth;
|
||||
extern const EVP_PKEY_ASN1_METHOD ecx448_asn1_meth;
|
||||
extern const EVP_PKEY_ASN1_METHOD ed25519_asn1_meth;
|
||||
extern const EVP_PKEY_ASN1_METHOD ed448_asn1_meth;
|
||||
extern const EVP_PKEY_ASN1_METHOD poly1305_asn1_meth;
|
||||
|
||||
extern const EVP_PKEY_ASN1_METHOD hmac_asn1_meth;
|
||||
|
||||
@@ -90,7 +90,9 @@ extern const EVP_PKEY_METHOD dhx_pkey_meth;
|
||||
extern const EVP_PKEY_METHOD dsa_pkey_meth;
|
||||
extern const EVP_PKEY_METHOD ec_pkey_meth;
|
||||
extern const EVP_PKEY_METHOD ecx25519_pkey_meth;
|
||||
extern const EVP_PKEY_METHOD ecx448_pkey_meth;
|
||||
extern const EVP_PKEY_METHOD ed25519_pkey_meth;
|
||||
extern const EVP_PKEY_METHOD ed448_pkey_meth;
|
||||
extern const EVP_PKEY_METHOD hmac_pkey_meth;
|
||||
extern const EVP_PKEY_METHOD rsa_pkey_meth;
|
||||
extern const EVP_PKEY_METHOD rsa_pss_pkey_meth;
|
||||
@@ -361,6 +363,21 @@ const EVP_CIPHER *EVP_##cname##_ecb(void) { return &cname##_ecb; }
|
||||
cipher##_init_key, NULL, NULL, NULL, NULL)
|
||||
|
||||
|
||||
# ifndef OPENSSL_NO_EC
|
||||
|
||||
#define X25519_KEYLEN 32
|
||||
#define X448_KEYLEN 56
|
||||
#define ED448_KEYLEN 57
|
||||
|
||||
#define MAX_KEYLEN ED448_KEYLEN
|
||||
|
||||
typedef struct {
|
||||
unsigned char pubkey[MAX_KEYLEN];
|
||||
unsigned char *privkey;
|
||||
} ECX_KEY;
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Type needs to be a bit field Sub-type needs to be for variations on the
|
||||
* method, as in, can it do arbitrary encryption....
|
||||
@@ -385,6 +402,7 @@ struct evp_pkey_st {
|
||||
# endif
|
||||
# ifndef OPENSSL_NO_EC
|
||||
struct ec_key_st *ec; /* ECC */
|
||||
ECX_KEY *ecx; /* X25519, X448, Ed25519, Ed448 */
|
||||
# endif
|
||||
} pkey;
|
||||
int save_parameters;
|
||||
|
||||
Executable → Regular
+8
-2
@@ -201,7 +201,14 @@ void *CRYPTO_malloc(size_t num, const char *file, int line)
|
||||
return NULL;
|
||||
|
||||
FAILTEST();
|
||||
allow_customize = 0;
|
||||
if (allow_customize) {
|
||||
/*
|
||||
* Disallow customization after the first allocation. We only set this
|
||||
* if necessary to avoid a store to the same cache line on every
|
||||
* allocation.
|
||||
*/
|
||||
allow_customize = 0;
|
||||
}
|
||||
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
|
||||
if (call_malloc_debug) {
|
||||
CRYPTO_mem_debug_malloc(NULL, num, 0, file, line);
|
||||
@@ -243,7 +250,6 @@ void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
allow_customize = 0;
|
||||
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
|
||||
if (call_malloc_debug) {
|
||||
void *ret;
|
||||
|
||||
+7
-2
@@ -33,8 +33,10 @@
|
||||
# include <sys/mman.h>
|
||||
# if defined(OPENSSL_SYS_LINUX)
|
||||
# include <sys/syscall.h>
|
||||
# include <linux/mman.h>
|
||||
# include <errno.h>
|
||||
# if defined(SYS_mlock2)
|
||||
# include <linux/mman.h>
|
||||
# include <errno.h>
|
||||
# endif
|
||||
# endif
|
||||
# include <sys/param.h>
|
||||
# include <sys/stat.h>
|
||||
@@ -45,6 +47,9 @@
|
||||
#ifndef PAGE_SIZE
|
||||
# define PAGE_SIZE 4096
|
||||
#endif
|
||||
#if !defined(MAP_ANON) && defined(MAP_ANONYMOUS)
|
||||
# define MAP_ANON MAP_ANONYMOUS
|
||||
#endif
|
||||
|
||||
#ifdef IMPLEMENTED
|
||||
static size_t secure_mem_used;
|
||||
|
||||
Executable → Regular
Executable → Regular
@@ -213,7 +213,7 @@ int OBJ_add_object(const ASN1_OBJECT *obj)
|
||||
err:
|
||||
for (i = ADDED_DATA; i <= ADDED_NID; i++)
|
||||
OPENSSL_free(ao[i]);
|
||||
OPENSSL_free(o);
|
||||
ASN1_OBJECT_free(o);
|
||||
return NID_undef;
|
||||
}
|
||||
|
||||
|
||||
+120
-5
@@ -10,7 +10,7 @@
|
||||
*/
|
||||
|
||||
/* Serialized OID's */
|
||||
static const unsigned char so[7342] = {
|
||||
static const unsigned char so[7595] = {
|
||||
0x2A,0x86,0x48,0x86,0xF7,0x0D, /* [ 0] OBJ_rsadsi */
|
||||
0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01, /* [ 6] OBJ_pkcs */
|
||||
0x2A,0x86,0x48,0x86,0xF7,0x0D,0x02,0x02, /* [ 13] OBJ_md2 */
|
||||
@@ -1032,9 +1032,32 @@ static const unsigned char so[7342] = {
|
||||
0x2A,0x81,0x1C,0xCF,0x55,0x01,0x83,0x78, /* [ 7315] OBJ_sm3WithRSAEncryption */
|
||||
0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x0F, /* [ 7323] OBJ_sha512_224WithRSAEncryption */
|
||||
0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x10, /* [ 7332] OBJ_sha512_256WithRSAEncryption */
|
||||
0x2A,0x85,0x03,0x07,0x01,0x02,0x01,0x01, /* [ 7341] OBJ_id_tc26_gost_3410_2012_256_constants */
|
||||
0x2A,0x85,0x03,0x07,0x01,0x02,0x01,0x01,0x01, /* [ 7349] OBJ_id_tc26_gost_3410_2012_256_paramSetA */
|
||||
0x2A,0x85,0x03,0x07,0x01,0x02,0x01,0x02,0x03, /* [ 7358] OBJ_id_tc26_gost_3410_2012_512_paramSetC */
|
||||
0x2A,0x86,0x24, /* [ 7367] OBJ_ISO_UA */
|
||||
0x2A,0x86,0x24,0x02,0x01,0x01,0x01, /* [ 7370] OBJ_ua_pki */
|
||||
0x2A,0x86,0x24,0x02,0x01,0x01,0x01,0x01,0x01,0x01, /* [ 7377] OBJ_dstu28147 */
|
||||
0x2A,0x86,0x24,0x02,0x01,0x01,0x01,0x01,0x01,0x01,0x02, /* [ 7387] OBJ_dstu28147_ofb */
|
||||
0x2A,0x86,0x24,0x02,0x01,0x01,0x01,0x01,0x01,0x01,0x03, /* [ 7398] OBJ_dstu28147_cfb */
|
||||
0x2A,0x86,0x24,0x02,0x01,0x01,0x01,0x01,0x01,0x01,0x05, /* [ 7409] OBJ_dstu28147_wrap */
|
||||
0x2A,0x86,0x24,0x02,0x01,0x01,0x01,0x01,0x01,0x02, /* [ 7420] OBJ_hmacWithDstu34311 */
|
||||
0x2A,0x86,0x24,0x02,0x01,0x01,0x01,0x01,0x02,0x01, /* [ 7430] OBJ_dstu34311 */
|
||||
0x2A,0x86,0x24,0x02,0x01,0x01,0x01,0x01,0x03,0x01,0x01, /* [ 7440] OBJ_dstu4145le */
|
||||
0x2A,0x86,0x24,0x02,0x01,0x01,0x01,0x01,0x03,0x01,0x01,0x01,0x01, /* [ 7451] OBJ_dstu4145be */
|
||||
0x2A,0x86,0x24,0x02,0x01,0x01,0x01,0x01,0x03,0x01,0x01,0x02,0x00, /* [ 7464] OBJ_uacurve0 */
|
||||
0x2A,0x86,0x24,0x02,0x01,0x01,0x01,0x01,0x03,0x01,0x01,0x02,0x01, /* [ 7477] OBJ_uacurve1 */
|
||||
0x2A,0x86,0x24,0x02,0x01,0x01,0x01,0x01,0x03,0x01,0x01,0x02,0x02, /* [ 7490] OBJ_uacurve2 */
|
||||
0x2A,0x86,0x24,0x02,0x01,0x01,0x01,0x01,0x03,0x01,0x01,0x02,0x03, /* [ 7503] OBJ_uacurve3 */
|
||||
0x2A,0x86,0x24,0x02,0x01,0x01,0x01,0x01,0x03,0x01,0x01,0x02,0x04, /* [ 7516] OBJ_uacurve4 */
|
||||
0x2A,0x86,0x24,0x02,0x01,0x01,0x01,0x01,0x03,0x01,0x01,0x02,0x05, /* [ 7529] OBJ_uacurve5 */
|
||||
0x2A,0x86,0x24,0x02,0x01,0x01,0x01,0x01,0x03,0x01,0x01,0x02,0x06, /* [ 7542] OBJ_uacurve6 */
|
||||
0x2A,0x86,0x24,0x02,0x01,0x01,0x01,0x01,0x03,0x01,0x01,0x02,0x07, /* [ 7555] OBJ_uacurve7 */
|
||||
0x2A,0x86,0x24,0x02,0x01,0x01,0x01,0x01,0x03,0x01,0x01,0x02,0x08, /* [ 7568] OBJ_uacurve8 */
|
||||
0x2A,0x86,0x24,0x02,0x01,0x01,0x01,0x01,0x03,0x01,0x01,0x02,0x09, /* [ 7581] OBJ_uacurve9 */
|
||||
};
|
||||
|
||||
#define NUM_NID 1147
|
||||
#define NUM_NID 1170
|
||||
static const ASN1_OBJECT nid_objs[NUM_NID] = {
|
||||
{"UNDEF", "undefined", NID_undef},
|
||||
{"rsadsi", "RSA Data Security, Inc.", NID_rsadsi, 6, &so[0]},
|
||||
@@ -2183,9 +2206,32 @@ static const ASN1_OBJECT nid_objs[NUM_NID] = {
|
||||
{"RSA-SM3", "sm3WithRSAEncryption", NID_sm3WithRSAEncryption, 8, &so[7315]},
|
||||
{"RSA-SHA512/224", "sha512-224WithRSAEncryption", NID_sha512_224WithRSAEncryption, 9, &so[7323]},
|
||||
{"RSA-SHA512/256", "sha512-256WithRSAEncryption", NID_sha512_256WithRSAEncryption, 9, &so[7332]},
|
||||
{"id-tc26-gost-3410-2012-256-constants", "id-tc26-gost-3410-2012-256-constants", NID_id_tc26_gost_3410_2012_256_constants, 8, &so[7341]},
|
||||
{"id-tc26-gost-3410-2012-256-paramSetA", "GOST R 34.10-2012 (256 bit) ParamSet A", NID_id_tc26_gost_3410_2012_256_paramSetA, 9, &so[7349]},
|
||||
{"id-tc26-gost-3410-2012-512-paramSetC", "GOST R 34.10-2012 (512 bit) ParamSet C", NID_id_tc26_gost_3410_2012_512_paramSetC, 9, &so[7358]},
|
||||
{"ISO-UA", "ISO-UA", NID_ISO_UA, 3, &so[7367]},
|
||||
{"ua-pki", "ua-pki", NID_ua_pki, 7, &so[7370]},
|
||||
{"dstu28147", "DSTU Gost 28147-2009", NID_dstu28147, 10, &so[7377]},
|
||||
{"dstu28147-ofb", "DSTU Gost 28147-2009 OFB mode", NID_dstu28147_ofb, 11, &so[7387]},
|
||||
{"dstu28147-cfb", "DSTU Gost 28147-2009 CFB mode", NID_dstu28147_cfb, 11, &so[7398]},
|
||||
{"dstu28147-wrap", "DSTU Gost 28147-2009 key wrap", NID_dstu28147_wrap, 11, &so[7409]},
|
||||
{"hmacWithDstu34311", "HMAC DSTU Gost 34311-95", NID_hmacWithDstu34311, 10, &so[7420]},
|
||||
{"dstu34311", "DSTU Gost 34311-95", NID_dstu34311, 10, &so[7430]},
|
||||
{"dstu4145le", "DSTU 4145-2002 little endian", NID_dstu4145le, 11, &so[7440]},
|
||||
{"dstu4145be", "DSTU 4145-2002 big endian", NID_dstu4145be, 13, &so[7451]},
|
||||
{"uacurve0", "DSTU curve 0", NID_uacurve0, 13, &so[7464]},
|
||||
{"uacurve1", "DSTU curve 1", NID_uacurve1, 13, &so[7477]},
|
||||
{"uacurve2", "DSTU curve 2", NID_uacurve2, 13, &so[7490]},
|
||||
{"uacurve3", "DSTU curve 3", NID_uacurve3, 13, &so[7503]},
|
||||
{"uacurve4", "DSTU curve 4", NID_uacurve4, 13, &so[7516]},
|
||||
{"uacurve5", "DSTU curve 5", NID_uacurve5, 13, &so[7529]},
|
||||
{"uacurve6", "DSTU curve 6", NID_uacurve6, 13, &so[7542]},
|
||||
{"uacurve7", "DSTU curve 7", NID_uacurve7, 13, &so[7555]},
|
||||
{"uacurve8", "DSTU curve 8", NID_uacurve8, 13, &so[7568]},
|
||||
{"uacurve9", "DSTU curve 9", NID_uacurve9, 13, &so[7581]},
|
||||
};
|
||||
|
||||
#define NUM_SN 1138
|
||||
#define NUM_SN 1161
|
||||
static const unsigned int sn_objs[NUM_SN] = {
|
||||
364, /* "AD_DVCS" */
|
||||
419, /* "AES-128-CBC" */
|
||||
@@ -2345,6 +2391,7 @@ static const unsigned int sn_objs[NUM_SN] = {
|
||||
1004, /* "INN" */
|
||||
181, /* "ISO" */
|
||||
1140, /* "ISO-CN" */
|
||||
1150, /* "ISO-UA" */
|
||||
183, /* "ISO-US" */
|
||||
645, /* "ITU-T" */
|
||||
646, /* "JOINT-ISO-ITU-T" */
|
||||
@@ -2605,6 +2652,13 @@ static const unsigned int sn_objs[NUM_SN] = {
|
||||
452, /* "domainRelatedObject" */
|
||||
802, /* "dsa_with_SHA224" */
|
||||
803, /* "dsa_with_SHA256" */
|
||||
1152, /* "dstu28147" */
|
||||
1154, /* "dstu28147-cfb" */
|
||||
1153, /* "dstu28147-ofb" */
|
||||
1155, /* "dstu28147-wrap" */
|
||||
1157, /* "dstu34311" */
|
||||
1159, /* "dstu4145be" */
|
||||
1158, /* "dstu4145le" */
|
||||
791, /* "ecdsa-with-Recommended" */
|
||||
416, /* "ecdsa-with-SHA1" */
|
||||
793, /* "ecdsa-with-SHA224" */
|
||||
@@ -2653,6 +2707,7 @@ static const unsigned int sn_objs[NUM_SN] = {
|
||||
1012, /* "grasshopper-ecb" */
|
||||
1017, /* "grasshopper-mac" */
|
||||
1014, /* "grasshopper-ofb" */
|
||||
1156, /* "hmacWithDstu34311" */
|
||||
797, /* "hmacWithMD5" */
|
||||
163, /* "hmacWithSHA1" */
|
||||
798, /* "hmacWithSHA224" */
|
||||
@@ -2940,9 +2995,12 @@ static const unsigned int sn_objs[NUM_SN] = {
|
||||
1000, /* "id-tc26-digest-constants" */
|
||||
1002, /* "id-tc26-gost-28147-constants" */
|
||||
1003, /* "id-tc26-gost-28147-param-Z" */
|
||||
1147, /* "id-tc26-gost-3410-2012-256-constants" */
|
||||
1148, /* "id-tc26-gost-3410-2012-256-paramSetA" */
|
||||
996, /* "id-tc26-gost-3410-2012-512-constants" */
|
||||
998, /* "id-tc26-gost-3410-2012-512-paramSetA" */
|
||||
999, /* "id-tc26-gost-3410-2012-512-paramSetB" */
|
||||
1149, /* "id-tc26-gost-3410-2012-512-paramSetC" */
|
||||
997, /* "id-tc26-gost-3410-2012-512-paramSetTest" */
|
||||
988, /* "id-tc26-hmac-gost-3411-2012-256" */
|
||||
989, /* "id-tc26-hmac-gost-3411-2012-512" */
|
||||
@@ -3297,6 +3355,17 @@ static const unsigned int sn_objs[NUM_SN] = {
|
||||
1020, /* "tlsfeature" */
|
||||
682, /* "tpBasis" */
|
||||
375, /* "trustRoot" */
|
||||
1151, /* "ua-pki" */
|
||||
1160, /* "uacurve0" */
|
||||
1161, /* "uacurve1" */
|
||||
1162, /* "uacurve2" */
|
||||
1163, /* "uacurve3" */
|
||||
1164, /* "uacurve4" */
|
||||
1165, /* "uacurve5" */
|
||||
1166, /* "uacurve6" */
|
||||
1167, /* "uacurve7" */
|
||||
1168, /* "uacurve8" */
|
||||
1169, /* "uacurve9" */
|
||||
436, /* "ucl" */
|
||||
102, /* "uid" */
|
||||
888, /* "uniqueMember" */
|
||||
@@ -3327,7 +3396,7 @@ static const unsigned int sn_objs[NUM_SN] = {
|
||||
1093, /* "x509ExtAdmission" */
|
||||
};
|
||||
|
||||
#define NUM_LN 1138
|
||||
#define NUM_LN 1161
|
||||
static const unsigned int ln_objs[NUM_LN] = {
|
||||
363, /* "AD Time Stamping" */
|
||||
405, /* "ANSI X9.62" */
|
||||
@@ -3348,6 +3417,23 @@ static const unsigned int ln_objs[NUM_LN] = {
|
||||
131, /* "Code Signing" */
|
||||
1024, /* "Ctrl/Provision WAP Termination" */
|
||||
1023, /* "Ctrl/provision WAP Access" */
|
||||
1159, /* "DSTU 4145-2002 big endian" */
|
||||
1158, /* "DSTU 4145-2002 little endian" */
|
||||
1152, /* "DSTU Gost 28147-2009" */
|
||||
1154, /* "DSTU Gost 28147-2009 CFB mode" */
|
||||
1153, /* "DSTU Gost 28147-2009 OFB mode" */
|
||||
1155, /* "DSTU Gost 28147-2009 key wrap" */
|
||||
1157, /* "DSTU Gost 34311-95" */
|
||||
1160, /* "DSTU curve 0" */
|
||||
1161, /* "DSTU curve 1" */
|
||||
1162, /* "DSTU curve 2" */
|
||||
1163, /* "DSTU curve 3" */
|
||||
1164, /* "DSTU curve 4" */
|
||||
1165, /* "DSTU curve 5" */
|
||||
1166, /* "DSTU curve 6" */
|
||||
1167, /* "DSTU curve 7" */
|
||||
1168, /* "DSTU curve 8" */
|
||||
1169, /* "DSTU curve 9" */
|
||||
783, /* "Diffie-Hellman based MAC" */
|
||||
382, /* "Directory" */
|
||||
392, /* "Domain" */
|
||||
@@ -3366,8 +3452,10 @@ static const unsigned int ln_objs[NUM_LN] = {
|
||||
850, /* "GOST 34.10-94 Cryptocom" */
|
||||
811, /* "GOST R 34.10-2001" */
|
||||
817, /* "GOST R 34.10-2001 DH" */
|
||||
1148, /* "GOST R 34.10-2012 (256 bit) ParamSet A" */
|
||||
998, /* "GOST R 34.10-2012 (512 bit) ParamSet A" */
|
||||
999, /* "GOST R 34.10-2012 (512 bit) ParamSet B" */
|
||||
1149, /* "GOST R 34.10-2012 (512 bit) ParamSet C" */
|
||||
997, /* "GOST R 34.10-2012 (512 bit) testing parameter set" */
|
||||
979, /* "GOST R 34.10-2012 with 256 bit modulus" */
|
||||
980, /* "GOST R 34.10-2012 with 512 bit modulus" */
|
||||
@@ -3384,6 +3472,7 @@ static const unsigned int ln_objs[NUM_LN] = {
|
||||
808, /* "GOST R 34.11-94 with GOST R 34.10-94" */
|
||||
852, /* "GOST R 34.11-94 with GOST R 34.10-94 Cryptocom" */
|
||||
854, /* "GOST R 3410-2001 Parameter Set Cryptocom" */
|
||||
1156, /* "HMAC DSTU Gost 34311-95" */
|
||||
988, /* "HMAC GOST 34.11-2012 256 bit" */
|
||||
989, /* "HMAC GOST 34.11-2012 512 bit" */
|
||||
810, /* "HMAC GOST 34.11-94" */
|
||||
@@ -3399,6 +3488,7 @@ static const unsigned int ln_objs[NUM_LN] = {
|
||||
1140, /* "ISO CN Member Body" */
|
||||
182, /* "ISO Member Body" */
|
||||
183, /* "ISO US Member Body" */
|
||||
1150, /* "ISO-UA" */
|
||||
667, /* "Independent" */
|
||||
665, /* "Inherit all" */
|
||||
647, /* "International Organizations" */
|
||||
@@ -4056,6 +4146,7 @@ static const unsigned int ln_objs[NUM_LN] = {
|
||||
981, /* "id-tc26-digest" */
|
||||
1000, /* "id-tc26-digest-constants" */
|
||||
1002, /* "id-tc26-gost-28147-constants" */
|
||||
1147, /* "id-tc26-gost-3410-2012-256-constants" */
|
||||
996, /* "id-tc26-gost-3410-2012-512-constants" */
|
||||
987, /* "id-tc26-mac" */
|
||||
978, /* "id-tc26-sign" */
|
||||
@@ -4437,6 +4528,7 @@ static const unsigned int ln_objs[NUM_LN] = {
|
||||
106, /* "title" */
|
||||
1021, /* "tls1-prf" */
|
||||
682, /* "tpBasis" */
|
||||
1151, /* "ua-pki" */
|
||||
436, /* "ucl" */
|
||||
0, /* "undefined" */
|
||||
102, /* "uniqueIdentifier" */
|
||||
@@ -4469,7 +4561,7 @@ static const unsigned int ln_objs[NUM_LN] = {
|
||||
125, /* "zlib compression" */
|
||||
};
|
||||
|
||||
#define NUM_OBJ 1027
|
||||
#define NUM_OBJ 1050
|
||||
static const unsigned int obj_objs[NUM_OBJ] = {
|
||||
0, /* OBJ_undef 0 */
|
||||
181, /* OBJ_iso 1 */
|
||||
@@ -4491,6 +4583,7 @@ static const unsigned int obj_objs[NUM_OBJ] = {
|
||||
678, /* OBJ_wap 2 23 43 */
|
||||
435, /* OBJ_pss 0 9 2342 */
|
||||
1140, /* OBJ_ISO_CN 1 2 156 */
|
||||
1150, /* OBJ_ISO_UA 1 2 804 */
|
||||
183, /* OBJ_ISO_US 1 2 840 */
|
||||
381, /* OBJ_iana 1 3 6 1 */
|
||||
1034, /* OBJ_X25519 1 3 101 110 */
|
||||
@@ -4869,6 +4962,7 @@ static const unsigned int obj_objs[NUM_OBJ] = {
|
||||
995, /* OBJ_id_tc26_sign_constants 1 2 643 7 1 2 1 */
|
||||
1000, /* OBJ_id_tc26_digest_constants 1 2 643 7 1 2 2 */
|
||||
1001, /* OBJ_id_tc26_cipher_constants 1 2 643 7 1 2 5 */
|
||||
1151, /* OBJ_ua_pki 1 2 804 2 1 1 1 */
|
||||
2, /* OBJ_pkcs 1 2 840 113549 1 */
|
||||
431, /* OBJ_hold_instruction_none 1 2 840 10040 2 1 */
|
||||
432, /* OBJ_hold_instruction_call_issuer 1 2 840 10040 2 2 */
|
||||
@@ -4954,6 +5048,7 @@ static const unsigned int obj_objs[NUM_OBJ] = {
|
||||
989, /* OBJ_id_tc26_hmac_gost_3411_2012_512 1 2 643 7 1 1 4 2 */
|
||||
992, /* OBJ_id_tc26_agreement_gost_3410_2012_256 1 2 643 7 1 1 6 1 */
|
||||
993, /* OBJ_id_tc26_agreement_gost_3410_2012_512 1 2 643 7 1 1 6 2 */
|
||||
1147, /* OBJ_id_tc26_gost_3410_2012_256_constants 1 2 643 7 1 2 1 1 */
|
||||
996, /* OBJ_id_tc26_gost_3410_2012_512_constants 1 2 643 7 1 2 1 2 */
|
||||
1002, /* OBJ_id_tc26_gost_28147_constants 1 2 643 7 1 2 5 1 */
|
||||
186, /* OBJ_pkcs1 1 2 840 113549 1 1 */
|
||||
@@ -5156,9 +5251,11 @@ static const unsigned int obj_objs[NUM_OBJ] = {
|
||||
1120, /* OBJ_aria_128_ccm 1 2 410 200046 1 1 37 */
|
||||
1121, /* OBJ_aria_192_ccm 1 2 410 200046 1 1 38 */
|
||||
1122, /* OBJ_aria_256_ccm 1 2 410 200046 1 1 39 */
|
||||
1148, /* OBJ_id_tc26_gost_3410_2012_256_paramSetA 1 2 643 7 1 2 1 1 1 */
|
||||
997, /* OBJ_id_tc26_gost_3410_2012_512_paramSetTest 1 2 643 7 1 2 1 2 0 */
|
||||
998, /* OBJ_id_tc26_gost_3410_2012_512_paramSetA 1 2 643 7 1 2 1 2 1 */
|
||||
999, /* OBJ_id_tc26_gost_3410_2012_512_paramSetB 1 2 643 7 1 2 1 2 2 */
|
||||
1149, /* OBJ_id_tc26_gost_3410_2012_512_paramSetC 1 2 643 7 1 2 1 2 3 */
|
||||
1003, /* OBJ_id_tc26_gost_28147_param_Z 1 2 643 7 1 2 5 1 1 */
|
||||
108, /* OBJ_cast5_cbc 1 2 840 113533 7 66 10 */
|
||||
112, /* OBJ_pbeWithMD5AndCast5_CBC 1 2 840 113533 7 66 12 */
|
||||
@@ -5383,6 +5480,9 @@ static const unsigned int obj_objs[NUM_OBJ] = {
|
||||
455, /* OBJ_pilotOrganization 0 9 2342 19200300 100 4 20 */
|
||||
456, /* OBJ_pilotDSA 0 9 2342 19200300 100 4 21 */
|
||||
457, /* OBJ_qualityLabelledData 0 9 2342 19200300 100 4 22 */
|
||||
1152, /* OBJ_dstu28147 1 2 804 2 1 1 1 1 1 1 */
|
||||
1156, /* OBJ_hmacWithDstu34311 1 2 804 2 1 1 1 1 1 2 */
|
||||
1157, /* OBJ_dstu34311 1 2 804 2 1 1 1 1 2 1 */
|
||||
189, /* OBJ_id_smime_mod 1 2 840 113549 1 9 16 0 */
|
||||
190, /* OBJ_id_smime_ct 1 2 840 113549 1 9 16 1 */
|
||||
191, /* OBJ_id_smime_aa 1 2 840 113549 1 9 16 2 */
|
||||
@@ -5417,6 +5517,10 @@ static const unsigned int obj_objs[NUM_OBJ] = {
|
||||
907, /* OBJ_id_camellia128_wrap 1 2 392 200011 61 1 1 3 2 */
|
||||
908, /* OBJ_id_camellia192_wrap 1 2 392 200011 61 1 1 3 3 */
|
||||
909, /* OBJ_id_camellia256_wrap 1 2 392 200011 61 1 1 3 4 */
|
||||
1153, /* OBJ_dstu28147_ofb 1 2 804 2 1 1 1 1 1 1 2 */
|
||||
1154, /* OBJ_dstu28147_cfb 1 2 804 2 1 1 1 1 1 1 3 */
|
||||
1155, /* OBJ_dstu28147_wrap 1 2 804 2 1 1 1 1 1 1 5 */
|
||||
1158, /* OBJ_dstu4145le 1 2 804 2 1 1 1 1 3 1 1 */
|
||||
196, /* OBJ_id_smime_mod_cms 1 2 840 113549 1 9 16 0 1 */
|
||||
197, /* OBJ_id_smime_mod_ess 1 2 840 113549 1 9 16 0 2 */
|
||||
198, /* OBJ_id_smime_mod_oid 1 2 840 113549 1 9 16 0 3 */
|
||||
@@ -5498,4 +5602,15 @@ static const unsigned int obj_objs[NUM_OBJ] = {
|
||||
957, /* OBJ_jurisdictionCountryName 1 3 6 1 4 1 311 60 2 1 3 */
|
||||
1056, /* OBJ_blake2b512 1 3 6 1 4 1 1722 12 2 1 16 */
|
||||
1057, /* OBJ_blake2s256 1 3 6 1 4 1 1722 12 2 2 8 */
|
||||
1159, /* OBJ_dstu4145be 1 2 804 2 1 1 1 1 3 1 1 1 1 */
|
||||
1160, /* OBJ_uacurve0 1 2 804 2 1 1 1 1 3 1 1 2 0 */
|
||||
1161, /* OBJ_uacurve1 1 2 804 2 1 1 1 1 3 1 1 2 1 */
|
||||
1162, /* OBJ_uacurve2 1 2 804 2 1 1 1 1 3 1 1 2 2 */
|
||||
1163, /* OBJ_uacurve3 1 2 804 2 1 1 1 1 3 1 1 2 3 */
|
||||
1164, /* OBJ_uacurve4 1 2 804 2 1 1 1 1 3 1 1 2 4 */
|
||||
1165, /* OBJ_uacurve5 1 2 804 2 1 1 1 1 3 1 1 2 5 */
|
||||
1166, /* OBJ_uacurve6 1 2 804 2 1 1 1 1 3 1 1 2 6 */
|
||||
1167, /* OBJ_uacurve7 1 2 804 2 1 1 1 1 3 1 1 2 7 */
|
||||
1168, /* OBJ_uacurve8 1 2 804 2 1 1 1 1 3 1 1 2 8 */
|
||||
1169, /* OBJ_uacurve9 1 2 804 2 1 1 1 1 3 1 1 2 9 */
|
||||
};
|
||||
+21
-24
@@ -152,8 +152,7 @@ for (my $i = 0; $i < $n; $i++) {
|
||||
}
|
||||
|
||||
# Finally ready to generate the output.
|
||||
open(OUT, ">$ARGV[1]") || die "Can't open output file $ARGV[1], $!";
|
||||
print OUT <<"EOF";
|
||||
print <<"EOF";
|
||||
/*
|
||||
* WARNING: do not edit!
|
||||
* Generated by crypto/objects/obj_dat.pl
|
||||
@@ -167,44 +166,44 @@ print OUT <<"EOF";
|
||||
|
||||
EOF
|
||||
|
||||
print OUT "/* Serialized OID's */\n";
|
||||
printf OUT "static const unsigned char so[%d] = {\n", $lvalues + 1;
|
||||
print OUT @lvalues;
|
||||
print OUT "};\n\n";
|
||||
print "/* Serialized OID's */\n";
|
||||
printf "static const unsigned char so[%d] = {\n", $lvalues + 1;
|
||||
print @lvalues;
|
||||
print "};\n\n";
|
||||
|
||||
printf OUT "#define NUM_NID %d\n", $n;
|
||||
printf OUT "static const ASN1_OBJECT nid_objs[NUM_NID] = {\n";
|
||||
print OUT @out;
|
||||
print OUT "};\n\n";
|
||||
printf "#define NUM_NID %d\n", $n;
|
||||
printf "static const ASN1_OBJECT nid_objs[NUM_NID] = {\n";
|
||||
print @out;
|
||||
print "};\n\n";
|
||||
|
||||
{
|
||||
no warnings "uninitialized";
|
||||
@a = grep(defined $sn{$nid{$_}}, 0 .. $n);
|
||||
}
|
||||
printf OUT "#define NUM_SN %d\n", $#a + 1;
|
||||
printf OUT "static const unsigned int sn_objs[NUM_SN] = {\n";
|
||||
printf "#define NUM_SN %d\n", $#a + 1;
|
||||
printf "static const unsigned int sn_objs[NUM_SN] = {\n";
|
||||
foreach (sort { $sn{$nid{$a}} cmp $sn{$nid{$b}} } @a) {
|
||||
printf OUT " %4d, /* \"$sn{$nid{$_}}\" */\n", $_;
|
||||
printf " %4d, /* \"$sn{$nid{$_}}\" */\n", $_;
|
||||
}
|
||||
print OUT "};\n\n";
|
||||
print "};\n\n";
|
||||
|
||||
{
|
||||
no warnings "uninitialized";
|
||||
@a = grep(defined $ln{$nid{$_}}, 0 .. $n);
|
||||
}
|
||||
printf OUT "#define NUM_LN %d\n", $#a + 1;
|
||||
printf OUT "static const unsigned int ln_objs[NUM_LN] = {\n";
|
||||
printf "#define NUM_LN %d\n", $#a + 1;
|
||||
printf "static const unsigned int ln_objs[NUM_LN] = {\n";
|
||||
foreach (sort { $ln{$nid{$a}} cmp $ln{$nid{$b}} } @a) {
|
||||
printf OUT " %4d, /* \"$ln{$nid{$_}}\" */\n", $_;
|
||||
printf " %4d, /* \"$ln{$nid{$_}}\" */\n", $_;
|
||||
}
|
||||
print OUT "};\n\n";
|
||||
print "};\n\n";
|
||||
|
||||
{
|
||||
no warnings "uninitialized";
|
||||
@a = grep(defined $obj{$nid{$_}}, 0 .. $n);
|
||||
}
|
||||
printf OUT "#define NUM_OBJ %d\n", $#a + 1;
|
||||
printf OUT "static const unsigned int obj_objs[NUM_OBJ] = {\n";
|
||||
printf "#define NUM_OBJ %d\n", $#a + 1;
|
||||
printf "static const unsigned int obj_objs[NUM_OBJ] = {\n";
|
||||
|
||||
# Compare DER; prefer shorter; if some length, use the "smaller" encoding.
|
||||
sub obj_cmp
|
||||
@@ -224,8 +223,6 @@ foreach (sort obj_cmp @a) {
|
||||
my $v = $objd{$m};
|
||||
$v =~ s/L//g;
|
||||
$v =~ s/,/ /g;
|
||||
printf OUT " %4d, /* %-32s %s */\n", $_, $m, $v;
|
||||
printf " %4d, /* %-32s %s */\n", $_, $m, $v;
|
||||
}
|
||||
print OUT "};\n";
|
||||
|
||||
close OUT;
|
||||
print "};\n";
|
||||
@@ -1144,3 +1144,26 @@ sm3 1143
|
||||
sm3WithRSAEncryption 1144
|
||||
sha512_224WithRSAEncryption 1145
|
||||
sha512_256WithRSAEncryption 1146
|
||||
id_tc26_gost_3410_2012_256_constants 1147
|
||||
id_tc26_gost_3410_2012_256_paramSetA 1148
|
||||
id_tc26_gost_3410_2012_512_paramSetC 1149
|
||||
ISO_UA 1150
|
||||
ua_pki 1151
|
||||
dstu28147 1152
|
||||
dstu28147_ofb 1153
|
||||
dstu28147_cfb 1154
|
||||
dstu28147_wrap 1155
|
||||
hmacWithDstu34311 1156
|
||||
dstu34311 1157
|
||||
dstu4145le 1158
|
||||
dstu4145be 1159
|
||||
uacurve0 1160
|
||||
uacurve1 1161
|
||||
uacurve2 1162
|
||||
uacurve3 1163
|
||||
uacurve4 1164
|
||||
uacurve5 1165
|
||||
uacurve6 1166
|
||||
uacurve7 1167
|
||||
uacurve8 1168
|
||||
uacurve9 1169
|
||||
@@ -74,6 +74,7 @@ static const nid_triple sigoid_srt[] = {
|
||||
{NID_id_tc26_signwithdigest_gost3410_2012_512, NID_id_GostR3411_2012_512,
|
||||
NID_id_GostR3410_2012_512},
|
||||
{NID_ED25519, NID_undef, NID_ED25519},
|
||||
{NID_ED448, NID_undef, NID_ED448},
|
||||
{NID_RSA_SHA3_224, NID_sha3_224, NID_rsaEncryption},
|
||||
{NID_RSA_SHA3_256, NID_sha3_256, NID_rsaEncryption},
|
||||
{NID_RSA_SHA3_384, NID_sha3_384, NID_rsaEncryption},
|
||||
@@ -120,8 +121,8 @@ static const nid_triple *const sigoid_srt_xref[] = {
|
||||
&sigoid_srt[28],
|
||||
&sigoid_srt[40],
|
||||
&sigoid_srt[41],
|
||||
&sigoid_srt[43],
|
||||
&sigoid_srt[44],
|
||||
&sigoid_srt[45],
|
||||
&sigoid_srt[46],
|
||||
&sigoid_srt[47],
|
||||
};
|
||||
@@ -22,6 +22,7 @@ RSA_SHA3_512 sha3_512 rsaEncryption
|
||||
# method should handle this explicitly.
|
||||
rsassaPss undef rsaEncryption
|
||||
ED25519 undef ED25519
|
||||
ED448 undef ED448
|
||||
|
||||
# Alternative deprecated OIDs. By using the older "rsa" OID this
|
||||
# type will be recognized by not normally used.
|
||||
|
||||
+19
-16
@@ -6,7 +6,12 @@
|
||||
# in the file LICENSE in the source distribution or at
|
||||
# https://www.openssl.org/source/license.html
|
||||
|
||||
# Output year depends on the year of the script and the input files.
|
||||
use Getopt::Std;
|
||||
|
||||
our($opt_n);
|
||||
getopts('n');
|
||||
|
||||
# Output year depends on the year of the script and the input file.
|
||||
my $YEAR = [localtime([stat($0)]->[9])]->[5] + 1900;
|
||||
my $iYEAR = [localtime([stat($ARGV[0])]->[9])]->[5] + 1900;
|
||||
$YEAR = $iYEAR if $iYEAR > $YEAR;
|
||||
@@ -123,15 +128,15 @@ print STDERR "Added OID $Cname\n";
|
||||
}
|
||||
close IN;
|
||||
|
||||
open (NUMOUT,">$ARGV[1]") || die "Can't open output file $ARGV[1]";
|
||||
foreach (sort { $a <=> $b } keys %nidn)
|
||||
{
|
||||
print NUMOUT $nidn{$_},"\t\t",$_,"\n";
|
||||
}
|
||||
close NUMOUT;
|
||||
if ( $opt_n ) {
|
||||
foreach (sort { $a <=> $b } keys %nidn)
|
||||
{
|
||||
print $nidn{$_},"\t\t",$_,"\n";
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
open (OUT,">$ARGV[2]") || die "Can't open output file $ARGV[2]";
|
||||
print OUT <<"EOF";
|
||||
print <<"EOF";
|
||||
/*
|
||||
* WARNING: do not edit!
|
||||
* Generated by crypto/objects/objects.pl
|
||||
@@ -161,15 +166,13 @@ sub expand
|
||||
foreach (sort { $a <=> $b } keys %ordern)
|
||||
{
|
||||
$Cname=$ordern{$_};
|
||||
print OUT "\n";
|
||||
print OUT expand("#define SN_$Cname\t\t\"$sn{$Cname}\"\n") if $sn{$Cname} ne "";
|
||||
print OUT expand("#define LN_$Cname\t\t\"$ln{$Cname}\"\n") if $ln{$Cname} ne "";
|
||||
print OUT expand("#define NID_$Cname\t\t$nid{$Cname}\n") if $nid{$Cname} ne "";
|
||||
print OUT expand("#define OBJ_$Cname\t\t$obj{$Cname}\n") if $obj{$Cname} ne "";
|
||||
print "\n";
|
||||
print expand("#define SN_$Cname\t\t\"$sn{$Cname}\"\n") if $sn{$Cname} ne "";
|
||||
print expand("#define LN_$Cname\t\t\"$ln{$Cname}\"\n") if $ln{$Cname} ne "";
|
||||
print expand("#define NID_$Cname\t\t$nid{$Cname}\n") if $nid{$Cname} ne "";
|
||||
print expand("#define OBJ_$Cname\t\t$obj{$Cname}\n") if $obj{$Cname} ne "";
|
||||
}
|
||||
|
||||
close OUT;
|
||||
|
||||
sub process_oid
|
||||
{
|
||||
local($oid)=@_;
|
||||
|
||||
@@ -1337,10 +1337,13 @@ id-tc26-agreement 2 : id-tc26-agreement-gost-3410-2012-512
|
||||
id-tc26 2 : id-tc26-constants
|
||||
|
||||
id-tc26-constants 1 : id-tc26-sign-constants
|
||||
id-tc26-sign-constants 1: id-tc26-gost-3410-2012-256-constants
|
||||
id-tc26-gost-3410-2012-256-constants 1 : id-tc26-gost-3410-2012-256-paramSetA: GOST R 34.10-2012 (256 bit) ParamSet A
|
||||
id-tc26-sign-constants 2: id-tc26-gost-3410-2012-512-constants
|
||||
id-tc26-gost-3410-2012-512-constants 0 : id-tc26-gost-3410-2012-512-paramSetTest: GOST R 34.10-2012 (512 bit) testing parameter set
|
||||
id-tc26-gost-3410-2012-512-constants 1 : id-tc26-gost-3410-2012-512-paramSetA: GOST R 34.10-2012 (512 bit) ParamSet A
|
||||
id-tc26-gost-3410-2012-512-constants 2 : id-tc26-gost-3410-2012-512-paramSetB: GOST R 34.10-2012 (512 bit) ParamSet B
|
||||
id-tc26-gost-3410-2012-512-constants 3 : id-tc26-gost-3410-2012-512-paramSetC: GOST R 34.10-2012 (512 bit) ParamSet C
|
||||
|
||||
id-tc26-constants 2 : id-tc26-digest-constants
|
||||
id-tc26-constants 5 : id-tc26-cipher-constants
|
||||
@@ -1609,3 +1612,33 @@ id-pkinit 5 : pkInitKDC : Signing KDC Response
|
||||
: ffdhe4096
|
||||
: ffdhe6144
|
||||
: ffdhe8192
|
||||
|
||||
# OIDs for DSTU-4145/DSTU-7564 (http://zakon2.rada.gov.ua/laws/show/z0423-17)
|
||||
|
||||
# DSTU OIDs
|
||||
member-body 804 : ISO-UA
|
||||
ISO-UA 2 1 1 1 : ua-pki
|
||||
ua-pki 1 1 1 : dstu28147 : DSTU Gost 28147-2009
|
||||
dstu28147 2 : dstu28147-ofb : DSTU Gost 28147-2009 OFB mode
|
||||
dstu28147 3 : dstu28147-cfb : DSTU Gost 28147-2009 CFB mode
|
||||
dstu28147 5 : dstu28147-wrap : DSTU Gost 28147-2009 key wrap
|
||||
|
||||
ua-pki 1 1 2 : hmacWithDstu34311 : HMAC DSTU Gost 34311-95
|
||||
ua-pki 1 2 1 : dstu34311 : DSTU Gost 34311-95
|
||||
|
||||
ua-pki 1 3 1 1 : dstu4145le : DSTU 4145-2002 little endian
|
||||
dstu4145le 1 1 : dstu4145be : DSTU 4145-2002 big endian
|
||||
|
||||
# 1.2.804. 2.1.1.1 1.3.1.1 .2.6
|
||||
# UA ua-pki 4145 le
|
||||
# DSTU named curves
|
||||
dstu4145le 2 0 : uacurve0 : DSTU curve 0
|
||||
dstu4145le 2 1 : uacurve1 : DSTU curve 1
|
||||
dstu4145le 2 2 : uacurve2 : DSTU curve 2
|
||||
dstu4145le 2 3 : uacurve3 : DSTU curve 3
|
||||
dstu4145le 2 4 : uacurve4 : DSTU curve 4
|
||||
dstu4145le 2 5 : uacurve5 : DSTU curve 5
|
||||
dstu4145le 2 6 : uacurve6 : DSTU curve 6
|
||||
dstu4145le 2 7 : uacurve7 : DSTU curve 7
|
||||
dstu4145le 2 8 : uacurve8 : DSTU curve 8
|
||||
dstu4145le 2 9 : uacurve9 : DSTU curve 9
|
||||
@@ -722,14 +722,14 @@ static int sanitize_line(char *linebuf, int len, unsigned int flags)
|
||||
static const char beginstr[] = "-----BEGIN ";
|
||||
static const char endstr[] = "-----END ";
|
||||
static const char tailstr[] = "-----\n";
|
||||
#define BEGINLEN (sizeof(beginstr) - 1)
|
||||
#define ENDLEN (sizeof(endstr) - 1)
|
||||
#define TAILLEN (sizeof(tailstr) - 1)
|
||||
#define BEGINLEN ((int)(sizeof(beginstr) - 1))
|
||||
#define ENDLEN ((int)(sizeof(endstr) - 1))
|
||||
#define TAILLEN ((int)(sizeof(tailstr) - 1))
|
||||
static int get_name(BIO *bp, char **name, unsigned int flags)
|
||||
{
|
||||
char *linebuf;
|
||||
int ret = 0;
|
||||
size_t len;
|
||||
int len;
|
||||
|
||||
/*
|
||||
* Need to hold trailing NUL (accounted for by BIO_gets() and the newline
|
||||
|
||||
Executable → Regular
Executable → Regular
Executable → Regular
@@ -316,16 +316,18 @@ BIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio)
|
||||
}
|
||||
|
||||
if (bio == NULL) {
|
||||
if (PKCS7_is_detached(p7))
|
||||
if (PKCS7_is_detached(p7)) {
|
||||
bio = BIO_new(BIO_s_null());
|
||||
else if (os && os->length > 0)
|
||||
} else if (os && os->length > 0) {
|
||||
bio = BIO_new_mem_buf(os->data, os->length);
|
||||
if (bio == NULL) {
|
||||
} else {
|
||||
bio = BIO_new(BIO_s_mem());
|
||||
if (bio == NULL)
|
||||
goto err;
|
||||
BIO_set_mem_eof_return(bio, 0);
|
||||
}
|
||||
if (bio == NULL)
|
||||
goto err;
|
||||
}
|
||||
if (out)
|
||||
BIO_push(out, bio);
|
||||
|
||||
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
@@ -366,6 +366,6 @@ int drbg_ctr_init(RAND_DRBG *drbg)
|
||||
}
|
||||
|
||||
drbg->max_request = 1 << 16;
|
||||
drbg->reseed_interval = MAX_RESEED_INTERVAL;
|
||||
|
||||
return 1;
|
||||
}
|
||||
+56
-8
@@ -113,6 +113,12 @@ static const char ossl_pers_string[] = "OpenSSL NIST SP 800-90A DRBG";
|
||||
|
||||
static CRYPTO_ONCE rand_drbg_init = CRYPTO_ONCE_STATIC_INIT;
|
||||
|
||||
static unsigned int master_reseed_interval = MASTER_RESEED_INTERVAL;
|
||||
static unsigned int slave_reseed_interval = SLAVE_RESEED_INTERVAL;
|
||||
|
||||
static time_t master_reseed_time_interval = MASTER_RESEED_TIME_INTERVAL;
|
||||
static time_t slave_reseed_time_interval = SLAVE_RESEED_TIME_INTERVAL;
|
||||
|
||||
static RAND_DRBG *drbg_setup(RAND_DRBG *parent);
|
||||
|
||||
static RAND_DRBG *rand_drbg_new(int secure,
|
||||
@@ -175,9 +181,27 @@ static RAND_DRBG *rand_drbg_new(int secure,
|
||||
drbg->secure = secure && CRYPTO_secure_allocated(drbg);
|
||||
drbg->fork_count = rand_fork_count;
|
||||
drbg->parent = parent;
|
||||
|
||||
if (parent == NULL) {
|
||||
drbg->reseed_interval = master_reseed_interval;
|
||||
drbg->reseed_time_interval = master_reseed_time_interval;
|
||||
} else {
|
||||
drbg->reseed_interval = slave_reseed_interval;
|
||||
drbg->reseed_time_interval = slave_reseed_time_interval;
|
||||
}
|
||||
|
||||
if (RAND_DRBG_set(drbg, type, flags) == 0)
|
||||
goto err;
|
||||
|
||||
if (parent != NULL && drbg->strength > parent->strength) {
|
||||
/*
|
||||
* We currently don't support the algorithm from NIST SP 800-90C
|
||||
* 10.1.2 to use a weaker DRBG as source
|
||||
*/
|
||||
RANDerr(RAND_F_RAND_DRBG_NEW, RAND_R_PARENT_STRENGTH_TOO_WEAK);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (!RAND_DRBG_set_callbacks(drbg, rand_drbg_get_entropy,
|
||||
rand_drbg_cleanup_entropy,
|
||||
NULL, NULL))
|
||||
@@ -701,6 +725,38 @@ int RAND_DRBG_set_reseed_time_interval(RAND_DRBG *drbg, time_t interval)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the default values for reseed (time) intervals of new DRBG instances
|
||||
*
|
||||
* The default values can be set independently for master DRBG instances
|
||||
* (without a parent) and slave DRBG instances (with parent).
|
||||
*
|
||||
* Returns 1 on success, 0 on failure.
|
||||
*/
|
||||
|
||||
int RAND_DRBG_set_reseed_defaults(
|
||||
unsigned int _master_reseed_interval,
|
||||
unsigned int _slave_reseed_interval,
|
||||
time_t _master_reseed_time_interval,
|
||||
time_t _slave_reseed_time_interval
|
||||
)
|
||||
{
|
||||
if (_master_reseed_interval > MAX_RESEED_INTERVAL
|
||||
|| _slave_reseed_interval > MAX_RESEED_INTERVAL)
|
||||
return 0;
|
||||
|
||||
if (_master_reseed_time_interval > MAX_RESEED_TIME_INTERVAL
|
||||
|| _slave_reseed_time_interval > MAX_RESEED_TIME_INTERVAL)
|
||||
return 0;
|
||||
|
||||
master_reseed_interval = _master_reseed_interval;
|
||||
slave_reseed_interval = _slave_reseed_interval;
|
||||
|
||||
master_reseed_time_interval = _master_reseed_time_interval;
|
||||
slave_reseed_time_interval = _slave_reseed_time_interval;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Locks the given drbg. Locking a drbg which does not have locking
|
||||
@@ -800,14 +856,6 @@ static RAND_DRBG *drbg_setup(RAND_DRBG *parent)
|
||||
if (rand_drbg_enable_locking(drbg) == 0)
|
||||
goto err;
|
||||
|
||||
if (parent == NULL) {
|
||||
drbg->reseed_interval = MASTER_RESEED_INTERVAL;
|
||||
drbg->reseed_time_interval = MASTER_RESEED_TIME_INTERVAL;
|
||||
} else {
|
||||
drbg->reseed_interval = SLAVE_RESEED_INTERVAL;
|
||||
drbg->reseed_time_interval = SLAVE_RESEED_TIME_INTERVAL;
|
||||
}
|
||||
|
||||
/* enable seed propagation */
|
||||
drbg->reseed_counter = 1;
|
||||
|
||||
|
||||
@@ -23,6 +23,8 @@ static const ERR_STRING_DATA RAND_str_functs[] = {
|
||||
"rand_drbg_enable_locking"},
|
||||
{ERR_PACK(ERR_LIB_RAND, RAND_F_RAND_DRBG_GENERATE, 0),
|
||||
"RAND_DRBG_generate"},
|
||||
{ERR_PACK(ERR_LIB_RAND, RAND_F_RAND_DRBG_GET_ENTROPY, 0),
|
||||
"rand_drbg_get_entropy"},
|
||||
{ERR_PACK(ERR_LIB_RAND, RAND_F_RAND_DRBG_INSTANTIATE, 0),
|
||||
"RAND_DRBG_instantiate"},
|
||||
{ERR_PACK(ERR_LIB_RAND, RAND_F_RAND_DRBG_NEW, 0), "RAND_DRBG_new"},
|
||||
@@ -86,6 +88,8 @@ static const ERR_STRING_DATA RAND_str_reasons[] = {
|
||||
"no drbg implementation selected"},
|
||||
{ERR_PACK(ERR_LIB_RAND, 0, RAND_R_PARENT_LOCKING_NOT_ENABLED),
|
||||
"parent locking not enabled"},
|
||||
{ERR_PACK(ERR_LIB_RAND, 0, RAND_R_PARENT_STRENGTH_TOO_WEAK),
|
||||
"parent strength too weak"},
|
||||
{ERR_PACK(ERR_LIB_RAND, 0, RAND_R_PERSONALISATION_STRING_TOO_LONG),
|
||||
"personalisation string too long"},
|
||||
{ERR_PACK(ERR_LIB_RAND, 0, RAND_R_PRNG_NOT_SEEDED), "PRNG not seeded"},
|
||||
|
||||
+11
-1
@@ -176,8 +176,18 @@ size_t rand_drbg_get_entropy(RAND_DRBG *drbg,
|
||||
{
|
||||
size_t ret = 0;
|
||||
size_t entropy_available = 0;
|
||||
RAND_POOL *pool = RAND_POOL_new(entropy, min_len, max_len);
|
||||
RAND_POOL *pool;
|
||||
|
||||
if (drbg->parent && drbg->strength > drbg->parent->strength) {
|
||||
/*
|
||||
* We currently don't support the algorithm from NIST SP 800-90C
|
||||
* 10.1.2 to use a weaker DRBG as source
|
||||
*/
|
||||
RANDerr(RAND_F_RAND_DRBG_GET_ENTROPY, RAND_R_PARENT_STRENGTH_TOO_WEAK);
|
||||
return 0;
|
||||
}
|
||||
|
||||
pool = RAND_POOL_new(entropy, min_len, max_len);
|
||||
if (pool == NULL)
|
||||
return 0;
|
||||
|
||||
|
||||
@@ -186,5 +186,7 @@ rc4_options:
|
||||
.align 4
|
||||
___
|
||||
|
||||
$output=pop;
|
||||
open STDOUT,">$output";
|
||||
print $code;
|
||||
close STDOUT;
|
||||
Executable → Regular
@@ -967,7 +967,8 @@ static int rsa_cms_encrypt(CMS_RecipientInfo *ri)
|
||||
int pad_mode = RSA_PKCS1_PADDING, rv = 0, labellen;
|
||||
unsigned char *label;
|
||||
|
||||
CMS_RecipientInfo_ktri_get0_algs(ri, NULL, NULL, &alg);
|
||||
if (CMS_RecipientInfo_ktri_get0_algs(ri, NULL, NULL, &alg) <= 0)
|
||||
return 0;
|
||||
if (pkctx) {
|
||||
if (EVP_PKEY_CTX_get_rsa_padding(pkctx, &pad_mode) <= 0)
|
||||
return 0;
|
||||
|
||||
Executable → Regular
Executable → Regular
+3
@@ -1573,6 +1573,9 @@ ___
|
||||
}
|
||||
}
|
||||
|
||||
$output=pop;
|
||||
open STDOUT,">$output";
|
||||
|
||||
foreach (split($/,$code)) {
|
||||
s/\`([^\`]*)\`/eval $1/ge;
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user