Latest update.
This commit is contained in:
@@ -1,96 +0,0 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#include <openssl/des.h>
|
||||
#include <openssl/core_numbers.h>
|
||||
|
||||
#define DES_BLOCK_SIZE 8
|
||||
#define TDES_IVLEN 8
|
||||
|
||||
/* TODO(3.0) Figure out what flags need to be here */
|
||||
#define TDES_FLAGS (EVP_CIPH_RAND_KEY | EVP_CIPH_FLAG_DEFAULT_ASN1)
|
||||
|
||||
typedef struct prov_tdes_ctx_st {
|
||||
PROV_CIPHER_CTX base; /* Must be first */
|
||||
union {
|
||||
OSSL_UNION_ALIGN;
|
||||
DES_key_schedule ks[3];
|
||||
} tks;
|
||||
union {
|
||||
void (*cbc) (const void *, void *, size_t,
|
||||
const DES_key_schedule *, unsigned char *);
|
||||
} tstream;
|
||||
|
||||
} PROV_TDES_CTX;
|
||||
|
||||
#define IMPLEMENT_tdes_cipher(type, UCTYPE, lcmode, UCMODE, flags, \
|
||||
kbits, blkbits, ivbits, block) \
|
||||
static OSSL_OP_cipher_newctx_fn tdes_##type##_##lcmode##_newctx; \
|
||||
static void *tdes_##type##_##lcmode##_newctx(void *provctx) \
|
||||
{ \
|
||||
return tdes_newctx(provctx, EVP_CIPH_##UCMODE##_MODE, kbits, blkbits, \
|
||||
ivbits, flags, PROV_CIPHER_HW_tdes_##type##_##lcmode());\
|
||||
} \
|
||||
static OSSL_OP_cipher_get_params_fn tdes_##type##_##lcmode##_get_params; \
|
||||
static int tdes_##type##_##lcmode##_get_params(OSSL_PARAM params[]) \
|
||||
{ \
|
||||
return cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE, flags, \
|
||||
kbits, blkbits, ivbits); \
|
||||
} \
|
||||
const OSSL_DISPATCH tdes_##type##_##lcmode##_functions[] = { \
|
||||
{ OSSL_FUNC_CIPHER_ENCRYPT_INIT, (void (*)(void))tdes_einit }, \
|
||||
{ OSSL_FUNC_CIPHER_DECRYPT_INIT, (void (*)(void))tdes_dinit }, \
|
||||
{ OSSL_FUNC_CIPHER_UPDATE, \
|
||||
(void (*)(void))cipher_generic_##block##_update }, \
|
||||
{ OSSL_FUNC_CIPHER_FINAL, (void (*)(void))cipher_generic_##block##_final },\
|
||||
{ OSSL_FUNC_CIPHER_CIPHER, (void (*)(void))cipher_generic_cipher }, \
|
||||
{ OSSL_FUNC_CIPHER_NEWCTX, \
|
||||
(void (*)(void))tdes_##type##_##lcmode##_newctx }, \
|
||||
{ OSSL_FUNC_CIPHER_FREECTX, (void (*)(void))tdes_freectx }, \
|
||||
{ OSSL_FUNC_CIPHER_GET_PARAMS, \
|
||||
(void (*)(void))tdes_##type##_##lcmode##_get_params }, \
|
||||
{ OSSL_FUNC_CIPHER_GETTABLE_PARAMS, \
|
||||
(void (*)(void))cipher_generic_gettable_params }, \
|
||||
{ OSSL_FUNC_CIPHER_GET_CTX_PARAMS, (void (*)(void))tdes_get_ctx_params }, \
|
||||
{ OSSL_FUNC_CIPHER_GETTABLE_CTX_PARAMS, \
|
||||
(void (*)(void))tdes_gettable_ctx_params }, \
|
||||
{ OSSL_FUNC_CIPHER_SET_CTX_PARAMS, \
|
||||
(void (*)(void))cipher_generic_set_ctx_params }, \
|
||||
{ OSSL_FUNC_CIPHER_SETTABLE_CTX_PARAMS, \
|
||||
(void (*)(void))cipher_generic_settable_ctx_params }, \
|
||||
{ 0, NULL } \
|
||||
}
|
||||
|
||||
void *tdes_newctx(void *provctx, int mode, size_t kbits, size_t blkbits,
|
||||
size_t ivbits, uint64_t flags, const PROV_CIPHER_HW *hw);
|
||||
OSSL_OP_cipher_freectx_fn tdes_freectx;
|
||||
OSSL_OP_cipher_encrypt_init_fn tdes_einit;
|
||||
OSSL_OP_cipher_decrypt_init_fn tdes_dinit;
|
||||
OSSL_OP_cipher_get_ctx_params_fn tdes_get_ctx_params;
|
||||
OSSL_OP_cipher_gettable_ctx_params_fn tdes_gettable_ctx_params;
|
||||
|
||||
#define PROV_CIPHER_HW_tdes_mode(type, mode) \
|
||||
static const PROV_CIPHER_HW type##_##mode = { \
|
||||
cipher_hw_tdes_##type##_initkey, \
|
||||
cipher_hw_tdes_##mode \
|
||||
}; \
|
||||
const PROV_CIPHER_HW *PROV_CIPHER_HW_tdes_##type##_##mode(void) \
|
||||
{ \
|
||||
return &type##_##mode; \
|
||||
}
|
||||
|
||||
int cipher_hw_tdes_ede3_initkey(PROV_CIPHER_CTX *ctx, const unsigned char *key,
|
||||
size_t keylen);
|
||||
int cipher_hw_tdes_cbc(PROV_CIPHER_CTX *ctx, unsigned char *out,
|
||||
const unsigned char *in, size_t inl);
|
||||
int cipher_hw_tdes_ecb(PROV_CIPHER_CTX *ctx, unsigned char *out,
|
||||
const unsigned char *in, size_t len);
|
||||
|
||||
const PROV_CIPHER_HW *PROV_CIPHER_HW_tdes_ede3_cbc(void);
|
||||
const PROV_CIPHER_HW *PROV_CIPHER_HW_tdes_ede3_ecb(void);
|
||||
@@ -1,223 +0,0 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/* Digests */
|
||||
extern const OSSL_DISPATCH sha1_functions[];
|
||||
extern const OSSL_DISPATCH sha224_functions[];
|
||||
extern const OSSL_DISPATCH sha256_functions[];
|
||||
extern const OSSL_DISPATCH sha384_functions[];
|
||||
extern const OSSL_DISPATCH sha512_functions[];
|
||||
extern const OSSL_DISPATCH sha512_224_functions[];
|
||||
extern const OSSL_DISPATCH sha512_256_functions[];
|
||||
extern const OSSL_DISPATCH sha3_224_functions[];
|
||||
extern const OSSL_DISPATCH sha3_256_functions[];
|
||||
extern const OSSL_DISPATCH sha3_384_functions[];
|
||||
extern const OSSL_DISPATCH sha3_512_functions[];
|
||||
extern const OSSL_DISPATCH keccak_kmac_128_functions[];
|
||||
extern const OSSL_DISPATCH keccak_kmac_256_functions[];
|
||||
extern const OSSL_DISPATCH shake_128_functions[];
|
||||
extern const OSSL_DISPATCH shake_256_functions[];
|
||||
extern const OSSL_DISPATCH blake2s256_functions[];
|
||||
extern const OSSL_DISPATCH blake2b512_functions[];
|
||||
extern const OSSL_DISPATCH md5_functions[];
|
||||
extern const OSSL_DISPATCH md5_sha1_functions[];
|
||||
extern const OSSL_DISPATCH sm3_functions[];
|
||||
extern const OSSL_DISPATCH md2_functions[];
|
||||
extern const OSSL_DISPATCH md4_functions[];
|
||||
extern const OSSL_DISPATCH mdc2_functions[];
|
||||
extern const OSSL_DISPATCH wp_functions[];
|
||||
extern const OSSL_DISPATCH ripemd160_functions[];
|
||||
|
||||
/* Ciphers */
|
||||
extern const OSSL_DISPATCH aes256ecb_functions[];
|
||||
extern const OSSL_DISPATCH aes192ecb_functions[];
|
||||
extern const OSSL_DISPATCH aes128ecb_functions[];
|
||||
extern const OSSL_DISPATCH aes256cbc_functions[];
|
||||
extern const OSSL_DISPATCH aes192cbc_functions[];
|
||||
extern const OSSL_DISPATCH aes128cbc_functions[];
|
||||
extern const OSSL_DISPATCH aes256ofb_functions[];
|
||||
extern const OSSL_DISPATCH aes192ofb_functions[];
|
||||
extern const OSSL_DISPATCH aes128ofb_functions[];
|
||||
extern const OSSL_DISPATCH aes256cfb_functions[];
|
||||
extern const OSSL_DISPATCH aes192cfb_functions[];
|
||||
extern const OSSL_DISPATCH aes128cfb_functions[];
|
||||
extern const OSSL_DISPATCH aes256cfb1_functions[];
|
||||
extern const OSSL_DISPATCH aes192cfb1_functions[];
|
||||
extern const OSSL_DISPATCH aes128cfb1_functions[];
|
||||
extern const OSSL_DISPATCH aes256cfb8_functions[];
|
||||
extern const OSSL_DISPATCH aes192cfb8_functions[];
|
||||
extern const OSSL_DISPATCH aes128cfb8_functions[];
|
||||
extern const OSSL_DISPATCH aes256ctr_functions[];
|
||||
extern const OSSL_DISPATCH aes192ctr_functions[];
|
||||
extern const OSSL_DISPATCH aes128ctr_functions[];
|
||||
extern const OSSL_DISPATCH aes256xts_functions[];
|
||||
extern const OSSL_DISPATCH aes128xts_functions[];
|
||||
#ifndef OPENSSL_NO_OCB
|
||||
extern const OSSL_DISPATCH aes256ocb_functions[];
|
||||
extern const OSSL_DISPATCH aes192ocb_functions[];
|
||||
extern const OSSL_DISPATCH aes128ocb_functions[];
|
||||
#endif /* OPENSSL_NO_OCB */
|
||||
extern const OSSL_DISPATCH aes256gcm_functions[];
|
||||
extern const OSSL_DISPATCH aes192gcm_functions[];
|
||||
extern const OSSL_DISPATCH aes128gcm_functions[];
|
||||
extern const OSSL_DISPATCH aes256ccm_functions[];
|
||||
extern const OSSL_DISPATCH aes192ccm_functions[];
|
||||
extern const OSSL_DISPATCH aes128ccm_functions[];
|
||||
extern const OSSL_DISPATCH aes256wrap_functions[];
|
||||
extern const OSSL_DISPATCH aes192wrap_functions[];
|
||||
extern const OSSL_DISPATCH aes128wrap_functions[];
|
||||
extern const OSSL_DISPATCH aes256wrappad_functions[];
|
||||
extern const OSSL_DISPATCH aes192wrappad_functions[];
|
||||
extern const OSSL_DISPATCH aes128wrappad_functions[];
|
||||
|
||||
#ifndef OPENSSL_NO_ARIA
|
||||
extern const OSSL_DISPATCH aria256gcm_functions[];
|
||||
extern const OSSL_DISPATCH aria192gcm_functions[];
|
||||
extern const OSSL_DISPATCH aria128gcm_functions[];
|
||||
extern const OSSL_DISPATCH aria256ccm_functions[];
|
||||
extern const OSSL_DISPATCH aria192ccm_functions[];
|
||||
extern const OSSL_DISPATCH aria128ccm_functions[];
|
||||
extern const OSSL_DISPATCH aria256ecb_functions[];
|
||||
extern const OSSL_DISPATCH aria192ecb_functions[];
|
||||
extern const OSSL_DISPATCH aria128ecb_functions[];
|
||||
extern const OSSL_DISPATCH aria256cbc_functions[];
|
||||
extern const OSSL_DISPATCH aria192cbc_functions[];
|
||||
extern const OSSL_DISPATCH aria128cbc_functions[];
|
||||
extern const OSSL_DISPATCH aria256ofb_functions[];
|
||||
extern const OSSL_DISPATCH aria192ofb_functions[];
|
||||
extern const OSSL_DISPATCH aria128ofb_functions[];
|
||||
extern const OSSL_DISPATCH aria256cfb_functions[];
|
||||
extern const OSSL_DISPATCH aria192cfb_functions[];
|
||||
extern const OSSL_DISPATCH aria128cfb_functions[];
|
||||
extern const OSSL_DISPATCH aria256cfb1_functions[];
|
||||
extern const OSSL_DISPATCH aria192cfb1_functions[];
|
||||
extern const OSSL_DISPATCH aria128cfb1_functions[];
|
||||
extern const OSSL_DISPATCH aria256cfb8_functions[];
|
||||
extern const OSSL_DISPATCH aria192cfb8_functions[];
|
||||
extern const OSSL_DISPATCH aria128cfb8_functions[];
|
||||
extern const OSSL_DISPATCH aria256ctr_functions[];
|
||||
extern const OSSL_DISPATCH aria192ctr_functions[];
|
||||
extern const OSSL_DISPATCH aria128ctr_functions[];
|
||||
#endif /* OPENSSL_NO_ARIA */
|
||||
#ifndef OPENSSL_NO_CAMELLIA
|
||||
extern const OSSL_DISPATCH camellia256ecb_functions[];
|
||||
extern const OSSL_DISPATCH camellia192ecb_functions[];
|
||||
extern const OSSL_DISPATCH camellia128ecb_functions[];
|
||||
extern const OSSL_DISPATCH camellia256cbc_functions[];
|
||||
extern const OSSL_DISPATCH camellia192cbc_functions[];
|
||||
extern const OSSL_DISPATCH camellia128cbc_functions[];
|
||||
extern const OSSL_DISPATCH camellia256ofb_functions[];
|
||||
extern const OSSL_DISPATCH camellia192ofb_functions[];
|
||||
extern const OSSL_DISPATCH camellia128ofb_functions[];
|
||||
extern const OSSL_DISPATCH camellia256cfb_functions[];
|
||||
extern const OSSL_DISPATCH camellia192cfb_functions[];
|
||||
extern const OSSL_DISPATCH camellia128cfb_functions[];
|
||||
extern const OSSL_DISPATCH camellia256cfb1_functions[];
|
||||
extern const OSSL_DISPATCH camellia192cfb1_functions[];
|
||||
extern const OSSL_DISPATCH camellia128cfb1_functions[];
|
||||
extern const OSSL_DISPATCH camellia256cfb8_functions[];
|
||||
extern const OSSL_DISPATCH camellia192cfb8_functions[];
|
||||
extern const OSSL_DISPATCH camellia128cfb8_functions[];
|
||||
extern const OSSL_DISPATCH camellia256ctr_functions[];
|
||||
extern const OSSL_DISPATCH camellia192ctr_functions[];
|
||||
extern const OSSL_DISPATCH camellia128ctr_functions[];
|
||||
#endif /* OPENSSL_NO_CAMELLIA */
|
||||
#ifndef OPENSSL_NO_BF
|
||||
extern const OSSL_DISPATCH blowfish128ecb_functions[];
|
||||
extern const OSSL_DISPATCH blowfish128cbc_functions[];
|
||||
extern const OSSL_DISPATCH blowfish64ofb64_functions[];
|
||||
extern const OSSL_DISPATCH blowfish64cfb64_functions[];
|
||||
#endif /* OPENSSL_NO_BF */
|
||||
#ifndef OPENSSL_NO_IDEA
|
||||
extern const OSSL_DISPATCH idea128ecb_functions[];
|
||||
extern const OSSL_DISPATCH idea128cbc_functions[];
|
||||
extern const OSSL_DISPATCH idea128ofb64_functions[];
|
||||
extern const OSSL_DISPATCH idea128cfb64_functions[];
|
||||
#endif /* OPENSSL_NO_IDEA */
|
||||
#ifndef OPENSSL_NO_CAST
|
||||
extern const OSSL_DISPATCH cast5128ecb_functions[];
|
||||
extern const OSSL_DISPATCH cast5128cbc_functions[];
|
||||
extern const OSSL_DISPATCH cast564ofb64_functions[];
|
||||
extern const OSSL_DISPATCH cast564cfb64_functions[];
|
||||
#endif /* OPENSSL_NO_CAST */
|
||||
#ifndef OPENSSL_NO_SEED
|
||||
extern const OSSL_DISPATCH seed128ecb_functions[];
|
||||
extern const OSSL_DISPATCH seed128cbc_functions[];
|
||||
extern const OSSL_DISPATCH seed128ofb128_functions[];
|
||||
extern const OSSL_DISPATCH seed128cfb128_functions[];
|
||||
#endif /* OPENSSL_NO_SEED */
|
||||
#ifndef OPENSSL_NO_SM4
|
||||
extern const OSSL_DISPATCH sm4128ecb_functions[];
|
||||
extern const OSSL_DISPATCH sm4128cbc_functions[];
|
||||
extern const OSSL_DISPATCH sm4128ctr_functions[];
|
||||
extern const OSSL_DISPATCH sm4128ofb128_functions[];
|
||||
extern const OSSL_DISPATCH sm4128cfb128_functions[];
|
||||
#endif /* OPENSSL_NO_SM4 */
|
||||
|
||||
#ifndef OPENSSL_NO_DES
|
||||
extern const OSSL_DISPATCH tdes_ede3_ecb_functions[];
|
||||
extern const OSSL_DISPATCH tdes_ede3_cbc_functions[];
|
||||
# ifndef FIPS_MODE
|
||||
extern const OSSL_DISPATCH tdes_ede3_ofb_functions[];
|
||||
extern const OSSL_DISPATCH tdes_ede3_cfb_functions[];
|
||||
extern const OSSL_DISPATCH tdes_ede3_cfb8_functions[];
|
||||
extern const OSSL_DISPATCH tdes_ede3_cfb1_functions[];
|
||||
|
||||
extern const OSSL_DISPATCH tdes_ede2_ecb_functions[];
|
||||
extern const OSSL_DISPATCH tdes_ede2_cbc_functions[];
|
||||
extern const OSSL_DISPATCH tdes_ede2_ofb_functions[];
|
||||
extern const OSSL_DISPATCH tdes_ede2_cfb_functions[];
|
||||
|
||||
extern const OSSL_DISPATCH tdes_desx_cbc_functions[];
|
||||
extern const OSSL_DISPATCH tdes_wrap_cbc_functions[];
|
||||
|
||||
extern const OSSL_DISPATCH des_ecb_functions[];
|
||||
extern const OSSL_DISPATCH des_cbc_functions[];
|
||||
extern const OSSL_DISPATCH des_ofb64_functions[];
|
||||
extern const OSSL_DISPATCH des_cfb64_functions[];
|
||||
extern const OSSL_DISPATCH des_cfb1_functions[];
|
||||
extern const OSSL_DISPATCH des_cfb8_functions[];
|
||||
# endif /* FIPS_MODE */
|
||||
#endif /* OPENSSL_NO_DES */
|
||||
|
||||
/* MACs */
|
||||
extern const OSSL_DISPATCH blake2bmac_functions[];
|
||||
extern const OSSL_DISPATCH blake2smac_functions[];
|
||||
extern const OSSL_DISPATCH cmac_functions[];
|
||||
extern const OSSL_DISPATCH gmac_functions[];
|
||||
extern const OSSL_DISPATCH hmac_functions[];
|
||||
extern const OSSL_DISPATCH kmac128_functions[];
|
||||
extern const OSSL_DISPATCH kmac256_functions[];
|
||||
extern const OSSL_DISPATCH siphash_functions[];
|
||||
extern const OSSL_DISPATCH poly1305_functions[];
|
||||
|
||||
/* KDFs / PRFs */
|
||||
extern const OSSL_DISPATCH kdf_pbkdf2_functions[];
|
||||
#ifndef OPENSSL_NO_SCRYPT
|
||||
extern const OSSL_DISPATCH kdf_scrypt_functions[];
|
||||
#endif
|
||||
extern const OSSL_DISPATCH kdf_tls1_prf_functions[];
|
||||
extern const OSSL_DISPATCH kdf_hkdf_functions[];
|
||||
extern const OSSL_DISPATCH kdf_sshkdf_functions[];
|
||||
extern const OSSL_DISPATCH kdf_sskdf_functions[];
|
||||
extern const OSSL_DISPATCH kdf_x963_kdf_functions[];
|
||||
#ifndef OPENSSL_NO_CMS
|
||||
extern const OSSL_DISPATCH kdf_x942_kdf_functions[];
|
||||
#endif
|
||||
|
||||
|
||||
/* Key management */
|
||||
extern const OSSL_DISPATCH dh_keymgmt_functions[];
|
||||
extern const OSSL_DISPATCH dsa_keymgmt_functions[];
|
||||
|
||||
/* Key Exchange */
|
||||
extern const OSSL_DISPATCH dh_keyexch_functions[];
|
||||
|
||||
/* Signature */
|
||||
extern const OSSL_DISPATCH dsa_signature_functions[];
|
||||
+5
-4
@@ -10,10 +10,11 @@
|
||||
#define UNINITIALISED_SIZET ((size_t)-1)
|
||||
|
||||
/* TODO(3.0) Figure out what flags are really needed */
|
||||
#define AEAD_FLAGS (EVP_CIPH_FLAG_AEAD_CIPHER | EVP_CIPH_FLAG_DEFAULT_ASN1 \
|
||||
| EVP_CIPH_CUSTOM_IV | EVP_CIPH_FLAG_CUSTOM_CIPHER \
|
||||
| EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CTRL_INIT \
|
||||
| EVP_CIPH_CUSTOM_COPY)
|
||||
#define AEAD_FLAGS (EVP_CIPH_FLAG_AEAD_CIPHER \
|
||||
| EVP_CIPH_CUSTOM_IV \
|
||||
| EVP_CIPH_ALWAYS_CALL_INIT \
|
||||
| EVP_CIPH_CTRL_INIT \
|
||||
| EVP_CIPH_CUSTOM_COPY)
|
||||
|
||||
#define IMPLEMENT_aead_cipher(alg, lc, UCMODE, flags, kbits, blkbits, ivbits) \
|
||||
static OSSL_OP_cipher_get_params_fn alg##_##kbits##_##lc##_get_params; \
|
||||
-1
@@ -121,7 +121,6 @@ OSSL_OP_cipher_update_fn ccm_stream_update;
|
||||
OSSL_OP_cipher_final_fn ccm_stream_final;
|
||||
OSSL_OP_cipher_cipher_fn ccm_cipher;
|
||||
void ccm_initctx(PROV_CCM_CTX *ctx, size_t keybits, const PROV_CCM_HW *hw);
|
||||
void ccm_finalctx(PROV_CCM_CTX *ctx);
|
||||
|
||||
int ccm_generic_setiv(PROV_CCM_CTX *ctx, const unsigned char *nonce,
|
||||
size_t nlen, size_t mlen);
|
||||
-1
@@ -139,7 +139,6 @@ OSSL_OP_cipher_set_ctx_params_fn gcm_set_ctx_params;
|
||||
OSSL_OP_cipher_cipher_fn gcm_cipher;
|
||||
OSSL_OP_cipher_update_fn gcm_stream_update;
|
||||
OSSL_OP_cipher_final_fn gcm_stream_final;
|
||||
void gcm_deinitctx(PROV_GCM_CTX *ctx);
|
||||
void gcm_initctx(void *provctx, PROV_GCM_CTX *ctx, size_t keybits,
|
||||
const PROV_GCM_HW *hw, size_t ivlen_min);
|
||||
|
||||
+65
-25
@@ -12,8 +12,8 @@
|
||||
#include <openssl/core_names.h>
|
||||
#include <openssl/evp.h>
|
||||
#include "internal/cryptlib.h"
|
||||
#include "internal/modes_int.h"
|
||||
#include "internal/ciphermode_platform.h"
|
||||
#include "crypto/modes.h"
|
||||
#include "crypto/ciphermode_platform.h"
|
||||
|
||||
#define MAXCHUNK ((size_t)1 << (sizeof(long) * 8 - 2))
|
||||
#define MAXBITCHUNK ((size_t)1 << (sizeof(size_t) * 8 - 4))
|
||||
@@ -40,12 +40,13 @@ struct prov_cipher_ctx_st {
|
||||
} stream;
|
||||
|
||||
unsigned int mode;
|
||||
size_t keylen; /* key size (in bytes) */
|
||||
size_t keylen; /* key size (in bytes) */
|
||||
size_t ivlen;
|
||||
size_t blocksize;
|
||||
size_t bufsz; /* Number of bytes in buf */
|
||||
unsigned int pad : 1; /* Whether padding should be used or not */
|
||||
unsigned int enc : 1; /* Set to 1 for encrypt, or 0 otherwise */
|
||||
size_t bufsz; /* Number of bytes in buf */
|
||||
unsigned int pad : 1; /* Whether padding should be used or not */
|
||||
unsigned int enc : 1; /* Set to 1 for encrypt, or 0 otherwise */
|
||||
unsigned int iv_set : 1; /* Set when the iv is copied to the iv/oiv buffers */
|
||||
|
||||
/*
|
||||
* num contains the number of bytes of |iv| which are valid for modes that
|
||||
@@ -54,6 +55,8 @@ struct prov_cipher_ctx_st {
|
||||
unsigned int num;
|
||||
uint64_t flags;
|
||||
|
||||
/* The original value of the iv */
|
||||
unsigned char oiv[GENERIC_BLOCK_SIZE];
|
||||
/* Buffer of partial blocks processed via update calls */
|
||||
unsigned char buf[GENERIC_BLOCK_SIZE];
|
||||
unsigned char iv[GENERIC_BLOCK_SIZE];
|
||||
@@ -88,25 +91,8 @@ void cipher_generic_initkey(void *vctx, size_t kbits, size_t blkbits,
|
||||
size_t ivbits, unsigned int mode, uint64_t flags,
|
||||
const PROV_CIPHER_HW *hw, void *provctx);
|
||||
|
||||
#define IMPLEMENT_generic_cipher(alg, UCALG, lcmode, UCMODE, flags, kbits, \
|
||||
blkbits, ivbits, typ) \
|
||||
static OSSL_OP_cipher_get_params_fn alg##_##kbits##_##lcmode##_get_params; \
|
||||
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[]) \
|
||||
{ \
|
||||
return cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE, flags, \
|
||||
kbits, blkbits, ivbits); \
|
||||
} \
|
||||
static OSSL_OP_cipher_newctx_fn alg##_##kbits##_##lcmode##_newctx; \
|
||||
static void * alg##_##kbits##_##lcmode##_newctx(void *provctx) \
|
||||
{ \
|
||||
PROV_##UCALG##_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx)); \
|
||||
if (ctx != NULL) { \
|
||||
cipher_generic_initkey(ctx, kbits, blkbits, ivbits, \
|
||||
EVP_CIPH_##UCMODE##_MODE, flags, \
|
||||
PROV_CIPHER_HW_##alg##_##lcmode(kbits), NULL); \
|
||||
} \
|
||||
return ctx; \
|
||||
} \
|
||||
#define IMPLEMENT_generic_cipher_func(alg, UCALG, lcmode, UCMODE, flags, kbits,\
|
||||
blkbits, ivbits, typ) \
|
||||
const OSSL_DISPATCH alg##kbits##lcmode##_functions[] = { \
|
||||
{ OSSL_FUNC_CIPHER_NEWCTX, \
|
||||
(void (*)(void)) alg##_##kbits##_##lcmode##_newctx }, \
|
||||
@@ -132,6 +118,28 @@ const OSSL_DISPATCH alg##kbits##lcmode##_functions[] = { \
|
||||
{ 0, NULL } \
|
||||
};
|
||||
|
||||
#define IMPLEMENT_generic_cipher(alg, UCALG, lcmode, UCMODE, flags, kbits, \
|
||||
blkbits, ivbits, typ) \
|
||||
static OSSL_OP_cipher_get_params_fn alg##_##kbits##_##lcmode##_get_params; \
|
||||
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[]) \
|
||||
{ \
|
||||
return cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE, flags, \
|
||||
kbits, blkbits, ivbits); \
|
||||
} \
|
||||
static OSSL_OP_cipher_newctx_fn alg##_##kbits##_##lcmode##_newctx; \
|
||||
static void * alg##_##kbits##_##lcmode##_newctx(void *provctx) \
|
||||
{ \
|
||||
PROV_##UCALG##_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx)); \
|
||||
if (ctx != NULL) { \
|
||||
cipher_generic_initkey(ctx, kbits, blkbits, ivbits, \
|
||||
EVP_CIPH_##UCMODE##_MODE, flags, \
|
||||
PROV_CIPHER_HW_##alg##_##lcmode(kbits), NULL); \
|
||||
} \
|
||||
return ctx; \
|
||||
} \
|
||||
IMPLEMENT_generic_cipher_func(alg, UCALG, lcmode, UCMODE, flags, kbits, \
|
||||
blkbits, ivbits, typ)
|
||||
|
||||
PROV_CIPHER_HW_FN cipher_hw_generic_cbc;
|
||||
PROV_CIPHER_HW_FN cipher_hw_generic_ecb;
|
||||
PROV_CIPHER_HW_FN cipher_hw_generic_ofb128;
|
||||
@@ -225,6 +233,38 @@ static int cipher_hw_##NAME##_##MODE##_cipher(PROV_CIPHER_CTX *ctx, \
|
||||
return 1; \
|
||||
}
|
||||
|
||||
#define CIPHER_DEFAULT_GETTABLE_CTX_PARAMS_START(name) \
|
||||
static const OSSL_PARAM name##_known_gettable_ctx_params[] = { \
|
||||
OSSL_PARAM_size_t(OSSL_CIPHER_PARAM_KEYLEN, NULL), \
|
||||
OSSL_PARAM_size_t(OSSL_CIPHER_PARAM_IVLEN, NULL), \
|
||||
OSSL_PARAM_uint(OSSL_CIPHER_PARAM_PADDING, NULL), \
|
||||
OSSL_PARAM_uint(OSSL_CIPHER_PARAM_NUM, NULL), \
|
||||
OSSL_PARAM_octet_string(OSSL_CIPHER_PARAM_IV, NULL, 0),
|
||||
|
||||
#define CIPHER_DEFAULT_GETTABLE_CTX_PARAMS_END(name) \
|
||||
OSSL_PARAM_END \
|
||||
}; \
|
||||
const OSSL_PARAM * name##_gettable_ctx_params(void) \
|
||||
{ \
|
||||
return name##_known_gettable_ctx_params; \
|
||||
}
|
||||
|
||||
#define CIPHER_DEFAULT_SETTABLE_CTX_PARAMS_START(name) \
|
||||
static const OSSL_PARAM name##_known_settable_ctx_params[] = { \
|
||||
OSSL_PARAM_size_t(OSSL_CIPHER_PARAM_KEYLEN, NULL), \
|
||||
OSSL_PARAM_uint(OSSL_CIPHER_PARAM_PADDING, NULL), \
|
||||
OSSL_PARAM_uint(OSSL_CIPHER_PARAM_NUM, NULL),
|
||||
#define CIPHER_DEFAULT_SETTABLE_CTX_PARAMS_END(name) \
|
||||
OSSL_PARAM_END \
|
||||
}; \
|
||||
const OSSL_PARAM * name##_settable_ctx_params(void) \
|
||||
{ \
|
||||
return name##_known_settable_ctx_params; \
|
||||
}
|
||||
|
||||
int cipher_generic_initiv(PROV_CIPHER_CTX *ctx, const unsigned char *iv,
|
||||
size_t ivlen);
|
||||
|
||||
size_t fillblock(unsigned char *buf, size_t *buflen, size_t blocksize,
|
||||
const unsigned char **in, size_t *inlen);
|
||||
int trailingdata(unsigned char *buf, size_t *buflen, size_t blocksize,
|
||||
+3
-3
@@ -7,8 +7,8 @@
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#ifndef OSSL_DIGESTCOMMON_H
|
||||
# define OSSL_DIGESTCOMMON_H
|
||||
#ifndef OSSL_PROVIDERS_DIGESTCOMMON_H
|
||||
# define OSSL_PROVIDERS_DIGESTCOMMON_H
|
||||
|
||||
# include <openssl/core_numbers.h>
|
||||
# include <openssl/core_names.h>
|
||||
@@ -100,4 +100,4 @@ int digest_default_get_params(OSSL_PARAM params[], size_t blksz, size_t paramsz,
|
||||
}
|
||||
# endif
|
||||
|
||||
#endif /* OSSL_DIGESTCOMMON_H */
|
||||
#endif /* OSSL_PROVIDERS_DIGESTCOMMON_H */
|
||||
+7
-2
@@ -8,8 +8,8 @@
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#ifndef HEADER_PROVERR_H
|
||||
# define HEADER_PROVERR_H
|
||||
#ifndef OPENSSL_PROVERR_H
|
||||
# define OPENSSL_PROVERR_H
|
||||
|
||||
# include <openssl/opensslconf.h>
|
||||
# include <openssl/symhacks.h>
|
||||
@@ -69,13 +69,16 @@ int ERR_load_PROV_strings(void);
|
||||
# define PROV_R_INVALID_KEYLEN 117
|
||||
# define PROV_R_INVALID_KEY_LEN 124
|
||||
# define PROV_R_INVALID_KEY_LENGTH 105
|
||||
# define PROV_R_INVALID_MAC 151
|
||||
# define PROV_R_INVALID_MODE 125
|
||||
# define PROV_R_INVALID_MODE_INT 126
|
||||
# define PROV_R_INVALID_SALT_LENGTH 112
|
||||
# define PROV_R_INVALID_SEED_LENGTH 154
|
||||
# define PROV_R_INVALID_TAG 110
|
||||
# define PROV_R_INVALID_TAGLEN 118
|
||||
# define PROV_R_MISSING_CEK_ALG 144
|
||||
# define PROV_R_MISSING_KEY 128
|
||||
# define PROV_R_MISSING_MAC 150
|
||||
# define PROV_R_MISSING_MESSAGE_DIGEST 129
|
||||
# define PROV_R_MISSING_PASS 130
|
||||
# define PROV_R_MISSING_SALT 131
|
||||
@@ -93,7 +96,9 @@ int ERR_load_PROV_strings(void);
|
||||
# define PROV_R_UNABLE_TO_LOAD_SHA1 143
|
||||
# define PROV_R_UNABLE_TO_LOAD_SHA256 147
|
||||
# define PROV_R_UNSUPPORTED_CEK_ALG 145
|
||||
# define PROV_R_UNSUPPORTED_KEY_SIZE 153
|
||||
# define PROV_R_UNSUPPORTED_MAC_TYPE 137
|
||||
# define PROV_R_UNSUPPORTED_NUMBER_OF_ROUNDS 152
|
||||
# define PROV_R_VALUE_ERROR 138
|
||||
# define PROV_R_WRONG_FINAL_BLOCK_LENGTH 107
|
||||
# define PROV_R_WRONG_OUTPUT_BUFFER_SIZE 139
|
||||
Reference in New Issue
Block a user