aboutsummaryrefslogtreecommitdiff
path: root/crypto/modes/siv128.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/modes/siv128.c')
-rw-r--r--crypto/modes/siv128.c56
1 files changed, 27 insertions, 29 deletions
diff --git a/crypto/modes/siv128.c b/crypto/modes/siv128.c
index 4e52d8eb8782..0ab183b37b58 100644
--- a/crypto/modes/siv128.c
+++ b/crypto/modes/siv128.c
@@ -59,7 +59,7 @@ static ossl_inline void siv128_putword(SIV_BLOCK *b, size_t i, uint64_t x)
}
static ossl_inline void siv128_xorblock(SIV_BLOCK *x,
- SIV_BLOCK const *y)
+ SIV_BLOCK const *y)
{
x->word[0] ^= y->word[0];
x->word[1] ^= y->word[1];
@@ -87,7 +87,7 @@ static ossl_inline void siv128_dbl(SIV_BLOCK *b)
}
__owur static ossl_inline int siv128_do_s2v_p(SIV128_CONTEXT *ctx, SIV_BLOCK *out,
- unsigned char const* in, size_t len)
+ unsigned char const *in, size_t len)
{
SIV_BLOCK t;
size_t out_len = sizeof(out->byte);
@@ -101,7 +101,7 @@ __owur static ossl_inline int siv128_do_s2v_p(SIV128_CONTEXT *ctx, SIV_BLOCK *ou
if (len >= SIV_LEN) {
if (!EVP_MAC_update(mac_ctx, in, len - SIV_LEN))
goto err;
- memcpy(&t, in + (len-SIV_LEN), SIV_LEN);
+ memcpy(&t, in + (len - SIV_LEN), SIV_LEN);
siv128_xorblock(&t, &ctx->d);
if (!EVP_MAC_update(mac_ctx, t.byte, SIV_LEN))
goto err;
@@ -125,10 +125,9 @@ err:
return ret;
}
-
__owur static ossl_inline int siv128_do_encrypt(EVP_CIPHER_CTX *ctx, unsigned char *out,
- unsigned char const *in, size_t len,
- SIV_BLOCK *icv)
+ unsigned char const *in, size_t len,
+ SIV_BLOCK *icv)
{
int out_len = (int)len;
@@ -141,8 +140,8 @@ __owur static ossl_inline int siv128_do_encrypt(EVP_CIPHER_CTX *ctx, unsigned ch
* Create a new SIV128_CONTEXT
*/
SIV128_CONTEXT *ossl_siv128_new(const unsigned char *key, int klen,
- EVP_CIPHER *cbc, EVP_CIPHER *ctr,
- OSSL_LIB_CTX *libctx, const char *propq)
+ EVP_CIPHER *cbc, EVP_CIPHER *ctr,
+ OSSL_LIB_CTX *libctx, const char *propq)
{
SIV128_CONTEXT *ctx;
int ret;
@@ -161,8 +160,8 @@ SIV128_CONTEXT *ossl_siv128_new(const unsigned char *key, int klen,
* Initialise an existing SIV128_CONTEXT
*/
int ossl_siv128_init(SIV128_CONTEXT *ctx, const unsigned char *key, int klen,
- const EVP_CIPHER *cbc, const EVP_CIPHER *ctr,
- OSSL_LIB_CTX *libctx, const char *propq)
+ const EVP_CIPHER *cbc, const EVP_CIPHER *ctr,
+ OSSL_LIB_CTX *libctx, const char *propq)
{
static const unsigned char zero[SIV_LEN] = { 0 };
size_t out_len = SIV_LEN;
@@ -186,21 +185,20 @@ int ossl_siv128_init(SIV128_CONTEXT *ctx, const unsigned char *key, int klen,
cbc_name = EVP_CIPHER_get0_name(cbc);
params[0] = OSSL_PARAM_construct_utf8_string(OSSL_MAC_PARAM_CIPHER,
- (char *)cbc_name, 0);
+ (char *)cbc_name, 0);
params[1] = OSSL_PARAM_construct_octet_string(OSSL_MAC_PARAM_KEY,
- (void *)key, klen);
+ (void *)key, klen);
params[2] = OSSL_PARAM_construct_end();
if ((ctx->cipher_ctx = EVP_CIPHER_CTX_new()) == NULL
- || (ctx->mac =
- EVP_MAC_fetch(libctx, OSSL_MAC_NAME_CMAC, propq)) == NULL
- || (ctx->mac_ctx_init = EVP_MAC_CTX_new(ctx->mac)) == NULL
- || !EVP_MAC_CTX_set_params(ctx->mac_ctx_init, params)
- || !EVP_EncryptInit_ex(ctx->cipher_ctx, ctr, NULL, key + klen, NULL)
- || (mac_ctx = EVP_MAC_CTX_dup(ctx->mac_ctx_init)) == NULL
- || !EVP_MAC_update(mac_ctx, zero, sizeof(zero))
- || !EVP_MAC_final(mac_ctx, ctx->d.byte, &out_len,
- sizeof(ctx->d.byte))) {
+ || (ctx->mac = EVP_MAC_fetch(libctx, OSSL_MAC_NAME_CMAC, propq)) == NULL
+ || (ctx->mac_ctx_init = EVP_MAC_CTX_new(ctx->mac)) == NULL
+ || !EVP_MAC_CTX_set_params(ctx->mac_ctx_init, params)
+ || !EVP_EncryptInit_ex(ctx->cipher_ctx, ctr, NULL, key + klen, NULL)
+ || (mac_ctx = EVP_MAC_CTX_dup(ctx->mac_ctx_init)) == NULL
+ || !EVP_MAC_update(mac_ctx, zero, sizeof(zero))
+ || !EVP_MAC_final(mac_ctx, ctx->d.byte, &out_len,
+ sizeof(ctx->d.byte))) {
EVP_CIPHER_CTX_free(ctx->cipher_ctx);
ctx->cipher_ctx = NULL;
EVP_MAC_CTX_free(ctx->mac_ctx_init);
@@ -247,7 +245,7 @@ int ossl_siv128_copy_ctx(SIV128_CONTEXT *dest, SIV128_CONTEXT *src)
* is the nonce, but it's not treated special
*/
int ossl_siv128_aad(SIV128_CONTEXT *ctx, const unsigned char *aad,
- size_t len)
+ size_t len)
{
SIV_BLOCK mac_out;
size_t out_len = SIV_LEN;
@@ -258,7 +256,7 @@ int ossl_siv128_aad(SIV128_CONTEXT *ctx, const unsigned char *aad,
if ((mac_ctx = EVP_MAC_CTX_dup(ctx->mac_ctx_init)) == NULL
|| !EVP_MAC_update(mac_ctx, aad, len)
|| !EVP_MAC_final(mac_ctx, mac_out.byte, &out_len,
- sizeof(mac_out.byte))
+ sizeof(mac_out.byte))
|| out_len != SIV_LEN) {
EVP_MAC_CTX_free(mac_ctx);
return 0;
@@ -274,8 +272,8 @@ int ossl_siv128_aad(SIV128_CONTEXT *ctx, const unsigned char *aad,
* Provide any data to be encrypted. This can be called once.
*/
int ossl_siv128_encrypt(SIV128_CONTEXT *ctx,
- const unsigned char *in, unsigned char *out,
- size_t len)
+ const unsigned char *in, unsigned char *out,
+ size_t len)
{
SIV_BLOCK q;
@@ -301,10 +299,10 @@ int ossl_siv128_encrypt(SIV128_CONTEXT *ctx,
* Provide any data to be decrypted. This can be called once.
*/
int ossl_siv128_decrypt(SIV128_CONTEXT *ctx,
- const unsigned char *in, unsigned char *out,
- size_t len)
+ const unsigned char *in, unsigned char *out,
+ size_t len)
{
- unsigned char* p;
+ unsigned char *p;
SIV_BLOCK t, q;
int i;
@@ -393,4 +391,4 @@ int ossl_siv128_speed(SIV128_CONTEXT *ctx, int arg)
return 1;
}
-#endif /* OPENSSL_NO_SIV */
+#endif /* OPENSSL_NO_SIV */