Latest update.
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright 2019 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 HEADER_ASN1_DSA_H
|
||||
# define HEADER_ASN1_DSA_H
|
||||
|
||||
#include "internal/packet.h"
|
||||
|
||||
int encode_der_length(WPACKET *pkt, size_t cont_len);
|
||||
int encode_der_integer(WPACKET *pkt, const BIGNUM *n);
|
||||
int encode_der_dsa_sig(WPACKET *pkt, const BIGNUM *r, const BIGNUM *s);
|
||||
int decode_der_length(PACKET *pkt, PACKET *subpkt);
|
||||
int decode_der_integer(PACKET *pkt, BIGNUM *n);
|
||||
size_t decode_der_dsa_sig(BIGNUM *r, BIGNUM *s, const unsigned char **ppin,
|
||||
size_t len);
|
||||
|
||||
#endif
|
||||
@@ -63,6 +63,14 @@ struct evp_pkey_asn1_method_st {
|
||||
int (*set_pub_key) (EVP_PKEY *pk, const unsigned char *pub, size_t len);
|
||||
int (*get_priv_key) (const EVP_PKEY *pk, unsigned char *priv, size_t *len);
|
||||
int (*get_pub_key) (const EVP_PKEY *pk, unsigned char *pub, size_t *len);
|
||||
|
||||
/*
|
||||
* TODO: Make sure these functions are defined for key types that are
|
||||
* implemented in providers.
|
||||
*/
|
||||
/* Exports to providers */
|
||||
size_t (*dirty_cnt) (const EVP_PKEY *pk);
|
||||
void *(*export_to) (const EVP_PKEY *pk, EVP_KEYMGMT *keymgmt);
|
||||
} /* EVP_PKEY_ASN1_METHOD */ ;
|
||||
|
||||
DEFINE_STACK_OF_CONST(EVP_PKEY_ASN1_METHOD)
|
||||
|
||||
@@ -110,4 +110,5 @@ int bn_rsa_fips186_4_derive_prime(BIGNUM *Y, BIGNUM *X, const BIGNUM *Xin,
|
||||
const BIGNUM *r1, const BIGNUM *r2, int nlen,
|
||||
const BIGNUM *e, BN_CTX *ctx, BN_GENCB *cb);
|
||||
|
||||
OPENSSL_CTX *bn_get_lib_ctx(BN_CTX *ctx);
|
||||
#endif
|
||||
@@ -35,8 +35,8 @@ void ChaCha20_ctr32(unsigned char *out, const unsigned char *inp,
|
||||
((unsigned int)(p)[0]) | ((unsigned int)(p)[1]<<8) | \
|
||||
((unsigned int)(p)[2]<<16) | ((unsigned int)(p)[3]<<24) )
|
||||
|
||||
#define CHACHA_KEY_SIZE 32
|
||||
#define CHACHA_CTR_SIZE 16
|
||||
#define CHACHA_BLK_SIZE 64
|
||||
#define CHACHA_KEY_SIZE 32
|
||||
#define CHACHA_CTR_SIZE 16
|
||||
#define CHACHA_BLK_SIZE 64
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,444 @@
|
||||
/*
|
||||
* Copyright 2019 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 HEADER_INTERNAL_CIPHERMODE_PLATFORM_H
|
||||
# define HEADER_INTERNAL_CIPHERMODE_PLATFORM_H
|
||||
|
||||
# include "openssl/aes.h"
|
||||
|
||||
# ifdef VPAES_ASM
|
||||
int vpaes_set_encrypt_key(const unsigned char *userKey, int bits,
|
||||
AES_KEY *key);
|
||||
int vpaes_set_decrypt_key(const unsigned char *userKey, int bits,
|
||||
AES_KEY *key);
|
||||
void vpaes_encrypt(const unsigned char *in, unsigned char *out,
|
||||
const AES_KEY *key);
|
||||
void vpaes_decrypt(const unsigned char *in, unsigned char *out,
|
||||
const AES_KEY *key);
|
||||
void vpaes_cbc_encrypt(const unsigned char *in,
|
||||
unsigned char *out,
|
||||
size_t length,
|
||||
const AES_KEY *key, unsigned char *ivec, int enc);
|
||||
# endif /* VPAES_ASM */
|
||||
|
||||
# ifdef BSAES_ASM
|
||||
void bsaes_cbc_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t length, const AES_KEY *key,
|
||||
unsigned char ivec[16], int enc);
|
||||
void bsaes_ctr32_encrypt_blocks(const unsigned char *in, unsigned char *out,
|
||||
size_t len, const AES_KEY *key,
|
||||
const unsigned char ivec[16]);
|
||||
void bsaes_xts_encrypt(const unsigned char *inp, unsigned char *out,
|
||||
size_t len, const AES_KEY *key1,
|
||||
const AES_KEY *key2, const unsigned char iv[16]);
|
||||
void bsaes_xts_decrypt(const unsigned char *inp, unsigned char *out,
|
||||
size_t len, const AES_KEY *key1,
|
||||
const AES_KEY *key2, const unsigned char iv[16]);
|
||||
# endif /* BSAES_ASM */
|
||||
|
||||
# ifdef AES_CTR_ASM
|
||||
void AES_ctr32_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t blocks, const AES_KEY *key,
|
||||
const unsigned char ivec[AES_BLOCK_SIZE]);
|
||||
# endif /* AES_CTR_ASM */
|
||||
|
||||
# ifdef AES_XTS_ASM
|
||||
void AES_xts_encrypt(const unsigned char *inp, unsigned char *out, size_t len,
|
||||
const AES_KEY *key1, const AES_KEY *key2,
|
||||
const unsigned char iv[16]);
|
||||
void AES_xts_decrypt(const unsigned char *inp, unsigned char *out, size_t len,
|
||||
const AES_KEY *key1, const AES_KEY *key2,
|
||||
const unsigned char iv[16]);
|
||||
# endif /* AES_XTS_ASM */
|
||||
|
||||
# if defined(OPENSSL_CPUID_OBJ)
|
||||
# if (defined(__powerpc__) || defined(__ppc__) || defined(_ARCH_PPC))
|
||||
# include "ppc_arch.h"
|
||||
# ifdef VPAES_ASM
|
||||
# define VPAES_CAPABLE (OPENSSL_ppccap_P & PPC_ALTIVEC)
|
||||
# endif
|
||||
# define HWAES_CAPABLE (OPENSSL_ppccap_P & PPC_CRYPTO207)
|
||||
# define HWAES_set_encrypt_key aes_p8_set_encrypt_key
|
||||
# define HWAES_set_decrypt_key aes_p8_set_decrypt_key
|
||||
# define HWAES_encrypt aes_p8_encrypt
|
||||
# define HWAES_decrypt aes_p8_decrypt
|
||||
# define HWAES_cbc_encrypt aes_p8_cbc_encrypt
|
||||
# define HWAES_ctr32_encrypt_blocks aes_p8_ctr32_encrypt_blocks
|
||||
# define HWAES_xts_encrypt aes_p8_xts_encrypt
|
||||
# define HWAES_xts_decrypt aes_p8_xts_decrypt
|
||||
# endif /* PPC */
|
||||
|
||||
# if (defined(__arm__) || defined(__arm) || defined(__aarch64__))
|
||||
# include "arm_arch.h"
|
||||
# if __ARM_MAX_ARCH__>=7
|
||||
# if defined(BSAES_ASM)
|
||||
# define BSAES_CAPABLE (OPENSSL_armcap_P & ARMV7_NEON)
|
||||
# endif
|
||||
# if defined(VPAES_ASM)
|
||||
# define VPAES_CAPABLE (OPENSSL_armcap_P & ARMV7_NEON)
|
||||
# endif
|
||||
# define HWAES_CAPABLE (OPENSSL_armcap_P & ARMV8_AES)
|
||||
# define HWAES_set_encrypt_key aes_v8_set_encrypt_key
|
||||
# define HWAES_set_decrypt_key aes_v8_set_decrypt_key
|
||||
# define HWAES_encrypt aes_v8_encrypt
|
||||
# define HWAES_decrypt aes_v8_decrypt
|
||||
# define HWAES_cbc_encrypt aes_v8_cbc_encrypt
|
||||
# define HWAES_ctr32_encrypt_blocks aes_v8_ctr32_encrypt_blocks
|
||||
# endif
|
||||
# endif
|
||||
# endif /* OPENSSL_CPUID_OBJ */
|
||||
|
||||
# if defined(AES_ASM) && !defined(I386_ONLY) && ( \
|
||||
((defined(__i386) || defined(__i386__) || \
|
||||
defined(_M_IX86)) && defined(OPENSSL_IA32_SSE2))|| \
|
||||
defined(__x86_64) || defined(__x86_64__) || \
|
||||
defined(_M_AMD64) || defined(_M_X64) )
|
||||
|
||||
/* AES-NI section */
|
||||
|
||||
# define AESNI_CAPABLE (OPENSSL_ia32cap_P[1]&(1<<(57-32)))
|
||||
# ifdef VPAES_ASM
|
||||
# define VPAES_CAPABLE (OPENSSL_ia32cap_P[1]&(1<<(41-32)))
|
||||
# endif
|
||||
# ifdef BSAES_ASM
|
||||
# define BSAES_CAPABLE (OPENSSL_ia32cap_P[1]&(1<<(41-32)))
|
||||
# endif
|
||||
|
||||
int aesni_set_encrypt_key(const unsigned char *userKey, int bits,
|
||||
AES_KEY *key);
|
||||
int aesni_set_decrypt_key(const unsigned char *userKey, int bits,
|
||||
AES_KEY *key);
|
||||
|
||||
void aesni_encrypt(const unsigned char *in, unsigned char *out,
|
||||
const AES_KEY *key);
|
||||
void aesni_decrypt(const unsigned char *in, unsigned char *out,
|
||||
const AES_KEY *key);
|
||||
|
||||
void aesni_ecb_encrypt(const unsigned char *in,
|
||||
unsigned char *out,
|
||||
size_t length, const AES_KEY *key, int enc);
|
||||
void aesni_cbc_encrypt(const unsigned char *in,
|
||||
unsigned char *out,
|
||||
size_t length,
|
||||
const AES_KEY *key, unsigned char *ivec, int enc);
|
||||
# ifndef OPENSSL_NO_OCB
|
||||
void aesni_ocb_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t blocks, const void *key,
|
||||
size_t start_block_num,
|
||||
unsigned char offset_i[16],
|
||||
const unsigned char L_[][16],
|
||||
unsigned char checksum[16]);
|
||||
void aesni_ocb_decrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t blocks, const void *key,
|
||||
size_t start_block_num,
|
||||
unsigned char offset_i[16],
|
||||
const unsigned char L_[][16],
|
||||
unsigned char checksum[16]);
|
||||
# endif /* OPENSSL_NO_OCB */
|
||||
|
||||
void aesni_ctr32_encrypt_blocks(const unsigned char *in,
|
||||
unsigned char *out,
|
||||
size_t blocks,
|
||||
const void *key, const unsigned char *ivec);
|
||||
|
||||
void aesni_xts_encrypt(const unsigned char *in,
|
||||
unsigned char *out,
|
||||
size_t length,
|
||||
const AES_KEY *key1, const AES_KEY *key2,
|
||||
const unsigned char iv[16]);
|
||||
|
||||
void aesni_xts_decrypt(const unsigned char *in,
|
||||
unsigned char *out,
|
||||
size_t length,
|
||||
const AES_KEY *key1, const AES_KEY *key2,
|
||||
const unsigned char iv[16]);
|
||||
|
||||
void aesni_ccm64_encrypt_blocks(const unsigned char *in,
|
||||
unsigned char *out,
|
||||
size_t blocks,
|
||||
const void *key,
|
||||
const unsigned char ivec[16],
|
||||
unsigned char cmac[16]);
|
||||
|
||||
void aesni_ccm64_decrypt_blocks(const unsigned char *in,
|
||||
unsigned char *out,
|
||||
size_t blocks,
|
||||
const void *key,
|
||||
const unsigned char ivec[16],
|
||||
unsigned char cmac[16]);
|
||||
|
||||
# if defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || defined(_M_X64)
|
||||
size_t aesni_gcm_encrypt(const unsigned char *in, unsigned char *out, size_t len,
|
||||
const void *key, unsigned char ivec[16], u64 *Xi);
|
||||
size_t aesni_gcm_decrypt(const unsigned char *in, unsigned char *out, size_t len,
|
||||
const void *key, unsigned char ivec[16], u64 *Xi);
|
||||
void gcm_ghash_avx(u64 Xi[2], const u128 Htable[16], const u8 *in, size_t len);
|
||||
|
||||
# define AES_GCM_ASM(ctx) (ctx->ctr == aesni_ctr32_encrypt_blocks && \
|
||||
ctx->gcm.ghash == gcm_ghash_avx)
|
||||
# endif
|
||||
|
||||
|
||||
# elif defined(AES_ASM) && (defined(__sparc) || defined(__sparc__))
|
||||
|
||||
/* Fujitsu SPARC64 X support */
|
||||
extern unsigned int OPENSSL_sparcv9cap_P[];
|
||||
# include "sparc_arch.h"
|
||||
|
||||
# ifndef OPENSSL_NO_CAMELLIA
|
||||
# define SPARC_CMLL_CAPABLE (OPENSSL_sparcv9cap_P[1] & CFR_CAMELLIA)
|
||||
# include "openssl/camellia.h"
|
||||
|
||||
void cmll_t4_set_key(const unsigned char *key, int bits, CAMELLIA_KEY *ks);
|
||||
void cmll_t4_encrypt(const unsigned char *in, unsigned char *out,
|
||||
const CAMELLIA_KEY *key);
|
||||
void cmll_t4_decrypt(const unsigned char *in, unsigned char *out,
|
||||
const CAMELLIA_KEY *key);
|
||||
|
||||
void cmll128_t4_cbc_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t len, const CAMELLIA_KEY *key,
|
||||
unsigned char *ivec);
|
||||
void cmll128_t4_cbc_decrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t len, const CAMELLIA_KEY *key,
|
||||
unsigned char *ivec);
|
||||
void cmll256_t4_cbc_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t len, const CAMELLIA_KEY *key,
|
||||
unsigned char *ivec);
|
||||
void cmll256_t4_cbc_decrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t len, const CAMELLIA_KEY *key,
|
||||
unsigned char *ivec);
|
||||
void cmll128_t4_ctr32_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t blocks, const CAMELLIA_KEY *key,
|
||||
unsigned char *ivec);
|
||||
void cmll256_t4_ctr32_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t blocks, const CAMELLIA_KEY *key,
|
||||
unsigned char *ivec);
|
||||
# endif /* OPENSSL_NO_CAMELLIA */
|
||||
|
||||
|
||||
# define SPARC_AES_CAPABLE (OPENSSL_sparcv9cap_P[1] & CFR_AES)
|
||||
# define SPARC_DES_CAPABLE (OPENSSL_sparcv9cap_P[1] & CFR_DES)
|
||||
# define HWAES_CAPABLE (OPENSSL_sparcv9cap_P[0] & SPARCV9_FJAESX)
|
||||
# define HWAES_set_encrypt_key aes_fx_set_encrypt_key
|
||||
# define HWAES_set_decrypt_key aes_fx_set_decrypt_key
|
||||
# define HWAES_encrypt aes_fx_encrypt
|
||||
# define HWAES_decrypt aes_fx_decrypt
|
||||
# define HWAES_cbc_encrypt aes_fx_cbc_encrypt
|
||||
# define HWAES_ctr32_encrypt_blocks aes_fx_ctr32_encrypt_blocks
|
||||
|
||||
void aes_t4_set_encrypt_key(const unsigned char *key, int bits, AES_KEY *ks);
|
||||
void aes_t4_set_decrypt_key(const unsigned char *key, int bits, AES_KEY *ks);
|
||||
void aes_t4_encrypt(const unsigned char *in, unsigned char *out,
|
||||
const AES_KEY *key);
|
||||
void aes_t4_decrypt(const unsigned char *in, unsigned char *out,
|
||||
const AES_KEY *key);
|
||||
/*
|
||||
* Key-length specific subroutines were chosen for following reason.
|
||||
* Each SPARC T4 core can execute up to 8 threads which share core's
|
||||
* resources. Loading as much key material to registers allows to
|
||||
* minimize references to shared memory interface, as well as amount
|
||||
* of instructions in inner loops [much needed on T4]. But then having
|
||||
* non-key-length specific routines would require conditional branches
|
||||
* either in inner loops or on subroutines' entries. Former is hardly
|
||||
* acceptable, while latter means code size increase to size occupied
|
||||
* by multiple key-length specific subroutines, so why fight?
|
||||
*/
|
||||
void aes128_t4_cbc_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t len, const AES_KEY *key,
|
||||
unsigned char *ivec);
|
||||
void aes128_t4_cbc_decrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t len, const AES_KEY *key,
|
||||
unsigned char *ivec);
|
||||
void aes192_t4_cbc_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t len, const AES_KEY *key,
|
||||
unsigned char *ivec);
|
||||
void aes192_t4_cbc_decrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t len, const AES_KEY *key,
|
||||
unsigned char *ivec);
|
||||
void aes256_t4_cbc_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t len, const AES_KEY *key,
|
||||
unsigned char *ivec);
|
||||
void aes256_t4_cbc_decrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t len, const AES_KEY *key,
|
||||
unsigned char *ivec);
|
||||
void aes128_t4_ctr32_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t blocks, const AES_KEY *key,
|
||||
unsigned char *ivec);
|
||||
void aes192_t4_ctr32_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t blocks, const AES_KEY *key,
|
||||
unsigned char *ivec);
|
||||
void aes256_t4_ctr32_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t blocks, const AES_KEY *key,
|
||||
unsigned char *ivec);
|
||||
void aes128_t4_xts_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t blocks, const AES_KEY *key1,
|
||||
const AES_KEY *key2, const unsigned char *ivec);
|
||||
void aes128_t4_xts_decrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t blocks, const AES_KEY *key1,
|
||||
const AES_KEY *key2, const unsigned char *ivec);
|
||||
void aes256_t4_xts_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t blocks, const AES_KEY *key1,
|
||||
const AES_KEY *key2, const unsigned char *ivec);
|
||||
void aes256_t4_xts_decrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t blocks, const AES_KEY *key1,
|
||||
const AES_KEY *key2, const unsigned char *ivec);
|
||||
|
||||
# ifndef OPENSSL_NO_DES
|
||||
# include <openssl/des.h>
|
||||
void des_t4_key_expand(const void *key, DES_key_schedule *ks);
|
||||
void des_t4_ede3_cbc_encrypt(const void *inp, void *out, size_t len,
|
||||
const DES_key_schedule ks[3], unsigned char iv[8]);
|
||||
void des_t4_ede3_cbc_decrypt(const void *inp, void *out, size_t len,
|
||||
const DES_key_schedule ks[3], unsigned char iv[8]);
|
||||
# endif /* OPENSSL_NO_DES */
|
||||
|
||||
# elif defined(OPENSSL_CPUID_OBJ) && defined(__s390__)
|
||||
/* IBM S390X support */
|
||||
# include "s390x_arch.h"
|
||||
|
||||
|
||||
/* Convert key size to function code: [16,24,32] -> [18,19,20]. */
|
||||
# define S390X_AES_FC(keylen) (S390X_AES_128 + ((((keylen) << 3) - 128) >> 6))
|
||||
|
||||
/* Most modes of operation need km for partial block processing. */
|
||||
# define S390X_aes_128_CAPABLE (OPENSSL_s390xcap_P.km[0] & \
|
||||
S390X_CAPBIT(S390X_AES_128))
|
||||
# define S390X_aes_192_CAPABLE (OPENSSL_s390xcap_P.km[0] & \
|
||||
S390X_CAPBIT(S390X_AES_192))
|
||||
# define S390X_aes_256_CAPABLE (OPENSSL_s390xcap_P.km[0] & \
|
||||
S390X_CAPBIT(S390X_AES_256))
|
||||
|
||||
# define S390X_aes_128_cbc_CAPABLE 1 /* checked by callee */
|
||||
# define S390X_aes_192_cbc_CAPABLE 1
|
||||
# define S390X_aes_256_cbc_CAPABLE 1
|
||||
|
||||
# define S390X_aes_128_ecb_CAPABLE S390X_aes_128_CAPABLE
|
||||
# define S390X_aes_192_ecb_CAPABLE S390X_aes_192_CAPABLE
|
||||
# define S390X_aes_256_ecb_CAPABLE S390X_aes_256_CAPABLE
|
||||
|
||||
# define S390X_aes_128_ofb_CAPABLE (S390X_aes_128_CAPABLE && \
|
||||
(OPENSSL_s390xcap_P.kmo[0] & \
|
||||
S390X_CAPBIT(S390X_AES_128)))
|
||||
# define S390X_aes_192_ofb_CAPABLE (S390X_aes_192_CAPABLE && \
|
||||
(OPENSSL_s390xcap_P.kmo[0] & \
|
||||
S390X_CAPBIT(S390X_AES_192)))
|
||||
# define S390X_aes_256_ofb_CAPABLE (S390X_aes_256_CAPABLE && \
|
||||
(OPENSSL_s390xcap_P.kmo[0] & \
|
||||
S390X_CAPBIT(S390X_AES_256)))
|
||||
|
||||
# define S390X_aes_128_cfb_CAPABLE (S390X_aes_128_CAPABLE && \
|
||||
(OPENSSL_s390xcap_P.kmf[0] & \
|
||||
S390X_CAPBIT(S390X_AES_128)))
|
||||
# define S390X_aes_192_cfb_CAPABLE (S390X_aes_192_CAPABLE && \
|
||||
(OPENSSL_s390xcap_P.kmf[0] & \
|
||||
S390X_CAPBIT(S390X_AES_192)))
|
||||
# define S390X_aes_256_cfb_CAPABLE (S390X_aes_256_CAPABLE && \
|
||||
(OPENSSL_s390xcap_P.kmf[0] & \
|
||||
S390X_CAPBIT(S390X_AES_256)))
|
||||
# define S390X_aes_128_cfb8_CAPABLE (OPENSSL_s390xcap_P.kmf[0] & \
|
||||
S390X_CAPBIT(S390X_AES_128))
|
||||
# define S390X_aes_192_cfb8_CAPABLE (OPENSSL_s390xcap_P.kmf[0] & \
|
||||
S390X_CAPBIT(S390X_AES_192))
|
||||
# define S390X_aes_256_cfb8_CAPABLE (OPENSSL_s390xcap_P.kmf[0] & \
|
||||
S390X_CAPBIT(S390X_AES_256))
|
||||
# define S390X_aes_128_cfb1_CAPABLE 0
|
||||
# define S390X_aes_192_cfb1_CAPABLE 0
|
||||
# define S390X_aes_256_cfb1_CAPABLE 0
|
||||
|
||||
# define S390X_aes_128_ctr_CAPABLE 1 /* checked by callee */
|
||||
# define S390X_aes_192_ctr_CAPABLE 1
|
||||
# define S390X_aes_256_ctr_CAPABLE 1
|
||||
|
||||
# define S390X_aes_128_xts_CAPABLE 1 /* checked by callee */
|
||||
# define S390X_aes_256_xts_CAPABLE 1
|
||||
|
||||
# define S390X_aes_128_gcm_CAPABLE (S390X_aes_128_CAPABLE && \
|
||||
(OPENSSL_s390xcap_P.kma[0] & \
|
||||
S390X_CAPBIT(S390X_AES_128)))
|
||||
# define S390X_aes_192_gcm_CAPABLE (S390X_aes_192_CAPABLE && \
|
||||
(OPENSSL_s390xcap_P.kma[0] & \
|
||||
S390X_CAPBIT(S390X_AES_192)))
|
||||
# define S390X_aes_256_gcm_CAPABLE (S390X_aes_256_CAPABLE && \
|
||||
(OPENSSL_s390xcap_P.kma[0] & \
|
||||
S390X_CAPBIT(S390X_AES_256)))
|
||||
|
||||
# define S390X_aes_128_ccm_CAPABLE (S390X_aes_128_CAPABLE && \
|
||||
(OPENSSL_s390xcap_P.kmac[0] & \
|
||||
S390X_CAPBIT(S390X_AES_128)))
|
||||
# define S390X_aes_192_ccm_CAPABLE (S390X_aes_192_CAPABLE && \
|
||||
(OPENSSL_s390xcap_P.kmac[0] & \
|
||||
S390X_CAPBIT(S390X_AES_192)))
|
||||
# define S390X_aes_256_ccm_CAPABLE (S390X_aes_256_CAPABLE && \
|
||||
(OPENSSL_s390xcap_P.kmac[0] & \
|
||||
S390X_CAPBIT(S390X_AES_256)))
|
||||
# define S390X_CCM_AAD_FLAG 0x40
|
||||
|
||||
# ifndef OPENSSL_NO_OCB
|
||||
# define S390X_aes_128_ocb_CAPABLE 0
|
||||
# define S390X_aes_192_ocb_CAPABLE 0
|
||||
# define S390X_aes_256_ocb_CAPABLE 0
|
||||
# endif /* OPENSSL_NO_OCB */
|
||||
|
||||
# ifndef OPENSSL_NO_SIV
|
||||
# define S390X_aes_128_siv_CAPABLE 0
|
||||
# define S390X_aes_192_siv_CAPABLE 0
|
||||
# define S390X_aes_256_siv_CAPABLE 0
|
||||
# endif /* OPENSSL_NO_SIV */
|
||||
|
||||
/* Convert key size to function code: [16,24,32] -> [18,19,20]. */
|
||||
# define S390X_AES_FC(keylen) (S390X_AES_128 + ((((keylen) << 3) - 128) >> 6))
|
||||
# endif
|
||||
|
||||
# if defined(HWAES_CAPABLE)
|
||||
int HWAES_set_encrypt_key(const unsigned char *userKey, const int bits,
|
||||
AES_KEY *key);
|
||||
int HWAES_set_decrypt_key(const unsigned char *userKey, const int bits,
|
||||
AES_KEY *key);
|
||||
void HWAES_encrypt(const unsigned char *in, unsigned char *out,
|
||||
const AES_KEY *key);
|
||||
void HWAES_decrypt(const unsigned char *in, unsigned char *out,
|
||||
const AES_KEY *key);
|
||||
void HWAES_cbc_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t length, const AES_KEY *key,
|
||||
unsigned char *ivec, const int enc);
|
||||
void HWAES_ctr32_encrypt_blocks(const unsigned char *in, unsigned char *out,
|
||||
size_t len, const AES_KEY *key,
|
||||
const unsigned char ivec[16]);
|
||||
void HWAES_xts_encrypt(const unsigned char *inp, unsigned char *out,
|
||||
size_t len, const AES_KEY *key1,
|
||||
const AES_KEY *key2, const unsigned char iv[16]);
|
||||
void HWAES_xts_decrypt(const unsigned char *inp, unsigned char *out,
|
||||
size_t len, const AES_KEY *key1,
|
||||
const AES_KEY *key2, const unsigned char iv[16]);
|
||||
# ifndef OPENSSL_NO_OCB
|
||||
# ifdef HWAES_ocb_encrypt
|
||||
void HWAES_ocb_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t blocks, const void *key,
|
||||
size_t start_block_num,
|
||||
unsigned char offset_i[16],
|
||||
const unsigned char L_[][16],
|
||||
unsigned char checksum[16]);
|
||||
# else
|
||||
# define HWAES_ocb_encrypt ((ocb128_f)NULL)
|
||||
# endif
|
||||
# ifdef HWAES_ocb_decrypt
|
||||
void HWAES_ocb_decrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t blocks, const void *key,
|
||||
size_t start_block_num,
|
||||
unsigned char offset_i[16],
|
||||
const unsigned char L_[][16],
|
||||
unsigned char checksum[16]);
|
||||
# else
|
||||
# define HWAES_ocb_decrypt ((ocb128_f)NULL)
|
||||
# endif
|
||||
# endif /* OPENSSL_NO_OCB */
|
||||
|
||||
# endif /* HWAES_CAPABLE */
|
||||
|
||||
#endif /* HEADER_INTERNAL_CIPHERMODE_PLATFORM_H */
|
||||
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
* Copyright 2019 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
|
||||
*/
|
||||
|
||||
/* internal CMS-ESS related stuff */
|
||||
|
||||
int cms_add1_signing_cert(CMS_SignerInfo *si, ESS_SIGNING_CERT *sc);
|
||||
int cms_add1_signing_cert_v2(CMS_SignerInfo *si, ESS_SIGNING_CERT_V2 *sc);
|
||||
@@ -27,6 +27,5 @@ void ossl_ctx_thread_stop(void *arg);
|
||||
# define OPENSSL_INIT_ZLIB 0x00010000L
|
||||
# define OPENSSL_INIT_BASE_ONLY 0x00040000L
|
||||
|
||||
int ossl_trace_init(void);
|
||||
void ossl_trace_cleanup(void);
|
||||
void ossl_malloc_setup_failures(void);
|
||||
@@ -57,6 +57,8 @@ int ossl_ctype_check(int c, unsigned int mask);
|
||||
int ossl_tolower(int c);
|
||||
int ossl_toupper(int c);
|
||||
|
||||
int ascii_isdigit(const char inchar);
|
||||
|
||||
# define ossl_isalnum(c) (ossl_ctype_check((c), CTYPE_MASK_alnum))
|
||||
# define ossl_isalpha(c) (ossl_ctype_check((c), CTYPE_MASK_alpha))
|
||||
# ifdef CHARSET_EBCDIC
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
# has support compiled in for them. Currently each method is enabled
|
||||
# by a define "DSO_<name>" ... we translate the "dso_scheme" config
|
||||
# string entry into using the following logic;
|
||||
my $scheme = uc $target{dso_scheme};
|
||||
my $scheme = $disabled{dso} ? undef : uc $target{dso_scheme};
|
||||
if (!$scheme) {
|
||||
$scheme = "NONE";
|
||||
}
|
||||
|
||||
@@ -12,9 +12,18 @@
|
||||
ESS_SIGNING_CERT *ESS_SIGNING_CERT_get(PKCS7_SIGNER_INFO *si);
|
||||
int ESS_SIGNING_CERT_add(PKCS7_SIGNER_INFO *si, ESS_SIGNING_CERT *sc);
|
||||
|
||||
ESS_SIGNING_CERT *ESS_SIGNING_CERT_new_init(X509 *signcert,
|
||||
STACK_OF(X509) *certs,
|
||||
int issuer_needed);
|
||||
|
||||
ESS_SIGNING_CERT_V2 *ESS_SIGNING_CERT_V2_get(PKCS7_SIGNER_INFO *si);
|
||||
int ESS_SIGNING_CERT_V2_add(PKCS7_SIGNER_INFO *si, ESS_SIGNING_CERT_V2 *sc);
|
||||
|
||||
ESS_SIGNING_CERT_V2 *ESS_SIGNING_CERT_V2_new_init(const EVP_MD *hash_alg,
|
||||
X509 *signcert,
|
||||
STACK_OF(X509) *certs,
|
||||
int issuer_needed);
|
||||
|
||||
/*-
|
||||
* IssuerSerial ::= SEQUENCE {
|
||||
* issuer GeneralNames,
|
||||
|
||||
@@ -18,6 +18,23 @@
|
||||
#define EVP_MD_CTX_FLAG_KEEP_PKEY_CTX 0x0400
|
||||
|
||||
struct evp_pkey_ctx_st {
|
||||
/* Actual operation */
|
||||
int operation;
|
||||
|
||||
union {
|
||||
struct {
|
||||
EVP_KEYEXCH *exchange;
|
||||
void *exchprovctx;
|
||||
} kex;
|
||||
|
||||
struct {
|
||||
EVP_SIGNATURE *signature;
|
||||
void *sigprovctx;
|
||||
} sig;
|
||||
} op;
|
||||
|
||||
/* Legacy fields below */
|
||||
|
||||
/* Method associated with this operation */
|
||||
const EVP_PKEY_METHOD *pmeth;
|
||||
/* Engine that implements this method or NULL if builtin */
|
||||
@@ -26,8 +43,6 @@ struct evp_pkey_ctx_st {
|
||||
EVP_PKEY *pkey;
|
||||
/* Peer key for key agreement, may be NULL */
|
||||
EVP_PKEY *peerkey;
|
||||
/* Actual operation */
|
||||
int operation;
|
||||
/* Algorithm specific data */
|
||||
void *data;
|
||||
/* Application specific data */
|
||||
@@ -113,57 +128,45 @@ extern const EVP_PKEY_METHOD hkdf_pkey_meth;
|
||||
extern const EVP_PKEY_METHOD poly1305_pkey_meth;
|
||||
extern const EVP_PKEY_METHOD siphash_pkey_meth;
|
||||
|
||||
/* struct evp_mac_impl_st is defined by the implementation */
|
||||
typedef struct evp_mac_impl_st EVP_MAC_IMPL;
|
||||
struct evp_mac_st {
|
||||
int type;
|
||||
EVP_MAC_IMPL *(*new) (void);
|
||||
EVP_MAC_IMPL *(*dup) (const EVP_MAC_IMPL *macsrc);
|
||||
void (*free) (EVP_MAC_IMPL *macctx);
|
||||
size_t (*size) (EVP_MAC_IMPL *macctx);
|
||||
int (*init) (EVP_MAC_IMPL *macctx);
|
||||
int (*update) (EVP_MAC_IMPL *macctx, const unsigned char *data,
|
||||
size_t datalen);
|
||||
int (*final) (EVP_MAC_IMPL *macctx, unsigned char *out);
|
||||
int (*ctrl) (EVP_MAC_IMPL *macctx, int cmd, va_list args);
|
||||
int (*ctrl_str) (EVP_MAC_IMPL *macctx, const char *type, const char *value);
|
||||
OSSL_PROVIDER *prov;
|
||||
int name_id;
|
||||
|
||||
CRYPTO_REF_COUNT refcnt;
|
||||
CRYPTO_RWLOCK *lock;
|
||||
|
||||
OSSL_OP_mac_newctx_fn *newctx;
|
||||
OSSL_OP_mac_dupctx_fn *dupctx;
|
||||
OSSL_OP_mac_freectx_fn *freectx;
|
||||
OSSL_OP_mac_size_fn *size;
|
||||
OSSL_OP_mac_init_fn *init;
|
||||
OSSL_OP_mac_update_fn *update;
|
||||
OSSL_OP_mac_final_fn *final;
|
||||
OSSL_OP_mac_gettable_params_fn *gettable_params;
|
||||
OSSL_OP_mac_gettable_ctx_params_fn *gettable_ctx_params;
|
||||
OSSL_OP_mac_settable_ctx_params_fn *settable_ctx_params;
|
||||
OSSL_OP_mac_get_params_fn *get_params;
|
||||
OSSL_OP_mac_get_ctx_params_fn *get_ctx_params;
|
||||
OSSL_OP_mac_set_ctx_params_fn *set_ctx_params;
|
||||
};
|
||||
|
||||
extern const EVP_MAC blake2b_mac_meth;
|
||||
extern const EVP_MAC blake2s_mac_meth;
|
||||
extern const EVP_MAC cmac_meth;
|
||||
extern const EVP_MAC gmac_meth;
|
||||
extern const EVP_MAC hmac_meth;
|
||||
extern const EVP_MAC kmac128_meth;
|
||||
extern const EVP_MAC kmac256_meth;
|
||||
extern const EVP_MAC siphash_meth;
|
||||
extern const EVP_MAC poly1305_meth;
|
||||
|
||||
/* Internal keccak algorithms used for KMAC */
|
||||
const EVP_MD *evp_keccak_kmac128(void);
|
||||
const EVP_MD *evp_keccak_kmac256(void);
|
||||
|
||||
/*
|
||||
* This function is internal for now, but can be made external when needed.
|
||||
* The documentation would read:
|
||||
*
|
||||
* EVP_add_mac() adds the MAC implementation C<mac> to the internal
|
||||
* object database.
|
||||
*/
|
||||
int EVP_add_mac(const EVP_MAC *mac);
|
||||
int EVP_add_kdf(const EVP_KDF *kdf);
|
||||
|
||||
/* struct evp_kdf_impl_st is defined by the implementation */
|
||||
typedef struct evp_kdf_impl_st EVP_KDF_IMPL;
|
||||
struct evp_kdf_st {
|
||||
int type;
|
||||
EVP_KDF_IMPL *(*new) (void);
|
||||
void (*free) (EVP_KDF_IMPL *impl);
|
||||
void (*reset) (EVP_KDF_IMPL *impl);
|
||||
int (*ctrl) (EVP_KDF_IMPL *impl, int cmd, va_list args);
|
||||
int (*ctrl_str) (EVP_KDF_IMPL *impl, const char *type, const char *value);
|
||||
size_t (*size) (EVP_KDF_IMPL *impl);
|
||||
int (*derive) (EVP_KDF_IMPL *impl, unsigned char *key, size_t keylen);
|
||||
OSSL_PROVIDER *prov;
|
||||
int name_id;
|
||||
CRYPTO_REF_COUNT refcnt;
|
||||
CRYPTO_RWLOCK *lock;
|
||||
|
||||
OSSL_OP_kdf_newctx_fn *newctx;
|
||||
OSSL_OP_kdf_dupctx_fn *dupctx;
|
||||
OSSL_OP_kdf_freectx_fn *freectx;
|
||||
OSSL_OP_kdf_reset_fn *reset;
|
||||
OSSL_OP_kdf_derive_fn *derive;
|
||||
OSSL_OP_kdf_gettable_params_fn *gettable_params;
|
||||
OSSL_OP_kdf_gettable_ctx_params_fn *gettable_ctx_params;
|
||||
OSSL_OP_kdf_settable_ctx_params_fn *settable_ctx_params;
|
||||
OSSL_OP_kdf_get_params_fn *get_params;
|
||||
OSSL_OP_kdf_get_ctx_params_fn *get_ctx_params;
|
||||
OSSL_OP_kdf_set_ctx_params_fn *set_ctx_params;
|
||||
};
|
||||
|
||||
extern const EVP_KDF pbkdf2_kdf_meth;
|
||||
@@ -196,6 +199,7 @@ struct evp_md_st {
|
||||
|
||||
/* New structure members */
|
||||
/* TODO(3.0): Remove above comment when legacy has gone */
|
||||
int name_id;
|
||||
OSSL_PROVIDER *prov;
|
||||
CRYPTO_REF_COUNT refcnt;
|
||||
CRYPTO_RWLOCK *lock;
|
||||
@@ -206,10 +210,12 @@ struct evp_md_st {
|
||||
OSSL_OP_digest_digest_fn *digest;
|
||||
OSSL_OP_digest_freectx_fn *freectx;
|
||||
OSSL_OP_digest_dupctx_fn *dupctx;
|
||||
OSSL_OP_digest_size_fn *size;
|
||||
OSSL_OP_digest_block_size_fn *dblock_size;
|
||||
OSSL_OP_digest_set_params_fn *set_params;
|
||||
OSSL_OP_digest_get_params_fn *get_params;
|
||||
OSSL_OP_digest_set_ctx_params_fn *set_ctx_params;
|
||||
OSSL_OP_digest_get_ctx_params_fn *get_ctx_params;
|
||||
OSSL_OP_digest_gettable_params_fn *gettable_params;
|
||||
OSSL_OP_digest_settable_ctx_params_fn *settable_ctx_params;
|
||||
OSSL_OP_digest_gettable_ctx_params_fn *gettable_ctx_params;
|
||||
|
||||
} /* EVP_MD */ ;
|
||||
|
||||
@@ -246,6 +252,7 @@ struct evp_cipher_st {
|
||||
|
||||
/* New structure members */
|
||||
/* TODO(3.0): Remove above comment when legacy has gone */
|
||||
int name_id;
|
||||
OSSL_PROVIDER *prov;
|
||||
CRYPTO_REF_COUNT refcnt;
|
||||
CRYPTO_RWLOCK *lock;
|
||||
@@ -258,8 +265,11 @@ struct evp_cipher_st {
|
||||
OSSL_OP_cipher_freectx_fn *freectx;
|
||||
OSSL_OP_cipher_dupctx_fn *dupctx;
|
||||
OSSL_OP_cipher_get_params_fn *get_params;
|
||||
OSSL_OP_cipher_ctx_get_params_fn *ctx_get_params;
|
||||
OSSL_OP_cipher_ctx_set_params_fn *ctx_set_params;
|
||||
OSSL_OP_cipher_get_ctx_params_fn *get_ctx_params;
|
||||
OSSL_OP_cipher_set_ctx_params_fn *set_ctx_params;
|
||||
OSSL_OP_cipher_gettable_params_fn *gettable_params;
|
||||
OSSL_OP_cipher_gettable_ctx_params_fn *gettable_ctx_params;
|
||||
OSSL_OP_cipher_settable_ctx_params_fn *settable_ctx_params;
|
||||
} /* EVP_CIPHER */ ;
|
||||
|
||||
/* Macros to code block cipher wrappers */
|
||||
@@ -499,9 +509,9 @@ typedef struct {
|
||||
* method, as in, can it do arbitrary encryption....
|
||||
*/
|
||||
struct evp_pkey_st {
|
||||
/* == Legacy attributes == */
|
||||
int type;
|
||||
int save_type;
|
||||
CRYPTO_REF_COUNT references;
|
||||
const EVP_PKEY_ASN1_METHOD *ameth;
|
||||
ENGINE *engine;
|
||||
ENGINE *pmeth_engine; /* If not NULL public key ENGINE to use */
|
||||
@@ -521,19 +531,77 @@ struct evp_pkey_st {
|
||||
ECX_KEY *ecx; /* X25519, X448, Ed25519, Ed448 */
|
||||
# endif
|
||||
} pkey;
|
||||
int save_parameters;
|
||||
STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */
|
||||
|
||||
/* == Common attributes == */
|
||||
CRYPTO_REF_COUNT references;
|
||||
CRYPTO_RWLOCK *lock;
|
||||
STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */
|
||||
int save_parameters;
|
||||
|
||||
/* == Provider attributes == */
|
||||
/*
|
||||
* To support transparent export/import between providers that
|
||||
* support the methods for it, and still not having to do the
|
||||
* export/import every time a key is used, we maintain a cache
|
||||
* of imported key, indexed by provider address.
|
||||
* pkeys[0] is *always* the "original" key.
|
||||
*/
|
||||
struct {
|
||||
EVP_KEYMGMT *keymgmt;
|
||||
void *provkey;
|
||||
} pkeys[10];
|
||||
/*
|
||||
* If there is a legacy key assigned to this structure, we keep
|
||||
* a copy of that key's dirty count.
|
||||
*/
|
||||
size_t dirty_cnt_copy;
|
||||
} /* EVP_PKEY */ ;
|
||||
|
||||
#define EVP_PKEY_CTX_IS_SIGNATURE_OP(ctx) \
|
||||
((ctx)->operation == EVP_PKEY_OP_SIGN \
|
||||
|| (ctx)->operation == EVP_PKEY_OP_SIGNCTX \
|
||||
|| (ctx)->operation == EVP_PKEY_OP_VERIFY \
|
||||
|| (ctx)->operation == EVP_PKEY_OP_VERIFYCTX \
|
||||
|| (ctx)->operation == EVP_PKEY_OP_VERIFYRECOVER)
|
||||
|
||||
#define EVP_PKEY_CTX_IS_DERIVE_OP(ctx) \
|
||||
((ctx)->operation == EVP_PKEY_OP_DERIVE)
|
||||
|
||||
void openssl_add_all_ciphers_int(void);
|
||||
void openssl_add_all_digests_int(void);
|
||||
void openssl_add_all_macs_int(void);
|
||||
void openssl_add_all_kdfs_int(void);
|
||||
void evp_cleanup_int(void);
|
||||
void evp_app_cleanup_int(void);
|
||||
|
||||
/* KEYMGMT helper functions */
|
||||
void *evp_keymgmt_export_to_provider(EVP_PKEY *pk, EVP_KEYMGMT *keymgmt);
|
||||
void evp_keymgmt_clear_pkey_cache(EVP_PKEY *pk);
|
||||
|
||||
/* KEYMGMT provider interface functions */
|
||||
void *evp_keymgmt_importdomparams(const EVP_KEYMGMT *keymgmt,
|
||||
const OSSL_PARAM params[]);
|
||||
void *evp_keymgmt_gendomparams(const EVP_KEYMGMT *keymgmt,
|
||||
const OSSL_PARAM params[]);
|
||||
void evp_keymgmt_freedomparams(const EVP_KEYMGMT *keymgmt,
|
||||
void *provdomparams);
|
||||
int evp_keymgmt_exportdomparams(const EVP_KEYMGMT *keymgmt,
|
||||
void *provdomparams, OSSL_PARAM params[]);
|
||||
const OSSL_PARAM *
|
||||
evp_keymgmt_importdomparam_types(const EVP_KEYMGMT *keymgmt);
|
||||
const OSSL_PARAM *
|
||||
evp_keymgmt_exportdomparam_types(const EVP_KEYMGMT *keymgmt);
|
||||
|
||||
void *evp_keymgmt_importkey(const EVP_KEYMGMT *keymgmt,
|
||||
const OSSL_PARAM params[]);
|
||||
void *evp_keymgmt_genkey(const EVP_KEYMGMT *keymgmt, void *domparams,
|
||||
const OSSL_PARAM params[]);
|
||||
void *evp_keymgmt_loadkey(const EVP_KEYMGMT *keymgmt,
|
||||
void *id, size_t idlen);
|
||||
void evp_keymgmt_freekey(const EVP_KEYMGMT *keymgmt, void *provkey);
|
||||
int evp_keymgmt_exportkey(const EVP_KEYMGMT *keymgmt,
|
||||
void *provkey, OSSL_PARAM params[]);
|
||||
const OSSL_PARAM *evp_keymgmt_importkey_types(const EVP_KEYMGMT *keymgmt);
|
||||
const OSSL_PARAM *evp_keymgmt_exportkey_types(const EVP_KEYMGMT *keymgmt);
|
||||
|
||||
/* Pulling defines out of C source files */
|
||||
|
||||
#define EVP_RC4_KEY_SIZE 16
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2010-2019 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
|
||||
@@ -7,28 +7,214 @@
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
/* TODO(3.0) Move this header into provider when dependencies are removed */
|
||||
#include <openssl/modes.h>
|
||||
|
||||
#if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32__)
|
||||
typedef __int64 i64;
|
||||
typedef unsigned __int64 u64;
|
||||
# define U64(C) C##UI64
|
||||
#elif defined(__arch64__)
|
||||
typedef long i64;
|
||||
typedef unsigned long u64;
|
||||
# define U64(C) C##UL
|
||||
#else
|
||||
typedef long long i64;
|
||||
typedef unsigned long long u64;
|
||||
# define U64(C) C##ULL
|
||||
#endif
|
||||
|
||||
typedef unsigned int u32;
|
||||
typedef unsigned char u8;
|
||||
|
||||
#define STRICT_ALIGNMENT 1
|
||||
#ifndef PEDANTIC
|
||||
# if defined(__i386) || defined(__i386__) || \
|
||||
defined(__x86_64) || defined(__x86_64__) || \
|
||||
defined(_M_IX86) || defined(_M_AMD64) || defined(_M_X64) || \
|
||||
defined(__aarch64__) || \
|
||||
defined(__s390__) || defined(__s390x__)
|
||||
# undef STRICT_ALIGNMENT
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined(PEDANTIC) && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM)
|
||||
# if defined(__GNUC__) && __GNUC__>=2
|
||||
# if defined(__x86_64) || defined(__x86_64__)
|
||||
# define BSWAP8(x) ({ u64 ret_=(x); \
|
||||
asm ("bswapq %0" \
|
||||
: "+r"(ret_)); ret_; })
|
||||
# define BSWAP4(x) ({ u32 ret_=(x); \
|
||||
asm ("bswapl %0" \
|
||||
: "+r"(ret_)); ret_; })
|
||||
# elif (defined(__i386) || defined(__i386__)) && !defined(I386_ONLY)
|
||||
# define BSWAP8(x) ({ u32 lo_=(u64)(x)>>32,hi_=(x); \
|
||||
asm ("bswapl %0; bswapl %1" \
|
||||
: "+r"(hi_),"+r"(lo_)); \
|
||||
(u64)hi_<<32|lo_; })
|
||||
# define BSWAP4(x) ({ u32 ret_=(x); \
|
||||
asm ("bswapl %0" \
|
||||
: "+r"(ret_)); ret_; })
|
||||
# elif defined(__aarch64__)
|
||||
# define BSWAP8(x) ({ u64 ret_; \
|
||||
asm ("rev %0,%1" \
|
||||
: "=r"(ret_) : "r"(x)); ret_; })
|
||||
# define BSWAP4(x) ({ u32 ret_; \
|
||||
asm ("rev %w0,%w1" \
|
||||
: "=r"(ret_) : "r"(x)); ret_; })
|
||||
# elif (defined(__arm__) || defined(__arm)) && !defined(STRICT_ALIGNMENT)
|
||||
# define BSWAP8(x) ({ u32 lo_=(u64)(x)>>32,hi_=(x); \
|
||||
asm ("rev %0,%0; rev %1,%1" \
|
||||
: "+r"(hi_),"+r"(lo_)); \
|
||||
(u64)hi_<<32|lo_; })
|
||||
# define BSWAP4(x) ({ u32 ret_; \
|
||||
asm ("rev %0,%1" \
|
||||
: "=r"(ret_) : "r"((u32)(x))); \
|
||||
ret_; })
|
||||
# endif
|
||||
# elif defined(_MSC_VER)
|
||||
# if _MSC_VER>=1300
|
||||
# include <stdlib.h>
|
||||
# pragma intrinsic(_byteswap_uint64,_byteswap_ulong)
|
||||
# define BSWAP8(x) _byteswap_uint64((u64)(x))
|
||||
# define BSWAP4(x) _byteswap_ulong((u32)(x))
|
||||
# elif defined(_M_IX86)
|
||||
__inline u32 _bswap4(u32 val)
|
||||
{
|
||||
_asm mov eax, val _asm bswap eax}
|
||||
# define BSWAP4(x) _bswap4(x)
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
#if defined(BSWAP4) && !defined(STRICT_ALIGNMENT)
|
||||
# define GETU32(p) BSWAP4(*(const u32 *)(p))
|
||||
# define PUTU32(p,v) *(u32 *)(p) = BSWAP4(v)
|
||||
#else
|
||||
# define GETU32(p) ((u32)(p)[0]<<24|(u32)(p)[1]<<16|(u32)(p)[2]<<8|(u32)(p)[3])
|
||||
# define PUTU32(p,v) ((p)[0]=(u8)((v)>>24),(p)[1]=(u8)((v)>>16),(p)[2]=(u8)((v)>>8),(p)[3]=(u8)(v))
|
||||
#endif
|
||||
/*- GCM definitions */ typedef struct {
|
||||
u64 hi, lo;
|
||||
} u128;
|
||||
|
||||
#ifdef TABLE_BITS
|
||||
# undef TABLE_BITS
|
||||
#endif
|
||||
/*
|
||||
* Even though permitted values for TABLE_BITS are 8, 4 and 1, it should
|
||||
* never be set to 8 [or 1]. For further information see gcm128.c.
|
||||
*/
|
||||
#define TABLE_BITS 4
|
||||
|
||||
struct gcm128_context {
|
||||
/* Following 6 names follow names in GCM specification */
|
||||
union {
|
||||
u64 u[2];
|
||||
u32 d[4];
|
||||
u8 c[16];
|
||||
size_t t[16 / sizeof(size_t)];
|
||||
} Yi, EKi, EK0, len, Xi, H;
|
||||
/*
|
||||
* Relative position of Xi, H and pre-computed Htable is used in some
|
||||
* assembler modules, i.e. don't change the order!
|
||||
*/
|
||||
#if TABLE_BITS==8
|
||||
u128 Htable[256];
|
||||
#else
|
||||
u128 Htable[16];
|
||||
void (*gmult) (u64 Xi[2], const u128 Htable[16]);
|
||||
void (*ghash) (u64 Xi[2], const u128 Htable[16], const u8 *inp,
|
||||
size_t len);
|
||||
#endif
|
||||
unsigned int mres, ares;
|
||||
block128_f block;
|
||||
void *key;
|
||||
#if !defined(OPENSSL_SMALL_FOOTPRINT)
|
||||
unsigned char Xn[48];
|
||||
#endif
|
||||
};
|
||||
|
||||
/*
|
||||
* The maximum permitted number of cipher blocks per data unit in XTS mode.
|
||||
* Reference IEEE Std 1619-2018.
|
||||
*/
|
||||
#define XTS_MAX_BLOCKS_PER_DATA_UNIT (1<<20)
|
||||
|
||||
struct xts128_context {
|
||||
void *key1, *key2;
|
||||
block128_f block1, block2;
|
||||
};
|
||||
|
||||
struct ccm128_context {
|
||||
union {
|
||||
u64 u[2];
|
||||
u8 c[16];
|
||||
} nonce, cmac;
|
||||
u64 blocks;
|
||||
block128_f block;
|
||||
void *key;
|
||||
};
|
||||
|
||||
#ifndef OPENSSL_NO_OCB
|
||||
|
||||
typedef union {
|
||||
u64 a[2];
|
||||
unsigned char c[16];
|
||||
} OCB_BLOCK;
|
||||
# define ocb_block16_xor(in1,in2,out) \
|
||||
( (out)->a[0]=(in1)->a[0]^(in2)->a[0], \
|
||||
(out)->a[1]=(in1)->a[1]^(in2)->a[1] )
|
||||
# if STRICT_ALIGNMENT
|
||||
# define ocb_block16_xor_misaligned(in1,in2,out) \
|
||||
ocb_block_xor((in1)->c,(in2)->c,16,(out)->c)
|
||||
# else
|
||||
# define ocb_block16_xor_misaligned ocb_block16_xor
|
||||
# endif
|
||||
|
||||
struct ocb128_context {
|
||||
/* Need both encrypt and decrypt key schedules for decryption */
|
||||
block128_f encrypt;
|
||||
block128_f decrypt;
|
||||
void *keyenc;
|
||||
void *keydec;
|
||||
ocb128_f stream; /* direction dependent */
|
||||
/* Key dependent variables. Can be reused if key remains the same */
|
||||
size_t l_index;
|
||||
size_t max_l_index;
|
||||
OCB_BLOCK l_star;
|
||||
OCB_BLOCK l_dollar;
|
||||
OCB_BLOCK *l;
|
||||
/* Must be reset for each session */
|
||||
struct {
|
||||
u64 blocks_hashed;
|
||||
u64 blocks_processed;
|
||||
OCB_BLOCK offset_aad;
|
||||
OCB_BLOCK sum;
|
||||
OCB_BLOCK offset;
|
||||
OCB_BLOCK checksum;
|
||||
} sess;
|
||||
};
|
||||
#endif /* OPENSSL_NO_OCB */
|
||||
|
||||
#ifndef OPENSSL_NO_SIV
|
||||
|
||||
typedef struct siv128_context SIV128_CONTEXT;
|
||||
#define SIV_LEN 16
|
||||
|
||||
SIV128_CONTEXT *CRYPTO_siv128_new(const unsigned char *key, int klen,
|
||||
EVP_CIPHER* cbc, EVP_CIPHER* ctr);
|
||||
int CRYPTO_siv128_init(SIV128_CONTEXT *ctx, const unsigned char *key, int klen,
|
||||
const EVP_CIPHER* cbc, const EVP_CIPHER* ctr);
|
||||
int CRYPTO_siv128_copy_ctx(SIV128_CONTEXT *dest, SIV128_CONTEXT *src);
|
||||
int CRYPTO_siv128_aad(SIV128_CONTEXT *ctx, const unsigned char *aad,
|
||||
size_t len);
|
||||
int CRYPTO_siv128_encrypt(SIV128_CONTEXT *ctx,
|
||||
const unsigned char *in, unsigned char *out,
|
||||
size_t len);
|
||||
int CRYPTO_siv128_decrypt(SIV128_CONTEXT *ctx,
|
||||
const unsigned char *in, unsigned char *out,
|
||||
size_t len);
|
||||
int CRYPTO_siv128_finish(SIV128_CONTEXT *ctx);
|
||||
int CRYPTO_siv128_set_tag(SIV128_CONTEXT *ctx, const unsigned char *tag,
|
||||
size_t len);
|
||||
int CRYPTO_siv128_get_tag(SIV128_CONTEXT *ctx, unsigned char *tag, size_t len);
|
||||
int CRYPTO_siv128_cleanup(SIV128_CONTEXT *ctx);
|
||||
int CRYPTO_siv128_speed(SIV128_CONTEXT *ctx, int arg);
|
||||
typedef union siv_block_u {
|
||||
uint64_t word[SIV_LEN/sizeof(uint64_t)];
|
||||
unsigned char byte[SIV_LEN];
|
||||
} SIV_BLOCK;
|
||||
|
||||
struct siv128_context {
|
||||
/* d stores intermediate results of S2V; it corresponds to D from the
|
||||
pseudocode in section 2.4 of RFC 5297. */
|
||||
SIV_BLOCK d;
|
||||
SIV_BLOCK tag;
|
||||
EVP_CIPHER_CTX *cipher_ctx;
|
||||
EVP_MAC *mac;
|
||||
EVP_MAC_CTX *mac_ctx_init;
|
||||
int final_ret;
|
||||
int crypto_ok;
|
||||
};
|
||||
|
||||
#endif /* OPENSSL_NO_SIV */
|
||||
@@ -24,7 +24,6 @@
|
||||
typedef struct rand_pool_st RAND_POOL;
|
||||
|
||||
void rand_cleanup_int(void);
|
||||
void rand_fork(void);
|
||||
|
||||
/* Hardware-based seeding functions. */
|
||||
size_t rand_acquire_entropy_from_tsc(RAND_POOL *pool);
|
||||
@@ -58,7 +57,8 @@ void rand_crngt_cleanup_entropy(RAND_DRBG *drbg,
|
||||
/*
|
||||
* RAND_POOL functions
|
||||
*/
|
||||
RAND_POOL *rand_pool_new(int entropy_requested, size_t min_len, size_t max_len);
|
||||
RAND_POOL *rand_pool_new(int entropy_requested, int secure,
|
||||
size_t min_len, size_t max_len);
|
||||
RAND_POOL *rand_pool_attach(const unsigned char *buffer, size_t len,
|
||||
size_t entropy);
|
||||
void rand_pool_free(RAND_POOL *pool);
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2019 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 OPENSSL_NO_SIV
|
||||
|
||||
typedef struct siv128_context SIV128_CONTEXT;
|
||||
|
||||
SIV128_CONTEXT *CRYPTO_siv128_new(const unsigned char *key, int klen,
|
||||
EVP_CIPHER* cbc, EVP_CIPHER* ctr);
|
||||
int CRYPTO_siv128_init(SIV128_CONTEXT *ctx, const unsigned char *key, int klen,
|
||||
const EVP_CIPHER* cbc, const EVP_CIPHER* ctr);
|
||||
int CRYPTO_siv128_copy_ctx(SIV128_CONTEXT *dest, SIV128_CONTEXT *src);
|
||||
int CRYPTO_siv128_aad(SIV128_CONTEXT *ctx, const unsigned char *aad,
|
||||
size_t len);
|
||||
int CRYPTO_siv128_encrypt(SIV128_CONTEXT *ctx,
|
||||
const unsigned char *in, unsigned char *out,
|
||||
size_t len);
|
||||
int CRYPTO_siv128_decrypt(SIV128_CONTEXT *ctx,
|
||||
const unsigned char *in, unsigned char *out,
|
||||
size_t len);
|
||||
int CRYPTO_siv128_finish(SIV128_CONTEXT *ctx);
|
||||
int CRYPTO_siv128_set_tag(SIV128_CONTEXT *ctx, const unsigned char *tag,
|
||||
size_t len);
|
||||
int CRYPTO_siv128_get_tag(SIV128_CONTEXT *ctx, unsigned char *tag, size_t len);
|
||||
int CRYPTO_siv128_cleanup(SIV128_CONTEXT *ctx);
|
||||
int CRYPTO_siv128_speed(SIV128_CONTEXT *ctx, int arg);
|
||||
|
||||
#endif /* OPENSSL_NO_SIV */
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Generated by util/mkerr.pl DO NOT EDIT
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2019 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
|
||||
@@ -11,6 +11,10 @@
|
||||
#ifndef HEADER_SM2ERR_H
|
||||
# define HEADER_SM2ERR_H
|
||||
|
||||
# include <openssl/opensslconf.h>
|
||||
# include <openssl/symhacks.h>
|
||||
|
||||
|
||||
# include <openssl/opensslconf.h>
|
||||
|
||||
# ifndef OPENSSL_NO_SM2
|
||||
@@ -23,22 +27,24 @@ int ERR_load_SM2_strings(void);
|
||||
/*
|
||||
* SM2 function codes.
|
||||
*/
|
||||
# define SM2_F_PKEY_SM2_COPY 115
|
||||
# define SM2_F_PKEY_SM2_CTRL 109
|
||||
# define SM2_F_PKEY_SM2_CTRL_STR 110
|
||||
# define SM2_F_PKEY_SM2_DIGEST_CUSTOM 114
|
||||
# define SM2_F_PKEY_SM2_INIT 111
|
||||
# define SM2_F_PKEY_SM2_SIGN 112
|
||||
# define SM2_F_SM2_COMPUTE_MSG_HASH 100
|
||||
# define SM2_F_SM2_COMPUTE_USERID_DIGEST 101
|
||||
# define SM2_F_SM2_COMPUTE_Z_DIGEST 113
|
||||
# define SM2_F_SM2_DECRYPT 102
|
||||
# define SM2_F_SM2_ENCRYPT 103
|
||||
# define SM2_F_SM2_PLAINTEXT_SIZE 104
|
||||
# define SM2_F_SM2_SIGN 105
|
||||
# define SM2_F_SM2_SIG_GEN 106
|
||||
# define SM2_F_SM2_SIG_VERIFY 107
|
||||
# define SM2_F_SM2_VERIFY 108
|
||||
# if !OPENSSL_API_3
|
||||
# define SM2_F_PKEY_SM2_COPY 0
|
||||
# define SM2_F_PKEY_SM2_CTRL 0
|
||||
# define SM2_F_PKEY_SM2_CTRL_STR 0
|
||||
# define SM2_F_PKEY_SM2_DIGEST_CUSTOM 0
|
||||
# define SM2_F_PKEY_SM2_INIT 0
|
||||
# define SM2_F_PKEY_SM2_SIGN 0
|
||||
# define SM2_F_SM2_COMPUTE_MSG_HASH 0
|
||||
# define SM2_F_SM2_COMPUTE_USERID_DIGEST 0
|
||||
# define SM2_F_SM2_COMPUTE_Z_DIGEST 0
|
||||
# define SM2_F_SM2_DECRYPT 0
|
||||
# define SM2_F_SM2_ENCRYPT 0
|
||||
# define SM2_F_SM2_PLAINTEXT_SIZE 0
|
||||
# define SM2_F_SM2_SIGN 0
|
||||
# define SM2_F_SM2_SIG_GEN 0
|
||||
# define SM2_F_SM2_SIG_VERIFY 0
|
||||
# define SM2_F_SM2_VERIFY 0
|
||||
# endif
|
||||
|
||||
/*
|
||||
* SM2 reason codes.
|
||||
|
||||
@@ -197,7 +197,7 @@ struct x509_st {
|
||||
* kept and passed around.
|
||||
*/
|
||||
struct x509_store_ctx_st { /* X509_STORE_CTX */
|
||||
X509_STORE *ctx;
|
||||
X509_STORE *store;
|
||||
/* The following are set by the caller */
|
||||
/* The cert to check */
|
||||
X509 *cert;
|
||||
|
||||
Reference in New Issue
Block a user