Latest update.

This commit is contained in:
2020-01-17 19:45:12 +09:00
parent 016df9f433
commit 0f7abb4eb6
1100 changed files with 47785 additions and 16292 deletions
+28
View File
@@ -352,6 +352,34 @@ static ossl_inline void constant_time_cond_swap_64(uint64_t mask, uint64_t *a,
*b ^= xor;
}
/*
* mask must be 0xFF or 0x00.
* "constant time" is per len.
*
* if (mask) {
* unsigned char tmp[len];
*
* memcpy(tmp, a, len);
* memcpy(a, b);
* memcpy(b, tmp);
* }
*/
static ossl_inline void constant_time_cond_swap_buff(unsigned char mask,
unsigned char *a,
unsigned char *b,
size_t len)
{
size_t i;
unsigned char tmp;
for (i = 0; i < len; i++) {
tmp = a[i] ^ b[i];
tmp &= mask;
a[i] ^= tmp;
b[i] ^= tmp;
}
}
/*
* table is a two dimensional array of bytes. Each row has rowsize elements.
* Copies row number idx into out. rowsize and numrows are not considered
+2 -2
View File
@@ -38,8 +38,8 @@ typedef struct ossl_method_construct_method_st {
const OSSL_PROVIDER *prov, int operation_id, const char *name,
const char *propdef, void *data);
/* Construct a new method */
void *(*construct)(const char *name, const OSSL_DISPATCH *fns,
OSSL_PROVIDER *prov, void *data);
void *(*construct)(const OSSL_ALGORITHM *algodef, OSSL_PROVIDER *prov,
void *data);
/* Destruct a method */
void (*destruct)(void *method, void *data);
} OSSL_METHOD_CONSTRUCT_METHOD;
+4 -2
View File
@@ -144,7 +144,7 @@ typedef struct ossl_ex_data_global_st {
# define OPENSSL_CTX_METHOD_STORE_RUN_ONCE_INDEX 2
# define OPENSSL_CTX_MAX_RUN_ONCE 3
# define OPENSSL_CTX_DEFAULT_METHOD_STORE_INDEX 0
# define OPENSSL_CTX_EVP_METHOD_STORE_INDEX 0
# define OPENSSL_CTX_PROVIDER_STORE_INDEX 1
# define OPENSSL_CTX_PROPERTY_DEFN_INDEX 2
# define OPENSSL_CTX_PROPERTY_STRING_INDEX 3
@@ -154,7 +154,9 @@ typedef struct ossl_ex_data_global_st {
# define OPENSSL_CTX_RAND_CRNGT_INDEX 7
# define OPENSSL_CTX_THREAD_EVENT_HANDLER_INDEX 8
# define OPENSSL_CTX_FIPS_PROV_INDEX 9
# define OPENSSL_CTX_MAX_INDEXES 10
# define OPENSSL_CTX_SERIALIZER_STORE_INDEX 10
# define OPENSSL_CTX_SELF_TEST_CB_INDEX 11
# define OPENSSL_CTX_MAX_INDEXES 12
typedef struct openssl_ctx_method {
void *(*new_func)(OPENSSL_CTX *ctx);
+29
View File
@@ -0,0 +1,29 @@
/*
* Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the Apache License 2.0 (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
* in the file LICENSE in the source distribution or at
* https://www.openssl.org/source/license.html
*/
/*
* This header file should be included by internal code that needs to use APIs
* that have been deprecated for public use, but where those symbols will still
* be available internally. For example the EVP and provider code needs to use
* low level APIs that are otherwise deprecated.
*
* This header *must* be the first OpenSSL header included by a source file.
*/
#ifndef OSSL_INTERNAL_DEPRECATED_H
# define OSSL_INTERNAL_DEPRECATED_H
# include <openssl/configuration.h>
# undef OPENSSL_NO_DEPRECATED
# define OPENSSL_SUPPRESS_DEPRECATED
# include <openssl/macros.h>
#endif
+1 -1
View File
@@ -23,7 +23,7 @@ int ERR_load_DSO_strings(void);
/*
* DSO function codes.
*/
# if !OPENSSL_API_3
# ifndef OPENSSL_NO_DEPRECATED_3_0
# define DSO_F_DLFCN_BIND_FUNC 0
# define DSO_F_DLFCN_LOAD 0
# define DSO_F_DLFCN_MERGER 0
+97
View File
@@ -11,6 +11,103 @@
# ifndef HEADER_INTERNAL_KTLS
# define HEADER_INTERNAL_KTLS
# if defined(__FreeBSD__)
# include <sys/types.h>
# include <sys/socket.h>
# include <sys/ktls.h>
# include <netinet/in.h>
# include <netinet/tcp.h>
# include <crypto/cryptodev.h>
/*
* Only used by the tests in sslapitest.c.
*/
# define TLS_CIPHER_AES_GCM_128_REC_SEQ_SIZE 8
/*
* FreeBSD does not require any additional steps to enable KTLS before
* setting keys.
*/
static ossl_inline int ktls_enable(int fd)
{
return 1;
}
/*
* The TCP_TXTLS_ENABLE socket option marks the outgoing socket buffer
* as using TLS. If successful, then data sent using this socket will
* be encrypted and encapsulated in TLS records using the tls_en.
* provided here.
*/
static ossl_inline int ktls_start(int fd,
struct tls_enable *tls_en,
size_t len, int is_tx)
{
if (is_tx)
return setsockopt(fd, IPPROTO_TCP, TCP_TXTLS_ENABLE,
tls_en, sizeof(*tls_en)) ? 0 : 1;
else
return 0;
}
/*
* Send a TLS record using the tls_en provided in ktls_start and use
* record_type instead of the default SSL3_RT_APPLICATION_DATA.
* When the socket is non-blocking, then this call either returns EAGAIN or
* the entire record is pushed to TCP. It is impossible to send a partial
* record using this control message.
*/
static ossl_inline int ktls_send_ctrl_message(int fd, unsigned char record_type,
const void *data, size_t length)
{
struct msghdr msg = { 0 };
int cmsg_len = sizeof(record_type);
struct cmsghdr *cmsg;
char buf[CMSG_SPACE(cmsg_len)];
struct iovec msg_iov; /* Vector of data to send/receive into */
msg.msg_control = buf;
msg.msg_controllen = sizeof(buf);
cmsg = CMSG_FIRSTHDR(&msg);
cmsg->cmsg_level = IPPROTO_TCP;
cmsg->cmsg_type = TLS_SET_RECORD_TYPE;
cmsg->cmsg_len = CMSG_LEN(cmsg_len);
*((unsigned char *)CMSG_DATA(cmsg)) = record_type;
msg.msg_controllen = cmsg->cmsg_len;
msg_iov.iov_base = (void *)data;
msg_iov.iov_len = length;
msg.msg_iov = &msg_iov;
msg.msg_iovlen = 1;
return sendmsg(fd, &msg, 0);
}
static ossl_inline int ktls_read_record(int fd, void *data, size_t length)
{
return -1;
}
/*
* KTLS enables the sendfile system call to send data from a file over
* TLS.
*/
static ossl_inline ossl_ssize_t ktls_sendfile(int s, int fd, off_t off,
size_t size, int flags)
{
off_t sbytes;
int ret;
ret = sendfile(fd, s, off, size, NULL, &sbytes, flags);
if (ret == -1) {
if (errno == EAGAIN && sbytes != 0)
return sbytes;
return -1;
}
return sbytes;
}
# endif /* __FreeBSD__ */
# if defined(OPENSSL_SYS_LINUX)
# include <linux/version.h>
+11 -3
View File
@@ -15,10 +15,11 @@ OSSL_NAMEMAP *ossl_namemap_stored(OPENSSL_CTX *libctx);
OSSL_NAMEMAP *ossl_namemap_new(void);
void ossl_namemap_free(OSSL_NAMEMAP *namemap);
int ossl_namemap_empty(OSSL_NAMEMAP *namemap);
int ossl_namemap_add(OSSL_NAMEMAP *namemap, int number, const char *name);
int ossl_namemap_add_n(OSSL_NAMEMAP *namemap, int number,
const char *name, size_t name_len);
int ossl_namemap_add_name(OSSL_NAMEMAP *namemap, int number, const char *name);
int ossl_namemap_add_name_n(OSSL_NAMEMAP *namemap, int number,
const char *name, size_t name_len);
/*
* The number<->name relationship is 1<->many
@@ -33,3 +34,10 @@ const char *ossl_namemap_num2name(const OSSL_NAMEMAP *namemap, int number,
void ossl_namemap_doall_names(const OSSL_NAMEMAP *namemap, int number,
void (*fn)(const char *name, void *data),
void *data);
/*
* A utility that handles several names in a string, divided by a given
* separator.
*/
int ossl_namemap_add_names(OSSL_NAMEMAP *namemap, int number,
const char *names, const char separator);
+1 -1
View File
@@ -11,7 +11,7 @@
#include <openssl/params.h>
#include <openssl/types.h>
#define OSSL_PARAM_BLD_MAX 10
#define OSSL_PARAM_BLD_MAX 25
typedef struct {
const char *key;
+12 -1
View File
@@ -14,10 +14,19 @@
#include "internal/cryptlib.h"
typedef struct ossl_method_store_st OSSL_METHOD_STORE;
typedef struct ossl_property_list_st OSSL_PROPERTY_LIST;
/* Initialisation */
int ossl_property_parse_init(OPENSSL_CTX *ctx);
/* Property definition parser */
OSSL_PROPERTY_LIST *ossl_parse_property(OPENSSL_CTX *ctx, const char *defn);
/* Property query parser */
OSSL_PROPERTY_LIST *ossl_parse_query(OPENSSL_CTX *ctx, const char *s);
/* Property checker of query vs definition */
int ossl_property_match_count(const OSSL_PROPERTY_LIST *query,
const OSSL_PROPERTY_LIST *defn);
/* Implementation store functions */
OSSL_METHOD_STORE *ossl_method_store_new(OPENSSL_CTX *ctx);
void ossl_method_store_free(OSSL_METHOD_STORE *store);
@@ -36,5 +45,7 @@ int ossl_method_store_set_global_properties(OSSL_METHOD_STORE *store,
int ossl_method_store_cache_get(OSSL_METHOD_STORE *store, int nid,
const char *prop_query, void **result);
int ossl_method_store_cache_set(OSSL_METHOD_STORE *store, int nid,
const char *prop_query, void *result);
const char *prop_query, void *result,
int (*method_up_ref)(void *),
void (*method_destruct)(void *));
#endif
+2 -2
View File
@@ -23,7 +23,7 @@ int ERR_load_PROP_strings(void);
/*
* PROP function codes.
*/
# if !OPENSSL_API_3
# ifndef OPENSSL_NO_DEPRECATED_3_0
# define PROP_F_OSSL_PARSE_PROPERTY 0
# define PROP_F_OSSL_PARSE_QUERY 0
# define PROP_F_PARSE_HEX 0
@@ -43,7 +43,7 @@ int ERR_load_PROP_strings(void);
# define PROP_R_NOT_AN_IDENTIFIER 103
# define PROP_R_NOT_AN_OCTAL_DIGIT 104
# define PROP_R_NOT_A_DECIMAL_DIGIT 105
# define PROP_R_NO_MATCHING_STRING_DELIMETER 106
# define PROP_R_NO_MATCHING_STRING_DELIMITER 106
# define PROP_R_NO_VALUE 107
# define PROP_R_PARSE_FAILED 108
# define PROP_R_STRING_TOO_LONG 109
+1
View File
@@ -11,6 +11,7 @@
# define OSSL_INTERNAL_PROVIDER_H
# include <openssl/core.h>
# include <openssl/core_numbers.h>
# include "internal/dso.h"
# include "internal/symhacks.h"
+1 -1
View File
@@ -15,7 +15,7 @@
* OPENSSL_CTX object. In this way data will get cleaned up correctly when the
* module gets unloaded.
*/
#ifndef FIPS_MODE
#if !defined(FIPS_MODE) || defined(ALLOW_RUN_ONCE_IN_FIPS)
/*
* DEFINE_RUN_ONCE: Define an initialiser function that should be run exactly
* once. It takes no arguments and returns and int result (1 for success or