Latest update.

This commit is contained in:
2020-04-15 18:45:34 +09:00
parent be29e7bcc6
commit 2015c00c43
573 changed files with 22943 additions and 6714 deletions
+4
View File
@@ -23,6 +23,7 @@
# include <openssl/crypto.h>
# include <openssl/buffer.h>
# include <openssl/bio.h>
# include <openssl/asn1.h>
# include <openssl/err.h>
# include "internal/nelem.h"
@@ -164,6 +165,7 @@ typedef struct openssl_ctx_method {
} OPENSSL_CTX_METHOD;
OPENSSL_CTX *openssl_ctx_get_concrete(OPENSSL_CTX *ctx);
int openssl_ctx_is_default(OPENSSL_CTX *ctx);
/* Functions to retrieve pointers to data by index */
void *openssl_ctx_get_data(OPENSSL_CTX *, int /* index */,
@@ -234,5 +236,7 @@ static ossl_inline void ossl_sleep(unsigned long millis)
}
#endif /* defined OPENSSL_SYS_UNIX */
char *sk_ASN1_UTF8STRING2text(STACK_OF(ASN1_UTF8STRING) *text, const char *sep,
size_t max_len);
#endif
+84
View File
@@ -0,0 +1,84 @@
/*
* Copyright 2020 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
*/
#include <openssl/bn.h>
#include "internal/packet.h"
/*
* NOTE: X.690 numbers the identifier octet bits 1 to 8.
* We use the same numbering in comments here.
*/
/* Well known primitive tags */
/*
* DER UNIVERSAL tags, occupying bits 1-5 in the DER identifier byte
* These are only valid for the UNIVERSAL class. With the other classes,
* these bits have a different meaning.
*/
#define DER_P_EOC 0 /* BER End Of Contents tag */
#define DER_P_BOOLEAN 1
#define DER_P_INTEGER 2
#define DER_P_BIT_STRING 3
#define DER_P_OCTET_STRING 4
#define DER_P_NULL 5
#define DER_P_OBJECT 6
#define DER_P_OBJECT_DESCRIPTOR 7
#define DER_P_EXTERNAL 8
#define DER_P_REAL 9
#define DER_P_ENUMERATED 10
#define DER_P_UTF8STRING 12
#define DER_P_SEQUENCE 16
#define DER_P_SET 17
#define DER_P_NUMERICSTRING 18
#define DER_P_PRINTABLESTRING 19
#define DER_P_T61STRING 20
#define DER_P_VIDEOTEXSTRING 21
#define DER_P_IA5STRING 22
#define DER_P_UTCTIME 23
#define DER_P_GENERALIZEDTIME 24
#define DER_P_GRAPHICSTRING 25
#define DER_P_ISO64STRING 26
#define DER_P_GENERALSTRING 27
#define DER_P_UNIVERSALSTRING 28
#define DER_P_BMPSTRING 30
/* DER Flags, occupying bit 6 in the DER identifier byte */
#define DER_F_PRIMITIVE 0x00
#define DER_F_CONSTRUCTED 0x20
/* DER classes tags, occupying bits 7-8 in the DER identifier byte */
#define DER_C_UNIVERSAL 0x00
#define DER_C_APPLICATION 0x40
#define DER_C_CONTEXT 0x80
#define DER_C_PRIVATE 0xC0
/*
* Run-time constructors.
*
* They all construct DER backwards, so care should be taken to use them
* that way.
*/
/* This can be used for all items that don't have a context */
#define DER_NO_CONTEXT -1
int DER_w_precompiled(WPACKET *pkt, int tag,
const unsigned char *precompiled, size_t precompiled_n);
int DER_w_boolean(WPACKET *pkt, int tag, int b);
int DER_w_ulong(WPACKET *pkt, int tag, unsigned long v);
int DER_w_bn(WPACKET *pkt, int tag, const BIGNUM *v);
int DER_w_null(WPACKET *pkt, int tag);
/*
* All constructors for constructed elements have a begin and a end function
*/
int DER_w_begin_sequence(WPACKET *pkt, int tag);
int DER_w_end_sequence(WPACKET *pkt, int tag);
+23
View File
@@ -0,0 +1,23 @@
/*
* Copyright 2020 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
*/
#ifndef OSSL_INTERNAL_EVP_H
# define OSSL_INTERNAL_EVP_H
# include <openssl/evp.h>
# ifndef OPENSSL_NO_EC
/*
* TODO(3.0) While waiting for more generic getters, we have these functions
* as an interim solution. This should be removed when the generic getters
* appear.
*/
int evp_pkey_get_EC_KEY_curve_nid(const EVP_PKEY *pkey);
# endif
#endif
+3
View File
@@ -10,6 +10,7 @@
#ifndef OSSL_INTERNAL_FFC_H
# define OSSL_INTERNAL_FFC_H
# include <openssl/core.h>
# include <openssl/bn.h>
# include <openssl/evp.h>
# include <openssl/dh.h> /* Uses Error codes from DH */
@@ -154,4 +155,6 @@ int ffc_validate_public_key_partial(const FFC_PARAMS *params,
int ffc_validate_private_key(const BIGNUM *upper, const BIGNUM *priv_key,
int *ret);
int ffc_fromdata(FFC_PARAMS *ffc, const OSSL_PARAM params[]);
#endif /* OSSL_INTERNAL_FFC_H */
+17
View File
@@ -638,6 +638,9 @@ struct wpacket_st {
/* Our sub-packets (always at least one if not finished) */
WPACKET_SUB *subs;
/* Writing from the end first? */
unsigned int endfirst : 1;
};
/* Flags */
@@ -676,6 +679,12 @@ int WPACKET_init(WPACKET *pkt, BUF_MEM *buf);
*/
int WPACKET_init_null(WPACKET *pkt, size_t lenbytes);
/*
* Same as WPACKET_init_null except we set the WPACKET to assume DER length
* encoding for sub-packets.
*/
int WPACKET_init_null_der(WPACKET *pkt);
/*
* Same as WPACKET_init_len except we do not use a growable BUF_MEM structure.
* A fixed buffer of memory |buf| of size |len| is used instead. A failure will
@@ -683,6 +692,14 @@ int WPACKET_init_null(WPACKET *pkt, size_t lenbytes);
*/
int WPACKET_init_static_len(WPACKET *pkt, unsigned char *buf, size_t len,
size_t lenbytes);
/*
* Same as WPACKET_init_static_len except lenbytes is always 0, and we set the
* WPACKET to write to the end of the buffer moving towards the start and use
* DER length encoding for sub-packets.
*/
int WPACKET_init_der(WPACKET *pkt, unsigned char *buf, size_t len);
/*
* Set the flags to be applied to the current sub-packet
*/
-76
View File
@@ -1,76 +0,0 @@
/*
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
* Copyright (c) 2019, Oracle and/or its affiliates. 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
*/
#include <openssl/params.h>
#include <openssl/types.h>
#define OSSL_PARAM_BLD_MAX 25
typedef struct {
const char *key;
int type;
int secure;
size_t size;
size_t alloc_blocks;
const BIGNUM *bn;
const void *string;
union {
/*
* These fields are never directly addressed, but their sizes are
* imporant so that all native types can be copied here without overrun.
*/
ossl_intmax_t i;
ossl_uintmax_t u;
double d;
} num;
} OSSL_PARAM_BLD_DEF;
typedef struct {
size_t curr;
size_t total_blocks;
size_t secure_blocks;
OSSL_PARAM_BLD_DEF params[OSSL_PARAM_BLD_MAX];
} OSSL_PARAM_BLD;
void ossl_param_bld_init(OSSL_PARAM_BLD *bld);
OSSL_PARAM *ossl_param_bld_to_param(OSSL_PARAM_BLD *bld);
void ossl_param_bld_free(OSSL_PARAM *params);
int ossl_param_bld_push_int(OSSL_PARAM_BLD *bld, const char *key, int val);
int ossl_param_bld_push_uint(OSSL_PARAM_BLD *bld, const char *key,
unsigned int val);
int ossl_param_bld_push_long(OSSL_PARAM_BLD *bld, const char *key,
long int val);
int ossl_param_bld_push_ulong(OSSL_PARAM_BLD *bld, const char *key,
unsigned long int val);
int ossl_param_bld_push_int32(OSSL_PARAM_BLD *bld, const char *key,
int32_t val);
int ossl_param_bld_push_uint32(OSSL_PARAM_BLD *bld, const char *key,
uint32_t val);
int ossl_param_bld_push_int64(OSSL_PARAM_BLD *bld, const char *key,
int64_t val);
int ossl_param_bld_push_uint64(OSSL_PARAM_BLD *bld, const char *key,
uint64_t val);
int ossl_param_bld_push_size_t(OSSL_PARAM_BLD *bld, const char *key,
size_t val);
int ossl_param_bld_push_double(OSSL_PARAM_BLD *bld, const char *key,
double val);
int ossl_param_bld_push_BN(OSSL_PARAM_BLD *bld, const char *key,
const BIGNUM *bn);
int ossl_param_bld_push_BN_pad(OSSL_PARAM_BLD *bld, const char *key,
const BIGNUM *bn, size_t sz);
int ossl_param_bld_push_utf8_string(OSSL_PARAM_BLD *bld, const char *key,
const char *buf, size_t bsize);
int ossl_param_bld_push_utf8_ptr(OSSL_PARAM_BLD *bld, const char *key,
char *buf, size_t bsize);
int ossl_param_bld_push_octet_string(OSSL_PARAM_BLD *bld, const char *key,
const void *buf, size_t bsize);
int ossl_param_bld_push_octet_ptr(OSSL_PARAM_BLD *bld, const char *key,
void *buf, size_t bsize);
+27
View File
@@ -0,0 +1,27 @@
/*
* Copyright 2020 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
*/
#include <openssl/safestack.h>
#include <openssl/param_build.h>
int ossl_param_build_set_int(OSSL_PARAM_BLD *bld, OSSL_PARAM *p,
const char *key, int num);
int ossl_param_build_set_utf8_string(OSSL_PARAM_BLD *bld, OSSL_PARAM *p,
const char *key, const char *buf);
int ossl_param_build_set_octet_string(OSSL_PARAM_BLD *bld, OSSL_PARAM *p,
const char *key,
const unsigned char *data,
size_t data_len);
int ossl_param_build_set_bn(OSSL_PARAM_BLD *bld, OSSL_PARAM *p,
const char *key, const BIGNUM *bn);
int ossl_param_build_set_bn_pad(OSSL_PARAM_BLD *bld, OSSL_PARAM *p,
const char *key, const BIGNUM *bn, size_t sz);
int ossl_param_build_set_multi_key_bn(OSSL_PARAM_BLD *bld, OSSL_PARAM *p,
const char *names[],
STACK_OF(BIGNUM_const) *stk);