mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2026-07-09 20:10:52 +02:00
Merge pull request #8216 from douzzer/20241122-opensslcoexist-expansion
20241122-opensslcoexist-expansion
This commit is contained in:
+79
-79
@@ -367,14 +367,14 @@ static struct skcipher_alg cbcAesAlg = {
|
||||
.base.cra_name = WOLFKM_AESCBC_NAME,
|
||||
.base.cra_driver_name = WOLFKM_AESCBC_DRIVER,
|
||||
.base.cra_priority = WOLFSSL_LINUXKM_LKCAPI_PRIORITY,
|
||||
.base.cra_blocksize = AES_BLOCK_SIZE,
|
||||
.base.cra_blocksize = WC_AES_BLOCK_SIZE,
|
||||
.base.cra_ctxsize = sizeof(struct km_AesCtx),
|
||||
.base.cra_module = THIS_MODULE,
|
||||
.init = km_AesCbcInit,
|
||||
.exit = km_AesExit,
|
||||
.min_keysize = AES_128_KEY_SIZE,
|
||||
.max_keysize = AES_256_KEY_SIZE,
|
||||
.ivsize = AES_BLOCK_SIZE,
|
||||
.ivsize = WC_AES_BLOCK_SIZE,
|
||||
.setkey = km_AesCbcSetKey,
|
||||
.encrypt = km_AesCbcEncrypt,
|
||||
.decrypt = km_AesCbcDecrypt,
|
||||
@@ -506,14 +506,14 @@ static struct skcipher_alg cfbAesAlg = {
|
||||
.base.cra_name = WOLFKM_AESCFB_NAME,
|
||||
.base.cra_driver_name = WOLFKM_AESCFB_DRIVER,
|
||||
.base.cra_priority = WOLFSSL_LINUXKM_LKCAPI_PRIORITY,
|
||||
.base.cra_blocksize = AES_BLOCK_SIZE,
|
||||
.base.cra_blocksize = WC_AES_BLOCK_SIZE,
|
||||
.base.cra_ctxsize = sizeof(struct km_AesCtx),
|
||||
.base.cra_module = THIS_MODULE,
|
||||
.init = km_AesCfbInit,
|
||||
.exit = km_AesExit,
|
||||
.min_keysize = AES_128_KEY_SIZE,
|
||||
.max_keysize = AES_256_KEY_SIZE,
|
||||
.ivsize = AES_BLOCK_SIZE,
|
||||
.ivsize = WC_AES_BLOCK_SIZE,
|
||||
.setkey = km_AesCfbSetKey,
|
||||
.encrypt = km_AesCfbEncrypt,
|
||||
.decrypt = km_AesCfbDecrypt,
|
||||
@@ -565,7 +565,7 @@ static int km_AesGcmSetKey(struct crypto_aead *tfm, const u8 *in_key,
|
||||
static int km_AesGcmSetAuthsize(struct crypto_aead *tfm, unsigned int authsize)
|
||||
{
|
||||
(void)tfm;
|
||||
if (authsize > AES_BLOCK_SIZE ||
|
||||
if (authsize > WC_AES_BLOCK_SIZE ||
|
||||
authsize < WOLFSSL_MIN_AUTH_TAG_SZ) {
|
||||
pr_err("%s: invalid authsize: %d\n",
|
||||
crypto_tfm_alg_driver_name(crypto_aead_tfm(tfm)), authsize);
|
||||
@@ -591,7 +591,7 @@ static int km_AesGcmEncrypt(struct aead_request *req)
|
||||
struct skcipher_walk walk;
|
||||
struct scatter_walk assocSgWalk;
|
||||
unsigned int nbytes = 0;
|
||||
u8 authTag[AES_BLOCK_SIZE];
|
||||
u8 authTag[WC_AES_BLOCK_SIZE];
|
||||
int err = 0;
|
||||
unsigned int assocLeft = 0;
|
||||
unsigned int cryptLeft = 0;
|
||||
@@ -612,7 +612,7 @@ static int km_AesGcmEncrypt(struct aead_request *req)
|
||||
}
|
||||
|
||||
err = wc_AesGcmInit(ctx->aes_encrypt, NULL /*key*/, 0 /*keylen*/, walk.iv,
|
||||
AES_BLOCK_SIZE);
|
||||
WC_AES_BLOCK_SIZE);
|
||||
if (unlikely(err)) {
|
||||
pr_err("%s: wc_AesGcmInit failed: %d\n",
|
||||
crypto_tfm_alg_driver_name(crypto_aead_tfm(tfm)), err);
|
||||
@@ -692,7 +692,7 @@ static int km_AesGcmDecrypt(struct aead_request *req)
|
||||
struct skcipher_walk walk;
|
||||
struct scatter_walk assocSgWalk;
|
||||
unsigned int nbytes = 0;
|
||||
u8 origAuthTag[AES_BLOCK_SIZE];
|
||||
u8 origAuthTag[WC_AES_BLOCK_SIZE];
|
||||
int err = 0;
|
||||
unsigned int assocLeft = 0;
|
||||
unsigned int cryptLeft = 0;
|
||||
@@ -718,7 +718,7 @@ static int km_AesGcmDecrypt(struct aead_request *req)
|
||||
}
|
||||
|
||||
err = wc_AesGcmInit(ctx->aes_encrypt, NULL /*key*/, 0 /*keylen*/, walk.iv,
|
||||
AES_BLOCK_SIZE);
|
||||
WC_AES_BLOCK_SIZE);
|
||||
if (unlikely(err)) {
|
||||
pr_err("%s: wc_AesGcmInit failed: %d\n",
|
||||
crypto_tfm_alg_driver_name(crypto_aead_tfm(tfm)), err);
|
||||
@@ -805,9 +805,9 @@ static struct aead_alg gcmAesAead = {
|
||||
.setauthsize = km_AesGcmSetAuthsize,
|
||||
.encrypt = km_AesGcmEncrypt,
|
||||
.decrypt = km_AesGcmDecrypt,
|
||||
.ivsize = AES_BLOCK_SIZE,
|
||||
.maxauthsize = AES_BLOCK_SIZE,
|
||||
.chunksize = AES_BLOCK_SIZE,
|
||||
.ivsize = WC_AES_BLOCK_SIZE,
|
||||
.maxauthsize = WC_AES_BLOCK_SIZE,
|
||||
.chunksize = WC_AES_BLOCK_SIZE,
|
||||
};
|
||||
static int gcmAesAead_loaded = 0;
|
||||
|
||||
@@ -894,7 +894,7 @@ static int km_AesXtsEncrypt(struct skcipher_request *req)
|
||||
tfm = crypto_skcipher_reqtfm(req);
|
||||
ctx = crypto_skcipher_ctx(tfm);
|
||||
|
||||
if (req->cryptlen < AES_BLOCK_SIZE)
|
||||
if (req->cryptlen < WC_AES_BLOCK_SIZE)
|
||||
return -EINVAL;
|
||||
|
||||
err = skcipher_walk_virt(&walk, req, false);
|
||||
@@ -918,12 +918,12 @@ static int km_AesXtsEncrypt(struct skcipher_request *req)
|
||||
err = skcipher_walk_done(&walk, 0);
|
||||
|
||||
} else {
|
||||
int tail = req->cryptlen % AES_BLOCK_SIZE;
|
||||
int tail = req->cryptlen % WC_AES_BLOCK_SIZE;
|
||||
struct skcipher_request subreq;
|
||||
struct XtsAesStreamData stream;
|
||||
|
||||
if (tail > 0) {
|
||||
int blocks = DIV_ROUND_UP(req->cryptlen, AES_BLOCK_SIZE) - 2;
|
||||
int blocks = DIV_ROUND_UP(req->cryptlen, WC_AES_BLOCK_SIZE) - 2;
|
||||
|
||||
skcipher_walk_abort(&walk);
|
||||
|
||||
@@ -932,7 +932,7 @@ static int km_AesXtsEncrypt(struct skcipher_request *req)
|
||||
skcipher_request_flags(req),
|
||||
NULL, NULL);
|
||||
skcipher_request_set_crypt(&subreq, req->src, req->dst,
|
||||
blocks * AES_BLOCK_SIZE, req->iv);
|
||||
blocks * WC_AES_BLOCK_SIZE, req->iv);
|
||||
req = &subreq;
|
||||
|
||||
err = skcipher_walk_virt(&walk, req, false);
|
||||
@@ -955,9 +955,9 @@ static int km_AesXtsEncrypt(struct skcipher_request *req)
|
||||
* end-of-message ciphertext stealing.
|
||||
*/
|
||||
if (nbytes < walk.total)
|
||||
nbytes &= ~(AES_BLOCK_SIZE - 1);
|
||||
nbytes &= ~(WC_AES_BLOCK_SIZE - 1);
|
||||
|
||||
if (nbytes & ((unsigned int)AES_BLOCK_SIZE - 1U))
|
||||
if (nbytes & ((unsigned int)WC_AES_BLOCK_SIZE - 1U))
|
||||
err = wc_AesXtsEncryptFinal(ctx->aesXts, walk.dst.virt.addr,
|
||||
walk.src.virt.addr, nbytes,
|
||||
&stream);
|
||||
@@ -989,7 +989,7 @@ static int km_AesXtsEncrypt(struct skcipher_request *req)
|
||||
if (req->dst != req->src)
|
||||
dst = scatterwalk_ffwd(sg_dst, req->dst, req->cryptlen);
|
||||
|
||||
skcipher_request_set_crypt(req, src, dst, AES_BLOCK_SIZE + tail,
|
||||
skcipher_request_set_crypt(req, src, dst, WC_AES_BLOCK_SIZE + tail,
|
||||
req->iv);
|
||||
|
||||
err = skcipher_walk_virt(&walk, &subreq, false);
|
||||
@@ -1007,7 +1007,7 @@ static int km_AesXtsEncrypt(struct skcipher_request *req)
|
||||
}
|
||||
|
||||
err = skcipher_walk_done(&walk, 0);
|
||||
} else if (! (stream.bytes_crypted_with_this_tweak & ((word32)AES_BLOCK_SIZE - 1U))) {
|
||||
} else if (! (stream.bytes_crypted_with_this_tweak & ((word32)WC_AES_BLOCK_SIZE - 1U))) {
|
||||
err = wc_AesXtsEncryptFinal(ctx->aesXts, NULL, NULL, 0, &stream);
|
||||
}
|
||||
}
|
||||
@@ -1026,7 +1026,7 @@ static int km_AesXtsDecrypt(struct skcipher_request *req)
|
||||
tfm = crypto_skcipher_reqtfm(req);
|
||||
ctx = crypto_skcipher_ctx(tfm);
|
||||
|
||||
if (req->cryptlen < AES_BLOCK_SIZE)
|
||||
if (req->cryptlen < WC_AES_BLOCK_SIZE)
|
||||
return -EINVAL;
|
||||
|
||||
err = skcipher_walk_virt(&walk, req, false);
|
||||
@@ -1050,12 +1050,12 @@ static int km_AesXtsDecrypt(struct skcipher_request *req)
|
||||
|
||||
err = skcipher_walk_done(&walk, 0);
|
||||
} else {
|
||||
int tail = req->cryptlen % AES_BLOCK_SIZE;
|
||||
int tail = req->cryptlen % WC_AES_BLOCK_SIZE;
|
||||
struct skcipher_request subreq;
|
||||
struct XtsAesStreamData stream;
|
||||
|
||||
if (unlikely(tail > 0)) {
|
||||
int blocks = DIV_ROUND_UP(req->cryptlen, AES_BLOCK_SIZE) - 2;
|
||||
int blocks = DIV_ROUND_UP(req->cryptlen, WC_AES_BLOCK_SIZE) - 2;
|
||||
|
||||
skcipher_walk_abort(&walk);
|
||||
|
||||
@@ -1064,7 +1064,7 @@ static int km_AesXtsDecrypt(struct skcipher_request *req)
|
||||
skcipher_request_flags(req),
|
||||
NULL, NULL);
|
||||
skcipher_request_set_crypt(&subreq, req->src, req->dst,
|
||||
blocks * AES_BLOCK_SIZE, req->iv);
|
||||
blocks * WC_AES_BLOCK_SIZE, req->iv);
|
||||
req = &subreq;
|
||||
|
||||
err = skcipher_walk_virt(&walk, req, false);
|
||||
@@ -1087,9 +1087,9 @@ static int km_AesXtsDecrypt(struct skcipher_request *req)
|
||||
* end-of-message ciphertext stealing.
|
||||
*/
|
||||
if (nbytes < walk.total)
|
||||
nbytes &= ~(AES_BLOCK_SIZE - 1);
|
||||
nbytes &= ~(WC_AES_BLOCK_SIZE - 1);
|
||||
|
||||
if (nbytes & ((unsigned int)AES_BLOCK_SIZE - 1U))
|
||||
if (nbytes & ((unsigned int)WC_AES_BLOCK_SIZE - 1U))
|
||||
err = wc_AesXtsDecryptFinal(ctx->aesXts, walk.dst.virt.addr,
|
||||
walk.src.virt.addr, nbytes,
|
||||
&stream);
|
||||
@@ -1121,7 +1121,7 @@ static int km_AesXtsDecrypt(struct skcipher_request *req)
|
||||
if (req->dst != req->src)
|
||||
dst = scatterwalk_ffwd(sg_dst, req->dst, req->cryptlen);
|
||||
|
||||
skcipher_request_set_crypt(req, src, dst, AES_BLOCK_SIZE + tail,
|
||||
skcipher_request_set_crypt(req, src, dst, WC_AES_BLOCK_SIZE + tail,
|
||||
req->iv);
|
||||
|
||||
err = skcipher_walk_virt(&walk, &subreq, false);
|
||||
@@ -1139,7 +1139,7 @@ static int km_AesXtsDecrypt(struct skcipher_request *req)
|
||||
}
|
||||
|
||||
err = skcipher_walk_done(&walk, 0);
|
||||
} else if (! (stream.bytes_crypted_with_this_tweak & ((word32)AES_BLOCK_SIZE - 1U))) {
|
||||
} else if (! (stream.bytes_crypted_with_this_tweak & ((word32)WC_AES_BLOCK_SIZE - 1U))) {
|
||||
err = wc_AesXtsDecryptFinal(ctx->aesXts, NULL, NULL, 0, &stream);
|
||||
}
|
||||
}
|
||||
@@ -1150,14 +1150,14 @@ static struct skcipher_alg xtsAesAlg = {
|
||||
.base.cra_name = WOLFKM_AESXTS_NAME,
|
||||
.base.cra_driver_name = WOLFKM_AESXTS_DRIVER,
|
||||
.base.cra_priority = WOLFSSL_LINUXKM_LKCAPI_PRIORITY,
|
||||
.base.cra_blocksize = AES_BLOCK_SIZE,
|
||||
.base.cra_blocksize = WC_AES_BLOCK_SIZE,
|
||||
.base.cra_ctxsize = sizeof(struct km_AesXtsCtx),
|
||||
.base.cra_module = THIS_MODULE,
|
||||
|
||||
.min_keysize = 2 * AES_128_KEY_SIZE,
|
||||
.max_keysize = 2 * AES_256_KEY_SIZE,
|
||||
.ivsize = AES_BLOCK_SIZE,
|
||||
.walksize = 2 * AES_BLOCK_SIZE,
|
||||
.ivsize = WC_AES_BLOCK_SIZE,
|
||||
.walksize = 2 * WC_AES_BLOCK_SIZE,
|
||||
.init = km_AesXtsInit,
|
||||
.exit = km_AesXtsExit,
|
||||
.setkey = km_AesXtsSetKey,
|
||||
@@ -1229,7 +1229,7 @@ static int linuxkm_test_aescbc(void)
|
||||
}
|
||||
aes_inited = 1;
|
||||
|
||||
ret = wc_AesSetKey(aes, key32, AES_BLOCK_SIZE * 2, iv, AES_ENCRYPTION);
|
||||
ret = wc_AesSetKey(aes, key32, WC_AES_BLOCK_SIZE * 2, iv, AES_ENCRYPTION);
|
||||
if (ret) {
|
||||
pr_err("wolfcrypt wc_AesSetKey failed with return code %d\n", ret);
|
||||
goto test_cbc_end;
|
||||
@@ -1257,7 +1257,7 @@ static int linuxkm_test_aescbc(void)
|
||||
}
|
||||
aes_inited = 1;
|
||||
|
||||
ret = wc_AesSetKey(aes, key32, AES_BLOCK_SIZE * 2, iv, AES_DECRYPTION);
|
||||
ret = wc_AesSetKey(aes, key32, WC_AES_BLOCK_SIZE * 2, iv, AES_DECRYPTION);
|
||||
if (ret) {
|
||||
pr_err("wolfcrypt wc_AesSetKey failed with return code %d.\n", ret);
|
||||
goto test_cbc_end;
|
||||
@@ -1310,7 +1310,7 @@ static int linuxkm_test_aescbc(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
ret = crypto_skcipher_setkey(tfm, key32, AES_BLOCK_SIZE * 2);
|
||||
ret = crypto_skcipher_setkey(tfm, key32, WC_AES_BLOCK_SIZE * 2);
|
||||
if (ret) {
|
||||
pr_err("error: crypto_skcipher_setkey returned: %d\n", ret);
|
||||
goto test_cbc_end;
|
||||
@@ -1435,7 +1435,7 @@ static int linuxkm_test_aescfb(void)
|
||||
}
|
||||
aes_inited = 1;
|
||||
|
||||
ret = wc_AesSetKey(aes, key32, AES_BLOCK_SIZE * 2, iv, AES_ENCRYPTION);
|
||||
ret = wc_AesSetKey(aes, key32, WC_AES_BLOCK_SIZE * 2, iv, AES_ENCRYPTION);
|
||||
if (ret) {
|
||||
pr_err("wolfcrypt wc_AesSetKey failed with return code %d\n", ret);
|
||||
goto test_cfb_end;
|
||||
@@ -1463,7 +1463,7 @@ static int linuxkm_test_aescfb(void)
|
||||
}
|
||||
aes_inited = 1;
|
||||
|
||||
ret = wc_AesSetKey(aes, key32, AES_BLOCK_SIZE * 2, iv, AES_ENCRYPTION);
|
||||
ret = wc_AesSetKey(aes, key32, WC_AES_BLOCK_SIZE * 2, iv, AES_ENCRYPTION);
|
||||
if (ret) {
|
||||
pr_err("wolfcrypt wc_AesSetKey failed with return code %d.\n", ret);
|
||||
goto test_cfb_end;
|
||||
@@ -1516,7 +1516,7 @@ static int linuxkm_test_aescfb(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
ret = crypto_skcipher_setkey(tfm, key32, AES_BLOCK_SIZE * 2);
|
||||
ret = crypto_skcipher_setkey(tfm, key32, WC_AES_BLOCK_SIZE * 2);
|
||||
if (ret) {
|
||||
pr_err("error: crypto_skcipher_setkey returned: %d\n", ret);
|
||||
goto test_cfb_end;
|
||||
@@ -1632,7 +1632,7 @@ static int linuxkm_test_aesgcm(void)
|
||||
0xe4,0x28,0x90,0xaa,0x09,0xab,0xf9,0x7c
|
||||
};
|
||||
byte enc[sizeof(p_vector)];
|
||||
byte authTag[AES_BLOCK_SIZE];
|
||||
byte authTag[WC_AES_BLOCK_SIZE];
|
||||
byte dec[sizeof(p_vector)];
|
||||
u8 * assoc2 = NULL;
|
||||
u8 * enc2 = NULL;
|
||||
@@ -1644,7 +1644,7 @@ static int linuxkm_test_aesgcm(void)
|
||||
/* Init stack variables. */
|
||||
XMEMSET(enc, 0, sizeof(p_vector));
|
||||
XMEMSET(dec, 0, sizeof(p_vector));
|
||||
XMEMSET(authTag, 0, AES_BLOCK_SIZE);
|
||||
XMEMSET(authTag, 0, WC_AES_BLOCK_SIZE);
|
||||
|
||||
aes = (Aes *)malloc(sizeof(*aes));
|
||||
if (aes == NULL)
|
||||
@@ -1658,7 +1658,7 @@ static int linuxkm_test_aesgcm(void)
|
||||
aes_inited = 1;
|
||||
|
||||
ret = wc_AesGcmInit(aes, key32, sizeof(key32)/sizeof(byte), ivstr,
|
||||
AES_BLOCK_SIZE);
|
||||
WC_AES_BLOCK_SIZE);
|
||||
if (ret) {
|
||||
pr_err("error: wc_AesGcmInit failed with return code %d.\n", ret);
|
||||
goto test_gcm_end;
|
||||
@@ -1684,7 +1684,7 @@ static int linuxkm_test_aesgcm(void)
|
||||
goto test_gcm_end;
|
||||
}
|
||||
|
||||
ret = wc_AesGcmEncryptFinal(aes, authTag, AES_BLOCK_SIZE);
|
||||
ret = wc_AesGcmEncryptFinal(aes, authTag, WC_AES_BLOCK_SIZE);
|
||||
if (ret) {
|
||||
pr_err("error: wc_AesGcmEncryptFinal failed with return code %d\n",
|
||||
ret);
|
||||
@@ -1698,7 +1698,7 @@ static int linuxkm_test_aesgcm(void)
|
||||
}
|
||||
|
||||
ret = wc_AesGcmInit(aes, key32, sizeof(key32)/sizeof(byte), ivstr,
|
||||
AES_BLOCK_SIZE);
|
||||
WC_AES_BLOCK_SIZE);
|
||||
if (ret) {
|
||||
pr_err("error: wc_AesGcmInit failed with return code %d.\n", ret);
|
||||
goto test_gcm_end;
|
||||
@@ -1712,7 +1712,7 @@ static int linuxkm_test_aesgcm(void)
|
||||
goto test_gcm_end;
|
||||
}
|
||||
|
||||
ret = wc_AesGcmDecryptFinal(aes, authTag, AES_BLOCK_SIZE);
|
||||
ret = wc_AesGcmDecryptFinal(aes, authTag, WC_AES_BLOCK_SIZE);
|
||||
if (ret) {
|
||||
pr_err("error: wc_AesGcmEncryptFinal failed with return code %d\n",
|
||||
ret);
|
||||
@@ -1734,13 +1734,13 @@ static int linuxkm_test_aesgcm(void)
|
||||
memset(assoc2, 0, sizeof(assoc));
|
||||
memcpy(assoc2, assoc, sizeof(assoc));
|
||||
|
||||
iv = malloc(AES_BLOCK_SIZE);
|
||||
iv = malloc(WC_AES_BLOCK_SIZE);
|
||||
if (IS_ERR(iv)) {
|
||||
pr_err("error: malloc failed\n");
|
||||
goto test_gcm_end;
|
||||
}
|
||||
memset(iv, 0, AES_BLOCK_SIZE);
|
||||
memcpy(iv, ivstr, AES_BLOCK_SIZE);
|
||||
memset(iv, 0, WC_AES_BLOCK_SIZE);
|
||||
memcpy(iv, ivstr, WC_AES_BLOCK_SIZE);
|
||||
|
||||
enc2 = malloc(decryptLen);
|
||||
if (IS_ERR(enc2)) {
|
||||
@@ -1777,7 +1777,7 @@ static int linuxkm_test_aesgcm(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
ret = crypto_aead_setkey(tfm, key32, AES_BLOCK_SIZE * 2);
|
||||
ret = crypto_aead_setkey(tfm, key32, WC_AES_BLOCK_SIZE * 2);
|
||||
if (ret) {
|
||||
pr_err("error: crypto_aead_setkey returned: %d\n", ret);
|
||||
goto test_gcm_end;
|
||||
@@ -1891,7 +1891,7 @@ static int aes_xts_128_test(void)
|
||||
XtsAes *aes = NULL;
|
||||
int aes_inited = 0;
|
||||
int ret = 0;
|
||||
#define AES_XTS_128_TEST_BUF_SIZ (AES_BLOCK_SIZE * 2 + 8)
|
||||
#define AES_XTS_128_TEST_BUF_SIZ (WC_AES_BLOCK_SIZE * 2 + 8)
|
||||
unsigned char *buf = NULL;
|
||||
unsigned char *cipher = NULL;
|
||||
u8 * enc2 = NULL;
|
||||
@@ -2049,12 +2049,12 @@ static int aes_xts_128_test(void)
|
||||
ret = wc_AesXtsEncryptInit(aes, i2, sizeof(i2), &stream);
|
||||
if (ret != 0)
|
||||
goto out;
|
||||
ret = wc_AesXtsEncryptUpdate(aes, buf, p2, AES_BLOCK_SIZE, &stream);
|
||||
ret = wc_AesXtsEncryptUpdate(aes, buf, p2, WC_AES_BLOCK_SIZE, &stream);
|
||||
if (ret != 0)
|
||||
goto out;
|
||||
ret = wc_AesXtsEncryptFinal(aes, buf + AES_BLOCK_SIZE,
|
||||
p2 + AES_BLOCK_SIZE,
|
||||
sizeof(p2) - AES_BLOCK_SIZE, &stream);
|
||||
ret = wc_AesXtsEncryptFinal(aes, buf + WC_AES_BLOCK_SIZE,
|
||||
p2 + WC_AES_BLOCK_SIZE,
|
||||
sizeof(p2) - WC_AES_BLOCK_SIZE, &stream);
|
||||
if (ret != 0)
|
||||
goto out;
|
||||
if (XMEMCMP(c2, buf, sizeof(c2))) {
|
||||
@@ -2070,7 +2070,7 @@ static int aes_xts_128_test(void)
|
||||
ret = wc_AesXtsEncrypt(aes, buf, p1, sizeof(p1), i1, sizeof(i1));
|
||||
if (ret != 0)
|
||||
goto out;
|
||||
if (XMEMCMP(c1, buf, AES_BLOCK_SIZE)) {
|
||||
if (XMEMCMP(c1, buf, WC_AES_BLOCK_SIZE)) {
|
||||
ret = LINUXKM_LKCAPI_AES_KAT_MISMATCH_E;
|
||||
goto out;
|
||||
}
|
||||
@@ -2081,7 +2081,7 @@ static int aes_xts_128_test(void)
|
||||
WC_DEBUG_SET_VECTOR_REGISTERS_RETVAL(0);
|
||||
if (ret != 0)
|
||||
goto out;
|
||||
if (XMEMCMP(c1, buf, AES_BLOCK_SIZE)) {
|
||||
if (XMEMCMP(c1, buf, WC_AES_BLOCK_SIZE)) {
|
||||
ret = LINUXKM_LKCAPI_AES_KAT_MISMATCH_E;
|
||||
goto out;
|
||||
}
|
||||
@@ -2141,7 +2141,7 @@ static int aes_xts_128_test(void)
|
||||
ret = wc_AesXtsDecrypt(aes, buf, c1, sizeof(c1), i1, sizeof(i1));
|
||||
if (ret != 0)
|
||||
goto out;
|
||||
if (XMEMCMP(p1, buf, AES_BLOCK_SIZE)) {
|
||||
if (XMEMCMP(p1, buf, WC_AES_BLOCK_SIZE)) {
|
||||
ret = LINUXKM_LKCAPI_AES_KAT_MISMATCH_E;
|
||||
goto out;
|
||||
}
|
||||
@@ -2153,7 +2153,7 @@ static int aes_xts_128_test(void)
|
||||
WC_DEBUG_SET_VECTOR_REGISTERS_RETVAL(0);
|
||||
if (ret != 0)
|
||||
goto out;
|
||||
if (XMEMCMP(p1, buf, AES_BLOCK_SIZE)) {
|
||||
if (XMEMCMP(p1, buf, WC_AES_BLOCK_SIZE)) {
|
||||
ret = LINUXKM_LKCAPI_AES_KAT_MISMATCH_E;
|
||||
goto out;
|
||||
}
|
||||
@@ -2235,14 +2235,14 @@ static int aes_xts_128_test(void)
|
||||
ret = wc_AesXtsEncryptInit(aes, i1, sizeof(i1), &stream);
|
||||
if (ret != 0)
|
||||
goto out;
|
||||
for (k = 0; k < j; k += AES_BLOCK_SIZE) {
|
||||
if ((j - k) < AES_BLOCK_SIZE*2)
|
||||
for (k = 0; k < j; k += WC_AES_BLOCK_SIZE) {
|
||||
if ((j - k) < WC_AES_BLOCK_SIZE*2)
|
||||
ret = wc_AesXtsEncryptFinal(aes, large_input + k, large_input + k, j - k, &stream);
|
||||
else
|
||||
ret = wc_AesXtsEncryptUpdate(aes, large_input + k, large_input + k, AES_BLOCK_SIZE, &stream);
|
||||
ret = wc_AesXtsEncryptUpdate(aes, large_input + k, large_input + k, WC_AES_BLOCK_SIZE, &stream);
|
||||
if (ret != 0)
|
||||
goto out;
|
||||
if ((j - k) < AES_BLOCK_SIZE*2)
|
||||
if ((j - k) < WC_AES_BLOCK_SIZE*2)
|
||||
break;
|
||||
}
|
||||
ret = wc_AesXtsSetKeyNoInit(aes, k1, sizeof(k1), AES_DECRYPTION);
|
||||
@@ -2275,14 +2275,14 @@ static int aes_xts_128_test(void)
|
||||
ret = wc_AesXtsDecryptInit(aes, i1, sizeof(i1), &stream);
|
||||
if (ret != 0)
|
||||
goto out;
|
||||
for (k = 0; k < j; k += AES_BLOCK_SIZE) {
|
||||
if ((j - k) < AES_BLOCK_SIZE*2)
|
||||
for (k = 0; k < j; k += WC_AES_BLOCK_SIZE) {
|
||||
if ((j - k) < WC_AES_BLOCK_SIZE*2)
|
||||
ret = wc_AesXtsDecryptFinal(aes, large_input + k, large_input + k, j - k, &stream);
|
||||
else
|
||||
ret = wc_AesXtsDecryptUpdate(aes, large_input + k, large_input + k, AES_BLOCK_SIZE, &stream);
|
||||
ret = wc_AesXtsDecryptUpdate(aes, large_input + k, large_input + k, WC_AES_BLOCK_SIZE, &stream);
|
||||
if (ret != 0)
|
||||
goto out;
|
||||
if ((j - k) < AES_BLOCK_SIZE*2)
|
||||
if ((j - k) < WC_AES_BLOCK_SIZE*2)
|
||||
break;
|
||||
}
|
||||
for (i = 0; i < j; i++) {
|
||||
@@ -2491,7 +2491,7 @@ static int aes_xts_256_test(void)
|
||||
XtsAes *aes = NULL;
|
||||
int aes_inited = 0;
|
||||
int ret = 0;
|
||||
#define AES_XTS_256_TEST_BUF_SIZ (AES_BLOCK_SIZE * 3)
|
||||
#define AES_XTS_256_TEST_BUF_SIZ (WC_AES_BLOCK_SIZE * 3)
|
||||
unsigned char *buf = NULL;
|
||||
unsigned char *cipher = NULL;
|
||||
u8 * enc2 = NULL;
|
||||
@@ -2625,12 +2625,12 @@ static int aes_xts_256_test(void)
|
||||
ret = wc_AesXtsEncryptInit(aes, i2, sizeof(i2), &stream);
|
||||
if (ret != 0)
|
||||
goto out;
|
||||
ret = wc_AesXtsEncryptUpdate(aes, buf, p2, AES_BLOCK_SIZE, &stream);
|
||||
ret = wc_AesXtsEncryptUpdate(aes, buf, p2, WC_AES_BLOCK_SIZE, &stream);
|
||||
if (ret != 0)
|
||||
goto out;
|
||||
ret = wc_AesXtsEncryptFinal(aes, buf + AES_BLOCK_SIZE,
|
||||
p2 + AES_BLOCK_SIZE,
|
||||
sizeof(p2) - AES_BLOCK_SIZE, &stream);
|
||||
ret = wc_AesXtsEncryptFinal(aes, buf + WC_AES_BLOCK_SIZE,
|
||||
p2 + WC_AES_BLOCK_SIZE,
|
||||
sizeof(p2) - WC_AES_BLOCK_SIZE, &stream);
|
||||
if (ret != 0)
|
||||
goto out;
|
||||
if (XMEMCMP(c2, buf, sizeof(c2))) {
|
||||
@@ -2645,7 +2645,7 @@ static int aes_xts_256_test(void)
|
||||
ret = wc_AesXtsEncrypt(aes, buf, p1, sizeof(p1), i1, sizeof(i1));
|
||||
if (ret != 0)
|
||||
goto out;
|
||||
if (XMEMCMP(c1, buf, AES_BLOCK_SIZE)) {
|
||||
if (XMEMCMP(c1, buf, WC_AES_BLOCK_SIZE)) {
|
||||
ret = LINUXKM_LKCAPI_AES_KAT_MISMATCH_E;
|
||||
goto out;
|
||||
}
|
||||
@@ -2674,7 +2674,7 @@ static int aes_xts_256_test(void)
|
||||
ret = wc_AesXtsDecrypt(aes, buf, c1, sizeof(c1), i1, sizeof(i1));
|
||||
if (ret != 0)
|
||||
goto out;
|
||||
if (XMEMCMP(p1, buf, AES_BLOCK_SIZE)) {
|
||||
if (XMEMCMP(p1, buf, WC_AES_BLOCK_SIZE)) {
|
||||
ret = LINUXKM_LKCAPI_AES_KAT_MISMATCH_E;
|
||||
goto out;
|
||||
}
|
||||
@@ -2715,14 +2715,14 @@ static int aes_xts_256_test(void)
|
||||
ret = wc_AesXtsEncryptInit(aes, i1, sizeof(i1), &stream);
|
||||
if (ret != 0)
|
||||
goto out;
|
||||
for (k = 0; k < j; k += AES_BLOCK_SIZE) {
|
||||
if ((j - k) < AES_BLOCK_SIZE*2)
|
||||
for (k = 0; k < j; k += WC_AES_BLOCK_SIZE) {
|
||||
if ((j - k) < WC_AES_BLOCK_SIZE*2)
|
||||
ret = wc_AesXtsEncryptFinal(aes, large_input + k, large_input + k, j - k, &stream);
|
||||
else
|
||||
ret = wc_AesXtsEncryptUpdate(aes, large_input + k, large_input + k, AES_BLOCK_SIZE, &stream);
|
||||
ret = wc_AesXtsEncryptUpdate(aes, large_input + k, large_input + k, WC_AES_BLOCK_SIZE, &stream);
|
||||
if (ret != 0)
|
||||
goto out;
|
||||
if ((j - k) < AES_BLOCK_SIZE*2)
|
||||
if ((j - k) < WC_AES_BLOCK_SIZE*2)
|
||||
break;
|
||||
}
|
||||
ret = wc_AesXtsSetKeyNoInit(aes, k1, sizeof(k1), AES_DECRYPTION);
|
||||
@@ -2755,14 +2755,14 @@ static int aes_xts_256_test(void)
|
||||
ret = wc_AesXtsDecryptInit(aes, i1, sizeof(i1), &stream);
|
||||
if (ret != 0)
|
||||
goto out;
|
||||
for (k = 0; k < j; k += AES_BLOCK_SIZE) {
|
||||
if ((j - k) < AES_BLOCK_SIZE*2)
|
||||
for (k = 0; k < j; k += WC_AES_BLOCK_SIZE) {
|
||||
if ((j - k) < WC_AES_BLOCK_SIZE*2)
|
||||
ret = wc_AesXtsDecryptFinal(aes, large_input + k, large_input + k, j - k, &stream);
|
||||
else
|
||||
ret = wc_AesXtsDecryptUpdate(aes, large_input + k, large_input + k, AES_BLOCK_SIZE, &stream);
|
||||
ret = wc_AesXtsDecryptUpdate(aes, large_input + k, large_input + k, WC_AES_BLOCK_SIZE, &stream);
|
||||
if (ret != 0)
|
||||
goto out;
|
||||
if ((j - k) < AES_BLOCK_SIZE*2)
|
||||
if ((j - k) < WC_AES_BLOCK_SIZE*2)
|
||||
break;
|
||||
}
|
||||
for (i = 0; i < j; i++) {
|
||||
|
||||
+12
-12
@@ -796,16 +796,16 @@ static int ExportCipherSpecState(WOLFSSL* ssl, byte* exp, word32 len, byte ver,
|
||||
ssl->specs.bulk_cipher_algorithm == wolfssl_aes) {
|
||||
byte *pt = (byte*)ssl->encrypt.aes->reg;
|
||||
|
||||
if ((idx + 2*AES_BLOCK_SIZE) > len) {
|
||||
if ((idx + 2*WC_AES_BLOCK_SIZE) > len) {
|
||||
WOLFSSL_MSG("Can not fit AES state into buffer");
|
||||
return BUFFER_E;
|
||||
}
|
||||
XMEMCPY(exp + idx, pt, AES_BLOCK_SIZE);
|
||||
idx += AES_BLOCK_SIZE;
|
||||
XMEMCPY(exp + idx, pt, WC_AES_BLOCK_SIZE);
|
||||
idx += WC_AES_BLOCK_SIZE;
|
||||
|
||||
pt = (byte*)ssl->decrypt.aes->reg;
|
||||
XMEMCPY(exp + idx, pt, AES_BLOCK_SIZE);
|
||||
idx += AES_BLOCK_SIZE;
|
||||
XMEMCPY(exp + idx, pt, WC_AES_BLOCK_SIZE);
|
||||
idx += WC_AES_BLOCK_SIZE;
|
||||
}
|
||||
|
||||
WOLFSSL_LEAVE("ExportCipherSpecState", idx);
|
||||
@@ -1048,12 +1048,12 @@ static int ImportCipherSpecState(WOLFSSL* ssl, const byte* exp, word32 len,
|
||||
if (type == WOLFSSL_EXPORT_TLS &&
|
||||
ssl->specs.bulk_cipher_algorithm == wolfssl_aes) {
|
||||
byte *pt = (byte*)ssl->encrypt.aes->reg;
|
||||
XMEMCPY(pt, exp + idx, AES_BLOCK_SIZE);
|
||||
idx += AES_BLOCK_SIZE;
|
||||
XMEMCPY(pt, exp + idx, WC_AES_BLOCK_SIZE);
|
||||
idx += WC_AES_BLOCK_SIZE;
|
||||
|
||||
pt = (byte*)ssl->decrypt.aes->reg;
|
||||
XMEMCPY(pt, exp + idx, AES_BLOCK_SIZE);
|
||||
idx += AES_BLOCK_SIZE;
|
||||
XMEMCPY(pt, exp + idx, WC_AES_BLOCK_SIZE);
|
||||
idx += WC_AES_BLOCK_SIZE;
|
||||
}
|
||||
|
||||
WOLFSSL_LEAVE("ImportCipherSpecState", idx);
|
||||
@@ -2108,7 +2108,7 @@ int wolfSSL_session_export_internal(WOLFSSL* ssl, byte* buf, word32* sz,
|
||||
|
||||
/* possible AES state needed */
|
||||
if (type == WOLFSSL_EXPORT_TLS) {
|
||||
*sz += AES_BLOCK_SIZE*2;
|
||||
*sz += WC_AES_BLOCK_SIZE*2;
|
||||
}
|
||||
ret = WC_NO_ERR_TRACE(LENGTH_ONLY_E);
|
||||
}
|
||||
@@ -39554,7 +39554,7 @@ static int TicketEncDec(byte* key, int keyLen, byte* iv, byte* aad, int aadSz,
|
||||
}
|
||||
if (ret == 0) {
|
||||
ret = wc_AesGcmEncrypt(aes, in, out, inLen, iv, GCM_NONCE_MID_SZ,
|
||||
tag, AES_BLOCK_SIZE, aad, aadSz);
|
||||
tag, WC_AES_BLOCK_SIZE, aad, aadSz);
|
||||
}
|
||||
wc_AesFree(aes);
|
||||
}
|
||||
@@ -39565,7 +39565,7 @@ static int TicketEncDec(byte* key, int keyLen, byte* iv, byte* aad, int aadSz,
|
||||
}
|
||||
if (ret == 0) {
|
||||
ret = wc_AesGcmDecrypt(aes, in, out, inLen, iv, GCM_NONCE_MID_SZ,
|
||||
tag, AES_BLOCK_SIZE, aad, aadSz);
|
||||
tag, WC_AES_BLOCK_SIZE, aad, aadSz);
|
||||
}
|
||||
wc_AesFree(aes);
|
||||
}
|
||||
|
||||
+75
-75
@@ -341,7 +341,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = AES_128_KEY_SIZE;
|
||||
specs->iv_size = AES_IV_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
|
||||
break;
|
||||
#endif
|
||||
@@ -358,7 +358,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = AES_256_KEY_SIZE;
|
||||
specs->iv_size = AES_IV_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
|
||||
break;
|
||||
#endif
|
||||
@@ -374,7 +374,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = AES_128_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AES_IV_SIZE;
|
||||
|
||||
break;
|
||||
@@ -431,7 +431,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = AES_256_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AES_IV_SIZE;
|
||||
|
||||
break;
|
||||
@@ -448,7 +448,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = AES_128_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AESGCM_IMP_IV_SZ;
|
||||
specs->aead_mac_size = AES_GCM_AUTH_SZ;
|
||||
|
||||
@@ -466,7 +466,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = AES_256_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AESGCM_IMP_IV_SZ;
|
||||
specs->aead_mac_size = AES_GCM_AUTH_SZ;
|
||||
|
||||
@@ -503,7 +503,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = AES_128_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AES_IV_SIZE;
|
||||
|
||||
if (opts != NULL)
|
||||
@@ -530,7 +530,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = AES_128_KEY_SIZE;
|
||||
specs->iv_size = AES_IV_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
|
||||
break;
|
||||
#endif
|
||||
@@ -547,7 +547,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = AES_256_KEY_SIZE;
|
||||
specs->iv_size = AES_IV_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
|
||||
break;
|
||||
#endif
|
||||
@@ -601,7 +601,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = AES_128_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AES_IV_SIZE;
|
||||
|
||||
break;
|
||||
@@ -618,7 +618,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = AES_256_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AES_IV_SIZE;
|
||||
|
||||
break;
|
||||
@@ -635,7 +635,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = AES_128_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AESGCM_IMP_IV_SZ;
|
||||
specs->aead_mac_size = AES_GCM_AUTH_SZ;
|
||||
|
||||
@@ -653,7 +653,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = AES_256_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AESGCM_IMP_IV_SZ;
|
||||
specs->aead_mac_size = AES_GCM_AUTH_SZ;
|
||||
|
||||
@@ -671,7 +671,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = AES_128_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AESCCM_IMP_IV_SZ;
|
||||
specs->aead_mac_size = AES_CCM_16_AUTH_SZ;
|
||||
|
||||
@@ -689,7 +689,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = AES_128_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AESCCM_IMP_IV_SZ;
|
||||
specs->aead_mac_size = AES_CCM_8_AUTH_SZ;
|
||||
|
||||
@@ -707,7 +707,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = AES_256_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AESCCM_IMP_IV_SZ;
|
||||
specs->aead_mac_size = AES_CCM_8_AUTH_SZ;
|
||||
|
||||
@@ -747,7 +747,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->static_ecdh = 1;
|
||||
specs->key_size = AES_128_KEY_SIZE;
|
||||
specs->iv_size = AES_IV_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
|
||||
break;
|
||||
#endif
|
||||
@@ -764,7 +764,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->static_ecdh = 1;
|
||||
specs->key_size = AES_128_KEY_SIZE;
|
||||
specs->iv_size = AES_IV_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
|
||||
break;
|
||||
#endif
|
||||
@@ -781,7 +781,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->static_ecdh = 1;
|
||||
specs->key_size = AES_256_KEY_SIZE;
|
||||
specs->iv_size = AES_IV_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
|
||||
break;
|
||||
#endif
|
||||
@@ -798,7 +798,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->static_ecdh = 1;
|
||||
specs->key_size = AES_256_KEY_SIZE;
|
||||
specs->iv_size = AES_IV_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
|
||||
break;
|
||||
#endif
|
||||
@@ -814,7 +814,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 1;
|
||||
specs->key_size = AES_128_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AES_IV_SIZE;
|
||||
|
||||
break;
|
||||
@@ -907,7 +907,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 1;
|
||||
specs->key_size = AES_256_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AES_IV_SIZE;
|
||||
|
||||
break;
|
||||
@@ -924,7 +924,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 1;
|
||||
specs->key_size = AES_128_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AES_IV_SIZE;
|
||||
|
||||
break;
|
||||
@@ -941,7 +941,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 1;
|
||||
specs->key_size = AES_256_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AES_IV_SIZE;
|
||||
|
||||
break;
|
||||
@@ -958,7 +958,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 1;
|
||||
specs->key_size = AES_128_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AESGCM_IMP_IV_SZ;
|
||||
specs->aead_mac_size = AES_GCM_AUTH_SZ;
|
||||
|
||||
@@ -976,7 +976,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 1;
|
||||
specs->key_size = AES_256_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AESGCM_IMP_IV_SZ;
|
||||
specs->aead_mac_size = AES_GCM_AUTH_SZ;
|
||||
|
||||
@@ -994,7 +994,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 1;
|
||||
specs->key_size = AES_128_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AESGCM_IMP_IV_SZ;
|
||||
specs->aead_mac_size = AES_GCM_AUTH_SZ;
|
||||
|
||||
@@ -1012,7 +1012,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 1;
|
||||
specs->key_size = AES_256_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AESGCM_IMP_IV_SZ;
|
||||
specs->aead_mac_size = AES_GCM_AUTH_SZ;
|
||||
|
||||
@@ -1068,7 +1068,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = AES_128_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AESCCM_IMP_IV_SZ;
|
||||
specs->aead_mac_size = AES_CCM_8_AUTH_SZ;
|
||||
|
||||
@@ -1086,7 +1086,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = AES_256_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AESCCM_IMP_IV_SZ;
|
||||
specs->aead_mac_size = AES_CCM_8_AUTH_SZ;
|
||||
|
||||
@@ -1104,7 +1104,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = AES_128_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AESCCM_IMP_IV_SZ;
|
||||
specs->aead_mac_size = AES_CCM_8_AUTH_SZ;
|
||||
|
||||
@@ -1124,7 +1124,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = AES_256_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AESCCM_IMP_IV_SZ;
|
||||
specs->aead_mac_size = AES_CCM_8_AUTH_SZ;
|
||||
|
||||
@@ -1144,7 +1144,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = AES_128_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AESCCM_IMP_IV_SZ;
|
||||
specs->aead_mac_size = AES_CCM_16_AUTH_SZ;
|
||||
|
||||
@@ -1164,7 +1164,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = AES_256_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AESCCM_IMP_IV_SZ;
|
||||
specs->aead_mac_size = AES_CCM_16_AUTH_SZ;
|
||||
|
||||
@@ -1184,7 +1184,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = AES_128_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AESCCM_IMP_IV_SZ;
|
||||
specs->aead_mac_size = AES_CCM_16_AUTH_SZ;
|
||||
|
||||
@@ -1204,7 +1204,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = AES_256_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AESCCM_IMP_IV_SZ;
|
||||
specs->aead_mac_size = AES_CCM_16_AUTH_SZ;
|
||||
|
||||
@@ -1273,7 +1273,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = AES_128_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AESGCM_NONCE_SZ;
|
||||
specs->aead_mac_size = AES_GCM_AUTH_SZ;
|
||||
|
||||
@@ -1291,7 +1291,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = AES_256_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AESGCM_NONCE_SZ;
|
||||
specs->aead_mac_size = AES_GCM_AUTH_SZ;
|
||||
|
||||
@@ -1329,7 +1329,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = AES_128_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AESCCM_NONCE_SZ;
|
||||
specs->aead_mac_size = AES_CCM_16_AUTH_SZ;
|
||||
|
||||
@@ -1347,7 +1347,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = AES_128_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AESCCM_NONCE_SZ;
|
||||
specs->aead_mac_size = AES_CCM_8_AUTH_SZ;
|
||||
|
||||
@@ -1375,7 +1375,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = AES_128_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AESGCM_IMP_IV_SZ;
|
||||
specs->aead_mac_size = AES_GCM_AUTH_SZ;
|
||||
|
||||
@@ -1564,7 +1564,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = AES_128_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AES_IV_SIZE;
|
||||
|
||||
break;
|
||||
@@ -1581,7 +1581,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = AES_128_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AES_IV_SIZE;
|
||||
|
||||
break;
|
||||
@@ -1649,7 +1649,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = AES_256_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AES_IV_SIZE;
|
||||
|
||||
break;
|
||||
@@ -1666,7 +1666,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = AES_256_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AES_IV_SIZE;
|
||||
|
||||
break;
|
||||
@@ -1683,7 +1683,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = AES_128_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AESGCM_IMP_IV_SZ;
|
||||
specs->aead_mac_size = AES_GCM_AUTH_SZ;
|
||||
|
||||
@@ -1703,7 +1703,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = AES_256_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AESGCM_IMP_IV_SZ;
|
||||
specs->aead_mac_size = AES_GCM_AUTH_SZ;
|
||||
|
||||
@@ -1723,7 +1723,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = AES_256_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AESGCM_IMP_IV_SZ;
|
||||
specs->aead_mac_size = AES_GCM_AUTH_SZ;
|
||||
|
||||
@@ -1743,7 +1743,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = AES_128_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AESGCM_IMP_IV_SZ;
|
||||
specs->aead_mac_size = AES_GCM_AUTH_SZ;
|
||||
|
||||
@@ -1763,7 +1763,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = AES_256_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AESGCM_IMP_IV_SZ;
|
||||
specs->aead_mac_size = AES_GCM_AUTH_SZ;
|
||||
|
||||
@@ -1783,7 +1783,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = AES_128_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AES_IV_SIZE;
|
||||
|
||||
if (opts != NULL)
|
||||
@@ -1802,7 +1802,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = AES_256_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AES_IV_SIZE;
|
||||
|
||||
if (opts != NULL)
|
||||
@@ -1821,7 +1821,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = AES_128_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AES_IV_SIZE;
|
||||
|
||||
if (opts != NULL)
|
||||
@@ -1840,7 +1840,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = AES_256_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AES_IV_SIZE;
|
||||
|
||||
if (opts != NULL)
|
||||
@@ -1859,7 +1859,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = AES_128_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AES_IV_SIZE;
|
||||
|
||||
if (opts != NULL)
|
||||
@@ -1878,7 +1878,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = AES_256_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AES_IV_SIZE;
|
||||
|
||||
if (opts != NULL)
|
||||
@@ -1992,7 +1992,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = AES_128_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AES_IV_SIZE;
|
||||
|
||||
break;
|
||||
@@ -2026,7 +2026,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = AES_256_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AES_IV_SIZE;
|
||||
|
||||
break;
|
||||
@@ -2043,7 +2043,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = AES_128_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AES_IV_SIZE;
|
||||
|
||||
break;
|
||||
@@ -2060,7 +2060,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = AES_256_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AES_IV_SIZE;
|
||||
|
||||
break;
|
||||
@@ -2077,7 +2077,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = AES_128_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AESGCM_IMP_IV_SZ;
|
||||
specs->aead_mac_size = AES_GCM_AUTH_SZ;
|
||||
|
||||
@@ -2095,7 +2095,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = AES_256_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AESGCM_IMP_IV_SZ;
|
||||
specs->aead_mac_size = AES_GCM_AUTH_SZ;
|
||||
|
||||
@@ -2113,7 +2113,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = AES_128_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AESGCM_IMP_IV_SZ;
|
||||
specs->aead_mac_size = AES_GCM_AUTH_SZ;
|
||||
|
||||
@@ -2131,7 +2131,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = AES_256_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AESGCM_IMP_IV_SZ;
|
||||
specs->aead_mac_size = AES_GCM_AUTH_SZ;
|
||||
|
||||
@@ -2149,7 +2149,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = CAMELLIA_128_KEY_SIZE;
|
||||
specs->block_size = CAMELLIA_BLOCK_SIZE;
|
||||
specs->block_size = WC_CAMELLIA_BLOCK_SIZE;
|
||||
specs->iv_size = CAMELLIA_IV_SIZE;
|
||||
|
||||
break;
|
||||
@@ -2166,7 +2166,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = CAMELLIA_256_KEY_SIZE;
|
||||
specs->block_size = CAMELLIA_BLOCK_SIZE;
|
||||
specs->block_size = WC_CAMELLIA_BLOCK_SIZE;
|
||||
specs->iv_size = CAMELLIA_IV_SIZE;
|
||||
|
||||
break;
|
||||
@@ -2183,7 +2183,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = CAMELLIA_128_KEY_SIZE;
|
||||
specs->block_size = CAMELLIA_BLOCK_SIZE;
|
||||
specs->block_size = WC_CAMELLIA_BLOCK_SIZE;
|
||||
specs->iv_size = CAMELLIA_IV_SIZE;
|
||||
|
||||
break;
|
||||
@@ -2200,7 +2200,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = CAMELLIA_256_KEY_SIZE;
|
||||
specs->block_size = CAMELLIA_BLOCK_SIZE;
|
||||
specs->block_size = WC_CAMELLIA_BLOCK_SIZE;
|
||||
specs->iv_size = CAMELLIA_IV_SIZE;
|
||||
|
||||
break;
|
||||
@@ -2217,7 +2217,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = CAMELLIA_128_KEY_SIZE;
|
||||
specs->block_size = CAMELLIA_BLOCK_SIZE;
|
||||
specs->block_size = WC_CAMELLIA_BLOCK_SIZE;
|
||||
specs->iv_size = CAMELLIA_IV_SIZE;
|
||||
|
||||
break;
|
||||
@@ -2234,7 +2234,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = CAMELLIA_256_KEY_SIZE;
|
||||
specs->block_size = CAMELLIA_BLOCK_SIZE;
|
||||
specs->block_size = WC_CAMELLIA_BLOCK_SIZE;
|
||||
specs->iv_size = CAMELLIA_IV_SIZE;
|
||||
|
||||
break;
|
||||
@@ -2251,7 +2251,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = CAMELLIA_128_KEY_SIZE;
|
||||
specs->block_size = CAMELLIA_BLOCK_SIZE;
|
||||
specs->block_size = WC_CAMELLIA_BLOCK_SIZE;
|
||||
specs->iv_size = CAMELLIA_IV_SIZE;
|
||||
|
||||
break;
|
||||
@@ -2268,7 +2268,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = CAMELLIA_256_KEY_SIZE;
|
||||
specs->block_size = CAMELLIA_BLOCK_SIZE;
|
||||
specs->block_size = WC_CAMELLIA_BLOCK_SIZE;
|
||||
specs->iv_size = CAMELLIA_IV_SIZE;
|
||||
|
||||
break;
|
||||
@@ -2285,7 +2285,7 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
||||
specs->pad_size = PAD_SHA;
|
||||
specs->static_ecdh = 0;
|
||||
specs->key_size = AES_128_KEY_SIZE;
|
||||
specs->block_size = AES_BLOCK_SIZE;
|
||||
specs->block_size = WC_AES_BLOCK_SIZE;
|
||||
specs->iv_size = AES_IV_SIZE;
|
||||
|
||||
if (opts != NULL)
|
||||
@@ -2976,13 +2976,13 @@ int SetKeys(Ciphers* enc, Ciphers* dec, Keys* keys, CipherSpecs* specs,
|
||||
|
||||
if (enc && enc->cam == NULL)
|
||||
enc->cam =
|
||||
(Camellia*)XMALLOC(sizeof(Camellia), heap, DYNAMIC_TYPE_CIPHER);
|
||||
(wc_Camellia*)XMALLOC(sizeof(wc_Camellia), heap, DYNAMIC_TYPE_CIPHER);
|
||||
if (enc && enc->cam == NULL)
|
||||
return MEMORY_E;
|
||||
|
||||
if (dec && dec->cam == NULL)
|
||||
dec->cam =
|
||||
(Camellia*)XMALLOC(sizeof(Camellia), heap, DYNAMIC_TYPE_CIPHER);
|
||||
(wc_Camellia*)XMALLOC(sizeof(wc_Camellia), heap, DYNAMIC_TYPE_CIPHER);
|
||||
if (dec && dec->cam == NULL)
|
||||
return MEMORY_E;
|
||||
|
||||
|
||||
@@ -12980,7 +12980,7 @@ int wolfSSL_PEM_write_mem_ECPrivateKey(WOLFSSL_EC_KEY* ec,
|
||||
/* Calculate maximum size of DER encoding.
|
||||
* 4 > size of pub, priv + ASN.1 additional information */
|
||||
der_max_len = 4 * (word32)wc_ecc_size((ecc_key*)ec->internal) +
|
||||
AES_BLOCK_SIZE;
|
||||
WC_AES_BLOCK_SIZE;
|
||||
|
||||
/* Allocate buffer big enough to hold encoding. */
|
||||
derBuf = (byte*)XMALLOC((size_t)der_max_len, NULL,
|
||||
|
||||
@@ -24982,7 +24982,7 @@ int wolfSSL_RAND_load_file(const char* fname, long len)
|
||||
case WC_AES_192_CTR_TYPE :
|
||||
case WC_AES_256_CTR_TYPE :
|
||||
WOLFSSL_MSG("AES CTR");
|
||||
XMEMCPY(ctx->iv, &ctx->cipher.aes.reg, AES_BLOCK_SIZE);
|
||||
XMEMCPY(ctx->iv, &ctx->cipher.aes.reg, WC_AES_BLOCK_SIZE);
|
||||
break;
|
||||
#endif /* WOLFSSL_AES_COUNTER */
|
||||
#ifdef WOLFSSL_AES_CFB
|
||||
@@ -25121,7 +25121,7 @@ int wolfSSL_RAND_load_file(const char* fname, long len)
|
||||
case WC_AES_192_CBC_TYPE :
|
||||
case WC_AES_256_CBC_TYPE :
|
||||
WOLFSSL_MSG("AES CBC");
|
||||
XMEMCPY(&ctx->cipher.aes.reg, ctx->iv, AES_BLOCK_SIZE);
|
||||
XMEMCPY(&ctx->cipher.aes.reg, ctx->iv, WC_AES_BLOCK_SIZE);
|
||||
break;
|
||||
#endif
|
||||
#ifdef HAVE_AESGCM
|
||||
@@ -25129,7 +25129,7 @@ int wolfSSL_RAND_load_file(const char* fname, long len)
|
||||
case WC_AES_192_GCM_TYPE :
|
||||
case WC_AES_256_GCM_TYPE :
|
||||
WOLFSSL_MSG("AES GCM");
|
||||
XMEMCPY(&ctx->cipher.aes.reg, ctx->iv, AES_BLOCK_SIZE);
|
||||
XMEMCPY(&ctx->cipher.aes.reg, ctx->iv, WC_AES_BLOCK_SIZE);
|
||||
break;
|
||||
#endif
|
||||
#ifdef HAVE_AES_ECB
|
||||
@@ -25144,7 +25144,7 @@ int wolfSSL_RAND_load_file(const char* fname, long len)
|
||||
case WC_AES_192_CTR_TYPE :
|
||||
case WC_AES_256_CTR_TYPE :
|
||||
WOLFSSL_MSG("AES CTR");
|
||||
XMEMCPY(&ctx->cipher.aes.reg, ctx->iv, AES_BLOCK_SIZE);
|
||||
XMEMCPY(&ctx->cipher.aes.reg, ctx->iv, WC_AES_BLOCK_SIZE);
|
||||
break;
|
||||
#endif
|
||||
|
||||
@@ -25274,7 +25274,7 @@ void wolfSSL_aes_ctr_iv(WOLFSSL_EVP_CIPHER_CTX* ctx, int doset,
|
||||
if (doset)
|
||||
(void)wc_AesSetIV(&ctx->cipher.aes, iv); /* OpenSSL compat, no ret */
|
||||
else
|
||||
XMEMCPY(iv, &ctx->cipher.aes.reg, AES_BLOCK_SIZE);
|
||||
XMEMCPY(iv, &ctx->cipher.aes.reg, WC_AES_BLOCK_SIZE);
|
||||
}
|
||||
|
||||
#endif /* NO_AES */
|
||||
|
||||
+51
-51
@@ -45,12 +45,12 @@
|
||||
void wolfSSL_MD4_Init(WOLFSSL_MD4_CTX* md4)
|
||||
{
|
||||
/* Ensure WOLFSSL_MD4_CTX is big enough for wolfCrypt Md4. */
|
||||
WOLFSSL_ASSERT_SIZEOF_GE(md4->buffer, Md4);
|
||||
WOLFSSL_ASSERT_SIZEOF_GE(md4->buffer, wc_Md4);
|
||||
|
||||
WOLFSSL_ENTER("MD4_Init");
|
||||
|
||||
/* Initialize wolfCrypt MD4 object. */
|
||||
wc_InitMd4((Md4*)md4);
|
||||
wc_InitMd4((wc_Md4*)md4);
|
||||
}
|
||||
|
||||
/* Update MD4 hash with data.
|
||||
@@ -65,7 +65,7 @@ void wolfSSL_MD4_Update(WOLFSSL_MD4_CTX* md4, const void* data,
|
||||
WOLFSSL_ENTER("MD4_Update");
|
||||
|
||||
/* Update wolfCrypt MD4 object with data. */
|
||||
wc_Md4Update((Md4*)md4, (const byte*)data, (word32)len);
|
||||
wc_Md4Update((wc_Md4*)md4, (const byte*)data, (word32)len);
|
||||
}
|
||||
|
||||
/* Finalize MD4 hash and return output.
|
||||
@@ -79,7 +79,7 @@ void wolfSSL_MD4_Final(unsigned char* digest, WOLFSSL_MD4_CTX* md4)
|
||||
WOLFSSL_ENTER("MD4_Final");
|
||||
|
||||
/* Finalize wolfCrypt MD4 hash into digest. */
|
||||
wc_Md4Final((Md4*)md4, digest);
|
||||
wc_Md4Final((wc_Md4*)md4, digest);
|
||||
}
|
||||
|
||||
#endif /* NO_MD4 */
|
||||
@@ -2228,7 +2228,7 @@ int wolfSSL_CMAC_Update(WOLFSSL_CMAC_CTX* ctx, const void* data, size_t len)
|
||||
*
|
||||
* @param [in, out] ctx CMAC context object.
|
||||
* @param [out] out Buffer to place CMAC result into.
|
||||
* Must be able to hold AES_BLOCK_SIZE bytes.
|
||||
* Must be able to hold WC_AES_BLOCK_SIZE bytes.
|
||||
* @param [out] len Length of CMAC result. May be NULL.
|
||||
* @return 1 on success.
|
||||
* @return 0 when ctx is NULL.
|
||||
@@ -2567,7 +2567,7 @@ WOLFSSL_DES_LONG wolfSSL_DES_cbc_cksum(const unsigned char* in,
|
||||
if (!err) {
|
||||
/* Encrypt data into temporary. */
|
||||
wolfSSL_DES_cbc_encrypt(data, tmp, dataSz, sc, (WOLFSSL_DES_cblock*)iv,
|
||||
DES_ENCRYPT);
|
||||
WC_DES_ENCRYPT);
|
||||
/* Copy out last block. */
|
||||
XMEMCPY((unsigned char*)out, tmp + (dataSz - DES_BLOCK_SIZE),
|
||||
DES_BLOCK_SIZE);
|
||||
@@ -2631,7 +2631,7 @@ void wolfSSL_DES_cbc_encrypt(const unsigned char* input, unsigned char* output,
|
||||
/* Length of data that is a multiple of a block. */
|
||||
word32 len = (word32)(length - lb_sz);
|
||||
|
||||
if (enc == DES_ENCRYPT) {
|
||||
if (enc == WC_DES_ENCRYPT) {
|
||||
/* Encrypt full blocks into output. */
|
||||
wc_Des_CbcEncrypt(des, output, input, len);
|
||||
if (lb_sz != 0) {
|
||||
@@ -2687,7 +2687,7 @@ void wolfSSL_DES_ncbc_encrypt(const unsigned char* input, unsigned char* output,
|
||||
offset = (offset + DES_BLOCK_SIZE - 1) / DES_BLOCK_SIZE;
|
||||
offset *= DES_BLOCK_SIZE;
|
||||
offset -= DES_BLOCK_SIZE;
|
||||
if (enc == DES_ENCRYPT) {
|
||||
if (enc == WC_DES_ENCRYPT) {
|
||||
/* Encrypt data. */
|
||||
wolfSSL_DES_cbc_encrypt(input, output, length, schedule, ivec, enc);
|
||||
/* Use last encrypted block as new IV. */
|
||||
@@ -2761,7 +2761,7 @@ void wolfSSL_DES_ede3_cbc_encrypt(const unsigned char* input,
|
||||
ret = wc_Des3Init(des3, NULL, INVALID_DEVID);
|
||||
(void)ret;
|
||||
|
||||
if (enc == DES_ENCRYPT) {
|
||||
if (enc == WC_DES_ENCRYPT) {
|
||||
/* Initialize wolfCrypt DES3 object. */
|
||||
if (wc_Des3_SetKey(des3, key, (const byte*)ivec, DES_ENCRYPTION)
|
||||
== 0) {
|
||||
@@ -2858,7 +2858,7 @@ void wolfSSL_DES_ecb_encrypt(WOLFSSL_DES_cblock* in, WOLFSSL_DES_cblock* out,
|
||||
|
||||
/* Validate parameters. */
|
||||
if ((in == NULL) || (out == NULL) || (key == NULL) ||
|
||||
((enc != DES_ENCRYPT) && (enc != DES_DECRYPT))) {
|
||||
((enc != WC_DES_ENCRYPT) && (enc != WC_DES_DECRYPT))) {
|
||||
WOLFSSL_MSG("Bad argument passed to wolfSSL_DES_ecb_encrypt");
|
||||
}
|
||||
#ifdef WOLFSSL_SMALL_STACK
|
||||
@@ -2869,13 +2869,13 @@ void wolfSSL_DES_ecb_encrypt(WOLFSSL_DES_cblock* in, WOLFSSL_DES_cblock* out,
|
||||
}
|
||||
#endif
|
||||
/* Set key in wolfCrypt DES object for encryption or decryption.
|
||||
* DES_ENCRYPT = 1, wolfSSL DES_ENCRYPTION = 0.
|
||||
* DES_DECRYPT = 0, wolfSSL DES_DECRYPTION = 1.
|
||||
* WC_DES_ENCRYPT = 1, wolfSSL DES_ENCRYPTION = 0.
|
||||
* WC_DES_DECRYPT = 0, wolfSSL DES_DECRYPTION = 1.
|
||||
*/
|
||||
else if (wc_Des_SetKey(des, (const byte*)key, NULL, !enc) != 0) {
|
||||
WOLFSSL_MSG("wc_Des_SetKey return error.");
|
||||
}
|
||||
else if (enc == DES_ENCRYPT) {
|
||||
else if (enc == WC_DES_ENCRYPT) {
|
||||
/* Encrypt a block with wolfCrypt DES object. */
|
||||
if (wc_Des_EcbEncrypt(des, (byte*)out, (const byte*)in, DES_KEY_SIZE)
|
||||
!= 0) {
|
||||
@@ -2917,15 +2917,15 @@ void wolfSSL_DES_ecb_encrypt(WOLFSSL_DES_cblock* in, WOLFSSL_DES_cblock* out,
|
||||
* @param [in] key Key data.
|
||||
* @param [in] bits Number of bits in key.
|
||||
* @param [out] aes AES key object.
|
||||
* @param [in] enc Whether to encrypt. AES_ENCRYPT or AES_DECRYPT.
|
||||
* @param [in] enc Whether to encrypt. AES_ENCRYPTION or AES_DECRYPTION.
|
||||
* @return 0 on success.
|
||||
* @return -1 when key or aes is NULL.
|
||||
* @return -1 when setting key with wolfCrypt fails.
|
||||
*/
|
||||
static int wolfssl_aes_set_key(const unsigned char *key, const int bits,
|
||||
AES_KEY *aes, int enc)
|
||||
WOLFSSL_AES_KEY *aes, int enc)
|
||||
{
|
||||
wc_static_assert(sizeof(AES_KEY) >= sizeof(Aes));
|
||||
wc_static_assert(sizeof(WOLFSSL_AES_KEY) >= sizeof(Aes));
|
||||
|
||||
/* Validate parameters. */
|
||||
if ((key == NULL) || (aes == NULL)) {
|
||||
@@ -2933,7 +2933,7 @@ static int wolfssl_aes_set_key(const unsigned char *key, const int bits,
|
||||
return WOLFSSL_FATAL_ERROR;
|
||||
}
|
||||
|
||||
XMEMSET(aes, 0, sizeof(AES_KEY));
|
||||
XMEMSET(aes, 0, sizeof(WOLFSSL_AES_KEY));
|
||||
|
||||
if (wc_AesInit((Aes*)aes, NULL, INVALID_DEVID) != 0) {
|
||||
WOLFSSL_MSG("Error in initting AES key");
|
||||
@@ -2957,11 +2957,11 @@ static int wolfssl_aes_set_key(const unsigned char *key, const int bits,
|
||||
* @return -1 when setting key with wolfCrypt fails.
|
||||
*/
|
||||
int wolfSSL_AES_set_encrypt_key(const unsigned char *key, const int bits,
|
||||
AES_KEY *aes)
|
||||
WOLFSSL_AES_KEY *aes)
|
||||
{
|
||||
WOLFSSL_ENTER("wolfSSL_AES_set_encrypt_key");
|
||||
|
||||
return wolfssl_aes_set_key(key, bits, aes, AES_ENCRYPT);
|
||||
return wolfssl_aes_set_key(key, bits, aes, AES_ENCRYPTION);
|
||||
}
|
||||
|
||||
/* Sets the key into the AES key object for decryption.
|
||||
@@ -2974,11 +2974,11 @@ int wolfSSL_AES_set_encrypt_key(const unsigned char *key, const int bits,
|
||||
* @return -1 when setting key with wolfCrypt fails.
|
||||
*/
|
||||
int wolfSSL_AES_set_decrypt_key(const unsigned char *key, const int bits,
|
||||
AES_KEY *aes)
|
||||
WOLFSSL_AES_KEY *aes)
|
||||
{
|
||||
WOLFSSL_ENTER("wolfSSL_AES_set_decrypt_key");
|
||||
|
||||
return wolfssl_aes_set_key(key, bits, aes, AES_DECRYPT);
|
||||
return wolfssl_aes_set_key(key, bits, aes, AES_DECRYPTION);
|
||||
}
|
||||
|
||||
#ifdef WOLFSSL_AES_DIRECT
|
||||
@@ -2986,15 +2986,15 @@ int wolfSSL_AES_set_decrypt_key(const unsigned char *key, const int bits,
|
||||
*
|
||||
* wolfSSL_AES_set_encrypt_key() must have been called.
|
||||
*
|
||||
* #input must contain AES_BLOCK_SIZE bytes of data.
|
||||
* #output must be a buffer at least AES_BLOCK_SIZE bytes in length.
|
||||
* #input must contain WC_AES_BLOCK_SIZE bytes of data.
|
||||
* #output must be a buffer at least WC_AES_BLOCK_SIZE bytes in length.
|
||||
*
|
||||
* @param [in] input Data to encrypt.
|
||||
* @param [out] output Encrypted data.
|
||||
* @param [in] key AES key to use for encryption.
|
||||
*/
|
||||
void wolfSSL_AES_encrypt(const unsigned char* input, unsigned char* output,
|
||||
AES_KEY *key)
|
||||
WOLFSSL_AES_KEY *key)
|
||||
{
|
||||
WOLFSSL_ENTER("wolfSSL_AES_encrypt");
|
||||
|
||||
@@ -3023,15 +3023,15 @@ void wolfSSL_AES_encrypt(const unsigned char* input, unsigned char* output,
|
||||
*
|
||||
* wolfSSL_AES_set_decrypt_key() must have been called.
|
||||
*
|
||||
* #input must contain AES_BLOCK_SIZE bytes of data.
|
||||
* #output must be a buffer at least AES_BLOCK_SIZE bytes in length.
|
||||
* #input must contain WC_AES_BLOCK_SIZE bytes of data.
|
||||
* #output must be a buffer at least WC_AES_BLOCK_SIZE bytes in length.
|
||||
*
|
||||
* @param [in] input Data to decrypt.
|
||||
* @param [out] output Decrypted data.
|
||||
* @param [in] key AES key to use for encryption.
|
||||
*/
|
||||
void wolfSSL_AES_decrypt(const unsigned char* input, unsigned char* output,
|
||||
AES_KEY *key)
|
||||
WOLFSSL_AES_KEY *key)
|
||||
{
|
||||
WOLFSSL_ENTER("wolfSSL_AES_decrypt");
|
||||
|
||||
@@ -3063,17 +3063,17 @@ void wolfSSL_AES_decrypt(const unsigned char* input, unsigned char* output,
|
||||
* wolfSSL_AES_set_encrypt_key() or wolfSSL_AES_set_decrypt_key ()must have been
|
||||
* called.
|
||||
*
|
||||
* #input must contain AES_BLOCK_SIZE bytes of data.
|
||||
* #output must be a buffer at least AES_BLOCK_SIZE bytes in length.
|
||||
* #input must contain WC_AES_BLOCK_SIZE bytes of data.
|
||||
* #output must be a buffer at least WC_AES_BLOCK_SIZE bytes in length.
|
||||
*
|
||||
* @param [in] in Data to encipher.
|
||||
* @param [out] out Enciphered data.
|
||||
* @param [in] key AES key to use for encryption/decryption.
|
||||
* @param [in] enc Whether to encrypt.
|
||||
* AES_ENCRPT for encryption, AES_DECRYPT for decryption.
|
||||
* AES_ENCRPT for encryption, AES_DECRYPTION for decryption.
|
||||
*/
|
||||
void wolfSSL_AES_ecb_encrypt(const unsigned char *in, unsigned char* out,
|
||||
AES_KEY *key, const int enc)
|
||||
WOLFSSL_AES_KEY *key, const int enc)
|
||||
{
|
||||
WOLFSSL_ENTER("wolfSSL_AES_ecb_encrypt");
|
||||
|
||||
@@ -3081,16 +3081,16 @@ void wolfSSL_AES_ecb_encrypt(const unsigned char *in, unsigned char* out,
|
||||
if ((key == NULL) || (in == NULL) || (out == NULL)) {
|
||||
WOLFSSL_MSG("Error, Null argument passed in");
|
||||
}
|
||||
else if (enc == AES_ENCRYPT) {
|
||||
else if (enc == AES_ENCRYPTION) {
|
||||
/* Encrypt block. */
|
||||
if (wc_AesEcbEncrypt((Aes*)key, out, in, AES_BLOCK_SIZE) != 0) {
|
||||
if (wc_AesEcbEncrypt((Aes*)key, out, in, WC_AES_BLOCK_SIZE) != 0) {
|
||||
WOLFSSL_MSG("Error with AES CBC encrypt");
|
||||
}
|
||||
}
|
||||
else {
|
||||
#ifdef HAVE_AES_DECRYPT
|
||||
/* Decrypt block. */
|
||||
if (wc_AesEcbDecrypt((Aes*)key, out, in, AES_BLOCK_SIZE) != 0) {
|
||||
if (wc_AesEcbDecrypt((Aes*)key, out, in, WC_AES_BLOCK_SIZE) != 0) {
|
||||
WOLFSSL_MSG("Error with AES CBC decrypt");
|
||||
}
|
||||
#else
|
||||
@@ -3114,10 +3114,10 @@ void wolfSSL_AES_ecb_encrypt(const unsigned char *in, unsigned char* out,
|
||||
* On in, used with first block.
|
||||
* On out, IV for further operations.
|
||||
* @param [in] enc Whether to encrypt.
|
||||
* AES_ENCRPT for encryption, AES_DECRYPT for decryption.
|
||||
* AES_ENCRPT for encryption, AES_DECRYPTION for decryption.
|
||||
*/
|
||||
void wolfSSL_AES_cbc_encrypt(const unsigned char *in, unsigned char* out,
|
||||
size_t len, AES_KEY *key, unsigned char* iv, const int enc)
|
||||
size_t len, WOLFSSL_AES_KEY *key, unsigned char* iv, const int enc)
|
||||
{
|
||||
WOLFSSL_ENTER("wolfSSL_AES_cbc_encrypt");
|
||||
|
||||
@@ -3134,7 +3134,7 @@ void wolfSSL_AES_cbc_encrypt(const unsigned char *in, unsigned char* out,
|
||||
if ((ret = wc_AesSetIV(aes, (const byte*)iv)) != 0) {
|
||||
WOLFSSL_MSG("Error with setting iv");
|
||||
}
|
||||
else if (enc == AES_ENCRYPT) {
|
||||
else if (enc == AES_ENCRYPTION) {
|
||||
/* Encrypt with wolfCrypt AES object. */
|
||||
if ((ret = wc_AesCbcEncrypt(aes, out, in, (word32)len)) != 0) {
|
||||
WOLFSSL_MSG("Error with AES CBC encrypt");
|
||||
@@ -3149,7 +3149,7 @@ void wolfSSL_AES_cbc_encrypt(const unsigned char *in, unsigned char* out,
|
||||
|
||||
if (ret == 0) {
|
||||
/* Get IV for next operation. */
|
||||
XMEMCPY(iv, (byte*)(aes->reg), AES_BLOCK_SIZE);
|
||||
XMEMCPY(iv, (byte*)(aes->reg), WC_AES_BLOCK_SIZE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3169,10 +3169,10 @@ void wolfSSL_AES_cbc_encrypt(const unsigned char *in, unsigned char* out,
|
||||
* On out, IV for further operations.
|
||||
* @param [out] num Number of bytes used from last incomplete block.
|
||||
* @param [in] enc Whether to encrypt.
|
||||
* AES_ENCRPT for encryption, AES_DECRYPT for decryption.
|
||||
* AES_ENCRPT for encryption, AES_DECRYPTION for decryption.
|
||||
*/
|
||||
void wolfSSL_AES_cfb128_encrypt(const unsigned char *in, unsigned char* out,
|
||||
size_t len, AES_KEY *key, unsigned char* iv, int* num, const int enc)
|
||||
size_t len, WOLFSSL_AES_KEY *key, unsigned char* iv, int* num, const int enc)
|
||||
{
|
||||
#ifndef WOLFSSL_AES_CFB
|
||||
WOLFSSL_MSG("CFB mode not enabled please use macro WOLFSSL_AES_CFB");
|
||||
@@ -3199,9 +3199,9 @@ void wolfSSL_AES_cfb128_encrypt(const unsigned char *in, unsigned char* out,
|
||||
* leftover bytes field "left", and this function relies on the leftover
|
||||
* bytes being preserved between calls.
|
||||
*/
|
||||
XMEMCPY(aes->reg, iv, AES_BLOCK_SIZE);
|
||||
XMEMCPY(aes->reg, iv, WC_AES_BLOCK_SIZE);
|
||||
|
||||
if (enc == AES_ENCRYPT) {
|
||||
if (enc == AES_ENCRYPTION) {
|
||||
/* Encrypt data with AES-CFB. */
|
||||
if ((ret = wc_AesCfbEncrypt(aes, out, in, (word32)len)) != 0) {
|
||||
WOLFSSL_MSG("Error with AES CBC encrypt");
|
||||
@@ -3216,11 +3216,11 @@ void wolfSSL_AES_cfb128_encrypt(const unsigned char *in, unsigned char* out,
|
||||
|
||||
if (ret == 0) {
|
||||
/* Copy IV out after operation. */
|
||||
XMEMCPY(iv, (byte*)(aes->reg), AES_BLOCK_SIZE);
|
||||
XMEMCPY(iv, (byte*)(aes->reg), WC_AES_BLOCK_SIZE);
|
||||
|
||||
/* Store number of left over bytes to num. */
|
||||
if (num != NULL) {
|
||||
*num = (AES_BLOCK_SIZE - aes->left) % AES_BLOCK_SIZE;
|
||||
*num = (WC_AES_BLOCK_SIZE - aes->left) % WC_AES_BLOCK_SIZE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3240,7 +3240,7 @@ void wolfSSL_AES_cfb128_encrypt(const unsigned char *in, unsigned char* out,
|
||||
* @return 0 when key, iv, out or in is NULL.
|
||||
* @return 0 when key length is not valid.
|
||||
*/
|
||||
int wolfSSL_AES_wrap_key(AES_KEY *key, const unsigned char *iv,
|
||||
int wolfSSL_AES_wrap_key(WOLFSSL_AES_KEY *key, const unsigned char *iv,
|
||||
unsigned char *out, const unsigned char *in, unsigned int inSz)
|
||||
{
|
||||
int ret = 0;
|
||||
@@ -3275,7 +3275,7 @@ int wolfSSL_AES_wrap_key(AES_KEY *key, const unsigned char *iv,
|
||||
* @return 0 when key, iv, out or in is NULL.
|
||||
* @return 0 when wrapped key data length is not valid.
|
||||
*/
|
||||
int wolfSSL_AES_unwrap_key(AES_KEY *key, const unsigned char *iv,
|
||||
int wolfSSL_AES_unwrap_key(WOLFSSL_AES_KEY *key, const unsigned char *iv,
|
||||
unsigned char *out, const unsigned char *in, unsigned int inSz)
|
||||
{
|
||||
int ret = 0;
|
||||
@@ -3336,7 +3336,7 @@ size_t wolfSSL_CRYPTO_cts128_encrypt(const unsigned char *in,
|
||||
}
|
||||
|
||||
/* Encrypt data up to last block */
|
||||
(*cbc)(in, out, len - lastBlkLen, key, iv, AES_ENCRYPT);
|
||||
(*cbc)(in, out, len - lastBlkLen, key, iv, AES_ENCRYPTION);
|
||||
|
||||
/* Move to last block */
|
||||
in += len - lastBlkLen;
|
||||
@@ -3349,7 +3349,7 @@ size_t wolfSSL_CRYPTO_cts128_encrypt(const unsigned char *in,
|
||||
XMEMCPY(out, out - WOLFSSL_CTS128_BLOCK_SZ, lastBlkLen);
|
||||
/* Encrypt last block. */
|
||||
(*cbc)(lastBlk, out - WOLFSSL_CTS128_BLOCK_SZ, WOLFSSL_CTS128_BLOCK_SZ,
|
||||
key, iv, AES_ENCRYPT);
|
||||
key, iv, AES_ENCRYPTION);
|
||||
}
|
||||
|
||||
return len;
|
||||
@@ -3404,13 +3404,13 @@ size_t wolfSSL_CRYPTO_cts128_decrypt(const unsigned char *in,
|
||||
* Use 0 buffer as IV to do straight decryption.
|
||||
* This places the Cn-1 block at lastBlk */
|
||||
XMEMSET(lastBlk, 0, WOLFSSL_CTS128_BLOCK_SZ);
|
||||
(*cbc)(in, prevBlk, WOLFSSL_CTS128_BLOCK_SZ, key, lastBlk, AES_DECRYPT);
|
||||
(*cbc)(in, prevBlk, WOLFSSL_CTS128_BLOCK_SZ, key, lastBlk, AES_DECRYPTION);
|
||||
/* RFC2040: Append the tail (BB minus Ln) bytes of Xn to Cn
|
||||
* to create En. */
|
||||
XMEMCPY(prevBlk, in + WOLFSSL_CTS128_BLOCK_SZ, lastBlkLen);
|
||||
/* Cn and Cn-1 can now be decrypted */
|
||||
(*cbc)(prevBlk, out, WOLFSSL_CTS128_BLOCK_SZ, key, iv, AES_DECRYPT);
|
||||
(*cbc)(lastBlk, lastBlk, WOLFSSL_CTS128_BLOCK_SZ, key, iv, AES_DECRYPT);
|
||||
(*cbc)(prevBlk, out, WOLFSSL_CTS128_BLOCK_SZ, key, iv, AES_DECRYPTION);
|
||||
(*cbc)(lastBlk, lastBlk, WOLFSSL_CTS128_BLOCK_SZ, key, iv, AES_DECRYPTION);
|
||||
XMEMCPY(out + WOLFSSL_CTS128_BLOCK_SZ, lastBlk, lastBlkLen);
|
||||
}
|
||||
|
||||
|
||||
@@ -12474,7 +12474,7 @@ static int TLSX_ECH_Parse(WOLFSSL* ssl, const byte* readBuf, word16 size,
|
||||
readBuf_p += ech->encLen;
|
||||
|
||||
ato16(readBuf_p, &ech->innerClientHelloLen);
|
||||
ech->innerClientHelloLen -= AES_BLOCK_SIZE;
|
||||
ech->innerClientHelloLen -= WC_AES_BLOCK_SIZE;
|
||||
readBuf_p += 2;
|
||||
|
||||
ech->outerClientPayload = readBuf_p;
|
||||
@@ -12490,7 +12490,7 @@ static int TLSX_ECH_Parse(WOLFSSL* ssl, const byte* readBuf, word16 size,
|
||||
|
||||
/* set the ech payload of the copy to zeros */
|
||||
XMEMSET(aadCopy + (readBuf_p - ech->aad), 0,
|
||||
ech->innerClientHelloLen + AES_BLOCK_SIZE);
|
||||
ech->innerClientHelloLen + WC_AES_BLOCK_SIZE);
|
||||
|
||||
/* allocate the inner payload buffer */
|
||||
ech->innerClientHello =
|
||||
|
||||
+11
-11
@@ -49,10 +49,10 @@ unsigned int wolfSSL_X509_get_extension_flags(WOLFSSL_X509* x509)
|
||||
|
||||
if (x509 != NULL) {
|
||||
if (x509->keyUsageSet) {
|
||||
flags |= EXFLAG_KUSAGE;
|
||||
flags |= WOLFSSL_EXFLAG_KUSAGE;
|
||||
}
|
||||
if (x509->extKeyUsageSrc != NULL) {
|
||||
flags |= EXFLAG_XKUSAGE;
|
||||
flags |= WOLFSSL_EXFLAG_XKUSAGE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,19 +92,19 @@ unsigned int wolfSSL_X509_get_extended_key_usage(WOLFSSL_X509* x509)
|
||||
|
||||
if (x509 != NULL) {
|
||||
if (x509->extKeyUsage & EXTKEYUSE_OCSP_SIGN)
|
||||
ret |= XKU_OCSP_SIGN;
|
||||
ret |= WOLFSSL_XKU_OCSP_SIGN;
|
||||
if (x509->extKeyUsage & EXTKEYUSE_TIMESTAMP)
|
||||
ret |= XKU_TIMESTAMP;
|
||||
ret |= WOLFSSL_XKU_TIMESTAMP;
|
||||
if (x509->extKeyUsage & EXTKEYUSE_EMAILPROT)
|
||||
ret |= XKU_SMIME;
|
||||
ret |= WOLFSSL_XKU_SMIME;
|
||||
if (x509->extKeyUsage & EXTKEYUSE_CODESIGN)
|
||||
ret |= XKU_CODE_SIGN;
|
||||
ret |= WOLFSSL_XKU_CODE_SIGN;
|
||||
if (x509->extKeyUsage & EXTKEYUSE_CLIENT_AUTH)
|
||||
ret |= XKU_SSL_CLIENT;
|
||||
ret |= WOLFSSL_XKU_SSL_CLIENT;
|
||||
if (x509->extKeyUsage & EXTKEYUSE_SERVER_AUTH)
|
||||
ret |= XKU_SSL_SERVER;
|
||||
ret |= WOLFSSL_XKU_SSL_SERVER;
|
||||
if (x509->extKeyUsage & EXTKEYUSE_ANY)
|
||||
ret |= XKU_ANYEKU;
|
||||
ret |= WOLFSSL_XKU_ANYEKU;
|
||||
}
|
||||
|
||||
WOLFSSL_LEAVE("wolfSSL_X509_get_extended_key_usage", ret);
|
||||
@@ -1688,7 +1688,7 @@ WOLFSSL_v3_ext_method* wolfSSL_X509V3_EXT_get(WOLFSSL_X509_EXTENSION* ex)
|
||||
case WC_NID_basic_constraints:
|
||||
break;
|
||||
case WC_NID_subject_key_identifier:
|
||||
method.i2s = (X509V3_EXT_I2S)wolfSSL_i2s_ASN1_STRING;
|
||||
method.i2s = (WOLFSSL_X509V3_EXT_I2S)wolfSSL_i2s_ASN1_STRING;
|
||||
break;
|
||||
case WC_NID_subject_alt_name:
|
||||
WOLFSSL_MSG("i2v function not yet implemented for Subject "
|
||||
@@ -2965,7 +2965,7 @@ static void wolfSSL_X509V3_EXT_METHOD_populate(WOLFSSL_v3_ext_method *method,
|
||||
WOLFSSL_ENTER("wolfSSL_X509V3_EXT_METHOD_populate");
|
||||
switch (nid) {
|
||||
case WC_NID_subject_key_identifier:
|
||||
method->i2s = (X509V3_EXT_I2S)wolfSSL_i2s_ASN1_STRING;
|
||||
method->i2s = (WOLFSSL_X509V3_EXT_I2S)wolfSSL_i2s_ASN1_STRING;
|
||||
FALL_THROUGH;
|
||||
case WC_NID_authority_key_identifier:
|
||||
case WC_NID_key_usage:
|
||||
|
||||
@@ -2485,7 +2485,7 @@ static void bench_multi_value_stats(double max, double min, double sum,
|
||||
#endif
|
||||
|
||||
/* countSz is number of bytes that 1 count represents. Normally bench_size,
|
||||
* except for AES direct that operates on AES_BLOCK_SIZE blocks */
|
||||
* except for AES direct that operates on WC_AES_BLOCK_SIZE blocks */
|
||||
static void bench_stats_sym_finish(const char* desc, int useDeviceID,
|
||||
int count, word32 countSz,
|
||||
double start, int ret)
|
||||
@@ -4846,7 +4846,7 @@ static void bench_aesecb_internal(int useDeviceID,
|
||||
double start;
|
||||
DECLARE_MULTI_VALUE_STATS_VARS()
|
||||
#ifdef HAVE_FIPS
|
||||
const word32 benchSz = AES_BLOCK_SIZE;
|
||||
const word32 benchSz = WC_AES_BLOCK_SIZE;
|
||||
#else
|
||||
const word32 benchSz = bench_size;
|
||||
#endif
|
||||
@@ -5373,9 +5373,9 @@ static void bench_aessiv_internal(const byte* key, word32 keySz, const char*
|
||||
{
|
||||
int i;
|
||||
int ret = 0;
|
||||
byte assoc[AES_BLOCK_SIZE];
|
||||
byte nonce[AES_BLOCK_SIZE];
|
||||
byte siv[AES_BLOCK_SIZE];
|
||||
byte assoc[WC_AES_BLOCK_SIZE];
|
||||
byte nonce[WC_AES_BLOCK_SIZE];
|
||||
byte siv[WC_AES_BLOCK_SIZE];
|
||||
int count = 0;
|
||||
double start;
|
||||
DECLARE_MULTI_VALUE_STATS_VARS()
|
||||
@@ -5383,8 +5383,8 @@ static void bench_aessiv_internal(const byte* key, word32 keySz, const char*
|
||||
bench_stats_start(&count, &start);
|
||||
do {
|
||||
for (i = 0; i < numBlocks; i++) {
|
||||
ret = wc_AesSivEncrypt(key, keySz, assoc, AES_BLOCK_SIZE, nonce,
|
||||
AES_BLOCK_SIZE, bench_plain, bench_size,
|
||||
ret = wc_AesSivEncrypt(key, keySz, assoc, WC_AES_BLOCK_SIZE, nonce,
|
||||
WC_AES_BLOCK_SIZE, bench_plain, bench_size,
|
||||
siv, bench_cipher);
|
||||
if (ret != 0) {
|
||||
printf("wc_AesSivEncrypt failed (%d)\n", ret);
|
||||
@@ -5409,8 +5409,8 @@ static void bench_aessiv_internal(const byte* key, word32 keySz, const char*
|
||||
bench_stats_start(&count, &start);
|
||||
do {
|
||||
for (i = 0; i < numBlocks; i++) {
|
||||
ret = wc_AesSivDecrypt(key, keySz, assoc, AES_BLOCK_SIZE, nonce,
|
||||
AES_BLOCK_SIZE, bench_cipher, bench_size,
|
||||
ret = wc_AesSivDecrypt(key, keySz, assoc, WC_AES_BLOCK_SIZE, nonce,
|
||||
WC_AES_BLOCK_SIZE, bench_cipher, bench_size,
|
||||
siv, bench_plain);
|
||||
if (ret != 0) {
|
||||
printf("wc_AesSivDecrypt failed (%d)\n", ret);
|
||||
@@ -5510,7 +5510,7 @@ void bench_poly1305(void)
|
||||
#ifdef HAVE_CAMELLIA
|
||||
void bench_camellia(void)
|
||||
{
|
||||
Camellia cam;
|
||||
wc_Camellia cam;
|
||||
double start;
|
||||
int ret, i, count;
|
||||
DECLARE_MULTI_VALUE_STATS_VARS()
|
||||
@@ -7926,7 +7926,7 @@ void bench_blake2s(void)
|
||||
static void bench_cmac_helper(word32 keySz, const char* outMsg, int useDeviceID)
|
||||
{
|
||||
Cmac cmac;
|
||||
byte digest[AES_BLOCK_SIZE];
|
||||
byte digest[WC_AES_BLOCK_SIZE];
|
||||
word32 digestSz = sizeof(digest);
|
||||
double start;
|
||||
int ret, i, count;
|
||||
|
||||
+773
-773
File diff suppressed because it is too large
Load Diff
+5
-5
@@ -8150,7 +8150,7 @@ static int CheckAlgoV2(int oid, int* id, int* blockSz)
|
||||
case AES256CBCb:
|
||||
*id = PBE_AES256_CBC;
|
||||
if (blockSz != NULL) {
|
||||
*blockSz = AES_BLOCK_SIZE;
|
||||
*blockSz = WC_AES_BLOCK_SIZE;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
@@ -8158,7 +8158,7 @@ static int CheckAlgoV2(int oid, int* id, int* blockSz)
|
||||
case AES128CBCb:
|
||||
*id = PBE_AES128_CBC;
|
||||
if (blockSz != NULL) {
|
||||
*blockSz = AES_BLOCK_SIZE;
|
||||
*blockSz = WC_AES_BLOCK_SIZE;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
@@ -16632,7 +16632,7 @@ static int HashForSignature(const byte* buf, word32 bufSz, word32 sigOID,
|
||||
}
|
||||
else if ((ret = wc_Md2Hash(buf, bufSz, digest)) == 0) {
|
||||
*typeH = MD2h;
|
||||
*digestSz = MD2_DIGEST_SIZE;
|
||||
*digestSz = WC_MD2_DIGEST_SIZE;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
@@ -25816,9 +25816,9 @@ int PemToDer(const unsigned char* buff, long longSz, int type,
|
||||
#if !defined(NO_AES) && defined(HAVE_AES_CBC) && \
|
||||
defined(HAVE_AES_DECRYPT)
|
||||
if (info->cipherType == WC_CIPHER_AES_CBC) {
|
||||
if (der->length > AES_BLOCK_SIZE) {
|
||||
if (der->length > WC_AES_BLOCK_SIZE) {
|
||||
padVal = der->buffer[der->length-1];
|
||||
if (padVal <= AES_BLOCK_SIZE) {
|
||||
if (padVal <= WC_AES_BLOCK_SIZE) {
|
||||
der->length -= (word32)padVal;
|
||||
}
|
||||
}
|
||||
|
||||
+22
-22
@@ -1466,7 +1466,7 @@ static void camellia_decrypt256(const u32 *subkey, u32 *io)
|
||||
|
||||
static void Camellia_EncryptBlock(const word32 keyBitLength,
|
||||
const unsigned char *plaintext,
|
||||
const KEY_TABLE_TYPE keyTable,
|
||||
const WC_CAMELLIA_KEY_TABLE_TYPE keyTable,
|
||||
unsigned char *ciphertext)
|
||||
{
|
||||
u32 tmp[4];
|
||||
@@ -1497,7 +1497,7 @@ static void Camellia_EncryptBlock(const word32 keyBitLength,
|
||||
|
||||
static void Camellia_DecryptBlock(const word32 keyBitLength,
|
||||
const unsigned char *ciphertext,
|
||||
const KEY_TABLE_TYPE keyTable,
|
||||
const WC_CAMELLIA_KEY_TABLE_TYPE keyTable,
|
||||
unsigned char *plaintext)
|
||||
{
|
||||
u32 tmp[4];
|
||||
@@ -1529,13 +1529,13 @@ static void Camellia_DecryptBlock(const word32 keyBitLength,
|
||||
|
||||
/* wolfCrypt wrappers to the Camellia code */
|
||||
|
||||
int wc_CamelliaSetKey(Camellia* cam, const byte* key, word32 len, const byte* iv)
|
||||
int wc_CamelliaSetKey(wc_Camellia* cam, const byte* key, word32 len, const byte* iv)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (cam == NULL) return BAD_FUNC_ARG;
|
||||
|
||||
XMEMSET(cam->key, 0, CAMELLIA_TABLE_BYTE_LEN);
|
||||
XMEMSET(cam->key, 0, WC_CAMELLIA_TABLE_BYTE_LEN);
|
||||
|
||||
switch (len) {
|
||||
case 16:
|
||||
@@ -1560,21 +1560,21 @@ int wc_CamelliaSetKey(Camellia* cam, const byte* key, word32 len, const byte* iv
|
||||
}
|
||||
|
||||
|
||||
int wc_CamelliaSetIV(Camellia* cam, const byte* iv)
|
||||
int wc_CamelliaSetIV(wc_Camellia* cam, const byte* iv)
|
||||
{
|
||||
if (cam == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
if (iv)
|
||||
XMEMCPY(cam->reg, iv, CAMELLIA_BLOCK_SIZE);
|
||||
XMEMCPY(cam->reg, iv, WC_CAMELLIA_BLOCK_SIZE);
|
||||
else
|
||||
XMEMSET(cam->reg, 0, CAMELLIA_BLOCK_SIZE);
|
||||
XMEMSET(cam->reg, 0, WC_CAMELLIA_BLOCK_SIZE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int wc_CamelliaEncryptDirect(Camellia* cam, byte* out, const byte* in)
|
||||
int wc_CamelliaEncryptDirect(wc_Camellia* cam, byte* out, const byte* in)
|
||||
{
|
||||
if (cam == NULL || out == NULL || in == NULL) {
|
||||
return BAD_FUNC_ARG;
|
||||
@@ -1585,7 +1585,7 @@ int wc_CamelliaEncryptDirect(Camellia* cam, byte* out, const byte* in)
|
||||
}
|
||||
|
||||
|
||||
int wc_CamelliaDecryptDirect(Camellia* cam, byte* out, const byte* in)
|
||||
int wc_CamelliaDecryptDirect(wc_Camellia* cam, byte* out, const byte* in)
|
||||
{
|
||||
if (cam == NULL || out == NULL || in == NULL) {
|
||||
return BAD_FUNC_ARG;
|
||||
@@ -1596,44 +1596,44 @@ int wc_CamelliaDecryptDirect(Camellia* cam, byte* out, const byte* in)
|
||||
}
|
||||
|
||||
|
||||
int wc_CamelliaCbcEncrypt(Camellia* cam, byte* out, const byte* in, word32 sz)
|
||||
int wc_CamelliaCbcEncrypt(wc_Camellia* cam, byte* out, const byte* in, word32 sz)
|
||||
{
|
||||
word32 blocks;
|
||||
if (cam == NULL || out == NULL || in == NULL) {
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
blocks = sz / CAMELLIA_BLOCK_SIZE;
|
||||
blocks = sz / WC_CAMELLIA_BLOCK_SIZE;
|
||||
|
||||
while (blocks--) {
|
||||
xorbuf((byte*)cam->reg, in, CAMELLIA_BLOCK_SIZE);
|
||||
xorbuf((byte*)cam->reg, in, WC_CAMELLIA_BLOCK_SIZE);
|
||||
Camellia_EncryptBlock(cam->keySz, (byte*)cam->reg,
|
||||
cam->key, (byte*)cam->reg);
|
||||
XMEMCPY(out, cam->reg, CAMELLIA_BLOCK_SIZE);
|
||||
XMEMCPY(out, cam->reg, WC_CAMELLIA_BLOCK_SIZE);
|
||||
|
||||
out += CAMELLIA_BLOCK_SIZE;
|
||||
in += CAMELLIA_BLOCK_SIZE;
|
||||
out += WC_CAMELLIA_BLOCK_SIZE;
|
||||
in += WC_CAMELLIA_BLOCK_SIZE;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int wc_CamelliaCbcDecrypt(Camellia* cam, byte* out, const byte* in, word32 sz)
|
||||
int wc_CamelliaCbcDecrypt(wc_Camellia* cam, byte* out, const byte* in, word32 sz)
|
||||
{
|
||||
word32 blocks;
|
||||
if (cam == NULL || out == NULL || in == NULL) {
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
blocks = sz / CAMELLIA_BLOCK_SIZE;
|
||||
blocks = sz / WC_CAMELLIA_BLOCK_SIZE;
|
||||
|
||||
while (blocks--) {
|
||||
XMEMCPY(cam->tmp, in, CAMELLIA_BLOCK_SIZE);
|
||||
XMEMCPY(cam->tmp, in, WC_CAMELLIA_BLOCK_SIZE);
|
||||
Camellia_DecryptBlock(cam->keySz, (byte*)cam->tmp, cam->key, out);
|
||||
xorbuf(out, (byte*)cam->reg, CAMELLIA_BLOCK_SIZE);
|
||||
XMEMCPY(cam->reg, cam->tmp, CAMELLIA_BLOCK_SIZE);
|
||||
xorbuf(out, (byte*)cam->reg, WC_CAMELLIA_BLOCK_SIZE);
|
||||
XMEMCPY(cam->reg, cam->tmp, WC_CAMELLIA_BLOCK_SIZE);
|
||||
|
||||
out += CAMELLIA_BLOCK_SIZE;
|
||||
in += CAMELLIA_BLOCK_SIZE;
|
||||
out += WC_CAMELLIA_BLOCK_SIZE;
|
||||
in += WC_CAMELLIA_BLOCK_SIZE;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
+17
-17
@@ -90,7 +90,7 @@ void ShiftAndXorRb(byte* out, byte* in)
|
||||
|
||||
xorRb = (in[0] & 0x80) != 0;
|
||||
|
||||
for (i = 1, j = AES_BLOCK_SIZE - 1; i <= AES_BLOCK_SIZE; i++, j--) {
|
||||
for (i = 1, j = WC_AES_BLOCK_SIZE - 1; i <= WC_AES_BLOCK_SIZE; i++, j--) {
|
||||
last = (in[j] & 0x80) ? 1 : 0;
|
||||
out[j] = (byte)((in[j] << 1) | mask);
|
||||
mask = last;
|
||||
@@ -165,14 +165,14 @@ int wc_InitCmac_ex(Cmac* cmac, const byte* key, word32 keySz,
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
byte l[AES_BLOCK_SIZE];
|
||||
byte l[WC_AES_BLOCK_SIZE];
|
||||
|
||||
XMEMSET(l, 0, AES_BLOCK_SIZE);
|
||||
XMEMSET(l, 0, WC_AES_BLOCK_SIZE);
|
||||
ret = wc_AesEncryptDirect(&cmac->aes, l, l);
|
||||
if (ret == 0) {
|
||||
ShiftAndXorRb(cmac->k1, l);
|
||||
ShiftAndXorRb(cmac->k2, cmac->k1);
|
||||
ForceZero(l, AES_BLOCK_SIZE);
|
||||
ForceZero(l, WC_AES_BLOCK_SIZE);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -227,21 +227,21 @@ int wc_CmacUpdate(Cmac* cmac, const byte* in, word32 inSz)
|
||||
case WC_CMAC_AES:
|
||||
{
|
||||
while ((ret == 0) && (inSz != 0)) {
|
||||
word32 add = min(inSz, AES_BLOCK_SIZE - cmac->bufferSz);
|
||||
word32 add = min(inSz, WC_AES_BLOCK_SIZE - cmac->bufferSz);
|
||||
XMEMCPY(&cmac->buffer[cmac->bufferSz], in, add);
|
||||
|
||||
cmac->bufferSz += add;
|
||||
in += add;
|
||||
inSz -= add;
|
||||
|
||||
if (cmac->bufferSz == AES_BLOCK_SIZE && inSz != 0) {
|
||||
if (cmac->bufferSz == WC_AES_BLOCK_SIZE && inSz != 0) {
|
||||
if (cmac->totalSz != 0) {
|
||||
xorbuf(cmac->buffer, cmac->digest, AES_BLOCK_SIZE);
|
||||
xorbuf(cmac->buffer, cmac->digest, WC_AES_BLOCK_SIZE);
|
||||
}
|
||||
ret = wc_AesEncryptDirect(&cmac->aes, cmac->digest,
|
||||
cmac->buffer);
|
||||
if (ret == 0) {
|
||||
cmac->totalSz += AES_BLOCK_SIZE;
|
||||
cmac->totalSz += WC_AES_BLOCK_SIZE;
|
||||
cmac->bufferSz = 0;
|
||||
}
|
||||
}
|
||||
@@ -313,30 +313,30 @@ int wc_CmacFinalNoFree(Cmac* cmac, byte* out, word32* outSz)
|
||||
const byte* subKey;
|
||||
word32 remainder;
|
||||
|
||||
if (cmac->bufferSz == AES_BLOCK_SIZE) {
|
||||
if (cmac->bufferSz == WC_AES_BLOCK_SIZE) {
|
||||
subKey = cmac->k1;
|
||||
}
|
||||
else {
|
||||
/* ensure we will have a valid remainder value */
|
||||
if (cmac->bufferSz > AES_BLOCK_SIZE) {
|
||||
if (cmac->bufferSz > WC_AES_BLOCK_SIZE) {
|
||||
ret = BAD_STATE_E;
|
||||
break;
|
||||
}
|
||||
remainder = AES_BLOCK_SIZE - cmac->bufferSz;
|
||||
remainder = WC_AES_BLOCK_SIZE - cmac->bufferSz;
|
||||
|
||||
if (remainder == 0) {
|
||||
remainder = AES_BLOCK_SIZE;
|
||||
remainder = WC_AES_BLOCK_SIZE;
|
||||
}
|
||||
if (remainder > 1) {
|
||||
XMEMSET(cmac->buffer + AES_BLOCK_SIZE - remainder, 0,
|
||||
XMEMSET(cmac->buffer + WC_AES_BLOCK_SIZE - remainder, 0,
|
||||
remainder);
|
||||
}
|
||||
|
||||
cmac->buffer[AES_BLOCK_SIZE - remainder] = 0x80;
|
||||
cmac->buffer[WC_AES_BLOCK_SIZE - remainder] = 0x80;
|
||||
subKey = cmac->k2;
|
||||
}
|
||||
xorbuf(cmac->buffer, cmac->digest, AES_BLOCK_SIZE);
|
||||
xorbuf(cmac->buffer, subKey, AES_BLOCK_SIZE);
|
||||
xorbuf(cmac->buffer, cmac->digest, WC_AES_BLOCK_SIZE);
|
||||
xorbuf(cmac->buffer, subKey, WC_AES_BLOCK_SIZE);
|
||||
ret = wc_AesEncryptDirect(&cmac->aes, cmac->digest, cmac->buffer);
|
||||
if (ret == 0) {
|
||||
XMEMCPY(out, cmac->digest, *outSz);
|
||||
@@ -473,7 +473,7 @@ int wc_AesCmacVerify_ex(Cmac* cmac,
|
||||
void* heap, int devId)
|
||||
{
|
||||
int ret = 0;
|
||||
byte a[AES_BLOCK_SIZE];
|
||||
byte a[WC_AES_BLOCK_SIZE];
|
||||
word32 aSz = sizeof(a);
|
||||
int compareRet;
|
||||
|
||||
|
||||
+6
-6
@@ -14073,12 +14073,12 @@ static int ecc_get_key_sizes(ecEncCtx* ctx, int* encKeySz, int* ivSz,
|
||||
case ecAES_128_CBC:
|
||||
*encKeySz = KEY_SIZE_128;
|
||||
*ivSz = IV_SIZE_128;
|
||||
*blockSz = AES_BLOCK_SIZE;
|
||||
*blockSz = WC_AES_BLOCK_SIZE;
|
||||
break;
|
||||
case ecAES_256_CBC:
|
||||
*encKeySz = KEY_SIZE_256;
|
||||
*ivSz = IV_SIZE_128;
|
||||
*blockSz = AES_BLOCK_SIZE;
|
||||
*blockSz = WC_AES_BLOCK_SIZE;
|
||||
break;
|
||||
#endif
|
||||
#if !defined(NO_AES) && defined(WOLFSSL_AES_COUNTER)
|
||||
@@ -14375,7 +14375,7 @@ int wc_ecc_encrypt_ex(ecc_key* privKey, ecc_key* pubKey, const byte* msg,
|
||||
case ecAES_256_CTR:
|
||||
{
|
||||
#if !defined(NO_AES) && defined(WOLFSSL_AES_COUNTER)
|
||||
byte ctr_iv[AES_BLOCK_SIZE];
|
||||
byte ctr_iv[WC_AES_BLOCK_SIZE];
|
||||
#ifndef WOLFSSL_SMALL_STACK
|
||||
Aes aes[1];
|
||||
#else
|
||||
@@ -14390,7 +14390,7 @@ int wc_ecc_encrypt_ex(ecc_key* privKey, ecc_key* pubKey, const byte* msg,
|
||||
/* Include 4 byte counter starting at all zeros. */
|
||||
XMEMCPY(ctr_iv, encIv, WOLFSSL_ECIES_GEN_IV_SIZE);
|
||||
XMEMSET(ctr_iv + WOLFSSL_ECIES_GEN_IV_SIZE, 0,
|
||||
AES_BLOCK_SIZE - WOLFSSL_ECIES_GEN_IV_SIZE);
|
||||
WC_AES_BLOCK_SIZE - WOLFSSL_ECIES_GEN_IV_SIZE);
|
||||
|
||||
ret = wc_AesInit(aes, NULL, INVALID_DEVID);
|
||||
if (ret == 0) {
|
||||
@@ -14852,11 +14852,11 @@ int wc_ecc_decrypt(ecc_key* privKey, ecc_key* pubKey, const byte* msg,
|
||||
#endif
|
||||
ret = wc_AesInit(aes, NULL, INVALID_DEVID);
|
||||
if (ret == 0) {
|
||||
byte ctr_iv[AES_BLOCK_SIZE];
|
||||
byte ctr_iv[WC_AES_BLOCK_SIZE];
|
||||
/* Make a 16 byte IV from the bytes passed in. */
|
||||
XMEMCPY(ctr_iv, encIv, WOLFSSL_ECIES_GEN_IV_SIZE);
|
||||
XMEMSET(ctr_iv + WOLFSSL_ECIES_GEN_IV_SIZE, 0,
|
||||
AES_BLOCK_SIZE - WOLFSSL_ECIES_GEN_IV_SIZE);
|
||||
WC_AES_BLOCK_SIZE - WOLFSSL_ECIES_GEN_IV_SIZE);
|
||||
ret = wc_AesSetKey(aes, encKey, (word32)encKeySz, ctr_iv,
|
||||
AES_ENCRYPTION);
|
||||
if (ret == 0) {
|
||||
|
||||
+55
-55
@@ -1346,7 +1346,7 @@ int wolfSSL_EVP_CipherFinal(WOLFSSL_EVP_CIPHER_CTX *ctx, unsigned char *out,
|
||||
}
|
||||
else {
|
||||
/* Clear IV, since IV reuse is not recommended for AES GCM. */
|
||||
XMEMSET(ctx->iv, 0, AES_BLOCK_SIZE);
|
||||
XMEMSET(ctx->iv, 0, WC_AES_BLOCK_SIZE);
|
||||
}
|
||||
if (wolfSSL_StoreExternalIV(ctx) != WOLFSSL_SUCCESS) {
|
||||
ret = WOLFSSL_FAILURE;
|
||||
@@ -1405,7 +1405,7 @@ int wolfSSL_EVP_CipherFinal(WOLFSSL_EVP_CIPHER_CTX *ctx, unsigned char *out,
|
||||
else {
|
||||
/* Clear IV, since IV reuse is not recommended
|
||||
* for AES CCM. */
|
||||
XMEMSET(ctx->iv, 0, AES_BLOCK_SIZE);
|
||||
XMEMSET(ctx->iv, 0, WC_AES_BLOCK_SIZE);
|
||||
}
|
||||
if (wolfSSL_StoreExternalIV(ctx) != WOLFSSL_SUCCESS) {
|
||||
ret = WOLFSSL_FAILURE;
|
||||
@@ -2053,7 +2053,7 @@ int wolfSSL_EVP_CIPHER_block_size(const WOLFSSL_EVP_CIPHER *cipher)
|
||||
case WC_AES_128_CBC_TYPE:
|
||||
case WC_AES_192_CBC_TYPE:
|
||||
case WC_AES_256_CBC_TYPE:
|
||||
return AES_BLOCK_SIZE;
|
||||
return WC_AES_BLOCK_SIZE;
|
||||
#endif
|
||||
#if defined(HAVE_AESGCM)
|
||||
case WC_AES_128_GCM_TYPE:
|
||||
@@ -2077,7 +2077,7 @@ int wolfSSL_EVP_CIPHER_block_size(const WOLFSSL_EVP_CIPHER *cipher)
|
||||
case WC_AES_128_ECB_TYPE:
|
||||
case WC_AES_192_ECB_TYPE:
|
||||
case WC_AES_256_ECB_TYPE:
|
||||
return AES_BLOCK_SIZE;
|
||||
return WC_AES_BLOCK_SIZE;
|
||||
#endif
|
||||
#if defined(WOLFSSL_AES_CFB)
|
||||
case WC_AES_128_CFB1_TYPE:
|
||||
@@ -6031,7 +6031,7 @@ void wolfSSL_EVP_init(void)
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if (arg <= 0 || arg > AES_BLOCK_SIZE)
|
||||
if (arg <= 0 || arg > WC_AES_BLOCK_SIZE)
|
||||
break;
|
||||
}
|
||||
ret = wolfSSL_EVP_CIPHER_CTX_set_iv_length(ctx, arg);
|
||||
@@ -6215,7 +6215,7 @@ void wolfSSL_EVP_init(void)
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if (arg <= 0 || arg > AES_BLOCK_SIZE)
|
||||
if (arg <= 0 || arg > WC_AES_BLOCK_SIZE)
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -6462,7 +6462,7 @@ void wolfSSL_EVP_init(void)
|
||||
/* wc_AesSetKey clear aes.reg if iv == NULL.
|
||||
Keep IV for openSSL compatibility */
|
||||
if (iv == NULL)
|
||||
XMEMCPY((byte *)aes->tmp, (byte *)aes->reg, AES_BLOCK_SIZE);
|
||||
XMEMCPY((byte *)aes->tmp, (byte *)aes->reg, WC_AES_BLOCK_SIZE);
|
||||
if (direct) {
|
||||
#if defined(WOLFSSL_AES_DIRECT)
|
||||
ret = wc_AesSetKeyDirect(aes, key, len, iv, dir);
|
||||
@@ -6474,7 +6474,7 @@ void wolfSSL_EVP_init(void)
|
||||
ret = wc_AesSetKey(aes, key, len, iv, dir);
|
||||
}
|
||||
if (iv == NULL)
|
||||
XMEMCPY((byte *)aes->reg, (byte *)aes->tmp, AES_BLOCK_SIZE);
|
||||
XMEMCPY((byte *)aes->reg, (byte *)aes->tmp, WC_AES_BLOCK_SIZE);
|
||||
return ret;
|
||||
}
|
||||
#endif /* AES_ANY_SIZE && AES_SET_KEY */
|
||||
@@ -6492,8 +6492,8 @@ void wolfSSL_EVP_init(void)
|
||||
ctx->authIn = NULL;
|
||||
ctx->authInSz = 0;
|
||||
|
||||
ctx->block_size = AES_BLOCK_SIZE;
|
||||
ctx->authTagSz = AES_BLOCK_SIZE;
|
||||
ctx->block_size = WC_AES_BLOCK_SIZE;
|
||||
ctx->authTagSz = WC_AES_BLOCK_SIZE;
|
||||
if (ctx->ivSz == 0) {
|
||||
ctx->ivSz = GCM_NONCE_MID_SZ;
|
||||
}
|
||||
@@ -6697,8 +6697,8 @@ void wolfSSL_EVP_init(void)
|
||||
ctx->authIn = NULL;
|
||||
ctx->authInSz = 0;
|
||||
|
||||
ctx->block_size = AES_BLOCK_SIZE;
|
||||
ctx->authTagSz = AES_BLOCK_SIZE;
|
||||
ctx->block_size = WC_AES_BLOCK_SIZE;
|
||||
ctx->authTagSz = WC_AES_BLOCK_SIZE;
|
||||
if (ctx->ivSz == 0) {
|
||||
ctx->ivSz = GCM_NONCE_MID_SZ;
|
||||
}
|
||||
@@ -6846,8 +6846,8 @@ void wolfSSL_EVP_init(void)
|
||||
ctx->authIn = NULL;
|
||||
ctx->authInSz = 0;
|
||||
|
||||
ctx->block_size = AES_BLOCK_SIZE;
|
||||
ctx->authTagSz = AES_BLOCK_SIZE;
|
||||
ctx->block_size = WC_AES_BLOCK_SIZE;
|
||||
ctx->authTagSz = WC_AES_BLOCK_SIZE;
|
||||
if (ctx->ivSz == 0) {
|
||||
ctx->ivSz = GCM_NONCE_MID_SZ;
|
||||
}
|
||||
@@ -6938,8 +6938,8 @@ void wolfSSL_EVP_init(void)
|
||||
ctx->flags &= (unsigned long)~WOLFSSL_EVP_CIPH_MODE;
|
||||
ctx->flags |= WOLFSSL_EVP_CIPH_CBC_MODE;
|
||||
ctx->keyLen = 16;
|
||||
ctx->block_size = AES_BLOCK_SIZE;
|
||||
ctx->ivSz = AES_BLOCK_SIZE;
|
||||
ctx->block_size = WC_AES_BLOCK_SIZE;
|
||||
ctx->ivSz = WC_AES_BLOCK_SIZE;
|
||||
if (enc == 0 || enc == 1)
|
||||
ctx->enc = enc ? 1 : 0;
|
||||
if (! (ctx->flags & WOLFSSL_EVP_CIPH_LOW_LEVEL_INITED)) {
|
||||
@@ -6968,8 +6968,8 @@ void wolfSSL_EVP_init(void)
|
||||
ctx->flags &= (unsigned long)~WOLFSSL_EVP_CIPH_MODE;
|
||||
ctx->flags |= WOLFSSL_EVP_CIPH_CBC_MODE;
|
||||
ctx->keyLen = 24;
|
||||
ctx->block_size = AES_BLOCK_SIZE;
|
||||
ctx->ivSz = AES_BLOCK_SIZE;
|
||||
ctx->block_size = WC_AES_BLOCK_SIZE;
|
||||
ctx->ivSz = WC_AES_BLOCK_SIZE;
|
||||
if (enc == 0 || enc == 1)
|
||||
ctx->enc = enc ? 1 : 0;
|
||||
if (! (ctx->flags & WOLFSSL_EVP_CIPH_LOW_LEVEL_INITED)) {
|
||||
@@ -6998,8 +6998,8 @@ void wolfSSL_EVP_init(void)
|
||||
ctx->flags &= (unsigned long)~WOLFSSL_EVP_CIPH_MODE;
|
||||
ctx->flags |= WOLFSSL_EVP_CIPH_CBC_MODE;
|
||||
ctx->keyLen = 32;
|
||||
ctx->block_size = AES_BLOCK_SIZE;
|
||||
ctx->ivSz = AES_BLOCK_SIZE;
|
||||
ctx->block_size = WC_AES_BLOCK_SIZE;
|
||||
ctx->ivSz = WC_AES_BLOCK_SIZE;
|
||||
if (enc == 0 || enc == 1)
|
||||
ctx->enc = enc ? 1 : 0;
|
||||
if (! (ctx->flags & WOLFSSL_EVP_CIPH_LOW_LEVEL_INITED)) {
|
||||
@@ -7083,7 +7083,7 @@ void wolfSSL_EVP_init(void)
|
||||
ctx->flags |= WOLFSSL_EVP_CIPH_CTR_MODE;
|
||||
ctx->keyLen = 16;
|
||||
ctx->block_size = WOLFSSL_NO_PADDING_BLOCK_SIZE;
|
||||
ctx->ivSz = AES_BLOCK_SIZE;
|
||||
ctx->ivSz = WC_AES_BLOCK_SIZE;
|
||||
#if defined(WOLFSSL_AES_COUNTER) || defined(WOLFSSL_AES_CFB)
|
||||
ctx->cipher.aes.left = 0;
|
||||
#endif
|
||||
@@ -7116,7 +7116,7 @@ void wolfSSL_EVP_init(void)
|
||||
ctx->flags |= WOLFSSL_EVP_CIPH_CTR_MODE;
|
||||
ctx->keyLen = 24;
|
||||
ctx->block_size = WOLFSSL_NO_PADDING_BLOCK_SIZE;
|
||||
ctx->ivSz = AES_BLOCK_SIZE;
|
||||
ctx->ivSz = WC_AES_BLOCK_SIZE;
|
||||
#if defined(WOLFSSL_AES_COUNTER) || defined(WOLFSSL_AES_CFB)
|
||||
ctx->cipher.aes.left = 0;
|
||||
#endif
|
||||
@@ -7149,7 +7149,7 @@ void wolfSSL_EVP_init(void)
|
||||
ctx->flags |= WOLFSSL_EVP_CIPH_CTR_MODE;
|
||||
ctx->keyLen = 32;
|
||||
ctx->block_size = WOLFSSL_NO_PADDING_BLOCK_SIZE;
|
||||
ctx->ivSz = AES_BLOCK_SIZE;
|
||||
ctx->ivSz = WC_AES_BLOCK_SIZE;
|
||||
#if defined(WOLFSSL_AES_COUNTER) || defined(WOLFSSL_AES_CFB)
|
||||
ctx->cipher.aes.left = 0;
|
||||
#endif
|
||||
@@ -7183,7 +7183,7 @@ void wolfSSL_EVP_init(void)
|
||||
ctx->flags &= (unsigned long)~WOLFSSL_EVP_CIPH_MODE;
|
||||
ctx->flags |= WOLFSSL_EVP_CIPH_ECB_MODE;
|
||||
ctx->keyLen = 16;
|
||||
ctx->block_size = AES_BLOCK_SIZE;
|
||||
ctx->block_size = WC_AES_BLOCK_SIZE;
|
||||
if (enc == 0 || enc == 1)
|
||||
ctx->enc = enc ? 1 : 0;
|
||||
if (! (ctx->flags & WOLFSSL_EVP_CIPH_LOW_LEVEL_INITED)) {
|
||||
@@ -7207,7 +7207,7 @@ void wolfSSL_EVP_init(void)
|
||||
ctx->flags &= (unsigned long)~WOLFSSL_EVP_CIPH_MODE;
|
||||
ctx->flags |= WOLFSSL_EVP_CIPH_ECB_MODE;
|
||||
ctx->keyLen = 24;
|
||||
ctx->block_size = AES_BLOCK_SIZE;
|
||||
ctx->block_size = WC_AES_BLOCK_SIZE;
|
||||
if (enc == 0 || enc == 1)
|
||||
ctx->enc = enc ? 1 : 0;
|
||||
if (! (ctx->flags & WOLFSSL_EVP_CIPH_LOW_LEVEL_INITED)) {
|
||||
@@ -7231,7 +7231,7 @@ void wolfSSL_EVP_init(void)
|
||||
ctx->flags &= (unsigned long)~WOLFSSL_EVP_CIPH_MODE;
|
||||
ctx->flags |= WOLFSSL_EVP_CIPH_ECB_MODE;
|
||||
ctx->keyLen = 32;
|
||||
ctx->block_size = AES_BLOCK_SIZE;
|
||||
ctx->block_size = WC_AES_BLOCK_SIZE;
|
||||
if (enc == 0 || enc == 1)
|
||||
ctx->enc = enc ? 1 : 0;
|
||||
if (! (ctx->flags & WOLFSSL_EVP_CIPH_LOW_LEVEL_INITED)) {
|
||||
@@ -7627,14 +7627,14 @@ void wolfSSL_EVP_init(void)
|
||||
ctx->flags |= WOLFSSL_EVP_CIPH_XTS_MODE;
|
||||
ctx->keyLen = 32;
|
||||
ctx->block_size = 1;
|
||||
ctx->ivSz = AES_BLOCK_SIZE;
|
||||
ctx->ivSz = WC_AES_BLOCK_SIZE;
|
||||
|
||||
if (iv != NULL) {
|
||||
if (iv != ctx->iv) /* Valgrind error when src == dst */
|
||||
XMEMCPY(ctx->iv, iv, (size_t)ctx->ivSz);
|
||||
}
|
||||
else
|
||||
XMEMSET(ctx->iv, 0, AES_BLOCK_SIZE);
|
||||
XMEMSET(ctx->iv, 0, WC_AES_BLOCK_SIZE);
|
||||
|
||||
if (enc == 0 || enc == 1)
|
||||
ctx->enc = enc ? 1 : 0;
|
||||
@@ -7668,14 +7668,14 @@ void wolfSSL_EVP_init(void)
|
||||
ctx->flags |= WOLFSSL_EVP_CIPH_XTS_MODE;
|
||||
ctx->keyLen = 64;
|
||||
ctx->block_size = 1;
|
||||
ctx->ivSz = AES_BLOCK_SIZE;
|
||||
ctx->ivSz = WC_AES_BLOCK_SIZE;
|
||||
|
||||
if (iv != NULL) {
|
||||
if (iv != ctx->iv) /* Valgrind error when src == dst */
|
||||
XMEMCPY(ctx->iv, iv, (size_t)ctx->ivSz);
|
||||
}
|
||||
else
|
||||
XMEMSET(ctx->iv, 0, AES_BLOCK_SIZE);
|
||||
XMEMSET(ctx->iv, 0, WC_AES_BLOCK_SIZE);
|
||||
|
||||
if (enc == 0 || enc == 1)
|
||||
ctx->enc = enc ? 1 : 0;
|
||||
@@ -8312,7 +8312,7 @@ void wolfSSL_EVP_init(void)
|
||||
else
|
||||
ret = wc_AesCbcDecrypt(&ctx->cipher.aes, dst, src, len);
|
||||
if (ret == 0)
|
||||
ret = (int)((len / AES_BLOCK_SIZE) * AES_BLOCK_SIZE);
|
||||
ret = (int)((len / WC_AES_BLOCK_SIZE) * WC_AES_BLOCK_SIZE);
|
||||
break;
|
||||
#endif /* HAVE_AES_CBC */
|
||||
|
||||
@@ -8411,7 +8411,7 @@ void wolfSSL_EVP_init(void)
|
||||
else
|
||||
ret = wc_AesEcbDecrypt(&ctx->cipher.aes, dst, src, len);
|
||||
if (ret == 0)
|
||||
ret = (int)((len / AES_BLOCK_SIZE) * AES_BLOCK_SIZE);
|
||||
ret = (int)((len / WC_AES_BLOCK_SIZE) * WC_AES_BLOCK_SIZE);
|
||||
break;
|
||||
#endif
|
||||
#ifdef WOLFSSL_AES_COUNTER
|
||||
@@ -8861,7 +8861,7 @@ int wolfSSL_EVP_PKEY_set1_DSA(WOLFSSL_EVP_PKEY *pkey, WOLFSSL_DSA *key)
|
||||
dsa = (DsaKey*)key->internal;
|
||||
|
||||
/* 4 > size of pub, priv, p, q, g + ASN.1 additional information */
|
||||
derMax = 4 * wolfSSL_BN_num_bytes(key->g) + AES_BLOCK_SIZE;
|
||||
derMax = 4 * wolfSSL_BN_num_bytes(key->g) + WC_AES_BLOCK_SIZE;
|
||||
|
||||
derBuf = (byte*)XMALLOC((size_t)derMax, pkey->heap,
|
||||
DYNAMIC_TYPE_TMP_BUFFER);
|
||||
@@ -9405,7 +9405,7 @@ int wolfSSL_EVP_CIPHER_CTX_iv_length(const WOLFSSL_EVP_CIPHER_CTX* ctx)
|
||||
case WC_AES_192_CBC_TYPE :
|
||||
case WC_AES_256_CBC_TYPE :
|
||||
WOLFSSL_MSG("AES CBC");
|
||||
return AES_BLOCK_SIZE;
|
||||
return WC_AES_BLOCK_SIZE;
|
||||
#endif
|
||||
#if (!defined(HAVE_FIPS) && !defined(HAVE_SELFTEST)) || \
|
||||
(defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2))
|
||||
@@ -9435,7 +9435,7 @@ int wolfSSL_EVP_CIPHER_CTX_iv_length(const WOLFSSL_EVP_CIPHER_CTX* ctx)
|
||||
case WC_AES_192_CTR_TYPE :
|
||||
case WC_AES_256_CTR_TYPE :
|
||||
WOLFSSL_MSG("AES CTR");
|
||||
return AES_BLOCK_SIZE;
|
||||
return WC_AES_BLOCK_SIZE;
|
||||
#endif
|
||||
#ifndef NO_DES3
|
||||
case WC_DES_CBC_TYPE :
|
||||
@@ -9457,31 +9457,31 @@ int wolfSSL_EVP_CIPHER_CTX_iv_length(const WOLFSSL_EVP_CIPHER_CTX* ctx)
|
||||
case WC_AES_192_CFB1_TYPE:
|
||||
case WC_AES_256_CFB1_TYPE:
|
||||
WOLFSSL_MSG("AES CFB1");
|
||||
return AES_BLOCK_SIZE;
|
||||
return WC_AES_BLOCK_SIZE;
|
||||
case WC_AES_128_CFB8_TYPE:
|
||||
case WC_AES_192_CFB8_TYPE:
|
||||
case WC_AES_256_CFB8_TYPE:
|
||||
WOLFSSL_MSG("AES CFB8");
|
||||
return AES_BLOCK_SIZE;
|
||||
return WC_AES_BLOCK_SIZE;
|
||||
#endif /* !HAVE_SELFTEST && !HAVE_FIPS */
|
||||
case WC_AES_128_CFB128_TYPE:
|
||||
case WC_AES_192_CFB128_TYPE:
|
||||
case WC_AES_256_CFB128_TYPE:
|
||||
WOLFSSL_MSG("AES CFB128");
|
||||
return AES_BLOCK_SIZE;
|
||||
return WC_AES_BLOCK_SIZE;
|
||||
#endif /* WOLFSSL_AES_CFB */
|
||||
#if defined(WOLFSSL_AES_OFB)
|
||||
case WC_AES_128_OFB_TYPE:
|
||||
case WC_AES_192_OFB_TYPE:
|
||||
case WC_AES_256_OFB_TYPE:
|
||||
WOLFSSL_MSG("AES OFB");
|
||||
return AES_BLOCK_SIZE;
|
||||
return WC_AES_BLOCK_SIZE;
|
||||
#endif /* WOLFSSL_AES_OFB */
|
||||
#if defined(WOLFSSL_AES_XTS) && (!defined(HAVE_FIPS) || FIPS_VERSION_GE(5,3))
|
||||
case WC_AES_128_XTS_TYPE:
|
||||
case WC_AES_256_XTS_TYPE:
|
||||
WOLFSSL_MSG("AES XTS");
|
||||
return AES_BLOCK_SIZE;
|
||||
return WC_AES_BLOCK_SIZE;
|
||||
#endif /* WOLFSSL_AES_XTS && (!defined(HAVE_FIPS) || FIPS_VERSION_GE(5,3)) */
|
||||
#ifdef HAVE_ARIA
|
||||
case WC_ARIA_128_GCM_TYPE :
|
||||
@@ -9550,15 +9550,15 @@ int wolfSSL_EVP_CIPHER_iv_length(const WOLFSSL_EVP_CIPHER* cipher)
|
||||
#if defined(HAVE_AES_CBC) || defined(WOLFSSL_AES_DIRECT)
|
||||
#ifdef WOLFSSL_AES_128
|
||||
if (XSTRCMP(name, EVP_AES_128_CBC) == 0)
|
||||
return AES_BLOCK_SIZE;
|
||||
return WC_AES_BLOCK_SIZE;
|
||||
#endif
|
||||
#ifdef WOLFSSL_AES_192
|
||||
if (XSTRCMP(name, EVP_AES_192_CBC) == 0)
|
||||
return AES_BLOCK_SIZE;
|
||||
return WC_AES_BLOCK_SIZE;
|
||||
#endif
|
||||
#ifdef WOLFSSL_AES_256
|
||||
if (XSTRCMP(name, EVP_AES_256_CBC) == 0)
|
||||
return AES_BLOCK_SIZE;
|
||||
return WC_AES_BLOCK_SIZE;
|
||||
#endif
|
||||
#endif /* HAVE_AES_CBC || WOLFSSL_AES_DIRECT */
|
||||
#if (!defined(HAVE_FIPS) && !defined(HAVE_SELFTEST)) || \
|
||||
@@ -9595,26 +9595,26 @@ int wolfSSL_EVP_CIPHER_iv_length(const WOLFSSL_EVP_CIPHER* cipher)
|
||||
#ifdef WOLFSSL_AES_COUNTER
|
||||
#ifdef WOLFSSL_AES_128
|
||||
if (XSTRCMP(name, EVP_AES_128_CTR) == 0)
|
||||
return AES_BLOCK_SIZE;
|
||||
return WC_AES_BLOCK_SIZE;
|
||||
#endif
|
||||
#ifdef WOLFSSL_AES_192
|
||||
if (XSTRCMP(name, EVP_AES_192_CTR) == 0)
|
||||
return AES_BLOCK_SIZE;
|
||||
return WC_AES_BLOCK_SIZE;
|
||||
#endif
|
||||
#ifdef WOLFSSL_AES_256
|
||||
if (XSTRCMP(name, EVP_AES_256_CTR) == 0)
|
||||
return AES_BLOCK_SIZE;
|
||||
return WC_AES_BLOCK_SIZE;
|
||||
#endif
|
||||
#endif
|
||||
#if defined(WOLFSSL_AES_XTS) && (!defined(HAVE_FIPS) || FIPS_VERSION_GE(5,3))
|
||||
#ifdef WOLFSSL_AES_128
|
||||
if (XSTRCMP(name, EVP_AES_128_XTS) == 0)
|
||||
return AES_BLOCK_SIZE;
|
||||
return WC_AES_BLOCK_SIZE;
|
||||
#endif /* WOLFSSL_AES_128 */
|
||||
|
||||
#ifdef WOLFSSL_AES_256
|
||||
if (XSTRCMP(name, EVP_AES_256_XTS) == 0)
|
||||
return AES_BLOCK_SIZE;
|
||||
return WC_AES_BLOCK_SIZE;
|
||||
#endif /* WOLFSSL_AES_256 */
|
||||
#endif /* WOLFSSL_AES_XTS && (!defined(HAVE_FIPS) || FIPS_VERSION_GE(5,3)) */
|
||||
|
||||
@@ -10618,14 +10618,14 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD* type)
|
||||
switch (macType) {
|
||||
case WC_HASH_TYPE_MD4:
|
||||
#ifndef NO_MD4
|
||||
wolfSSL_MD4_Update((MD4_CTX*)&ctx->hash, data,
|
||||
wolfSSL_MD4_Update((WOLFSSL_MD4_CTX*)&ctx->hash, data,
|
||||
(unsigned long)sz);
|
||||
ret = WOLFSSL_SUCCESS;
|
||||
#endif
|
||||
break;
|
||||
case WC_HASH_TYPE_MD5:
|
||||
#ifndef NO_MD5
|
||||
ret = wolfSSL_MD5_Update((MD5_CTX*)&ctx->hash, data,
|
||||
ret = wolfSSL_MD5_Update((WOLFSSL_MD5_CTX*)&ctx->hash, data,
|
||||
(unsigned long)sz);
|
||||
#endif
|
||||
break;
|
||||
@@ -10745,14 +10745,14 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD* type)
|
||||
switch (macType) {
|
||||
case WC_HASH_TYPE_MD4:
|
||||
#ifndef NO_MD4
|
||||
wolfSSL_MD4_Final(md, (MD4_CTX*)&ctx->hash);
|
||||
if (s) *s = MD4_DIGEST_SIZE;
|
||||
wolfSSL_MD4_Final(md, (WOLFSSL_MD4_CTX*)&ctx->hash);
|
||||
if (s) *s = WC_MD4_DIGEST_SIZE;
|
||||
ret = WOLFSSL_SUCCESS;
|
||||
#endif
|
||||
break;
|
||||
case WC_HASH_TYPE_MD5:
|
||||
#ifndef NO_MD5
|
||||
ret = wolfSSL_MD5_Final(md, (MD5_CTX*)&ctx->hash);
|
||||
ret = wolfSSL_MD5_Final(md, (WOLFSSL_MD5_CTX*)&ctx->hash);
|
||||
if (s) *s = WC_MD5_DIGEST_SIZE;
|
||||
#endif
|
||||
break;
|
||||
@@ -10931,7 +10931,7 @@ int wolfSSL_EVP_MD_block_size(const WOLFSSL_EVP_MD* type)
|
||||
#endif
|
||||
#ifndef NO_MD4
|
||||
if (XSTRCMP(type, "MD4") == 0) {
|
||||
return MD4_BLOCK_SIZE;
|
||||
return WC_MD4_BLOCK_SIZE;
|
||||
} else
|
||||
#endif
|
||||
#ifndef NO_MD5
|
||||
@@ -11006,7 +11006,7 @@ int wolfSSL_EVP_MD_size(const WOLFSSL_EVP_MD* type)
|
||||
#endif
|
||||
#ifndef NO_MD4
|
||||
if (XSTRCMP(type, "MD4") == 0) {
|
||||
return MD4_DIGEST_SIZE;
|
||||
return WC_MD4_DIGEST_SIZE;
|
||||
} else
|
||||
#endif
|
||||
#ifndef NO_MD5
|
||||
|
||||
@@ -322,12 +322,12 @@ int wc_HashGetDigestSize(enum wc_HashType hash_type)
|
||||
{
|
||||
case WC_HASH_TYPE_MD2:
|
||||
#ifdef WOLFSSL_MD2
|
||||
dig_size = MD2_DIGEST_SIZE;
|
||||
dig_size = WC_MD2_DIGEST_SIZE;
|
||||
#endif
|
||||
break;
|
||||
case WC_HASH_TYPE_MD4:
|
||||
#ifndef NO_MD4
|
||||
dig_size = MD4_DIGEST_SIZE;
|
||||
dig_size = WC_MD4_DIGEST_SIZE;
|
||||
#endif
|
||||
break;
|
||||
case WC_HASH_TYPE_MD5:
|
||||
@@ -441,12 +441,12 @@ int wc_HashGetBlockSize(enum wc_HashType hash_type)
|
||||
{
|
||||
case WC_HASH_TYPE_MD2:
|
||||
#ifdef WOLFSSL_MD2
|
||||
block_size = MD2_BLOCK_SIZE;
|
||||
block_size = WC_MD2_BLOCK_SIZE;
|
||||
#endif
|
||||
break;
|
||||
case WC_HASH_TYPE_MD4:
|
||||
#ifndef NO_MD4
|
||||
block_size = MD4_BLOCK_SIZE;
|
||||
block_size = WC_MD4_BLOCK_SIZE;
|
||||
#endif
|
||||
break;
|
||||
case WC_HASH_TYPE_MD5:
|
||||
|
||||
@@ -256,13 +256,13 @@ int wc_HpkeInit(Hpke* hpke, int kem, int kdf, int aead, void* heap)
|
||||
case HPKE_AES_128_GCM:
|
||||
hpke->Nk = AES_128_KEY_SIZE;
|
||||
hpke->Nn = GCM_NONCE_MID_SZ;
|
||||
hpke->Nt = AES_BLOCK_SIZE;
|
||||
hpke->Nt = WC_AES_BLOCK_SIZE;
|
||||
break;
|
||||
|
||||
case HPKE_AES_256_GCM:
|
||||
hpke->Nk = AES_256_KEY_SIZE;
|
||||
hpke->Nn = GCM_NONCE_MID_SZ;
|
||||
hpke->Nt = AES_BLOCK_SIZE;
|
||||
hpke->Nt = WC_AES_BLOCK_SIZE;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
+10
-10
@@ -968,7 +968,7 @@ static int wc_srtp_kdf_derive_key(byte* block, int indexSz, byte label,
|
||||
int i;
|
||||
int ret = 0;
|
||||
/* Calculate the number of full blocks needed for derived key. */
|
||||
int blocks = (int)(keySz / AES_BLOCK_SIZE);
|
||||
int blocks = (int)(keySz / WC_AES_BLOCK_SIZE);
|
||||
|
||||
/* XOR in label. */
|
||||
block[WC_SRTP_MAX_SALT - indexSz - 1] ^= label;
|
||||
@@ -976,19 +976,19 @@ static int wc_srtp_kdf_derive_key(byte* block, int indexSz, byte label,
|
||||
/* Set counter. */
|
||||
block[15] = (byte)i;
|
||||
/* Encrypt block into key buffer. */
|
||||
ret = wc_AesEcbEncrypt(aes, key, block, AES_BLOCK_SIZE);
|
||||
ret = wc_AesEcbEncrypt(aes, key, block, WC_AES_BLOCK_SIZE);
|
||||
/* Reposition for more derived key. */
|
||||
key += AES_BLOCK_SIZE;
|
||||
key += WC_AES_BLOCK_SIZE;
|
||||
/* Reduce the count of key bytes required. */
|
||||
keySz -= AES_BLOCK_SIZE;
|
||||
keySz -= WC_AES_BLOCK_SIZE;
|
||||
}
|
||||
/* Do any partial blocks. */
|
||||
if ((ret == 0) && (keySz > 0)) {
|
||||
byte enc[AES_BLOCK_SIZE];
|
||||
byte enc[WC_AES_BLOCK_SIZE];
|
||||
/* Set counter. */
|
||||
block[15] = (byte)i;
|
||||
/* Encrypt block into temporary. */
|
||||
ret = wc_AesEcbEncrypt(aes, enc, block, AES_BLOCK_SIZE);
|
||||
ret = wc_AesEcbEncrypt(aes, enc, block, WC_AES_BLOCK_SIZE);
|
||||
if (ret == 0) {
|
||||
/* Copy into key required amount. */
|
||||
XMEMCPY(key, enc, keySz);
|
||||
@@ -1029,7 +1029,7 @@ int wc_SRTP_KDF(const byte* key, word32 keySz, const byte* salt, word32 saltSz,
|
||||
word32 key2Sz, byte* key3, word32 key3Sz)
|
||||
{
|
||||
int ret = 0;
|
||||
byte block[AES_BLOCK_SIZE];
|
||||
byte block[WC_AES_BLOCK_SIZE];
|
||||
#ifdef WOLFSSL_SMALL_STACK
|
||||
Aes* aes = NULL;
|
||||
#else
|
||||
@@ -1124,7 +1124,7 @@ int wc_SRTCP_KDF_ex(const byte* key, word32 keySz, const byte* salt, word32 salt
|
||||
word32 key2Sz, byte* key3, word32 key3Sz, int idxLenIndicator)
|
||||
{
|
||||
int ret = 0;
|
||||
byte block[AES_BLOCK_SIZE];
|
||||
byte block[WC_AES_BLOCK_SIZE];
|
||||
#ifdef WOLFSSL_SMALL_STACK
|
||||
Aes* aes = NULL;
|
||||
#else
|
||||
@@ -1233,7 +1233,7 @@ int wc_SRTP_KDF_label(const byte* key, word32 keySz, const byte* salt,
|
||||
word32 outKeySz)
|
||||
{
|
||||
int ret = 0;
|
||||
byte block[AES_BLOCK_SIZE];
|
||||
byte block[WC_AES_BLOCK_SIZE];
|
||||
#ifdef WOLFSSL_SMALL_STACK
|
||||
Aes* aes = NULL;
|
||||
#else
|
||||
@@ -1316,7 +1316,7 @@ int wc_SRTCP_KDF_label(const byte* key, word32 keySz, const byte* salt,
|
||||
word32 outKeySz)
|
||||
{
|
||||
int ret = 0;
|
||||
byte block[AES_BLOCK_SIZE];
|
||||
byte block[WC_AES_BLOCK_SIZE];
|
||||
#ifdef WOLFSSL_SMALL_STACK
|
||||
Aes* aes = NULL;
|
||||
#else
|
||||
|
||||
+20
-20
@@ -40,16 +40,16 @@
|
||||
#endif
|
||||
|
||||
|
||||
void wc_InitMd2(Md2* md2)
|
||||
void wc_InitMd2(wc_Md2* md2)
|
||||
{
|
||||
XMEMSET(md2->X, 0, MD2_X_SIZE);
|
||||
XMEMSET(md2->C, 0, MD2_BLOCK_SIZE);
|
||||
XMEMSET(md2->buffer, 0, MD2_BLOCK_SIZE);
|
||||
XMEMSET(md2->X, 0, WC_MD2_X_SIZE);
|
||||
XMEMSET(md2->C, 0, WC_MD2_BLOCK_SIZE);
|
||||
XMEMSET(md2->buffer, 0, WC_MD2_BLOCK_SIZE);
|
||||
md2->count = 0;
|
||||
}
|
||||
|
||||
|
||||
void wc_Md2Update(Md2* md2, const byte* data, word32 len)
|
||||
void wc_Md2Update(wc_Md2* md2, const byte* data, word32 len)
|
||||
{
|
||||
static const byte S[256] =
|
||||
{
|
||||
@@ -74,30 +74,30 @@ void wc_Md2Update(Md2* md2, const byte* data, word32 len)
|
||||
};
|
||||
|
||||
while (len) {
|
||||
word32 L = (MD2_PAD_SIZE - md2->count) < len ?
|
||||
(MD2_PAD_SIZE - md2->count) : len;
|
||||
word32 L = (WC_MD2_PAD_SIZE - md2->count) < len ?
|
||||
(WC_MD2_PAD_SIZE - md2->count) : len;
|
||||
XMEMCPY(md2->buffer + md2->count, data, L);
|
||||
md2->count += L;
|
||||
data += L;
|
||||
len -= L;
|
||||
|
||||
if (md2->count == MD2_PAD_SIZE) {
|
||||
if (md2->count == WC_MD2_PAD_SIZE) {
|
||||
int i;
|
||||
byte t;
|
||||
|
||||
md2->count = 0;
|
||||
XMEMCPY(md2->X + MD2_PAD_SIZE, md2->buffer, MD2_PAD_SIZE);
|
||||
XMEMCPY(md2->X + WC_MD2_PAD_SIZE, md2->buffer, WC_MD2_PAD_SIZE);
|
||||
t = md2->C[15];
|
||||
|
||||
for(i = 0; i < MD2_PAD_SIZE; i++) {
|
||||
md2->X[32 + i] = md2->X[MD2_PAD_SIZE + i] ^ md2->X[i];
|
||||
for(i = 0; i < WC_MD2_PAD_SIZE; i++) {
|
||||
md2->X[32 + i] = md2->X[WC_MD2_PAD_SIZE + i] ^ md2->X[i];
|
||||
t = md2->C[i] ^= S[md2->buffer[i] ^ t];
|
||||
}
|
||||
|
||||
t=0;
|
||||
for(i = 0; i < 18; i++) {
|
||||
int j;
|
||||
for(j = 0; j < MD2_X_SIZE; j += 8) {
|
||||
for(j = 0; j < WC_MD2_X_SIZE; j += 8) {
|
||||
t = md2->X[j+0] ^= S[t];
|
||||
t = md2->X[j+1] ^= S[t];
|
||||
t = md2->X[j+2] ^= S[t];
|
||||
@@ -114,19 +114,19 @@ void wc_Md2Update(Md2* md2, const byte* data, word32 len)
|
||||
}
|
||||
|
||||
|
||||
void wc_Md2Final(Md2* md2, byte* hash)
|
||||
void wc_Md2Final(wc_Md2* md2, byte* hash)
|
||||
{
|
||||
byte padding[MD2_BLOCK_SIZE];
|
||||
word32 padLen = MD2_PAD_SIZE - md2->count;
|
||||
byte padding[WC_MD2_BLOCK_SIZE];
|
||||
word32 padLen = WC_MD2_PAD_SIZE - md2->count;
|
||||
word32 i;
|
||||
|
||||
for (i = 0; i < padLen; i++)
|
||||
padding[i] = (byte)padLen;
|
||||
|
||||
wc_Md2Update(md2, padding, padLen); /* cppcheck-suppress uninitvar */
|
||||
wc_Md2Update(md2, md2->C, MD2_BLOCK_SIZE);
|
||||
wc_Md2Update(md2, md2->C, WC_MD2_BLOCK_SIZE);
|
||||
|
||||
XMEMCPY(hash, md2->X, MD2_DIGEST_SIZE);
|
||||
XMEMCPY(hash, md2->X, WC_MD2_DIGEST_SIZE);
|
||||
|
||||
wc_InitMd2(md2);
|
||||
}
|
||||
@@ -135,13 +135,13 @@ void wc_Md2Final(Md2* md2, byte* hash)
|
||||
int wc_Md2Hash(const byte* data, word32 len, byte* hash)
|
||||
{
|
||||
#ifdef WOLFSSL_SMALL_STACK
|
||||
Md2* md2;
|
||||
wc_Md2* md2;
|
||||
#else
|
||||
Md2 md2[1];
|
||||
wc_Md2 md2[1];
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_SMALL_STACK
|
||||
md2 = (Md2*)XMALLOC(sizeof(Md2), NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
md2 = (wc_Md2*)XMALLOC(sizeof(wc_Md2), NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
if (md2 == NULL)
|
||||
return MEMORY_E;
|
||||
#endif
|
||||
|
||||
+19
-19
@@ -37,7 +37,7 @@
|
||||
#endif
|
||||
|
||||
|
||||
void wc_InitMd4(Md4* md4)
|
||||
void wc_InitMd4(wc_Md4* md4)
|
||||
{
|
||||
md4->digest[0] = 0x67452301L;
|
||||
md4->digest[1] = 0xefcdab89L;
|
||||
@@ -50,7 +50,7 @@ void wc_InitMd4(Md4* md4)
|
||||
}
|
||||
|
||||
|
||||
static void Transform(Md4* md4)
|
||||
static void Transform(wc_Md4* md4)
|
||||
{
|
||||
#define F(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))
|
||||
#define G(x, y, z) (((x) & (y)) | ((x) & (z)) | ((y) & (z)))
|
||||
@@ -130,7 +130,7 @@ static void Transform(Md4* md4)
|
||||
}
|
||||
|
||||
|
||||
static WC_INLINE void AddLength(Md4* md4, word32 len)
|
||||
static WC_INLINE void AddLength(wc_Md4* md4, word32 len)
|
||||
{
|
||||
word32 tmp = md4->loLen;
|
||||
if ( (md4->loLen += len) < tmp)
|
||||
@@ -138,32 +138,32 @@ static WC_INLINE void AddLength(Md4* md4, word32 len)
|
||||
}
|
||||
|
||||
|
||||
void wc_Md4Update(Md4* md4, const byte* data, word32 len)
|
||||
void wc_Md4Update(wc_Md4* md4, const byte* data, word32 len)
|
||||
{
|
||||
/* do block size increments */
|
||||
byte* local = (byte*)md4->buffer;
|
||||
|
||||
while (len) {
|
||||
word32 add = min(len, MD4_BLOCK_SIZE - md4->buffLen);
|
||||
word32 add = min(len, WC_MD4_BLOCK_SIZE - md4->buffLen);
|
||||
XMEMCPY(&local[md4->buffLen], data, add);
|
||||
|
||||
md4->buffLen += add;
|
||||
data += add;
|
||||
len -= add;
|
||||
|
||||
if (md4->buffLen == MD4_BLOCK_SIZE) {
|
||||
if (md4->buffLen == WC_MD4_BLOCK_SIZE) {
|
||||
#ifdef BIG_ENDIAN_ORDER
|
||||
ByteReverseWords(md4->buffer, md4->buffer, MD4_BLOCK_SIZE);
|
||||
ByteReverseWords(md4->buffer, md4->buffer, WC_MD4_BLOCK_SIZE);
|
||||
#endif
|
||||
Transform(md4);
|
||||
AddLength(md4, MD4_BLOCK_SIZE);
|
||||
AddLength(md4, WC_MD4_BLOCK_SIZE);
|
||||
md4->buffLen = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void wc_Md4Final(Md4* md4, byte* hash)
|
||||
void wc_Md4Final(wc_Md4* md4, byte* hash)
|
||||
{
|
||||
byte* local = (byte*)md4->buffer;
|
||||
|
||||
@@ -172,17 +172,17 @@ void wc_Md4Final(Md4* md4, byte* hash)
|
||||
local[md4->buffLen++] = 0x80; /* add 1 */
|
||||
|
||||
/* pad with zeros */
|
||||
if (md4->buffLen > MD4_PAD_SIZE) {
|
||||
XMEMSET(&local[md4->buffLen], 0, MD4_BLOCK_SIZE - md4->buffLen);
|
||||
md4->buffLen += MD4_BLOCK_SIZE - md4->buffLen;
|
||||
if (md4->buffLen > WC_MD4_PAD_SIZE) {
|
||||
XMEMSET(&local[md4->buffLen], 0, WC_MD4_BLOCK_SIZE - md4->buffLen);
|
||||
md4->buffLen += WC_MD4_BLOCK_SIZE - md4->buffLen;
|
||||
|
||||
#ifdef BIG_ENDIAN_ORDER
|
||||
ByteReverseWords(md4->buffer, md4->buffer, MD4_BLOCK_SIZE);
|
||||
ByteReverseWords(md4->buffer, md4->buffer, WC_MD4_BLOCK_SIZE);
|
||||
#endif
|
||||
Transform(md4);
|
||||
md4->buffLen = 0;
|
||||
}
|
||||
XMEMSET(&local[md4->buffLen], 0, MD4_PAD_SIZE - md4->buffLen);
|
||||
XMEMSET(&local[md4->buffLen], 0, WC_MD4_PAD_SIZE - md4->buffLen);
|
||||
|
||||
/* put lengths in bits */
|
||||
md4->hiLen = (md4->loLen >> (8*sizeof(md4->loLen) - 3)) +
|
||||
@@ -191,17 +191,17 @@ void wc_Md4Final(Md4* md4, byte* hash)
|
||||
|
||||
/* store lengths */
|
||||
#ifdef BIG_ENDIAN_ORDER
|
||||
ByteReverseWords(md4->buffer, md4->buffer, MD4_BLOCK_SIZE);
|
||||
ByteReverseWords(md4->buffer, md4->buffer, WC_MD4_BLOCK_SIZE);
|
||||
#endif
|
||||
/* ! length ordering dependent on digest endian type ! */
|
||||
XMEMCPY(&local[MD4_PAD_SIZE], &md4->loLen, sizeof(word32));
|
||||
XMEMCPY(&local[MD4_PAD_SIZE + sizeof(word32)], &md4->hiLen, sizeof(word32));
|
||||
XMEMCPY(&local[WC_MD4_PAD_SIZE], &md4->loLen, sizeof(word32));
|
||||
XMEMCPY(&local[WC_MD4_PAD_SIZE + sizeof(word32)], &md4->hiLen, sizeof(word32));
|
||||
|
||||
Transform(md4);
|
||||
#ifdef BIG_ENDIAN_ORDER
|
||||
ByteReverseWords(md4->digest, md4->digest, MD4_DIGEST_SIZE);
|
||||
ByteReverseWords(md4->digest, md4->digest, WC_MD4_DIGEST_SIZE);
|
||||
#endif
|
||||
XMEMCPY(hash, md4->digest, MD4_DIGEST_SIZE);
|
||||
XMEMCPY(hash, md4->digest, WC_MD4_DIGEST_SIZE);
|
||||
|
||||
wc_InitMd4(md4); /* reset state */
|
||||
}
|
||||
|
||||
@@ -695,7 +695,7 @@ static int wc_PKCS7_GetOIDBlockSize(int oid)
|
||||
case AES256CCMb:
|
||||
#endif
|
||||
#endif
|
||||
blockSz = AES_BLOCK_SIZE;
|
||||
blockSz = WC_AES_BLOCK_SIZE;
|
||||
break;
|
||||
#endif /* !NO_AES */
|
||||
|
||||
@@ -8214,7 +8214,7 @@ static int wc_PKCS7_EncryptContent(wc_PKCS7* pkcs7, int encryptOID, byte* key,
|
||||
#ifdef WOLFSSL_AES_256
|
||||
(encryptOID == AES256CBCb && keySz != 32 ) ||
|
||||
#endif
|
||||
(ivSz != AES_BLOCK_SIZE) )
|
||||
(ivSz != WC_AES_BLOCK_SIZE) )
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
#ifdef WOLFSSL_SMALL_STACK
|
||||
@@ -8453,7 +8453,7 @@ static int wc_PKCS7_DecryptContent(wc_PKCS7* pkcs7, int encryptOID, byte* key,
|
||||
#ifdef WOLFSSL_AES_256
|
||||
(encryptOID == AES256CBCb && keySz != 32 ) ||
|
||||
#endif
|
||||
(ivSz != AES_BLOCK_SIZE) )
|
||||
(ivSz != WC_AES_BLOCK_SIZE) )
|
||||
return BAD_FUNC_ARG;
|
||||
#ifdef WOLFSSL_SMALL_STACK
|
||||
if ((aes = (Aes *)XMALLOC(sizeof *aes, NULL,
|
||||
@@ -12600,7 +12600,7 @@ int wc_PKCS7_EncodeAuthEnvelopedData(wc_PKCS7* pkcs7, byte* output,
|
||||
byte encContentOctet[MAX_OCTET_STR_SZ];
|
||||
byte macOctetString[MAX_OCTET_STR_SZ];
|
||||
|
||||
byte authTag[AES_BLOCK_SIZE];
|
||||
byte authTag[WC_AES_BLOCK_SIZE];
|
||||
byte nonce[GCM_NONCE_MID_SZ]; /* GCM nonce is larger than CCM */
|
||||
byte macInt[MAX_VERSION_SZ];
|
||||
byte algoParamSeq[MAX_SEQ_SZ];
|
||||
@@ -13135,7 +13135,7 @@ WOLFSSL_API int wc_PKCS7_DecodeAuthEnvelopedData(wc_PKCS7* pkcs7, byte* in,
|
||||
word32 pkiMsgSz = inSz;
|
||||
|
||||
int expBlockSz = 0, blockKeySz = 0;
|
||||
byte authTag[AES_BLOCK_SIZE];
|
||||
byte authTag[WC_AES_BLOCK_SIZE];
|
||||
byte nonce[GCM_NONCE_MID_SZ]; /* GCM nonce is larger than CCM */
|
||||
int nonceSz = 0, authTagSz = 0, macSz = 0;
|
||||
|
||||
@@ -13653,7 +13653,7 @@ authenv_atrbend:
|
||||
|
||||
if (pkcs7->stream->tagSz > 0) {
|
||||
authTagSz = (int)pkcs7->stream->tagSz;
|
||||
if (authTagSz > AES_BLOCK_SIZE) {
|
||||
if (authTagSz > WC_AES_BLOCK_SIZE) {
|
||||
WOLFSSL_MSG("PKCS7 saved tag is too large");
|
||||
ret = BUFFER_E;
|
||||
break;
|
||||
|
||||
@@ -3671,7 +3671,7 @@ static int Pkcs11AesCbcEncrypt(Pkcs11Session* session, wc_CryptoInfo* info)
|
||||
|
||||
if (ret == 0) {
|
||||
mech.mechanism = CKM_AES_CBC;
|
||||
mech.ulParameterLen = AES_BLOCK_SIZE;
|
||||
mech.ulParameterLen = WC_AES_BLOCK_SIZE;
|
||||
mech.pParameter = (CK_BYTE_PTR)info->cipher.aescbc.aes->reg;
|
||||
|
||||
rv = session->func->C_EncryptInit(session->handle, &mech, key);
|
||||
@@ -3747,7 +3747,7 @@ static int Pkcs11AesCbcDecrypt(Pkcs11Session* session, wc_CryptoInfo* info)
|
||||
|
||||
if (ret == 0) {
|
||||
mech.mechanism = CKM_AES_CBC;
|
||||
mech.ulParameterLen = AES_BLOCK_SIZE;
|
||||
mech.ulParameterLen = WC_AES_BLOCK_SIZE;
|
||||
mech.pParameter = (CK_BYTE_PTR)info->cipher.aescbc.aes->reg;
|
||||
|
||||
rv = session->func->C_DecryptInit(session->handle, &mech, key);
|
||||
|
||||
+375
-375
File diff suppressed because it is too large
Load Diff
+4
-3
@@ -1021,7 +1021,8 @@
|
||||
#endif
|
||||
|
||||
#if defined(NO_AES) || !defined(HAVE_AES_DECRYPT)
|
||||
#define AES_BLOCK_SIZE 16
|
||||
#undef WC_AES_BLOCK_SIZE
|
||||
#define WC_AES_BLOCK_SIZE 16
|
||||
#undef BUILD_AES
|
||||
#else
|
||||
#undef BUILD_AES
|
||||
@@ -1755,7 +1756,7 @@ enum Misc {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
MAX_IV_SZ = AES_BLOCK_SIZE,
|
||||
MAX_IV_SZ = WC_AES_BLOCK_SIZE,
|
||||
|
||||
AEAD_SEQ_OFFSET = 4, /* Auth Data: Sequence number */
|
||||
AEAD_TYPE_OFFSET = 8, /* Auth Data: Type */
|
||||
@@ -4372,7 +4373,7 @@ typedef struct Ciphers {
|
||||
byte* nonce;
|
||||
#endif
|
||||
#ifdef HAVE_CAMELLIA
|
||||
Camellia* cam;
|
||||
wc_Camellia* cam;
|
||||
#endif
|
||||
#ifdef HAVE_CHACHA
|
||||
ChaCha* chacha;
|
||||
|
||||
+20
-13
@@ -53,27 +53,37 @@
|
||||
typedef struct WOLFSSL_AES_KEY {
|
||||
ALIGN16 void *buf[(sizeof(Aes) / sizeof(void *)) + 1];
|
||||
} WOLFSSL_AES_KEY;
|
||||
typedef WOLFSSL_AES_KEY AES_KEY;
|
||||
|
||||
WOLFSSL_API int wolfSSL_AES_set_encrypt_key(
|
||||
const unsigned char *key, const int bits, AES_KEY *aes);
|
||||
const unsigned char *key, const int bits, WOLFSSL_AES_KEY *aes);
|
||||
WOLFSSL_API int wolfSSL_AES_set_decrypt_key(
|
||||
const unsigned char *key, const int bits, AES_KEY *aes);
|
||||
const unsigned char *key, const int bits, WOLFSSL_AES_KEY *aes);
|
||||
WOLFSSL_API void wolfSSL_AES_cbc_encrypt(
|
||||
const unsigned char *in, unsigned char* out, size_t len, AES_KEY *key,
|
||||
const unsigned char *in, unsigned char* out, size_t len, WOLFSSL_AES_KEY *key,
|
||||
unsigned char* iv, const int enc);
|
||||
WOLFSSL_API void wolfSSL_AES_ecb_encrypt(
|
||||
const unsigned char *in, unsigned char* out, AES_KEY *key, const int enc);
|
||||
const unsigned char *in, unsigned char* out, WOLFSSL_AES_KEY *key, const int enc);
|
||||
WOLFSSL_API void wolfSSL_AES_cfb128_encrypt(
|
||||
const unsigned char *in, unsigned char* out, size_t len, AES_KEY *key,
|
||||
const unsigned char *in, unsigned char* out, size_t len, WOLFSSL_AES_KEY *key,
|
||||
unsigned char* iv, int* num, const int enc);
|
||||
WOLFSSL_API int wolfSSL_AES_wrap_key(
|
||||
AES_KEY *key, const unsigned char *iv, unsigned char *out,
|
||||
WOLFSSL_AES_KEY *key, const unsigned char *iv, unsigned char *out,
|
||||
const unsigned char *in, unsigned int inlen);
|
||||
WOLFSSL_API int wolfSSL_AES_unwrap_key(
|
||||
AES_KEY *key, const unsigned char *iv, unsigned char *out,
|
||||
WOLFSSL_AES_KEY *key, const unsigned char *iv, unsigned char *out,
|
||||
const unsigned char *in, unsigned int inlen);
|
||||
|
||||
#ifdef WOLFSSL_AES_DIRECT
|
||||
WOLFSSL_API void wolfSSL_AES_encrypt(
|
||||
const unsigned char* input, unsigned char* output, WOLFSSL_AES_KEY *key);
|
||||
WOLFSSL_API void wolfSSL_AES_decrypt(
|
||||
const unsigned char* input, unsigned char* output, WOLFSSL_AES_KEY *key);
|
||||
#endif /* WOLFSSL_AES_DIRECT */
|
||||
|
||||
#ifndef OPENSSL_COEXIST
|
||||
|
||||
typedef WOLFSSL_AES_KEY AES_KEY;
|
||||
|
||||
#define AES_cbc_encrypt wolfSSL_AES_cbc_encrypt
|
||||
#define AES_ecb_encrypt wolfSSL_AES_ecb_encrypt
|
||||
#define AES_cfb128_encrypt wolfSSL_AES_cfb128_encrypt
|
||||
@@ -83,11 +93,6 @@ WOLFSSL_API int wolfSSL_AES_unwrap_key(
|
||||
#define AES_unwrap_key wolfSSL_AES_unwrap_key
|
||||
|
||||
#ifdef WOLFSSL_AES_DIRECT
|
||||
WOLFSSL_API void wolfSSL_AES_encrypt(
|
||||
const unsigned char* input, unsigned char* output, AES_KEY *key);
|
||||
WOLFSSL_API void wolfSSL_AES_decrypt(
|
||||
const unsigned char* input, unsigned char* output, AES_KEY *key);
|
||||
|
||||
#define AES_encrypt wolfSSL_AES_encrypt
|
||||
#define AES_decrypt wolfSSL_AES_decrypt
|
||||
#endif /* WOLFSSL_AES_DIRECT */
|
||||
@@ -99,6 +104,8 @@ WOLFSSL_API void wolfSSL_AES_decrypt(
|
||||
#define AES_DECRYPT AES_DECRYPTION
|
||||
#endif
|
||||
|
||||
#endif /* !OPENSSL_COEXIST */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
@@ -34,8 +34,6 @@ typedef struct WOLFSSL_CMAC_CTX {
|
||||
WOLFSSL_EVP_CIPHER_CTX* cctx;
|
||||
} WOLFSSL_CMAC_CTX;
|
||||
|
||||
typedef WOLFSSL_CMAC_CTX CMAC_CTX;
|
||||
|
||||
WOLFSSL_API WOLFSSL_CMAC_CTX* wolfSSL_CMAC_CTX_new(void);
|
||||
WOLFSSL_API void wolfSSL_CMAC_CTX_free(WOLFSSL_CMAC_CTX *ctx);
|
||||
WOLFSSL_API WOLFSSL_EVP_CIPHER_CTX* wolfSSL_CMAC_CTX_get0_cipher_ctx(
|
||||
@@ -48,6 +46,10 @@ WOLFSSL_API int wolfSSL_CMAC_Update(
|
||||
WOLFSSL_API int wolfSSL_CMAC_Final(
|
||||
WOLFSSL_CMAC_CTX* ctx, unsigned char* out, size_t* len);
|
||||
|
||||
#ifndef OPENSSL_COEXIST
|
||||
|
||||
typedef WOLFSSL_CMAC_CTX CMAC_CTX;
|
||||
|
||||
#define CMAC_CTX_new wolfSSL_CMAC_CTX_new
|
||||
#define CMAC_CTX_free wolfSSL_CMAC_CTX_free
|
||||
#define CMAC_CTX_get0_cipher_ctx wolfSSL_CMAC_CTX_get0_cipher_ctx
|
||||
@@ -55,6 +57,8 @@ WOLFSSL_API int wolfSSL_CMAC_Final(
|
||||
#define CMAC_Update wolfSSL_CMAC_Update
|
||||
#define CMAC_Final wolfSSL_CMAC_Final
|
||||
|
||||
#endif /* !OPENSSL_COEXIST */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
+11
-2
@@ -49,8 +49,8 @@ typedef unsigned int WOLFSSL_DES_LONG;
|
||||
|
||||
|
||||
enum {
|
||||
DES_ENCRYPT = 1,
|
||||
DES_DECRYPT = 0
|
||||
WC_DES_ENCRYPT = 1,
|
||||
WC_DES_DECRYPT = 0
|
||||
};
|
||||
|
||||
|
||||
@@ -87,6 +87,13 @@ WOLFSSL_API void wolfSSL_DES_ecb_encrypt(WOLFSSL_DES_cblock* desa,
|
||||
WOLFSSL_API int wolfSSL_DES_check_key_parity(WOLFSSL_DES_cblock *myDes);
|
||||
|
||||
|
||||
#ifndef OPENSSL_COEXIST
|
||||
|
||||
enum {
|
||||
DES_ENCRYPT = WC_DES_ENCRYPT,
|
||||
DES_DECRYPT = WC_DES_DECRYPT
|
||||
};
|
||||
|
||||
typedef WOLFSSL_DES_cblock DES_cblock;
|
||||
typedef WOLFSSL_const_DES_cblock const_DES_cblock;
|
||||
typedef WOLFSSL_DES_key_schedule DES_key_schedule;
|
||||
@@ -106,6 +113,8 @@ typedef WOLFSSL_DES_LONG DES_LONG;
|
||||
#define DES_cbc_cksum wolfSSL_DES_cbc_cksum
|
||||
#define DES_check_key_parity wolfSSL_DES_check_key_parity
|
||||
|
||||
#endif /* !OPENSSL_COEXIST */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
@@ -689,7 +689,7 @@ struct WOLFSSL_EVP_CIPHER_CTX {
|
||||
unsigned char cipherType;
|
||||
#if !defined(NO_AES)
|
||||
/* working iv pointer into cipher */
|
||||
ALIGN16 unsigned char iv[AES_BLOCK_SIZE];
|
||||
ALIGN16 unsigned char iv[WC_AES_BLOCK_SIZE];
|
||||
#elif defined(WOLFSSL_SM4)
|
||||
ALIGN16 unsigned char iv[SM4_BLOCK_SIZE];
|
||||
#elif defined(HAVE_CHACHA) && defined(HAVE_POLY1305)
|
||||
@@ -722,7 +722,7 @@ struct WOLFSSL_EVP_CIPHER_CTX {
|
||||
defined(WOLFSSL_SM4_GCM) || defined(WOLFSSL_SM4_CCM) || \
|
||||
(defined(HAVE_CHACHA) && defined(HAVE_POLY1305))
|
||||
#if defined(HAVE_AESGCM) || defined(HAVE_AESCCM) || defined(HAVE_ARIA)
|
||||
ALIGN16 unsigned char authTag[AES_BLOCK_SIZE];
|
||||
ALIGN16 unsigned char authTag[WC_AES_BLOCK_SIZE];
|
||||
#elif defined(WOLFSSL_SM4_GCM) || defined(WOLFSSL_SM4_CCM)
|
||||
ALIGN16 unsigned char authTag[SM4_BLOCK_SIZE];
|
||||
#else
|
||||
|
||||
@@ -46,6 +46,7 @@ WOLFSSL_API void wolfSSL_MD4_Update(WOLFSSL_MD4_CTX* md4, const void* data,
|
||||
unsigned long len);
|
||||
WOLFSSL_API void wolfSSL_MD4_Final(unsigned char* digest, WOLFSSL_MD4_CTX* md4);
|
||||
|
||||
#ifndef OPENSSL_COEXIST
|
||||
|
||||
typedef WOLFSSL_MD4_CTX MD4_CTX;
|
||||
|
||||
@@ -53,6 +54,8 @@ typedef WOLFSSL_MD4_CTX MD4_CTX;
|
||||
#define MD4_Update wolfSSL_MD4_Update
|
||||
#define MD4_Final wolfSSL_MD4_Final
|
||||
|
||||
#endif /* !OPENSSL_COEXIST */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
@@ -58,6 +58,8 @@ WOLFSSL_API int wolfSSL_MD5_Transform(WOLFSSL_MD5_CTX* md5, const unsigned char*
|
||||
WOLFSSL_API unsigned char *wolfSSL_MD5(const unsigned char* data, size_t len,
|
||||
unsigned char* hash);
|
||||
|
||||
#ifndef OPENSSL_COEXIST
|
||||
|
||||
typedef WOLFSSL_MD5_CTX MD5_CTX;
|
||||
|
||||
#define MD5_Init wolfSSL_MD5_Init
|
||||
@@ -95,6 +97,8 @@ typedef WOLFSSL_MD5_CTX MD5_CTX;
|
||||
#define MD5_DIGEST_LENGTH MD5_DIGEST_SIZE
|
||||
#endif
|
||||
|
||||
#endif /* !OPENSSL_COEXIST */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
@@ -41,16 +41,21 @@ typedef struct WOLFSSL_RC4_KEY {
|
||||
/* big enough for Arc4 from wolfssl/wolfcrypt/arc4.h */
|
||||
void* holder[(272 + WC_ASYNC_DEV_SIZE) / sizeof(void*)];
|
||||
} WOLFSSL_RC4_KEY;
|
||||
typedef WOLFSSL_RC4_KEY RC4_KEY;
|
||||
|
||||
WOLFSSL_API void wolfSSL_RC4_set_key(WOLFSSL_RC4_KEY* key, int len,
|
||||
const unsigned char* data);
|
||||
WOLFSSL_API void wolfSSL_RC4(WOLFSSL_RC4_KEY* key, size_t len,
|
||||
const unsigned char* in, unsigned char* out);
|
||||
|
||||
#ifndef OPENSSL_COEXIST
|
||||
|
||||
typedef WOLFSSL_RC4_KEY RC4_KEY;
|
||||
|
||||
#define RC4 wolfSSL_RC4
|
||||
#define RC4_set_key wolfSSL_RC4_set_key
|
||||
|
||||
#endif /* !OPENSSL_COEXIST */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
@@ -24,6 +24,10 @@
|
||||
|
||||
#include <wolfssl/wolfcrypt/srp.h>
|
||||
|
||||
#ifndef OPENSSL_COEXIST
|
||||
|
||||
#define SRP_MINIMAL_N SRP_MODULUS_MIN_BITS
|
||||
|
||||
#endif /* !OPENSSL_COEXIST */
|
||||
|
||||
#endif /* WOLFSSL_SRP_H_ */
|
||||
|
||||
+88
-65
@@ -36,60 +36,45 @@
|
||||
|
||||
#if defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL)
|
||||
|
||||
#define EXFLAG_KUSAGE 0x2
|
||||
#define EXFLAG_XKUSAGE 0x4
|
||||
#define WOLFSSL_EXFLAG_KUSAGE 0x2
|
||||
#define WOLFSSL_EXFLAG_XKUSAGE 0x4
|
||||
|
||||
#define KU_DIGITAL_SIGNATURE KEYUSE_DIGITAL_SIG
|
||||
#define KU_NON_REPUDIATION KEYUSE_CONTENT_COMMIT
|
||||
#define KU_KEY_ENCIPHERMENT KEYUSE_KEY_ENCIPHER
|
||||
#define KU_DATA_ENCIPHERMENT KEYUSE_DATA_ENCIPHER
|
||||
#define KU_KEY_AGREEMENT KEYUSE_KEY_AGREE
|
||||
#define KU_KEY_CERT_SIGN KEYUSE_KEY_CERT_SIGN
|
||||
#define KU_CRL_SIGN KEYUSE_CRL_SIGN
|
||||
#define KU_ENCIPHER_ONLY KEYUSE_ENCIPHER_ONLY
|
||||
#define KU_DECIPHER_ONLY KEYUSE_DECIPHER_ONLY
|
||||
#define WOLFSSL_XKU_SSL_SERVER 0x1
|
||||
#define WOLFSSL_XKU_SSL_CLIENT 0x2
|
||||
#define WOLFSSL_XKU_SMIME 0x4
|
||||
#define WOLFSSL_XKU_CODE_SIGN 0x8
|
||||
#define WOLFSSL_XKU_SGC 0x10
|
||||
#define WOLFSSL_XKU_OCSP_SIGN 0x20
|
||||
#define WOLFSSL_XKU_TIMESTAMP 0x40
|
||||
#define WOLFSSL_XKU_DVCS 0x80
|
||||
#define WOLFSSL_XKU_ANYEKU 0x100
|
||||
|
||||
#define XKU_SSL_SERVER 0x1
|
||||
#define XKU_SSL_CLIENT 0x2
|
||||
#define XKU_SMIME 0x4
|
||||
#define XKU_CODE_SIGN 0x8
|
||||
#define XKU_SGC 0x10
|
||||
#define XKU_OCSP_SIGN 0x20
|
||||
#define XKU_TIMESTAMP 0x40
|
||||
#define XKU_DVCS 0x80
|
||||
#define XKU_ANYEKU 0x100
|
||||
|
||||
#define X509_PURPOSE_SSL_CLIENT 0
|
||||
#define X509_PURPOSE_SSL_SERVER 1
|
||||
|
||||
#define NS_SSL_CLIENT WC_NS_SSL_CLIENT
|
||||
#define NS_SSL_SERVER WC_NS_SSL_SERVER
|
||||
|
||||
/* Forward reference */
|
||||
#define WOLFSSL_X509_PURPOSE_SSL_CLIENT 0
|
||||
#define WOLFSSL_X509_PURPOSE_SSL_SERVER 1
|
||||
|
||||
#if defined(OPENSSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER >= 0x0090801fL
|
||||
typedef void *(*X509V3_EXT_D2I)(void *, const unsigned char **, long);
|
||||
typedef void *(*WOLFSSL_X509V3_EXT_D2I)(void *, const unsigned char **, long);
|
||||
#else
|
||||
typedef void *(*X509V3_EXT_D2I)(void *, unsigned char **, long);
|
||||
typedef void *(*WOLFSSL_X509V3_EXT_D2I)(void *, unsigned char **, long);
|
||||
#endif
|
||||
typedef int (*X509V3_EXT_I2D) (void *, unsigned char **);
|
||||
typedef WOLF_STACK_OF(CONF_VALUE) *(*X509V3_EXT_I2V) (
|
||||
typedef int (*WOLFSSL_X509V3_EXT_I2D) (void *, unsigned char **);
|
||||
typedef WOLF_STACK_OF(CONF_VALUE) *(*WOLFSSL_X509V3_EXT_I2V) (
|
||||
struct WOLFSSL_v3_ext_method *method,
|
||||
void *ext, WOLF_STACK_OF(CONF_VALUE) *extlist);
|
||||
typedef char *(*X509V3_EXT_I2S)(struct WOLFSSL_v3_ext_method *method, void *ext);
|
||||
typedef int (*X509V3_EXT_I2R) (struct WOLFSSL_v3_ext_method *method,
|
||||
typedef char *(*WOLFSSL_X509V3_EXT_I2S)(struct WOLFSSL_v3_ext_method *method, void *ext);
|
||||
typedef int (*WOLFSSL_X509V3_EXT_I2R) (struct WOLFSSL_v3_ext_method *method,
|
||||
void *ext, WOLFSSL_BIO *out, int indent);
|
||||
typedef struct WOLFSSL_v3_ext_method X509V3_EXT_METHOD;
|
||||
typedef struct WOLFSSL_v3_ext_method WOLFSSL_X509V3_EXT_METHOD;
|
||||
|
||||
struct WOLFSSL_v3_ext_method {
|
||||
int ext_nid;
|
||||
int ext_flags;
|
||||
void *usr_data;
|
||||
X509V3_EXT_D2I d2i;
|
||||
X509V3_EXT_I2D i2d;
|
||||
X509V3_EXT_I2V i2v;
|
||||
X509V3_EXT_I2S i2s;
|
||||
X509V3_EXT_I2R i2r;
|
||||
WOLFSSL_X509V3_EXT_D2I d2i;
|
||||
WOLFSSL_X509V3_EXT_I2D i2d;
|
||||
WOLFSSL_X509V3_EXT_I2V i2v;
|
||||
WOLFSSL_X509V3_EXT_I2S i2s;
|
||||
WOLFSSL_X509V3_EXT_I2R i2r;
|
||||
};
|
||||
|
||||
struct WOLFSSL_X509_EXTENSION {
|
||||
@@ -113,31 +98,6 @@ struct WOLFSSL_X509_EXTENSION {
|
||||
#define WOLFSSL_GEN_RID 8
|
||||
#define WOLFSSL_GEN_IA5 9
|
||||
|
||||
#ifndef OPENSSL_COEXIST
|
||||
|
||||
#define GEN_OTHERNAME WOLFSSL_GEN_OTHERNAME
|
||||
#define GEN_EMAIL WOLFSSL_GEN_EMAIL
|
||||
#define GEN_DNS WOLFSSL_GEN_DNS
|
||||
#define GEN_X400 WOLFSSL_GEN_X400
|
||||
#define GEN_DIRNAME WOLFSSL_GEN_DIRNAME
|
||||
#define GEN_EDIPARTY WOLFSSL_GEN_EDIPARTY
|
||||
#define GEN_URI WOLFSSL_GEN_URI
|
||||
#define GEN_IPADD WOLFSSL_GEN_IPADD
|
||||
#define GEN_RID WOLFSSL_GEN_RID
|
||||
#define GEN_IA5 WOLFSSL_GEN_IA5
|
||||
|
||||
#define GENERAL_NAME WOLFSSL_GENERAL_NAME
|
||||
|
||||
#define X509V3_CTX WOLFSSL_X509V3_CTX
|
||||
|
||||
#define CTX_TEST 0x1
|
||||
|
||||
typedef struct WOLFSSL_AUTHORITY_KEYID AUTHORITY_KEYID;
|
||||
typedef struct WOLFSSL_BASIC_CONSTRAINTS BASIC_CONSTRAINTS;
|
||||
typedef struct WOLFSSL_ACCESS_DESCRIPTION ACCESS_DESCRIPTION;
|
||||
|
||||
#endif /* !OPENSSL_COEXIST */
|
||||
|
||||
typedef WOLF_STACK_OF(WOLFSSL_ACCESS_DESCRIPTION) WOLFSSL_AUTHORITY_INFO_ACCESS;
|
||||
|
||||
WOLFSSL_API WOLFSSL_BASIC_CONSTRAINTS* wolfSSL_BASIC_CONSTRAINTS_new(void);
|
||||
@@ -174,6 +134,67 @@ WOLFSSL_API int wolfSSL_X509V3_EXT_add_nconf(WOLFSSL_CONF *conf,
|
||||
WOLFSSL_X509V3_CTX *ctx, const char *section, WOLFSSL_X509 *cert);
|
||||
WOLFSSL_API WOLFSSL_ASN1_STRING* wolfSSL_a2i_IPADDRESS(const char* ipa);
|
||||
|
||||
#ifndef OPENSSL_COEXIST
|
||||
|
||||
#define EXFLAG_KUSAGE WOLFSSL_EXFLAG_KUSAGE
|
||||
#define EXFLAG_XKUSAGE WOLFSSL_EXFLAG_XKUSAGE
|
||||
|
||||
#define KU_DIGITAL_SIGNATURE KEYUSE_DIGITAL_SIG
|
||||
#define KU_NON_REPUDIATION KEYUSE_CONTENT_COMMIT
|
||||
#define KU_KEY_ENCIPHERMENT KEYUSE_KEY_ENCIPHER
|
||||
#define KU_DATA_ENCIPHERMENT KEYUSE_DATA_ENCIPHER
|
||||
#define KU_KEY_AGREEMENT KEYUSE_KEY_AGREE
|
||||
#define KU_KEY_CERT_SIGN KEYUSE_KEY_CERT_SIGN
|
||||
#define KU_CRL_SIGN KEYUSE_CRL_SIGN
|
||||
#define KU_ENCIPHER_ONLY KEYUSE_ENCIPHER_ONLY
|
||||
#define KU_DECIPHER_ONLY KEYUSE_DECIPHER_ONLY
|
||||
|
||||
#define XKU_SSL_SERVER WOLFSSL_XKU_SSL_SERVER
|
||||
#define XKU_SSL_CLIENT WOLFSSL_XKU_SSL_CLIENT
|
||||
#define XKU_SMIME WOLFSSL_XKU_SMIME
|
||||
#define XKU_CODE_SIGN WOLFSSL_XKU_CODE_SIGN
|
||||
#define XKU_SGC WOLFSSL_XKU_SGC
|
||||
#define XKU_OCSP_SIGN WOLFSSL_XKU_OCSP_SIGN
|
||||
#define XKU_TIMESTAMP WOLFSSL_XKU_TIMESTAMP
|
||||
#define XKU_DVCS WOLFSSL_XKU_DVCS
|
||||
#define XKU_ANYEKU WOLFSSL_XKU_ANYEKU
|
||||
|
||||
#define X509_PURPOSE_SSL_CLIENT WOLFSSL_X509_PURPOSE_SSL_CLIENT
|
||||
#define X509_PURPOSE_SSL_SERVER WOLFSSL_X509_PURPOSE_SSL_SERVER
|
||||
|
||||
#define NS_SSL_CLIENT WC_NS_SSL_CLIENT
|
||||
#define NS_SSL_SERVER WC_NS_SSL_SERVER
|
||||
|
||||
/* Forward reference */
|
||||
|
||||
#define X509V3_EXT_D2I WOLFSSL_X509V3_EXT_D2I
|
||||
#define X509V3_EXT_I2D WOLFSSL_X509V3_EXT_I2D
|
||||
#define X509V3_EXT_I2V WOLFSSL_X509V3_EXT_I2V
|
||||
#define X509V3_EXT_I2S WOLFSSL_X509V3_EXT_I2S
|
||||
#define X509V3_EXT_I2R WOLFSSL_X509V3_EXT_I2R
|
||||
typedef struct WOLFSSL_v3_ext_method X509V3_EXT_METHOD;
|
||||
|
||||
#define GEN_OTHERNAME WOLFSSL_GEN_OTHERNAME
|
||||
#define GEN_EMAIL WOLFSSL_GEN_EMAIL
|
||||
#define GEN_DNS WOLFSSL_GEN_DNS
|
||||
#define GEN_X400 WOLFSSL_GEN_X400
|
||||
#define GEN_DIRNAME WOLFSSL_GEN_DIRNAME
|
||||
#define GEN_EDIPARTY WOLFSSL_GEN_EDIPARTY
|
||||
#define GEN_URI WOLFSSL_GEN_URI
|
||||
#define GEN_IPADD WOLFSSL_GEN_IPADD
|
||||
#define GEN_RID WOLFSSL_GEN_RID
|
||||
#define GEN_IA5 WOLFSSL_GEN_IA5
|
||||
|
||||
#define GENERAL_NAME WOLFSSL_GENERAL_NAME
|
||||
|
||||
#define X509V3_CTX WOLFSSL_X509V3_CTX
|
||||
|
||||
#define CTX_TEST 0x1
|
||||
|
||||
typedef struct WOLFSSL_AUTHORITY_KEYID AUTHORITY_KEYID;
|
||||
typedef struct WOLFSSL_BASIC_CONSTRAINTS BASIC_CONSTRAINTS;
|
||||
typedef struct WOLFSSL_ACCESS_DESCRIPTION ACCESS_DESCRIPTION;
|
||||
|
||||
#define BASIC_CONSTRAINTS_free wolfSSL_BASIC_CONSTRAINTS_free
|
||||
#define AUTHORITY_KEYID_free wolfSSL_AUTHORITY_KEYID_free
|
||||
#define SSL_CTX_get_cert_store(x) wolfSSL_CTX_get_cert_store ((x))
|
||||
@@ -198,6 +219,8 @@ WOLFSSL_API WOLFSSL_ASN1_STRING* wolfSSL_a2i_IPADDRESS(const char* ipa);
|
||||
#define X509V3_set_ctx_nodb wolfSSL_X509V3_set_ctx_nodb
|
||||
#define X509v3_get_ext_count wolfSSL_sk_num
|
||||
|
||||
#endif /* !OPENSSL_COEXIST */
|
||||
|
||||
#endif /* OPENSSL_EXTRA || OPENSSL_EXTRA_X509_SMALL */
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -117,6 +117,62 @@
|
||||
#include <openssl/hmac.h>
|
||||
#include <openssl/bn.h>
|
||||
#include <openssl/crypto.h>
|
||||
#include <openssl/aes.h>
|
||||
#include <openssl/blowfish.h>
|
||||
#include <openssl/camellia.h>
|
||||
#include <openssl/cast.h>
|
||||
#include <openssl/cmac.h>
|
||||
#include <openssl/cmp.h>
|
||||
#include <openssl/cms.h>
|
||||
#include <openssl/conf_api.h>
|
||||
#include <openssl/core_object.h>
|
||||
#include <openssl/decoder.h>
|
||||
#include <openssl/des.h>
|
||||
#include <openssl/dh.h>
|
||||
#include <openssl/dsa.h>
|
||||
#include <openssl/ecdh.h>
|
||||
#include <openssl/ecdsa.h>
|
||||
#include <openssl/encoder.h>
|
||||
#include <openssl/engine.h>
|
||||
#include <openssl/ess.h>
|
||||
#include <openssl/fipskey.h>
|
||||
#include <openssl/fips_names.h>
|
||||
#include <openssl/hmac.h>
|
||||
#include <openssl/hpke.h>
|
||||
#include <openssl/http.h>
|
||||
#include <openssl/idea.h>
|
||||
#include <openssl/kdf.h>
|
||||
#include <openssl/md2.h>
|
||||
#include <openssl/md4.h>
|
||||
#include <openssl/md5.h>
|
||||
#include <openssl/mdc2.h>
|
||||
#include <openssl/modes.h>
|
||||
#include <openssl/ocsp.h>
|
||||
#include <openssl/ossl_typ.h>
|
||||
#include <openssl/param_build.h>
|
||||
#include <openssl/params.h>
|
||||
#include <openssl/pem2.h>
|
||||
#include <openssl/pem.h>
|
||||
#include <openssl/pkcs12.h>
|
||||
#include <openssl/pkcs7.h>
|
||||
#include <openssl/proverr.h>
|
||||
#include <openssl/provider.h>
|
||||
#include <openssl/rand.h>
|
||||
#include <openssl/rc2.h>
|
||||
#include <openssl/rc4.h>
|
||||
#include <openssl/rc5.h>
|
||||
#include <openssl/ripemd.h>
|
||||
#include <openssl/rsa.h>
|
||||
#include <openssl/seed.h>
|
||||
#include <openssl/self_test.h>
|
||||
#include <openssl/sha.h>
|
||||
#include <openssl/srp.h>
|
||||
#include <openssl/srtp.h>
|
||||
#include <openssl/ssl.h>
|
||||
#include <openssl/store.h>
|
||||
#include <openssl/txt_db.h>
|
||||
#include <openssl/ui.h>
|
||||
#include <openssl/whrlpool.h>
|
||||
#endif
|
||||
|
||||
#elif (defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL))
|
||||
@@ -231,7 +287,9 @@ typedef struct WOLFSSL_BIO_METHOD WOLFSSL_BIO_METHOD;
|
||||
typedef struct WOLFSSL_X509_EXTENSION WOLFSSL_X509_EXTENSION;
|
||||
typedef struct WOLFSSL_ASN1_OBJECT WOLFSSL_ASN1_OBJECT;
|
||||
typedef struct WOLFSSL_ASN1_OTHERNAME WOLFSSL_ASN1_OTHERNAME;
|
||||
#ifndef OPENSSL_COEXIST
|
||||
typedef struct WOLFSSL_ASN1_OTHERNAME OTHERNAME;
|
||||
#endif
|
||||
typedef struct WOLFSSL_X509V3_CTX WOLFSSL_X509V3_CTX;
|
||||
typedef struct WOLFSSL_v3_ext_method WOLFSSL_v3_ext_method;
|
||||
typedef struct WOLFSSL_OBJ_NAME WOLFSSL_OBJ_NAME;
|
||||
|
||||
+2
-2
@@ -4697,7 +4697,7 @@ static WC_INLINE int myTicketEncCb(WOLFSSL* ssl,
|
||||
mac);
|
||||
#elif defined(HAVE_AESGCM)
|
||||
ret = wc_AesGcmEncrypt(&tickCtx->aes, ticket, ticket, inLen,
|
||||
iv, GCM_NONCE_MID_SZ, mac, AES_BLOCK_SIZE,
|
||||
iv, GCM_NONCE_MID_SZ, mac, WC_AES_BLOCK_SIZE,
|
||||
tickCtx->aad, aadSz);
|
||||
#endif
|
||||
}
|
||||
@@ -4711,7 +4711,7 @@ static WC_INLINE int myTicketEncCb(WOLFSSL* ssl,
|
||||
ticket);
|
||||
#elif defined(HAVE_AESGCM)
|
||||
ret = wc_AesGcmDecrypt(&tickCtx->aes, ticket, ticket, inLen,
|
||||
iv, GCM_NONCE_MID_SZ, mac, AES_BLOCK_SIZE,
|
||||
iv, GCM_NONCE_MID_SZ, mac, WC_AES_BLOCK_SIZE,
|
||||
tickCtx->aad, aadSz);
|
||||
#endif
|
||||
}
|
||||
|
||||
+17
-14
@@ -188,7 +188,10 @@ enum {
|
||||
AES_ENCRYPTION_AND_DECRYPTION = 2,
|
||||
#endif
|
||||
|
||||
AES_BLOCK_SIZE = 16,
|
||||
WC_AES_BLOCK_SIZE = 16,
|
||||
#ifndef OPENSSL_COEXIST
|
||||
#define AES_BLOCK_SIZE WC_AES_BLOCK_SIZE
|
||||
#endif
|
||||
|
||||
KEYWRAP_BLOCK_SIZE = 8,
|
||||
|
||||
@@ -227,9 +230,9 @@ enum {
|
||||
#endif
|
||||
|
||||
/* Number of bits to a block. */
|
||||
#define AES_BLOCK_BITS (AES_BLOCK_SIZE * 8)
|
||||
#define AES_BLOCK_BITS (WC_AES_BLOCK_SIZE * 8)
|
||||
/* Number of bytes of input that can be processed in one call. */
|
||||
#define BS_BLOCK_SIZE (AES_BLOCK_SIZE * BS_WORD_SIZE)
|
||||
#define BS_BLOCK_SIZE (WC_AES_BLOCK_SIZE * BS_WORD_SIZE)
|
||||
/* Number of words in a block. */
|
||||
#define BS_BLOCK_WORDS (AES_BLOCK_BITS / BS_WORD_SIZE)
|
||||
|
||||
@@ -258,7 +261,7 @@ struct Aes {
|
||||
ALIGN16 word32 key[60];
|
||||
#ifdef WC_AES_BITSLICED
|
||||
/* Extra key schedule space required for bit-slicing technique. */
|
||||
ALIGN16 bs_word bs_key[15 * AES_BLOCK_SIZE * BS_WORD_SIZE];
|
||||
ALIGN16 bs_word bs_key[15 * WC_AES_BLOCK_SIZE * BS_WORD_SIZE];
|
||||
#endif
|
||||
word32 rounds;
|
||||
#ifdef WC_C_DYNAMIC_FALLBACK
|
||||
@@ -266,8 +269,8 @@ struct Aes {
|
||||
#endif
|
||||
int keylen;
|
||||
|
||||
ALIGN16 word32 reg[AES_BLOCK_SIZE / sizeof(word32)]; /* for CBC mode */
|
||||
ALIGN16 word32 tmp[AES_BLOCK_SIZE / sizeof(word32)]; /* same */
|
||||
ALIGN16 word32 reg[WC_AES_BLOCK_SIZE / sizeof(word32)]; /* for CBC mode */
|
||||
ALIGN16 word32 tmp[WC_AES_BLOCK_SIZE / sizeof(word32)]; /* same */
|
||||
|
||||
#if defined(HAVE_AESGCM) || defined(HAVE_AESCCM)
|
||||
word32 invokeCtr[2];
|
||||
@@ -379,7 +382,7 @@ struct Aes {
|
||||
void* heap; /* memory hint to use */
|
||||
#ifdef WOLFSSL_AESGCM_STREAM
|
||||
#if !defined(WOLFSSL_SMALL_STACK) || defined(WOLFSSL_AESNI)
|
||||
ALIGN16 byte streamData[5 * AES_BLOCK_SIZE];
|
||||
ALIGN16 byte streamData[5 * WC_AES_BLOCK_SIZE];
|
||||
#else
|
||||
byte* streamData;
|
||||
word32 streamData_sz;
|
||||
@@ -408,8 +411,8 @@ struct Aes {
|
||||
#ifdef WOLFSSL_AES_XTS
|
||||
#if FIPS_VERSION3_GE(6,0,0)
|
||||
/* SP800-38E - Restrict data unit to 2^20 blocks per key. A block is
|
||||
* AES_BLOCK_SIZE or 16-bytes (128-bits). So each key may only be used to
|
||||
* protect up to 1,048,576 blocks of AES_BLOCK_SIZE (16,777,216 bytes)
|
||||
* WC_AES_BLOCK_SIZE or 16-bytes (128-bits). So each key may only be used to
|
||||
* protect up to 1,048,576 blocks of WC_AES_BLOCK_SIZE (16,777,216 bytes)
|
||||
*/
|
||||
#define FIPS_AES_XTS_MAX_BYTES_PER_TWEAK 16777216
|
||||
#endif
|
||||
@@ -423,7 +426,7 @@ struct Aes {
|
||||
|
||||
#ifdef WOLFSSL_AESXTS_STREAM
|
||||
struct XtsAesStreamData {
|
||||
byte tweak_block[AES_BLOCK_SIZE];
|
||||
byte tweak_block[WC_AES_BLOCK_SIZE];
|
||||
word32 bytes_crypted_with_this_tweak;
|
||||
};
|
||||
#endif
|
||||
@@ -768,10 +771,10 @@ struct AesEax {
|
||||
Cmac nonceCmac;
|
||||
Cmac aadCmac;
|
||||
Cmac ciphertextCmac;
|
||||
byte nonceCmacFinal[AES_BLOCK_SIZE];
|
||||
byte aadCmacFinal[AES_BLOCK_SIZE];
|
||||
byte ciphertextCmacFinal[AES_BLOCK_SIZE];
|
||||
byte prefixBuf[AES_BLOCK_SIZE];
|
||||
byte nonceCmacFinal[WC_AES_BLOCK_SIZE];
|
||||
byte aadCmacFinal[WC_AES_BLOCK_SIZE];
|
||||
byte ciphertextCmacFinal[WC_AES_BLOCK_SIZE];
|
||||
byte prefixBuf[WC_AES_BLOCK_SIZE];
|
||||
};
|
||||
#endif /* !defined(WOLF_CRYPT_CMAC_H) */
|
||||
|
||||
|
||||
@@ -63,34 +63,49 @@
|
||||
#endif
|
||||
|
||||
enum {
|
||||
CAMELLIA_BLOCK_SIZE = 16
|
||||
WC_CAMELLIA_BLOCK_SIZE = 16
|
||||
};
|
||||
|
||||
#define CAMELLIA_TABLE_BYTE_LEN 272
|
||||
#define CAMELLIA_TABLE_WORD_LEN (CAMELLIA_TABLE_BYTE_LEN / sizeof(word32))
|
||||
#define WC_CAMELLIA_TABLE_BYTE_LEN 272
|
||||
#define WC_CAMELLIA_TABLE_WORD_LEN (WC_CAMELLIA_TABLE_BYTE_LEN / sizeof(word32))
|
||||
|
||||
typedef word32 KEY_TABLE_TYPE[CAMELLIA_TABLE_WORD_LEN];
|
||||
typedef word32 WC_CAMELLIA_KEY_TABLE_TYPE[WC_CAMELLIA_TABLE_WORD_LEN];
|
||||
|
||||
typedef struct Camellia {
|
||||
typedef struct wc_Camellia {
|
||||
word32 keySz;
|
||||
KEY_TABLE_TYPE key;
|
||||
word32 reg[CAMELLIA_BLOCK_SIZE / sizeof(word32)]; /* for CBC mode */
|
||||
word32 tmp[CAMELLIA_BLOCK_SIZE / sizeof(word32)]; /* for CBC mode */
|
||||
} Camellia;
|
||||
WC_CAMELLIA_KEY_TABLE_TYPE key;
|
||||
word32 reg[WC_CAMELLIA_BLOCK_SIZE / sizeof(word32)]; /* for CBC mode */
|
||||
word32 tmp[WC_CAMELLIA_BLOCK_SIZE / sizeof(word32)]; /* for CBC mode */
|
||||
} wc_Camellia;
|
||||
|
||||
|
||||
WOLFSSL_API int wc_CamelliaSetKey(Camellia* cam,
|
||||
WOLFSSL_API int wc_CamelliaSetKey(wc_Camellia* cam,
|
||||
const byte* key, word32 len, const byte* iv);
|
||||
WOLFSSL_API int wc_CamelliaSetIV(Camellia* cam, const byte* iv);
|
||||
WOLFSSL_API int wc_CamelliaEncryptDirect(Camellia* cam, byte* out,
|
||||
WOLFSSL_API int wc_CamelliaSetIV(wc_Camellia* cam, const byte* iv);
|
||||
WOLFSSL_API int wc_CamelliaEncryptDirect(wc_Camellia* cam, byte* out,
|
||||
const byte* in);
|
||||
WOLFSSL_API int wc_CamelliaDecryptDirect(Camellia* cam, byte* out,
|
||||
WOLFSSL_API int wc_CamelliaDecryptDirect(wc_Camellia* cam, byte* out,
|
||||
const byte* in);
|
||||
WOLFSSL_API int wc_CamelliaCbcEncrypt(Camellia* cam,
|
||||
WOLFSSL_API int wc_CamelliaCbcEncrypt(wc_Camellia* cam,
|
||||
byte* out, const byte* in, word32 sz);
|
||||
WOLFSSL_API int wc_CamelliaCbcDecrypt(Camellia* cam,
|
||||
WOLFSSL_API int wc_CamelliaCbcDecrypt(wc_Camellia* cam,
|
||||
byte* out, const byte* in, word32 sz);
|
||||
|
||||
#ifndef OPENSSL_COEXIST
|
||||
|
||||
enum {
|
||||
CAMELLIA_BLOCK_SIZE = WC_CAMELLIA_BLOCK_SIZE
|
||||
};
|
||||
|
||||
#define CAMELLIA_TABLE_BYTE_LEN WC_CAMELLIA_TABLE_BYTE_LEN
|
||||
#define CAMELLIA_TABLE_WORD_LEN WC_CAMELLIA_TABLE_WORD_LEN
|
||||
|
||||
typedef word32 KEY_TABLE_TYPE[WC_CAMELLIA_TABLE_WORD_LEN];
|
||||
|
||||
typedef struct wc_Camellia Camellia;
|
||||
|
||||
#endif /* !OPENSSL_COEXIST */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
|
||||
@@ -54,10 +54,10 @@ typedef enum CmacType {
|
||||
struct Cmac {
|
||||
#ifndef NO_AES
|
||||
Aes aes;
|
||||
byte buffer[AES_BLOCK_SIZE]; /* partially stored block */
|
||||
byte digest[AES_BLOCK_SIZE]; /* running digest */
|
||||
byte k1[AES_BLOCK_SIZE];
|
||||
byte k2[AES_BLOCK_SIZE];
|
||||
byte buffer[WC_AES_BLOCK_SIZE]; /* partially stored block */
|
||||
byte digest[WC_AES_BLOCK_SIZE]; /* running digest */
|
||||
byte k1[WC_AES_BLOCK_SIZE];
|
||||
byte k2[WC_AES_BLOCK_SIZE];
|
||||
#endif
|
||||
word32 bufferSz;
|
||||
word32 totalSz;
|
||||
@@ -86,8 +86,8 @@ struct Cmac {
|
||||
|
||||
|
||||
#ifndef NO_AES
|
||||
#define WC_CMAC_TAG_MAX_SZ AES_BLOCK_SIZE
|
||||
#define WC_CMAC_TAG_MIN_SZ (AES_BLOCK_SIZE/4)
|
||||
#define WC_CMAC_TAG_MAX_SZ WC_AES_BLOCK_SIZE
|
||||
#define WC_CMAC_TAG_MIN_SZ (WC_AES_BLOCK_SIZE/4)
|
||||
#else
|
||||
/* Reasonable defaults */
|
||||
#define WC_CMAC_TAG_MAX_SZ 16
|
||||
|
||||
+27
-13
@@ -37,28 +37,42 @@
|
||||
|
||||
/* in bytes */
|
||||
enum {
|
||||
MD2 = WC_HASH_TYPE_MD2,
|
||||
MD2_BLOCK_SIZE = 16,
|
||||
MD2_DIGEST_SIZE = 16,
|
||||
MD2_PAD_SIZE = 16,
|
||||
MD2_X_SIZE = 48
|
||||
WC_MD2_BLOCK_SIZE = 16,
|
||||
WC_MD2_DIGEST_SIZE = 16,
|
||||
WC_MD2_PAD_SIZE = 16,
|
||||
WC_MD2_X_SIZE = 48
|
||||
};
|
||||
|
||||
|
||||
/* Md2 digest */
|
||||
typedef struct Md2 {
|
||||
typedef struct wc_Md2 {
|
||||
word32 count; /* bytes % PAD_SIZE */
|
||||
byte X[MD2_X_SIZE];
|
||||
byte C[MD2_BLOCK_SIZE];
|
||||
byte buffer[MD2_BLOCK_SIZE];
|
||||
} Md2;
|
||||
byte X[WC_MD2_X_SIZE];
|
||||
byte C[WC_MD2_BLOCK_SIZE];
|
||||
byte buffer[WC_MD2_BLOCK_SIZE];
|
||||
} wc_Md2;
|
||||
|
||||
|
||||
WOLFSSL_API void wc_InitMd2(Md2* md2);
|
||||
WOLFSSL_API void wc_Md2Update(Md2* md2, const byte* data, word32 len);
|
||||
WOLFSSL_API void wc_Md2Final(Md2* md2, byte* hash);
|
||||
WOLFSSL_API void wc_InitMd2(wc_Md2* md2);
|
||||
WOLFSSL_API void wc_Md2Update(wc_Md2* md2, const byte* data, word32 len);
|
||||
WOLFSSL_API void wc_Md2Final(wc_Md2* md2, byte* hash);
|
||||
WOLFSSL_API int wc_Md2Hash(const byte* data, word32 len, byte* hash);
|
||||
|
||||
#ifndef OPENSSL_COEXIST
|
||||
|
||||
enum {
|
||||
MD2 = WC_HASH_TYPE_MD2,
|
||||
MD2_BLOCK_SIZE = WC_MD2_BLOCK_SIZE,
|
||||
MD2_DIGEST_SIZE = WC_MD2_DIGEST_SIZE,
|
||||
MD2_PAD_SIZE = WC_MD2_PAD_SIZE,
|
||||
MD2_X_SIZE = WC_MD2_X_SIZE
|
||||
};
|
||||
|
||||
|
||||
/* Md2 digest */
|
||||
typedef struct wc_Md2 Md2;
|
||||
|
||||
#endif /* !OPENSSL_COEXIST */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
|
||||
+22
-12
@@ -36,26 +36,36 @@
|
||||
|
||||
/* in bytes */
|
||||
enum {
|
||||
MD4 = WC_HASH_TYPE_MD4,
|
||||
MD4_BLOCK_SIZE = 64,
|
||||
MD4_DIGEST_SIZE = 16,
|
||||
MD4_PAD_SIZE = 56
|
||||
WC_MD4_BLOCK_SIZE = 64,
|
||||
WC_MD4_DIGEST_SIZE = 16,
|
||||
WC_MD4_PAD_SIZE = 56
|
||||
};
|
||||
|
||||
|
||||
/* MD4 digest */
|
||||
typedef struct Md4 {
|
||||
typedef struct wc_Md4 {
|
||||
word32 buffLen; /* in bytes */
|
||||
word32 loLen; /* length in bytes */
|
||||
word32 hiLen; /* length in bytes */
|
||||
word32 digest[MD4_DIGEST_SIZE / sizeof(word32)];
|
||||
word32 buffer[MD4_BLOCK_SIZE / sizeof(word32)];
|
||||
} Md4;
|
||||
word32 digest[WC_MD4_DIGEST_SIZE / sizeof(word32)];
|
||||
word32 buffer[WC_MD4_BLOCK_SIZE / sizeof(word32)];
|
||||
} wc_Md4;
|
||||
|
||||
WOLFSSL_API void wc_InitMd4(wc_Md4* md4);
|
||||
WOLFSSL_API void wc_Md4Update(wc_Md4* md4, const byte* data, word32 len);
|
||||
WOLFSSL_API void wc_Md4Final(wc_Md4* md4, byte* hash);
|
||||
|
||||
WOLFSSL_API void wc_InitMd4(Md4* md4);
|
||||
WOLFSSL_API void wc_Md4Update(Md4* md4, const byte* data, word32 len);
|
||||
WOLFSSL_API void wc_Md4Final(Md4* md4, byte* hash);
|
||||
#ifndef OPENSSL_COEXIST
|
||||
|
||||
enum {
|
||||
MD4 = WC_HASH_TYPE_MD4,
|
||||
MD4_BLOCK_SIZE = WC_MD4_BLOCK_SIZE,
|
||||
MD4_DIGEST_SIZE = WC_MD4_DIGEST_SIZE,
|
||||
MD4_PAD_SIZE = WC_MD4_PAD_SIZE
|
||||
};
|
||||
|
||||
typedef struct wc_Md4 Md4;
|
||||
|
||||
#endif /* !OPENSSL_COEXIST */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -158,7 +158,7 @@ enum Pkcs7_Misc {
|
||||
MAX_CONTENT_KEY_LEN = 32, /* highest current cipher is AES-256-CBC */
|
||||
MAX_CONTENT_IV_SIZE = 16, /* highest current is AES128 */
|
||||
#ifndef NO_AES
|
||||
MAX_CONTENT_BLOCK_LEN = AES_BLOCK_SIZE,
|
||||
MAX_CONTENT_BLOCK_LEN = WC_AES_BLOCK_SIZE,
|
||||
#else
|
||||
MAX_CONTENT_BLOCK_LEN = DES_BLOCK_SIZE,
|
||||
#endif
|
||||
|
||||
@@ -415,6 +415,11 @@
|
||||
#undef WC_RSA_BLINDING
|
||||
#endif
|
||||
|
||||
/* old FIPS has only AES_BLOCK_SIZE. */
|
||||
#if !defined(NO_AES) && (defined(HAVE_SELFTEST) || \
|
||||
(defined(HAVE_FIPS) && FIPS_VERSION3_LT(7,0,0)))
|
||||
#define WC_AES_BLOCK_SIZE AES_BLOCK_SIZE
|
||||
#endif /* !NO_AES && (HAVE_SELFTEST || FIPS_VERSION3_LT(7,0,0)) */
|
||||
|
||||
#ifdef WOLFSSL_HARDEN_TLS
|
||||
#if WOLFSSL_HARDEN_TLS != 112 && WOLFSSL_HARDEN_TLS != 128
|
||||
|
||||
Reference in New Issue
Block a user