diff options
author | deraadt <> | 2014-06-27 06:07:35 +0000 |
---|---|---|
committer | deraadt <> | 2014-06-27 06:07:35 +0000 |
commit | fd6338db9db0aa87673a9fb6d1abc0ebb4507099 (patch) | |
tree | a15b222a92fe994ec9b207cf12743f2f3cb61fa8 | |
parent | 83921e06b0fd7ce1393248d64f8cd3b5265d9790 (diff) | |
download | openbsd-fd6338db9db0aa87673a9fb6d1abc0ebb4507099.tar.gz openbsd-fd6338db9db0aa87673a9fb6d1abc0ebb4507099.tar.bz2 openbsd-fd6338db9db0aa87673a9fb6d1abc0ebb4507099.zip |
hand-KNF macro the do { } while loops
-rw-r--r-- | src/lib/libcrypto/bn/bn.h | 3 | ||||
-rw-r--r-- | src/lib/libcrypto/bn/bn_ctx.c | 24 | ||||
-rw-r--r-- | src/lib/libcrypto/dsa/dsa_ossl.c | 36 | ||||
-rw-r--r-- | src/lib/libcrypto/modes/gcm128.c | 26 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/bn/bn.h | 3 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/bn/bn_ctx.c | 24 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/dsa/dsa_ossl.c | 36 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/modes/gcm128.c | 26 |
8 files changed, 98 insertions, 80 deletions
diff --git a/src/lib/libcrypto/bn/bn.h b/src/lib/libcrypto/bn/bn.h index ca2d69c705..155adf4fe0 100644 --- a/src/lib/libcrypto/bn/bn.h +++ b/src/lib/libcrypto/bn/bn.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bn.h,v 1.23 2014/06/12 15:49:28 deraadt Exp $ */ | 1 | /* $OpenBSD: bn.h,v 1.24 2014/06/27 06:07:35 deraadt Exp $ */ |
2 | /* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -346,6 +346,7 @@ int BN_GENCB_call(BN_GENCB *cb, int a, int b); | |||
346 | _tmp_bn->top = 0; \ | 346 | _tmp_bn->top = 0; \ |
347 | _tmp_bn->neg = 0; \ | 347 | _tmp_bn->neg = 0; \ |
348 | } while(0) | 348 | } while(0) |
349 | |||
349 | #ifdef OPENSSL_NO_DEPRECATED | 350 | #ifdef OPENSSL_NO_DEPRECATED |
350 | #define BN_zero(a) BN_zero_ex(a) | 351 | #define BN_zero(a) BN_zero_ex(a) |
351 | #else | 352 | #else |
diff --git a/src/lib/libcrypto/bn/bn_ctx.c b/src/lib/libcrypto/bn/bn_ctx.c index ed0f434e60..e3ea72516b 100644 --- a/src/lib/libcrypto/bn/bn_ctx.c +++ b/src/lib/libcrypto/bn/bn_ctx.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bn_ctx.c,v 1.9 2014/06/12 15:49:28 deraadt Exp $ */ | 1 | /* $OpenBSD: bn_ctx.c,v 1.10 2014/06/27 06:07:35 deraadt Exp $ */ |
2 | /* Written by Ulf Moeller for the OpenSSL project. */ | 2 | /* Written by Ulf Moeller for the OpenSSL project. */ |
3 | /* ==================================================================== | 3 | /* ==================================================================== |
4 | * Copyright (c) 1998-2004 The OpenSSL Project. All rights reserved. | 4 | * Copyright (c) 1998-2004 The OpenSSL Project. All rights reserved. |
@@ -179,15 +179,19 @@ ctxdbg(BN_CTX *ctx) | |||
179 | } | 179 | } |
180 | fprintf(stderr, "\n"); | 180 | fprintf(stderr, "\n"); |
181 | } | 181 | } |
182 | #define CTXDBG_ENTRY(str, ctx) do { \ | 182 | #define CTXDBG_ENTRY(str, ctx) \ |
183 | ctxdbg_cur = (str); \ | 183 | do { \ |
184 | fprintf(stderr,"Starting %s\n", ctxdbg_cur); \ | 184 | ctxdbg_cur = (str); \ |
185 | ctxdbg(ctx); \ | 185 | fprintf(stderr, "Starting %s\n", ctxdbg_cur); \ |
186 | } while(0) | 186 | ctxdbg(ctx); \ |
187 | #define CTXDBG_EXIT(ctx) do { \ | 187 | } while(0) |
188 | fprintf(stderr,"Ending %s\n", ctxdbg_cur); \ | 188 | |
189 | ctxdbg(ctx); \ | 189 | #define CTXDBG_EXIT(ctx) \ |
190 | } while(0) | 190 | do { \ |
191 | fprintf(stderr, "Ending %s\n", ctxdbg_cur); \ | ||
192 | ctxdbg(ctx); \ | ||
193 | } while(0) | ||
194 | |||
191 | #define CTXDBG_RET(ctx,ret) | 195 | #define CTXDBG_RET(ctx,ret) |
192 | #else | 196 | #else |
193 | #define CTXDBG_ENTRY(str, ctx) | 197 | #define CTXDBG_ENTRY(str, ctx) |
diff --git a/src/lib/libcrypto/dsa/dsa_ossl.c b/src/lib/libcrypto/dsa/dsa_ossl.c index c3f01b0f11..61a20f41a7 100644 --- a/src/lib/libcrypto/dsa/dsa_ossl.c +++ b/src/lib/libcrypto/dsa/dsa_ossl.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: dsa_ossl.c,v 1.17 2014/06/12 15:49:28 deraadt Exp $ */ | 1 | /* $OpenBSD: dsa_ossl.c,v 1.18 2014/06/27 06:07:35 deraadt Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -97,24 +97,28 @@ static DSA_METHOD openssl_dsa_meth = { | |||
97 | 97 | ||
98 | #define DSA_MOD_EXP(err_instr,dsa,rr,a1,p1,a2,p2,m,ctx,in_mont) \ | 98 | #define DSA_MOD_EXP(err_instr,dsa,rr,a1,p1,a2,p2,m,ctx,in_mont) \ |
99 | do { \ | 99 | do { \ |
100 | int _tmp_res53; \ | 100 | int _tmp_res53; \ |
101 | if((dsa)->meth->dsa_mod_exp) \ | 101 | if((dsa)->meth->dsa_mod_exp) \ |
102 | _tmp_res53 = (dsa)->meth->dsa_mod_exp((dsa), (rr), (a1), (p1), \ | 102 | _tmp_res53 = (dsa)->meth->dsa_mod_exp((dsa), (rr), \ |
103 | (a2), (p2), (m), (ctx), (in_mont)); \ | 103 | (a1), (p1), (a2), (p2), (m), (ctx), (in_mont)); \ |
104 | else \ | 104 | else \ |
105 | _tmp_res53 = BN_mod_exp2_mont((rr), (a1), (p1), (a2), (p2), \ | 105 | _tmp_res53 = BN_mod_exp2_mont((rr), (a1), \ |
106 | (m), (ctx), (in_mont)); \ | 106 | (p1), (a2), (p2), (m), (ctx), (in_mont)); \ |
107 | if(!_tmp_res53) err_instr; \ | 107 | if(!_tmp_res53) \ |
108 | err_instr; \ | ||
108 | } while(0) | 109 | } while(0) |
110 | |||
109 | #define DSA_BN_MOD_EXP(err_instr,dsa,r,a,p,m,ctx,m_ctx) \ | 111 | #define DSA_BN_MOD_EXP(err_instr,dsa,r,a,p,m,ctx,m_ctx) \ |
110 | do { \ | 112 | do { \ |
111 | int _tmp_res53; \ | 113 | int _tmp_res53; \ |
112 | if((dsa)->meth->bn_mod_exp) \ | 114 | if((dsa)->meth->bn_mod_exp) \ |
113 | _tmp_res53 = (dsa)->meth->bn_mod_exp((dsa), (r), (a), (p), \ | 115 | _tmp_res53 = (dsa)->meth->bn_mod_exp((dsa), (r), \ |
114 | (m), (ctx), (m_ctx)); \ | 116 | (a), (p), (m), (ctx), (m_ctx)); \ |
115 | else \ | 117 | else \ |
116 | _tmp_res53 = BN_mod_exp_mont((r), (a), (p), (m), (ctx), (m_ctx)); \ | 118 | _tmp_res53 = BN_mod_exp_mont((r), (a), (p), (m), \ |
117 | if(!_tmp_res53) err_instr; \ | 119 | (ctx), (m_ctx)); \ |
120 | if(!_tmp_res53) \ | ||
121 | err_instr; \ | ||
118 | } while(0) | 122 | } while(0) |
119 | 123 | ||
120 | const DSA_METHOD *DSA_OpenSSL(void) | 124 | const DSA_METHOD *DSA_OpenSSL(void) |
diff --git a/src/lib/libcrypto/modes/gcm128.c b/src/lib/libcrypto/modes/gcm128.c index 45951878e5..def8cca496 100644 --- a/src/lib/libcrypto/modes/gcm128.c +++ b/src/lib/libcrypto/modes/gcm128.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: gcm128.c,v 1.8 2014/06/12 15:49:30 deraadt Exp $ */ | 1 | /* $OpenBSD: gcm128.c,v 1.9 2014/06/27 06:07:35 deraadt Exp $ */ |
2 | /* ==================================================================== | 2 | /* ==================================================================== |
3 | * Copyright (c) 2010 The OpenSSL Project. All rights reserved. | 3 | * Copyright (c) 2010 The OpenSSL Project. All rights reserved. |
4 | * | 4 | * |
@@ -70,18 +70,18 @@ | |||
70 | #endif | 70 | #endif |
71 | 71 | ||
72 | #define PACK(s) ((size_t)(s)<<(sizeof(size_t)*8-16)) | 72 | #define PACK(s) ((size_t)(s)<<(sizeof(size_t)*8-16)) |
73 | #define REDUCE1BIT(V) do { \ | 73 | #define REDUCE1BIT(V) \ |
74 | if (sizeof(size_t)==8) { \ | 74 | do { \ |
75 | u64 T = U64(0xe100000000000000) & (0-(V.lo&1)); \ | 75 | if (sizeof(size_t)==8) { \ |
76 | V.lo = (V.hi<<63)|(V.lo>>1); \ | 76 | u64 T = U64(0xe100000000000000) & (0-(V.lo&1)); \ |
77 | V.hi = (V.hi>>1 )^T; \ | 77 | V.lo = (V.hi<<63)|(V.lo>>1); \ |
78 | } \ | 78 | V.hi = (V.hi>>1 )^T; \ |
79 | else { \ | 79 | } else { \ |
80 | u32 T = 0xe1000000U & (0-(u32)(V.lo&1)); \ | 80 | u32 T = 0xe1000000U & (0-(u32)(V.lo&1)); \ |
81 | V.lo = (V.hi<<63)|(V.lo>>1); \ | 81 | V.lo = (V.hi<<63)|(V.lo>>1); \ |
82 | V.hi = (V.hi>>1 )^((u64)T<<32); \ | 82 | V.hi = (V.hi>>1 )^((u64)T<<32); \ |
83 | } \ | 83 | } \ |
84 | } while(0) | 84 | } while(0) |
85 | 85 | ||
86 | /* | 86 | /* |
87 | * Even though permitted values for TABLE_BITS are 8, 4 and 1, it should | 87 | * Even though permitted values for TABLE_BITS are 8, 4 and 1, it should |
diff --git a/src/lib/libssl/src/crypto/bn/bn.h b/src/lib/libssl/src/crypto/bn/bn.h index ca2d69c705..155adf4fe0 100644 --- a/src/lib/libssl/src/crypto/bn/bn.h +++ b/src/lib/libssl/src/crypto/bn/bn.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bn.h,v 1.23 2014/06/12 15:49:28 deraadt Exp $ */ | 1 | /* $OpenBSD: bn.h,v 1.24 2014/06/27 06:07:35 deraadt Exp $ */ |
2 | /* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -346,6 +346,7 @@ int BN_GENCB_call(BN_GENCB *cb, int a, int b); | |||
346 | _tmp_bn->top = 0; \ | 346 | _tmp_bn->top = 0; \ |
347 | _tmp_bn->neg = 0; \ | 347 | _tmp_bn->neg = 0; \ |
348 | } while(0) | 348 | } while(0) |
349 | |||
349 | #ifdef OPENSSL_NO_DEPRECATED | 350 | #ifdef OPENSSL_NO_DEPRECATED |
350 | #define BN_zero(a) BN_zero_ex(a) | 351 | #define BN_zero(a) BN_zero_ex(a) |
351 | #else | 352 | #else |
diff --git a/src/lib/libssl/src/crypto/bn/bn_ctx.c b/src/lib/libssl/src/crypto/bn/bn_ctx.c index ed0f434e60..e3ea72516b 100644 --- a/src/lib/libssl/src/crypto/bn/bn_ctx.c +++ b/src/lib/libssl/src/crypto/bn/bn_ctx.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bn_ctx.c,v 1.9 2014/06/12 15:49:28 deraadt Exp $ */ | 1 | /* $OpenBSD: bn_ctx.c,v 1.10 2014/06/27 06:07:35 deraadt Exp $ */ |
2 | /* Written by Ulf Moeller for the OpenSSL project. */ | 2 | /* Written by Ulf Moeller for the OpenSSL project. */ |
3 | /* ==================================================================== | 3 | /* ==================================================================== |
4 | * Copyright (c) 1998-2004 The OpenSSL Project. All rights reserved. | 4 | * Copyright (c) 1998-2004 The OpenSSL Project. All rights reserved. |
@@ -179,15 +179,19 @@ ctxdbg(BN_CTX *ctx) | |||
179 | } | 179 | } |
180 | fprintf(stderr, "\n"); | 180 | fprintf(stderr, "\n"); |
181 | } | 181 | } |
182 | #define CTXDBG_ENTRY(str, ctx) do { \ | 182 | #define CTXDBG_ENTRY(str, ctx) \ |
183 | ctxdbg_cur = (str); \ | 183 | do { \ |
184 | fprintf(stderr,"Starting %s\n", ctxdbg_cur); \ | 184 | ctxdbg_cur = (str); \ |
185 | ctxdbg(ctx); \ | 185 | fprintf(stderr, "Starting %s\n", ctxdbg_cur); \ |
186 | } while(0) | 186 | ctxdbg(ctx); \ |
187 | #define CTXDBG_EXIT(ctx) do { \ | 187 | } while(0) |
188 | fprintf(stderr,"Ending %s\n", ctxdbg_cur); \ | 188 | |
189 | ctxdbg(ctx); \ | 189 | #define CTXDBG_EXIT(ctx) \ |
190 | } while(0) | 190 | do { \ |
191 | fprintf(stderr, "Ending %s\n", ctxdbg_cur); \ | ||
192 | ctxdbg(ctx); \ | ||
193 | } while(0) | ||
194 | |||
191 | #define CTXDBG_RET(ctx,ret) | 195 | #define CTXDBG_RET(ctx,ret) |
192 | #else | 196 | #else |
193 | #define CTXDBG_ENTRY(str, ctx) | 197 | #define CTXDBG_ENTRY(str, ctx) |
diff --git a/src/lib/libssl/src/crypto/dsa/dsa_ossl.c b/src/lib/libssl/src/crypto/dsa/dsa_ossl.c index c3f01b0f11..61a20f41a7 100644 --- a/src/lib/libssl/src/crypto/dsa/dsa_ossl.c +++ b/src/lib/libssl/src/crypto/dsa/dsa_ossl.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: dsa_ossl.c,v 1.17 2014/06/12 15:49:28 deraadt Exp $ */ | 1 | /* $OpenBSD: dsa_ossl.c,v 1.18 2014/06/27 06:07:35 deraadt Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -97,24 +97,28 @@ static DSA_METHOD openssl_dsa_meth = { | |||
97 | 97 | ||
98 | #define DSA_MOD_EXP(err_instr,dsa,rr,a1,p1,a2,p2,m,ctx,in_mont) \ | 98 | #define DSA_MOD_EXP(err_instr,dsa,rr,a1,p1,a2,p2,m,ctx,in_mont) \ |
99 | do { \ | 99 | do { \ |
100 | int _tmp_res53; \ | 100 | int _tmp_res53; \ |
101 | if((dsa)->meth->dsa_mod_exp) \ | 101 | if((dsa)->meth->dsa_mod_exp) \ |
102 | _tmp_res53 = (dsa)->meth->dsa_mod_exp((dsa), (rr), (a1), (p1), \ | 102 | _tmp_res53 = (dsa)->meth->dsa_mod_exp((dsa), (rr), \ |
103 | (a2), (p2), (m), (ctx), (in_mont)); \ | 103 | (a1), (p1), (a2), (p2), (m), (ctx), (in_mont)); \ |
104 | else \ | 104 | else \ |
105 | _tmp_res53 = BN_mod_exp2_mont((rr), (a1), (p1), (a2), (p2), \ | 105 | _tmp_res53 = BN_mod_exp2_mont((rr), (a1), \ |
106 | (m), (ctx), (in_mont)); \ | 106 | (p1), (a2), (p2), (m), (ctx), (in_mont)); \ |
107 | if(!_tmp_res53) err_instr; \ | 107 | if(!_tmp_res53) \ |
108 | err_instr; \ | ||
108 | } while(0) | 109 | } while(0) |
110 | |||
109 | #define DSA_BN_MOD_EXP(err_instr,dsa,r,a,p,m,ctx,m_ctx) \ | 111 | #define DSA_BN_MOD_EXP(err_instr,dsa,r,a,p,m,ctx,m_ctx) \ |
110 | do { \ | 112 | do { \ |
111 | int _tmp_res53; \ | 113 | int _tmp_res53; \ |
112 | if((dsa)->meth->bn_mod_exp) \ | 114 | if((dsa)->meth->bn_mod_exp) \ |
113 | _tmp_res53 = (dsa)->meth->bn_mod_exp((dsa), (r), (a), (p), \ | 115 | _tmp_res53 = (dsa)->meth->bn_mod_exp((dsa), (r), \ |
114 | (m), (ctx), (m_ctx)); \ | 116 | (a), (p), (m), (ctx), (m_ctx)); \ |
115 | else \ | 117 | else \ |
116 | _tmp_res53 = BN_mod_exp_mont((r), (a), (p), (m), (ctx), (m_ctx)); \ | 118 | _tmp_res53 = BN_mod_exp_mont((r), (a), (p), (m), \ |
117 | if(!_tmp_res53) err_instr; \ | 119 | (ctx), (m_ctx)); \ |
120 | if(!_tmp_res53) \ | ||
121 | err_instr; \ | ||
118 | } while(0) | 122 | } while(0) |
119 | 123 | ||
120 | const DSA_METHOD *DSA_OpenSSL(void) | 124 | const DSA_METHOD *DSA_OpenSSL(void) |
diff --git a/src/lib/libssl/src/crypto/modes/gcm128.c b/src/lib/libssl/src/crypto/modes/gcm128.c index 45951878e5..def8cca496 100644 --- a/src/lib/libssl/src/crypto/modes/gcm128.c +++ b/src/lib/libssl/src/crypto/modes/gcm128.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: gcm128.c,v 1.8 2014/06/12 15:49:30 deraadt Exp $ */ | 1 | /* $OpenBSD: gcm128.c,v 1.9 2014/06/27 06:07:35 deraadt Exp $ */ |
2 | /* ==================================================================== | 2 | /* ==================================================================== |
3 | * Copyright (c) 2010 The OpenSSL Project. All rights reserved. | 3 | * Copyright (c) 2010 The OpenSSL Project. All rights reserved. |
4 | * | 4 | * |
@@ -70,18 +70,18 @@ | |||
70 | #endif | 70 | #endif |
71 | 71 | ||
72 | #define PACK(s) ((size_t)(s)<<(sizeof(size_t)*8-16)) | 72 | #define PACK(s) ((size_t)(s)<<(sizeof(size_t)*8-16)) |
73 | #define REDUCE1BIT(V) do { \ | 73 | #define REDUCE1BIT(V) \ |
74 | if (sizeof(size_t)==8) { \ | 74 | do { \ |
75 | u64 T = U64(0xe100000000000000) & (0-(V.lo&1)); \ | 75 | if (sizeof(size_t)==8) { \ |
76 | V.lo = (V.hi<<63)|(V.lo>>1); \ | 76 | u64 T = U64(0xe100000000000000) & (0-(V.lo&1)); \ |
77 | V.hi = (V.hi>>1 )^T; \ | 77 | V.lo = (V.hi<<63)|(V.lo>>1); \ |
78 | } \ | 78 | V.hi = (V.hi>>1 )^T; \ |
79 | else { \ | 79 | } else { \ |
80 | u32 T = 0xe1000000U & (0-(u32)(V.lo&1)); \ | 80 | u32 T = 0xe1000000U & (0-(u32)(V.lo&1)); \ |
81 | V.lo = (V.hi<<63)|(V.lo>>1); \ | 81 | V.lo = (V.hi<<63)|(V.lo>>1); \ |
82 | V.hi = (V.hi>>1 )^((u64)T<<32); \ | 82 | V.hi = (V.hi>>1 )^((u64)T<<32); \ |
83 | } \ | 83 | } \ |
84 | } while(0) | 84 | } while(0) |
85 | 85 | ||
86 | /* | 86 | /* |
87 | * Even though permitted values for TABLE_BITS are 8, 4 and 1, it should | 87 | * Even though permitted values for TABLE_BITS are 8, 4 and 1, it should |