summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/cmac
diff options
context:
space:
mode:
authorjsing <>2014-06-21 13:42:14 +0000
committerjsing <>2014-06-21 13:42:14 +0000
commit13487d6ff5ba78e217edd743efcdd9a1be05aa21 (patch)
tree630b9b1b9589f6fa12e705f2da2d35788b2dcbb7 /src/lib/libcrypto/cmac
parent08ade2d2f3bc84d98839ae9064475c6fca84a29f (diff)
downloadopenbsd-13487d6ff5ba78e217edd743efcdd9a1be05aa21.tar.gz
openbsd-13487d6ff5ba78e217edd743efcdd9a1be05aa21.tar.bz2
openbsd-13487d6ff5ba78e217edd743efcdd9a1be05aa21.zip
More KNF.
Diffstat (limited to 'src/lib/libcrypto/cmac')
-rw-r--r--src/lib/libcrypto/cmac/cm_ameth.c7
-rw-r--r--src/lib/libcrypto/cmac/cm_pmeth.c11
-rw-r--r--src/lib/libcrypto/cmac/cmac.c10
-rw-r--r--src/lib/libcrypto/cmac/cmac.h8
4 files changed, 17 insertions, 19 deletions
diff --git a/src/lib/libcrypto/cmac/cm_ameth.c b/src/lib/libcrypto/cmac/cm_ameth.c
index a793e65262..763d161cfe 100644
--- a/src/lib/libcrypto/cmac/cm_ameth.c
+++ b/src/lib/libcrypto/cmac/cm_ameth.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: cm_ameth.c,v 1.4 2014/06/21 12:07:02 miod Exp $ */ 1/* $OpenBSD: cm_ameth.c,v 1.5 2014/06/21 13:42:14 jsing Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2010. 3 * project 2010.
4 */ 4 */
@@ -10,7 +10,7 @@
10 * are met: 10 * are met:
11 * 11 *
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 14 *
15 * 2. Redistributions in binary form must reproduce the above copyright 15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in 16 * notice, this list of conditions and the following disclaimer in
@@ -77,8 +77,7 @@ cmac_key_free(EVP_PKEY *pkey)
77 CMAC_CTX_free(cmctx); 77 CMAC_CTX_free(cmctx);
78} 78}
79 79
80const EVP_PKEY_ASN1_METHOD 80const EVP_PKEY_ASN1_METHOD cmac_asn1_meth = {
81cmac_asn1_meth = {
82 .pkey_id = EVP_PKEY_CMAC, 81 .pkey_id = EVP_PKEY_CMAC,
83 .pkey_base_id = EVP_PKEY_CMAC, 82 .pkey_base_id = EVP_PKEY_CMAC,
84 83
diff --git a/src/lib/libcrypto/cmac/cm_pmeth.c b/src/lib/libcrypto/cmac/cm_pmeth.c
index 3010f91aca..5bb391d053 100644
--- a/src/lib/libcrypto/cmac/cm_pmeth.c
+++ b/src/lib/libcrypto/cmac/cm_pmeth.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: cm_pmeth.c,v 1.5 2014/06/21 12:07:02 miod Exp $ */ 1/* $OpenBSD: cm_pmeth.c,v 1.6 2014/06/21 13:42:14 jsing Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2010. 3 * project 2010.
4 */ 4 */
@@ -10,7 +10,7 @@
10 * are met: 10 * are met:
11 * 11 *
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 14 *
15 * 2. Redistributions in binary form must reproduce the above copyright 15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in 16 * notice, this list of conditions and the following disclaimer in
@@ -100,12 +100,12 @@ pkey_cmac_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
100 return 0; 100 return 0;
101 } 101 }
102 EVP_PKEY_assign(pkey, EVP_PKEY_CMAC, cmkey); 102 EVP_PKEY_assign(pkey, EVP_PKEY_CMAC, cmkey);
103 103
104 return 1; 104 return 1;
105} 105}
106 106
107static int 107static int
108int_update(EVP_MD_CTX *ctx,const void *data,size_t count) 108int_update(EVP_MD_CTX *ctx, const void *data, size_t count)
109{ 109{
110 if (!CMAC_Update(ctx->pctx->data, data, count)) 110 if (!CMAC_Update(ctx->pctx->data, data, count))
111 return 0; 111 return 0;
@@ -193,8 +193,7 @@ pkey_cmac_ctrl_str(EVP_PKEY_CTX *ctx, const char *type, const char *value)
193 return -2; 193 return -2;
194} 194}
195 195
196const EVP_PKEY_METHOD 196const EVP_PKEY_METHOD cmac_pkey_meth = {
197cmac_pkey_meth = {
198 .pkey_id = EVP_PKEY_CMAC, 197 .pkey_id = EVP_PKEY_CMAC,
199 .flags = EVP_PKEY_FLAG_SIGCTX_CUSTOM, 198 .flags = EVP_PKEY_FLAG_SIGCTX_CUSTOM,
200 199
diff --git a/src/lib/libcrypto/cmac/cmac.c b/src/lib/libcrypto/cmac/cmac.c
index b2f77c59bd..b717f786f1 100644
--- a/src/lib/libcrypto/cmac/cmac.c
+++ b/src/lib/libcrypto/cmac/cmac.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: cmac.c,v 1.6 2014/06/21 12:07:02 miod Exp $ */ 1/* $OpenBSD: cmac.c,v 1.7 2014/06/21 13:42:14 jsing Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project. 3 * project.
4 */ 4 */
@@ -10,7 +10,7 @@
10 * are met: 10 * are met:
11 * 11 *
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 14 *
15 * 2. Redistributions in binary form must reproduce the above copyright 15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in 16 * notice, this list of conditions and the following disclaimer in
@@ -217,7 +217,7 @@ CMAC_Update(CMAC_CTX *ctx, const void *in, size_t dlen)
217 return 1; 217 return 1;
218 data += nleft; 218 data += nleft;
219 /* Else not final block so encrypt it */ 219 /* Else not final block so encrypt it */
220 if (!EVP_Cipher(&ctx->cctx, ctx->tbl, ctx->last_block,bl)) 220 if (!EVP_Cipher(&ctx->cctx, ctx->tbl, ctx->last_block, bl))
221 return 0; 221 return 0;
222 } 222 }
223 /* Encrypt all but one of the complete blocks left */ 223 /* Encrypt all but one of the complete blocks left */
@@ -257,7 +257,7 @@ CMAC_Final(CMAC_CTX *ctx, unsigned char *out, size_t *poutlen)
257 out[i] = ctx->last_block[i] ^ ctx->k2[i]; 257 out[i] = ctx->last_block[i] ^ ctx->k2[i];
258 } 258 }
259 if (!EVP_Cipher(&ctx->cctx, out, out, bl)) { 259 if (!EVP_Cipher(&ctx->cctx, out, out, bl)) {
260 OPENSSL_cleanse(out, bl); 260 OPENSSL_cleanse(out, bl);
261 return 0; 261 return 0;
262 } 262 }
263 return 1; 263 return 1;
@@ -272,7 +272,7 @@ CMAC_resume(CMAC_CTX *ctx)
272 * which is the last IV (or all zeroes if no last encrypted block). 272 * which is the last IV (or all zeroes if no last encrypted block).
273 * The last block has not been modified since CMAC_final(). 273 * The last block has not been modified since CMAC_final().
274 * So reinitialising using the last decrypted block will allow 274 * So reinitialising using the last decrypted block will allow
275 * CMAC to continue after calling CMAC_Final(). 275 * CMAC to continue after calling CMAC_Final().
276 */ 276 */
277 return EVP_EncryptInit_ex(&ctx->cctx, NULL, NULL, NULL, ctx->tbl); 277 return EVP_EncryptInit_ex(&ctx->cctx, NULL, NULL, NULL, ctx->tbl);
278} 278}
diff --git a/src/lib/libcrypto/cmac/cmac.h b/src/lib/libcrypto/cmac/cmac.h
index 10ae543f41..cb6d64b02f 100644
--- a/src/lib/libcrypto/cmac/cmac.h
+++ b/src/lib/libcrypto/cmac/cmac.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: cmac.h,v 1.2 2014/06/12 15:49:28 deraadt Exp $ */ 1/* $OpenBSD: cmac.h,v 1.3 2014/06/21 13:42:14 jsing Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project. 3 * project.
4 */ 4 */
@@ -10,7 +10,7 @@
10 * are met: 10 * are met:
11 * 11 *
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 14 *
15 * 2. Redistributions in binary form must reproduce the above copyright 15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in 16 * notice, this list of conditions and the following disclaimer in
@@ -70,8 +70,8 @@ void CMAC_CTX_free(CMAC_CTX *ctx);
70EVP_CIPHER_CTX *CMAC_CTX_get0_cipher_ctx(CMAC_CTX *ctx); 70EVP_CIPHER_CTX *CMAC_CTX_get0_cipher_ctx(CMAC_CTX *ctx);
71int CMAC_CTX_copy(CMAC_CTX *out, const CMAC_CTX *in); 71int CMAC_CTX_copy(CMAC_CTX *out, const CMAC_CTX *in);
72 72
73int CMAC_Init(CMAC_CTX *ctx, const void *key, size_t keylen, 73int CMAC_Init(CMAC_CTX *ctx, const void *key, size_t keylen,
74 const EVP_CIPHER *cipher, ENGINE *impl); 74 const EVP_CIPHER *cipher, ENGINE *impl);
75int CMAC_Update(CMAC_CTX *ctx, const void *data, size_t dlen); 75int CMAC_Update(CMAC_CTX *ctx, const void *data, size_t dlen);
76int CMAC_Final(CMAC_CTX *ctx, unsigned char *out, size_t *poutlen); 76int CMAC_Final(CMAC_CTX *ctx, unsigned char *out, size_t *poutlen);
77int CMAC_resume(CMAC_CTX *ctx); 77int CMAC_resume(CMAC_CTX *ctx);