mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-08-05 19:35:48 +03:00
@@ -732,7 +732,8 @@ static inline int mbedtls_cipher_get_iv_size(
|
|||||||
return (int) ctx->MBEDTLS_PRIVATE(iv_size);
|
return (int) ctx->MBEDTLS_PRIVATE(iv_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (int) (((int)ctx->MBEDTLS_PRIVATE(cipher_info)->MBEDTLS_PRIVATE(iv_size)) << MBEDTLS_IV_SIZE_SHIFT);
|
return (int) (((int) ctx->MBEDTLS_PRIVATE(cipher_info)->MBEDTLS_PRIVATE(iv_size)) <<
|
||||||
|
MBEDTLS_IV_SIZE_SHIFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -793,7 +794,8 @@ static inline int mbedtls_cipher_get_key_bitlen(
|
|||||||
return MBEDTLS_KEY_LENGTH_NONE;
|
return MBEDTLS_KEY_LENGTH_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (int) ctx->MBEDTLS_PRIVATE(cipher_info)->MBEDTLS_PRIVATE(key_bitlen) << MBEDTLS_KEY_BITLEN_SHIFT;
|
return (int) ctx->MBEDTLS_PRIVATE(cipher_info)->MBEDTLS_PRIVATE(key_bitlen) <<
|
||||||
|
MBEDTLS_KEY_BITLEN_SHIFT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -67,7 +67,9 @@
|
|||||||
|
|
||||||
static int supported_init = 0;
|
static int supported_init = 0;
|
||||||
|
|
||||||
static inline const mbedtls_cipher_base_t* mbedtls_cipher_get_base(const mbedtls_cipher_info_t *info) {
|
static inline const mbedtls_cipher_base_t *mbedtls_cipher_get_base(
|
||||||
|
const mbedtls_cipher_info_t *info)
|
||||||
|
{
|
||||||
return mbedtls_cipher_base_lookup_table[info->base_idx];
|
return mbedtls_cipher_base_lookup_table[info->base_idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -553,7 +555,8 @@ int mbedtls_cipher_update(mbedtls_cipher_context_t *ctx, const unsigned char *in
|
|||||||
*olen = ilen;
|
*olen = ilen;
|
||||||
|
|
||||||
if (0 != (ret = mbedtls_cipher_get_base(ctx->cipher_info)->ecb_func(ctx->cipher_ctx,
|
if (0 != (ret = mbedtls_cipher_get_base(ctx->cipher_info)->ecb_func(ctx->cipher_ctx,
|
||||||
ctx->operation, input, output))) {
|
ctx->operation, input,
|
||||||
|
output))) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -619,8 +622,11 @@ int mbedtls_cipher_update(mbedtls_cipher_context_t *ctx, const unsigned char *in
|
|||||||
copy_len);
|
copy_len);
|
||||||
|
|
||||||
if (0 != (ret = mbedtls_cipher_get_base(ctx->cipher_info)->cbc_func(ctx->cipher_ctx,
|
if (0 != (ret = mbedtls_cipher_get_base(ctx->cipher_info)->cbc_func(ctx->cipher_ctx,
|
||||||
ctx->operation, block_size, ctx->iv,
|
ctx->operation,
|
||||||
ctx->unprocessed_data, output))) {
|
block_size, ctx->iv,
|
||||||
|
ctx->
|
||||||
|
unprocessed_data,
|
||||||
|
output))) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -659,7 +665,9 @@ int mbedtls_cipher_update(mbedtls_cipher_context_t *ctx, const unsigned char *in
|
|||||||
*/
|
*/
|
||||||
if (ilen) {
|
if (ilen) {
|
||||||
if (0 != (ret = mbedtls_cipher_get_base(ctx->cipher_info)->cbc_func(ctx->cipher_ctx,
|
if (0 != (ret = mbedtls_cipher_get_base(ctx->cipher_info)->cbc_func(ctx->cipher_ctx,
|
||||||
ctx->operation, ilen, ctx->iv, input,
|
ctx->operation,
|
||||||
|
ilen, ctx->iv,
|
||||||
|
input,
|
||||||
output))) {
|
output))) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -675,7 +683,8 @@ int mbedtls_cipher_update(mbedtls_cipher_context_t *ctx, const unsigned char *in
|
|||||||
if (ctx->cipher_info->mode == MBEDTLS_MODE_CFB) {
|
if (ctx->cipher_info->mode == MBEDTLS_MODE_CFB) {
|
||||||
if (0 != (ret = mbedtls_cipher_get_base(ctx->cipher_info)->cfb_func(ctx->cipher_ctx,
|
if (0 != (ret = mbedtls_cipher_get_base(ctx->cipher_info)->cfb_func(ctx->cipher_ctx,
|
||||||
ctx->operation, ilen,
|
ctx->operation, ilen,
|
||||||
&ctx->unprocessed_len, ctx->iv,
|
&ctx->unprocessed_len,
|
||||||
|
ctx->iv,
|
||||||
input, output))) {
|
input, output))) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -689,7 +698,9 @@ int mbedtls_cipher_update(mbedtls_cipher_context_t *ctx, const unsigned char *in
|
|||||||
#if defined(MBEDTLS_CIPHER_MODE_OFB)
|
#if defined(MBEDTLS_CIPHER_MODE_OFB)
|
||||||
if (ctx->cipher_info->mode == MBEDTLS_MODE_OFB) {
|
if (ctx->cipher_info->mode == MBEDTLS_MODE_OFB) {
|
||||||
if (0 != (ret = mbedtls_cipher_get_base(ctx->cipher_info)->ofb_func(ctx->cipher_ctx,
|
if (0 != (ret = mbedtls_cipher_get_base(ctx->cipher_info)->ofb_func(ctx->cipher_ctx,
|
||||||
ilen, &ctx->unprocessed_len, ctx->iv,
|
ilen,
|
||||||
|
&ctx->unprocessed_len,
|
||||||
|
ctx->iv,
|
||||||
input, output))) {
|
input, output))) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -703,8 +714,11 @@ int mbedtls_cipher_update(mbedtls_cipher_context_t *ctx, const unsigned char *in
|
|||||||
#if defined(MBEDTLS_CIPHER_MODE_CTR)
|
#if defined(MBEDTLS_CIPHER_MODE_CTR)
|
||||||
if (ctx->cipher_info->mode == MBEDTLS_MODE_CTR) {
|
if (ctx->cipher_info->mode == MBEDTLS_MODE_CTR) {
|
||||||
if (0 != (ret = mbedtls_cipher_get_base(ctx->cipher_info)->ctr_func(ctx->cipher_ctx,
|
if (0 != (ret = mbedtls_cipher_get_base(ctx->cipher_info)->ctr_func(ctx->cipher_ctx,
|
||||||
ilen, &ctx->unprocessed_len, ctx->iv,
|
ilen,
|
||||||
ctx->unprocessed_data, input, output))) {
|
&ctx->unprocessed_len,
|
||||||
|
ctx->iv,
|
||||||
|
ctx->unprocessed_data,
|
||||||
|
input, output))) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -722,7 +736,11 @@ int mbedtls_cipher_update(mbedtls_cipher_context_t *ctx, const unsigned char *in
|
|||||||
}
|
}
|
||||||
|
|
||||||
ret = mbedtls_cipher_get_base(ctx->cipher_info)->xts_func(ctx->cipher_ctx,
|
ret = mbedtls_cipher_get_base(ctx->cipher_info)->xts_func(ctx->cipher_ctx,
|
||||||
ctx->operation, ilen, ctx->iv, input, output);
|
ctx->operation,
|
||||||
|
ilen,
|
||||||
|
ctx->iv,
|
||||||
|
input,
|
||||||
|
output);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -736,7 +754,8 @@ int mbedtls_cipher_update(mbedtls_cipher_context_t *ctx, const unsigned char *in
|
|||||||
#if defined(MBEDTLS_CIPHER_MODE_STREAM)
|
#if defined(MBEDTLS_CIPHER_MODE_STREAM)
|
||||||
if (ctx->cipher_info->mode == MBEDTLS_MODE_STREAM) {
|
if (ctx->cipher_info->mode == MBEDTLS_MODE_STREAM) {
|
||||||
if (0 != (ret = mbedtls_cipher_get_base(ctx->cipher_info)->stream_func(ctx->cipher_ctx,
|
if (0 != (ret = mbedtls_cipher_get_base(ctx->cipher_info)->stream_func(ctx->cipher_ctx,
|
||||||
ilen, input, output))) {
|
ilen, input,
|
||||||
|
output))) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1002,9 +1021,11 @@ int mbedtls_cipher_finish(mbedtls_cipher_context_t *ctx,
|
|||||||
/* cipher block */
|
/* cipher block */
|
||||||
if (0 != (ret = mbedtls_cipher_get_base(ctx->cipher_info)->cbc_func(ctx->cipher_ctx,
|
if (0 != (ret = mbedtls_cipher_get_base(ctx->cipher_info)->cbc_func(ctx->cipher_ctx,
|
||||||
ctx->operation,
|
ctx->operation,
|
||||||
mbedtls_cipher_get_block_size(ctx),
|
mbedtls_cipher_get_block_size(
|
||||||
|
ctx),
|
||||||
ctx->iv,
|
ctx->iv,
|
||||||
ctx->unprocessed_data, output))) {
|
ctx->unprocessed_data,
|
||||||
|
output))) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -171,7 +171,9 @@ int mbedtls_pkcs12_pbe(mbedtls_asn1_buf *pbe_params, int mode,
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ret = mbedtls_cipher_set_iv(&cipher_ctx, iv, mbedtls_cipher_info_get_iv_size(cipher_info))) != 0) {
|
if ((ret =
|
||||||
|
mbedtls_cipher_set_iv(&cipher_ctx, iv,
|
||||||
|
mbedtls_cipher_info_get_iv_size(cipher_info))) != 0) {
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user