summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto
diff options
context:
space:
mode:
authordjm <>2008-09-06 12:20:16 +0000
committerdjm <>2008-09-06 12:20:16 +0000
commite08b42612a6c7d5705254f96233d4d7fa1907a4f (patch)
tree8bad2049c8c0044c7964fd985794ad61777e7163 /src/lib/libcrypto
parent38ce604e3cc97706b876b0525ddff0121115456d (diff)
downloadopenbsd-e08b42612a6c7d5705254f96233d4d7fa1907a4f.tar.gz
openbsd-e08b42612a6c7d5705254f96233d4d7fa1907a4f.tar.bz2
openbsd-e08b42612a6c7d5705254f96233d4d7fa1907a4f.zip
remerge local tweaks, update per-arch configuration headers, update
Makefiles, crank shlib_version
Diffstat (limited to 'src/lib/libcrypto')
-rw-r--r--src/lib/libcrypto/des/des_enc.c5
-rw-r--r--src/lib/libcrypto/des/fcrypt_b.c3
-rw-r--r--src/lib/libcrypto/dso/dso_dlfcn.c13
-rw-r--r--src/lib/libcrypto/engine/hw_cryptodev.c20
-rw-r--r--src/lib/libcrypto/x509v3/v3_alt.c4
5 files changed, 25 insertions, 20 deletions
diff --git a/src/lib/libcrypto/des/des_enc.c b/src/lib/libcrypto/des/des_enc.c
index 53705b9f5b..0fe4e0b2ad 100644
--- a/src/lib/libcrypto/des/des_enc.c
+++ b/src/lib/libcrypto/des/des_enc.c
@@ -58,6 +58,8 @@
58 58
59#include "des_locl.h" 59#include "des_locl.h"
60 60
61#ifndef OPENBSD_DES_ASM
62
61void DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc) 63void DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc)
62 { 64 {
63 register DES_LONG l,r,t,u; 65 register DES_LONG l,r,t,u;
@@ -246,7 +248,8 @@ void DES_encrypt2(DES_LONG *data, DES_key_schedule *ks, int enc)
246 data[1]=ROTATE(r,3)&0xffffffffL; 248 data[1]=ROTATE(r,3)&0xffffffffL;
247 l=r=t=u=0; 249 l=r=t=u=0;
248 } 250 }
249#endif 251
252#endif /* OPENBSD_DES_ASM */
250 253
251void DES_encrypt3(DES_LONG *data, DES_key_schedule *ks1, 254void DES_encrypt3(DES_LONG *data, DES_key_schedule *ks1,
252 DES_key_schedule *ks2, DES_key_schedule *ks3) 255 DES_key_schedule *ks2, DES_key_schedule *ks3)
diff --git a/src/lib/libcrypto/des/fcrypt_b.c b/src/lib/libcrypto/des/fcrypt_b.c
index 1390138787..c56b461e91 100644
--- a/src/lib/libcrypto/des/fcrypt_b.c
+++ b/src/lib/libcrypto/des/fcrypt_b.c
@@ -68,6 +68,8 @@
68#include "des_locl.h" 68#include "des_locl.h"
69#undef DES_FCRYPT 69#undef DES_FCRYPT
70 70
71#ifndef OPENBSD_DES_ASM
72
71#undef PERM_OP 73#undef PERM_OP
72#define PERM_OP(a,b,t,n,m) ((t)=((((a)>>(n))^(b))&(m)),\ 74#define PERM_OP(a,b,t,n,m) ((t)=((((a)>>(n))^(b))&(m)),\
73 (b)^=(t),\ 75 (b)^=(t),\
@@ -143,3 +145,4 @@ void fcrypt_body(DES_LONG *out, DES_key_schedule *ks, DES_LONG Eswap0,
143 out[1]=l; 145 out[1]=l;
144 } 146 }
145 147
148#endif /* OPENBSD_DES_ASM */
diff --git a/src/lib/libcrypto/dso/dso_dlfcn.c b/src/lib/libcrypto/dso/dso_dlfcn.c
index f734c1c6b7..656cd496f8 100644
--- a/src/lib/libcrypto/dso/dso_dlfcn.c
+++ b/src/lib/libcrypto/dso/dso_dlfcn.c
@@ -269,6 +269,7 @@ static char *dlfcn_merger(DSO *dso, const char *filespec1,
269 const char *filespec2) 269 const char *filespec2)
270 { 270 {
271 char *merged; 271 char *merged;
272 size_t len;
272 273
273 if(!filespec1 && !filespec2) 274 if(!filespec1 && !filespec2)
274 { 275 {
@@ -280,18 +281,20 @@ static char *dlfcn_merger(DSO *dso, const char *filespec1,
280 same goes if the second file specification is missing. */ 281 same goes if the second file specification is missing. */
281 if (!filespec2 || filespec1[0] == '/') 282 if (!filespec2 || filespec1[0] == '/')
282 { 283 {
283 merged = OPENSSL_malloc(strlen(filespec1) + 1); 284 len = strlen(filespec1) + 1;
285 merged = OPENSSL_malloc(len);
284 if(!merged) 286 if(!merged)
285 { 287 {
286 DSOerr(DSO_F_DLFCN_MERGER, 288 DSOerr(DSO_F_DLFCN_MERGER,
287 ERR_R_MALLOC_FAILURE); 289 ERR_R_MALLOC_FAILURE);
288 return(NULL); 290 return(NULL);
289 } 291 }
290 strcpy(merged, filespec1); 292 strlcpy(merged, filespec1, len);
291 } 293 }
292 /* If the first file specification is missing, the second one rules. */ 294 /* If the first file specification is missing, the second one rules. */
293 else if (!filespec1) 295 else if (!filespec1)
294 { 296 {
297 len = strlen(filespec2) + 1;
295 merged = OPENSSL_malloc(strlen(filespec2) + 1); 298 merged = OPENSSL_malloc(strlen(filespec2) + 1);
296 if(!merged) 299 if(!merged)
297 { 300 {
@@ -299,7 +302,7 @@ static char *dlfcn_merger(DSO *dso, const char *filespec1,
299 ERR_R_MALLOC_FAILURE); 302 ERR_R_MALLOC_FAILURE);
300 return(NULL); 303 return(NULL);
301 } 304 }
302 strcpy(merged, filespec2); 305 strlcpy(merged, filespec2, len);
303 } 306 }
304 else 307 else
305 /* This part isn't as trivial as it looks. It assumes that 308 /* This part isn't as trivial as it looks. It assumes that
@@ -325,9 +328,9 @@ static char *dlfcn_merger(DSO *dso, const char *filespec1,
325 ERR_R_MALLOC_FAILURE); 328 ERR_R_MALLOC_FAILURE);
326 return(NULL); 329 return(NULL);
327 } 330 }
328 strcpy(merged, filespec2); 331 strlcpy(merged, filespec2, len + 2);
329 merged[spec2len] = '/'; 332 merged[spec2len] = '/';
330 strcpy(&merged[spec2len + 1], filespec1); 333 strlcpy(&merged[spec2len + 1], filespec1, len + 1 - spec2len);
331 } 334 }
332 return(merged); 335 return(merged);
333 } 336 }
diff --git a/src/lib/libcrypto/engine/hw_cryptodev.c b/src/lib/libcrypto/engine/hw_cryptodev.c
index a98f5d7e57..4af40cdfc3 100644
--- a/src/lib/libcrypto/engine/hw_cryptodev.c
+++ b/src/lib/libcrypto/engine/hw_cryptodev.c
@@ -114,8 +114,9 @@ static int cryptodev_asym(struct crypt_kop *kop, int rlen, BIGNUM *r,
114static int cryptodev_bn_mod_exp(BIGNUM *r, const BIGNUM *a, 114static int cryptodev_bn_mod_exp(BIGNUM *r, const BIGNUM *a,
115 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); 115 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
116static int cryptodev_rsa_nocrt_mod_exp(BIGNUM *r0, const BIGNUM *I, 116static int cryptodev_rsa_nocrt_mod_exp(BIGNUM *r0, const BIGNUM *I,
117 RSA *rsa); 117 RSA *rsa, BN_CTX *ctx);
118static int cryptodev_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa); 118static int cryptodev_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa,
119 BN_CTX *ctx);
119static int cryptodev_dsa_bn_mod_exp(DSA *dsa, BIGNUM *r, BIGNUM *a, 120static int cryptodev_dsa_bn_mod_exp(DSA *dsa, BIGNUM *r, BIGNUM *a,
120 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); 121 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
121static int cryptodev_dsa_dsa_mod_exp(DSA *dsa, BIGNUM *t1, BIGNUM *g, 122static int cryptodev_dsa_dsa_mod_exp(DSA *dsa, BIGNUM *t1, BIGNUM *g,
@@ -978,19 +979,14 @@ err:
978} 979}
979 980
980static int 981static int
981cryptodev_rsa_nocrt_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa) 982cryptodev_rsa_nocrt_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa,
983 BN_CTX *ctx)
982{ 984{
983 int r; 985 return (RSA_PKCS1_SSLeay()->rsa_mod_exp)(r0, I, rsa, ctx);
984 BN_CTX *ctx;
985
986 ctx = BN_CTX_new();
987 r = cryptodev_bn_mod_exp(r0, I, rsa->d, rsa->n, ctx, NULL);
988 BN_CTX_free(ctx);
989 return (r);
990} 986}
991 987
992static int 988static int
993cryptodev_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa) 989cryptodev_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx)
994{ 990{
995 struct crypt_kop kop; 991 struct crypt_kop kop;
996 int ret = 1; 992 int ret = 1;
@@ -1019,7 +1015,7 @@ cryptodev_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa)
1019 1015
1020 if (cryptodev_asym(&kop, BN_num_bytes(rsa->n), r0, 0, NULL) == -1) { 1016 if (cryptodev_asym(&kop, BN_num_bytes(rsa->n), r0, 0, NULL) == -1) {
1021 const RSA_METHOD *meth = RSA_PKCS1_SSLeay(); 1017 const RSA_METHOD *meth = RSA_PKCS1_SSLeay();
1022 ret = (*meth->rsa_mod_exp)(r0, I, rsa); 1018 ret = (*meth->rsa_mod_exp)(r0, I, rsa, ctx);
1023 } 1019 }
1024err: 1020err:
1025 zapparams(&kop); 1021 zapparams(&kop);
diff --git a/src/lib/libcrypto/x509v3/v3_alt.c b/src/lib/libcrypto/x509v3/v3_alt.c
index bb2f5bc54e..ac3139d1e6 100644
--- a/src/lib/libcrypto/x509v3/v3_alt.c
+++ b/src/lib/libcrypto/x509v3/v3_alt.c
@@ -147,9 +147,9 @@ STACK_OF(CONF_VALUE) *i2v_GENERAL_NAME(X509V3_EXT_METHOD *method,
147 BIO_snprintf(htmp, sizeof htmp, 147 BIO_snprintf(htmp, sizeof htmp,
148 "%X", p[0] << 8 | p[1]); 148 "%X", p[0] << 8 | p[1]);
149 p += 2; 149 p += 2;
150 strcat(oline, htmp); 150 strlcat(oline, htmp, sizeof oline);
151 if (i != 7) 151 if (i != 7)
152 strcat(oline, ":"); 152 strlcat(oline, ":", sizeof oline);
153 } 153 }
154 } 154 }
155 else 155 else