summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordjm <>2011-11-03 02:32:21 +0000
committerdjm <>2011-11-03 02:32:21 +0000
commit074782d395f8a140cd5120b87574dcd928bacd24 (patch)
tree79374ba6e81c08ba6e78220557d6f6e9ca03f7b7
parentf6ca1ae73bb9eabfb510df2cffc2599db98d35a9 (diff)
downloadopenbsd-074782d395f8a140cd5120b87574dcd928bacd24.tar.gz
openbsd-074782d395f8a140cd5120b87574dcd928bacd24.tar.bz2
openbsd-074782d395f8a140cd5120b87574dcd928bacd24.zip
import OpenSSL 1.0.0e
-rw-r--r--src/lib/libcrypto/LPdir_vms.c49
-rw-r--r--src/lib/libcrypto/ecdsa/ecdsatest.c5
-rw-r--r--src/lib/libcrypto/jpake/jpake.c29
-rw-r--r--src/lib/libcrypto/jpake/jpake.h2
-rw-r--r--src/lib/libcrypto/jpake/jpake_err.c4
-rw-r--r--src/lib/libcrypto/pqueue/pqueue.c5
-rw-r--r--src/lib/libcrypto/rand/rand_nw.c4
-rwxr-xr-xsrc/lib/libcrypto/vms_rms.h51
-rw-r--r--src/lib/libcrypto/x509v3/v3_addr.c6
-rw-r--r--src/lib/libcrypto/x509v3/v3_asid.c31
-rw-r--r--src/lib/libssl/src/ACKNOWLEDGMENTS25
-rw-r--r--src/lib/libssl/src/Makefile.shared26
-rw-r--r--src/lib/libssl/src/apps/ec.c5
-rw-r--r--src/lib/libssl/src/apps/ecparam.c5
-rw-r--r--src/lib/libssl/src/apps/pkeyparam.c3
-rw-r--r--src/lib/libssl/src/apps/pkeyutl.c12
-rwxr-xr-xsrc/lib/libssl/src/apps/vms_decc_init.c188
-rw-r--r--src/lib/libssl/src/crypto/LPdir_vms.c49
-rw-r--r--src/lib/libssl/src/crypto/aes/aes_wrap.c12
-rw-r--r--src/lib/libssl/src/crypto/aes/asm/aes-armv4.pl397
-rw-r--r--src/lib/libssl/src/crypto/alphacpuid.pl126
-rw-r--r--src/lib/libssl/src/crypto/asn1/ameth_lib.c2
-rw-r--r--src/lib/libssl/src/crypto/asn1/bio_ndef.c3
-rw-r--r--src/lib/libssl/src/crypto/bio/bss_dgram.c20
-rw-r--r--src/lib/libssl/src/crypto/bn/asm/alpha-mont.pl36
-rw-r--r--src/lib/libssl/src/crypto/bn/asm/s390x-mont.pl4
-rwxr-xr-xsrc/lib/libssl/src/crypto/bn/asm/s390x.S86
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_gf2m.c1
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_nist.c64
-rw-r--r--src/lib/libssl/src/crypto/dsa/dsa_pmeth.c1
-rw-r--r--src/lib/libssl/src/crypto/ec/ec2_mult.c13
-rw-r--r--src/lib/libssl/src/crypto/ec/ec2_smpl.c3
-rw-r--r--src/lib/libssl/src/crypto/ec/ec_key.c8
-rw-r--r--src/lib/libssl/src/crypto/ecdh/ech_lib.c3
-rw-r--r--src/lib/libssl/src/crypto/ecdsa/ecdsatest.c5
-rw-r--r--src/lib/libssl/src/crypto/ecdsa/ecs_lib.c2
-rw-r--r--src/lib/libssl/src/crypto/ecdsa/ecs_ossl.c8
-rw-r--r--src/lib/libssl/src/crypto/evp/m_sigver.c4
-rw-r--r--src/lib/libssl/src/crypto/evp/pmeth_lib.c2
-rw-r--r--src/lib/libssl/src/crypto/hmac/hm_pmeth.c2
-rw-r--r--src/lib/libssl/src/crypto/jpake/jpake.c29
-rw-r--r--src/lib/libssl/src/crypto/jpake/jpake.h2
-rw-r--r--src/lib/libssl/src/crypto/jpake/jpake_err.c4
-rw-r--r--src/lib/libssl/src/crypto/pem/pvkfmt.c10
-rwxr-xr-xsrc/lib/libssl/src/crypto/perlasm/x86_64-xlate.pl6
-rw-r--r--src/lib/libssl/src/crypto/pqueue/pqueue.c5
-rw-r--r--src/lib/libssl/src/crypto/rand/rand_nw.c4
-rw-r--r--src/lib/libssl/src/crypto/sha/asm/sha1-armv4-large.pl76
-rw-r--r--src/lib/libssl/src/crypto/sha/asm/sha1-sparcv9.pl1
-rw-r--r--src/lib/libssl/src/crypto/sha/asm/sha1-sparcv9a.pl1
-rw-r--r--src/lib/libssl/src/crypto/sha/asm/sha256-armv4.pl33
-rw-r--r--src/lib/libssl/src/crypto/sha/asm/sha512-armv4.pl32
-rw-r--r--src/lib/libssl/src/crypto/sha/asm/sha512-sparcv9.pl1
-rw-r--r--src/lib/libssl/src/crypto/sparccpuid.S84
-rw-r--r--src/lib/libssl/src/crypto/sparcv9cap.c97
-rw-r--r--src/lib/libssl/src/crypto/ts/ts_verify_ctx.c5
-rwxr-xr-xsrc/lib/libssl/src/crypto/vms_rms.h51
-rw-r--r--src/lib/libssl/src/crypto/x509v3/pcy_tree.c3
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_addr.c6
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_asid.c31
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_ncons.c1
-rw-r--r--src/lib/libssl/src/doc/crypto/EVP_PKEY_verify.pod2
-rw-r--r--src/lib/libssl/src/engines/Makefile2
-rw-r--r--src/lib/libssl/src/engines/ccgost/Makefile2
-rw-r--r--src/lib/libssl/src/engines/ccgost/gost_ameth.c4
-rw-r--r--src/lib/libssl/src/engines/ccgost/gost_crypt.c3
-rw-r--r--src/lib/libssl/src/engines/e_aep.c8
-rw-r--r--src/lib/libssl/src/engines/e_capi.c14
-rw-r--r--src/lib/libssl/src/engines/e_capi_err.h4
-rw-r--r--src/lib/libssl/src/engines/e_chil.c4
-rw-r--r--src/lib/libssl/src/engines/e_cswift.c2
-rw-r--r--src/lib/libssl/src/engines/e_gmp.c2
-rw-r--r--src/lib/libssl/src/engines/e_padlock.c6
-rw-r--r--src/lib/libssl/src/engines/e_ubsec.c2
-rw-r--r--src/lib/libssl/src/ssl/d1_both.c28
-rw-r--r--src/lib/libssl/src/ssl/d1_clnt.c6
-rw-r--r--src/lib/libssl/src/ssl/d1_enc.c6
-rw-r--r--src/lib/libssl/src/ssl/d1_lib.c65
-rw-r--r--src/lib/libssl/src/ssl/d1_pkt.c22
-rw-r--r--src/lib/libssl/src/ssl/d1_srvr.c26
-rw-r--r--src/lib/libssl/src/test/cms-test.pl94
81 files changed, 1444 insertions, 641 deletions
diff --git a/src/lib/libcrypto/LPdir_vms.c b/src/lib/libcrypto/LPdir_vms.c
index 85b427a623..7613bd254e 100644
--- a/src/lib/libcrypto/LPdir_vms.c
+++ b/src/lib/libcrypto/LPdir_vms.c
@@ -40,22 +40,18 @@
40#ifndef LPDIR_H 40#ifndef LPDIR_H
41#include "LPdir.h" 41#include "LPdir.h"
42#endif 42#endif
43#include "vms_rms.h"
43 44
44/* Because some compiler options hide this macor */ 45/* Some compiler options hide EVMSERR. */
45#ifndef EVMSERR 46#ifndef EVMSERR
46#define EVMSERR 65535 /* error for non-translatable VMS errors */ 47# define EVMSERR 65535 /* error for non-translatable VMS errors */
47#endif 48#endif
48 49
49struct LP_dir_context_st 50struct LP_dir_context_st
50{ 51{
51 unsigned long VMS_context; 52 unsigned long VMS_context;
52#ifdef NAML$C_MAXRSS 53 char filespec[ NAMX_MAXRSS+ 1];
53 char filespec[NAML$C_MAXRSS+1]; 54 char result[ NAMX_MAXRSS+ 1];
54 char result[NAML$C_MAXRSS+1];
55#else
56 char filespec[256];
57 char result[256];
58#endif
59 struct dsc$descriptor_d filespec_dsc; 55 struct dsc$descriptor_d filespec_dsc;
60 struct dsc$descriptor_d result_dsc; 56 struct dsc$descriptor_d result_dsc;
61}; 57};
@@ -66,6 +62,16 @@ const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory)
66 char *p, *r; 62 char *p, *r;
67 size_t l; 63 size_t l;
68 unsigned long flags = 0; 64 unsigned long flags = 0;
65
66/* Arrange 32-bit pointer to (copied) string storage, if needed. */
67#if __INITIAL_POINTER_SIZE == 64
68# pragma pointer_size save
69# pragma pointer_size 32
70 char *ctx_filespec_32p;
71# pragma pointer_size restore
72 char ctx_filespec_32[ NAMX_MAXRSS+ 1];
73#endif /* __INITIAL_POINTER_SIZE == 64 */
74
69#ifdef NAML$C_MAXRSS 75#ifdef NAML$C_MAXRSS
70 flags |= LIB$M_FIL_LONG_NAMES; 76 flags |= LIB$M_FIL_LONG_NAMES;
71#endif 77#endif
@@ -93,13 +99,7 @@ const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory)
93 99
94 filespeclen += 4; /* "*.*;" */ 100 filespeclen += 4; /* "*.*;" */
95 101
96 if (filespeclen > 102 if (filespeclen > NAMX_MAXRSS)
97#ifdef NAML$C_MAXRSS
98 NAML$C_MAXRSS
99#else
100 255
101#endif
102 )
103 { 103 {
104 errno = ENAMETOOLONG; 104 errno = ENAMETOOLONG;
105 return 0; 105 return 0;
@@ -115,14 +115,21 @@ const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory)
115 115
116 strcpy((*ctx)->filespec,directory); 116 strcpy((*ctx)->filespec,directory);
117 strcat((*ctx)->filespec,"*.*;"); 117 strcat((*ctx)->filespec,"*.*;");
118
119/* Arrange 32-bit pointer to (copied) string storage, if needed. */
120#if __INITIAL_POINTER_SIZE == 64
121# define CTX_FILESPEC ctx_filespec_32p
122 /* Copy the file name to storage with a 32-bit pointer. */
123 ctx_filespec_32p = ctx_filespec_32;
124 strcpy( ctx_filespec_32p, (*ctx)->filespec);
125#else /* __INITIAL_POINTER_SIZE == 64 */
126# define CTX_FILESPEC (*ctx)->filespec
127#endif /* __INITIAL_POINTER_SIZE == 64 [else] */
128
118 (*ctx)->filespec_dsc.dsc$w_length = filespeclen; 129 (*ctx)->filespec_dsc.dsc$w_length = filespeclen;
119 (*ctx)->filespec_dsc.dsc$b_dtype = DSC$K_DTYPE_T; 130 (*ctx)->filespec_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
120 (*ctx)->filespec_dsc.dsc$b_class = DSC$K_CLASS_S; 131 (*ctx)->filespec_dsc.dsc$b_class = DSC$K_CLASS_S;
121 (*ctx)->filespec_dsc.dsc$a_pointer = (*ctx)->filespec; 132 (*ctx)->filespec_dsc.dsc$a_pointer = CTX_FILESPEC;
122 (*ctx)->result_dsc.dsc$w_length = 0;
123 (*ctx)->result_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
124 (*ctx)->result_dsc.dsc$b_class = DSC$K_CLASS_D;
125 (*ctx)->result_dsc.dsc$a_pointer = 0;
126 } 133 }
127 134
128 (*ctx)->result_dsc.dsc$w_length = 0; 135 (*ctx)->result_dsc.dsc$w_length = 0;
diff --git a/src/lib/libcrypto/ecdsa/ecdsatest.c b/src/lib/libcrypto/ecdsa/ecdsatest.c
index aa4e1481a8..26a4a9ee7c 100644
--- a/src/lib/libcrypto/ecdsa/ecdsatest.c
+++ b/src/lib/libcrypto/ecdsa/ecdsatest.c
@@ -168,10 +168,9 @@ int fbytes(unsigned char *buf, int num)
168 return 0; 168 return 0;
169 } 169 }
170 fbytes_counter ++; 170 fbytes_counter ++;
171 ret = BN_bn2bin(tmp, buf); 171 if (num != BN_num_bytes(tmp) || !BN_bn2bin(tmp, buf))
172 if (ret == 0 || ret != num)
173 ret = 0; 172 ret = 0;
174 else 173 else
175 ret = 1; 174 ret = 1;
176 if (tmp) 175 if (tmp)
177 BN_free(tmp); 176 BN_free(tmp);
diff --git a/src/lib/libcrypto/jpake/jpake.c b/src/lib/libcrypto/jpake/jpake.c
index 086d9f47e0..8e4b633ccc 100644
--- a/src/lib/libcrypto/jpake/jpake.c
+++ b/src/lib/libcrypto/jpake/jpake.c
@@ -282,8 +282,37 @@ int JPAKE_STEP1_generate(JPAKE_STEP1 *send, JPAKE_CTX *ctx)
282 return 1; 282 return 1;
283 } 283 }
284 284
285/* g^x is a legal value */
286static int is_legal(const BIGNUM *gx, const JPAKE_CTX *ctx)
287 {
288 BIGNUM *t;
289 int res;
290
291 if(BN_is_negative(gx) || BN_is_zero(gx) || BN_cmp(gx, ctx->p.p) >= 0)
292 return 0;
293
294 t = BN_new();
295 BN_mod_exp(t, gx, ctx->p.q, ctx->p.p, ctx->ctx);
296 res = BN_is_one(t);
297 BN_free(t);
298
299 return res;
300 }
301
285int JPAKE_STEP1_process(JPAKE_CTX *ctx, const JPAKE_STEP1 *received) 302int JPAKE_STEP1_process(JPAKE_CTX *ctx, const JPAKE_STEP1 *received)
286 { 303 {
304 if(!is_legal(received->p1.gx, ctx))
305 {
306 JPAKEerr(JPAKE_F_JPAKE_STEP1_PROCESS, JPAKE_R_G_TO_THE_X3_IS_NOT_LEGAL);
307 return 0;
308 }
309
310 if(!is_legal(received->p2.gx, ctx))
311 {
312 JPAKEerr(JPAKE_F_JPAKE_STEP1_PROCESS, JPAKE_R_G_TO_THE_X4_IS_NOT_LEGAL);
313 return 0;
314 }
315
287 /* verify their ZKP(xc) */ 316 /* verify their ZKP(xc) */
288 if(!verify_zkp(&received->p1, ctx->p.g, ctx)) 317 if(!verify_zkp(&received->p1, ctx->p.g, ctx))
289 { 318 {
diff --git a/src/lib/libcrypto/jpake/jpake.h b/src/lib/libcrypto/jpake/jpake.h
index 693ea188cb..fd143b4d9b 100644
--- a/src/lib/libcrypto/jpake/jpake.h
+++ b/src/lib/libcrypto/jpake/jpake.h
@@ -115,6 +115,8 @@ void ERR_load_JPAKE_strings(void);
115#define JPAKE_F_VERIFY_ZKP 100 115#define JPAKE_F_VERIFY_ZKP 100
116 116
117/* Reason codes. */ 117/* Reason codes. */
118#define JPAKE_R_G_TO_THE_X3_IS_NOT_LEGAL 108
119#define JPAKE_R_G_TO_THE_X4_IS_NOT_LEGAL 109
118#define JPAKE_R_G_TO_THE_X4_IS_ONE 105 120#define JPAKE_R_G_TO_THE_X4_IS_ONE 105
119#define JPAKE_R_HASH_OF_HASH_OF_KEY_MISMATCH 106 121#define JPAKE_R_HASH_OF_HASH_OF_KEY_MISMATCH 106
120#define JPAKE_R_HASH_OF_KEY_MISMATCH 107 122#define JPAKE_R_HASH_OF_KEY_MISMATCH 107
diff --git a/src/lib/libcrypto/jpake/jpake_err.c b/src/lib/libcrypto/jpake/jpake_err.c
index 1b95067967..a9a9dee75c 100644
--- a/src/lib/libcrypto/jpake/jpake_err.c
+++ b/src/lib/libcrypto/jpake/jpake_err.c
@@ -1,6 +1,6 @@
1/* crypto/jpake/jpake_err.c */ 1/* crypto/jpake/jpake_err.c */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1999-2008 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1999-2010 The OpenSSL Project. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
@@ -80,6 +80,8 @@ static ERR_STRING_DATA JPAKE_str_functs[]=
80 80
81static ERR_STRING_DATA JPAKE_str_reasons[]= 81static ERR_STRING_DATA JPAKE_str_reasons[]=
82 { 82 {
83{ERR_REASON(JPAKE_R_G_TO_THE_X3_IS_NOT_LEGAL),"g to the x3 is not legal"},
84{ERR_REASON(JPAKE_R_G_TO_THE_X4_IS_NOT_LEGAL),"g to the x4 is not legal"},
83{ERR_REASON(JPAKE_R_G_TO_THE_X4_IS_ONE) ,"g to the x4 is one"}, 85{ERR_REASON(JPAKE_R_G_TO_THE_X4_IS_ONE) ,"g to the x4 is one"},
84{ERR_REASON(JPAKE_R_HASH_OF_HASH_OF_KEY_MISMATCH),"hash of hash of key mismatch"}, 86{ERR_REASON(JPAKE_R_HASH_OF_HASH_OF_KEY_MISMATCH),"hash of hash of key mismatch"},
85{ERR_REASON(JPAKE_R_HASH_OF_KEY_MISMATCH),"hash of key mismatch"}, 87{ERR_REASON(JPAKE_R_HASH_OF_KEY_MISMATCH),"hash of key mismatch"},
diff --git a/src/lib/libcrypto/pqueue/pqueue.c b/src/lib/libcrypto/pqueue/pqueue.c
index 99a6fb874d..eab13a1250 100644
--- a/src/lib/libcrypto/pqueue/pqueue.c
+++ b/src/lib/libcrypto/pqueue/pqueue.c
@@ -167,14 +167,13 @@ pqueue_pop(pqueue_s *pq)
167pitem * 167pitem *
168pqueue_find(pqueue_s *pq, unsigned char *prio64be) 168pqueue_find(pqueue_s *pq, unsigned char *prio64be)
169 { 169 {
170 pitem *next, *prev = NULL; 170 pitem *next;
171 pitem *found = NULL; 171 pitem *found = NULL;
172 172
173 if ( pq->items == NULL) 173 if ( pq->items == NULL)
174 return NULL; 174 return NULL;
175 175
176 for ( next = pq->items; next->next != NULL; 176 for ( next = pq->items; next->next != NULL; next = next->next)
177 prev = next, next = next->next)
178 { 177 {
179 if ( memcmp(next->priority, prio64be,8) == 0) 178 if ( memcmp(next->priority, prio64be,8) == 0)
180 { 179 {
diff --git a/src/lib/libcrypto/rand/rand_nw.c b/src/lib/libcrypto/rand/rand_nw.c
index f177ffbe82..8d5b8d2e32 100644
--- a/src/lib/libcrypto/rand/rand_nw.c
+++ b/src/lib/libcrypto/rand/rand_nw.c
@@ -160,8 +160,8 @@ int RAND_poll(void)
160 rdtsc 160 rdtsc
161 mov tsc, eax 161 mov tsc, eax
162 } 162 }
163#else 163#elif defined(__GNUC__) && __GNUC__>=2 && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM)
164 asm volatile("rdtsc":"=A" (tsc)); 164 asm volatile("rdtsc":"=a"(tsc)::"edx");
165#endif 165#endif
166 166
167 RAND_add(&tsc, sizeof(tsc), 1); 167 RAND_add(&tsc, sizeof(tsc), 1);
diff --git a/src/lib/libcrypto/vms_rms.h b/src/lib/libcrypto/vms_rms.h
new file mode 100755
index 0000000000..00a00d993f
--- /dev/null
+++ b/src/lib/libcrypto/vms_rms.h
@@ -0,0 +1,51 @@
1
2#ifdef NAML$C_MAXRSS
3
4# define CC_RMS_NAMX cc$rms_naml
5# define FAB_NAMX fab$l_naml
6# define FAB_OR_NAML( fab, naml) naml
7# define FAB_OR_NAML_DNA naml$l_long_defname
8# define FAB_OR_NAML_DNS naml$l_long_defname_size
9# define FAB_OR_NAML_FNA naml$l_long_filename
10# define FAB_OR_NAML_FNS naml$l_long_filename_size
11# define NAMX_ESA naml$l_long_expand
12# define NAMX_ESL naml$l_long_expand_size
13# define NAMX_ESS naml$l_long_expand_alloc
14# define NAMX_NOP naml$b_nop
15# define SET_NAMX_NO_SHORT_UPCASE( nam) nam.naml$v_no_short_upcase = 1
16
17# if __INITIAL_POINTER_SIZE == 64
18# define NAMX_DNA_FNA_SET(fab) fab.fab$l_dna = (__char_ptr32) -1; \
19 fab.fab$l_fna = (__char_ptr32) -1;
20# else /* __INITIAL_POINTER_SIZE == 64 */
21# define NAMX_DNA_FNA_SET(fab) fab.fab$l_dna = (char *) -1; \
22 fab.fab$l_fna = (char *) -1;
23# endif /* __INITIAL_POINTER_SIZE == 64 [else] */
24
25# define NAMX_MAXRSS NAML$C_MAXRSS
26# define NAMX_STRUCT NAML
27
28#else /* def NAML$C_MAXRSS */
29
30# define CC_RMS_NAMX cc$rms_nam
31# define FAB_NAMX fab$l_nam
32# define FAB_OR_NAML( fab, naml) fab
33# define FAB_OR_NAML_DNA fab$l_dna
34# define FAB_OR_NAML_DNS fab$b_dns
35# define FAB_OR_NAML_FNA fab$l_fna
36# define FAB_OR_NAML_FNS fab$b_fns
37# define NAMX_ESA nam$l_esa
38# define NAMX_ESL nam$b_esl
39# define NAMX_ESS nam$b_ess
40# define NAMX_NOP nam$b_nop
41# define NAMX_DNA_FNA_SET(fab)
42# define NAMX_MAXRSS NAM$C_MAXRSS
43# define NAMX_STRUCT NAM
44# ifdef NAM$M_NO_SHORT_UPCASE
45# define SET_NAMX_NO_SHORT_UPCASE( nam) naml.naml$v_no_short_upcase = 1
46# else /* def NAM$M_NO_SHORT_UPCASE */
47# define SET_NAMX_NO_SHORT_UPCASE( nam)
48# endif /* def NAM$M_NO_SHORT_UPCASE [else] */
49
50#endif /* def NAML$C_MAXRSS [else] */
51
diff --git a/src/lib/libcrypto/x509v3/v3_addr.c b/src/lib/libcrypto/x509v3/v3_addr.c
index 9087d66e0a..0d70e8696d 100644
--- a/src/lib/libcrypto/x509v3/v3_addr.c
+++ b/src/lib/libcrypto/x509v3/v3_addr.c
@@ -177,12 +177,18 @@ static int i2r_address(BIO *out,
177 unsigned char addr[ADDR_RAW_BUF_LEN]; 177 unsigned char addr[ADDR_RAW_BUF_LEN];
178 int i, n; 178 int i, n;
179 179
180 if (bs->length < 0)
181 return 0;
180 switch (afi) { 182 switch (afi) {
181 case IANA_AFI_IPV4: 183 case IANA_AFI_IPV4:
184 if (bs->length > 4)
185 return 0;
182 addr_expand(addr, bs, 4, fill); 186 addr_expand(addr, bs, 4, fill);
183 BIO_printf(out, "%d.%d.%d.%d", addr[0], addr[1], addr[2], addr[3]); 187 BIO_printf(out, "%d.%d.%d.%d", addr[0], addr[1], addr[2], addr[3]);
184 break; 188 break;
185 case IANA_AFI_IPV6: 189 case IANA_AFI_IPV6:
190 if (bs->length > 16)
191 return 0;
186 addr_expand(addr, bs, 16, fill); 192 addr_expand(addr, bs, 16, fill);
187 for (n = 16; n > 1 && addr[n-1] == 0x00 && addr[n-2] == 0x00; n -= 2) 193 for (n = 16; n > 1 && addr[n-1] == 0x00 && addr[n-2] == 0x00; n -= 2)
188 ; 194 ;
diff --git a/src/lib/libcrypto/x509v3/v3_asid.c b/src/lib/libcrypto/x509v3/v3_asid.c
index 56702f86b9..3f434c0603 100644
--- a/src/lib/libcrypto/x509v3/v3_asid.c
+++ b/src/lib/libcrypto/x509v3/v3_asid.c
@@ -61,7 +61,6 @@
61 61
62#include <stdio.h> 62#include <stdio.h>
63#include <string.h> 63#include <string.h>
64#include <assert.h>
65#include "cryptlib.h" 64#include "cryptlib.h"
66#include <openssl/conf.h> 65#include <openssl/conf.h>
67#include <openssl/asn1.h> 66#include <openssl/asn1.h>
@@ -172,11 +171,11 @@ static int ASIdOrRange_cmp(const ASIdOrRange * const *a_,
172{ 171{
173 const ASIdOrRange *a = *a_, *b = *b_; 172 const ASIdOrRange *a = *a_, *b = *b_;
174 173
175 assert((a->type == ASIdOrRange_id && a->u.id != NULL) || 174 OPENSSL_assert((a->type == ASIdOrRange_id && a->u.id != NULL) ||
176 (a->type == ASIdOrRange_range && a->u.range != NULL && 175 (a->type == ASIdOrRange_range && a->u.range != NULL &&
177 a->u.range->min != NULL && a->u.range->max != NULL)); 176 a->u.range->min != NULL && a->u.range->max != NULL));
178 177
179 assert((b->type == ASIdOrRange_id && b->u.id != NULL) || 178 OPENSSL_assert((b->type == ASIdOrRange_id && b->u.id != NULL) ||
180 (b->type == ASIdOrRange_range && b->u.range != NULL && 179 (b->type == ASIdOrRange_range && b->u.range != NULL &&
181 b->u.range->min != NULL && b->u.range->max != NULL)); 180 b->u.range->min != NULL && b->u.range->max != NULL));
182 181
@@ -215,7 +214,7 @@ int v3_asid_add_inherit(ASIdentifiers *asid, int which)
215 if (*choice == NULL) { 214 if (*choice == NULL) {
216 if ((*choice = ASIdentifierChoice_new()) == NULL) 215 if ((*choice = ASIdentifierChoice_new()) == NULL)
217 return 0; 216 return 0;
218 assert((*choice)->u.inherit == NULL); 217 OPENSSL_assert((*choice)->u.inherit == NULL);
219 if (((*choice)->u.inherit = ASN1_NULL_new()) == NULL) 218 if (((*choice)->u.inherit = ASN1_NULL_new()) == NULL)
220 return 0; 219 return 0;
221 (*choice)->type = ASIdentifierChoice_inherit; 220 (*choice)->type = ASIdentifierChoice_inherit;
@@ -250,7 +249,7 @@ int v3_asid_add_id_or_range(ASIdentifiers *asid,
250 if (*choice == NULL) { 249 if (*choice == NULL) {
251 if ((*choice = ASIdentifierChoice_new()) == NULL) 250 if ((*choice = ASIdentifierChoice_new()) == NULL)
252 return 0; 251 return 0;
253 assert((*choice)->u.asIdsOrRanges == NULL); 252 OPENSSL_assert((*choice)->u.asIdsOrRanges == NULL);
254 (*choice)->u.asIdsOrRanges = sk_ASIdOrRange_new(ASIdOrRange_cmp); 253 (*choice)->u.asIdsOrRanges = sk_ASIdOrRange_new(ASIdOrRange_cmp);
255 if ((*choice)->u.asIdsOrRanges == NULL) 254 if ((*choice)->u.asIdsOrRanges == NULL)
256 return 0; 255 return 0;
@@ -286,7 +285,7 @@ static void extract_min_max(ASIdOrRange *aor,
286 ASN1_INTEGER **min, 285 ASN1_INTEGER **min,
287 ASN1_INTEGER **max) 286 ASN1_INTEGER **max)
288{ 287{
289 assert(aor != NULL && min != NULL && max != NULL); 288 OPENSSL_assert(aor != NULL && min != NULL && max != NULL);
290 switch (aor->type) { 289 switch (aor->type) {
291 case ASIdOrRange_id: 290 case ASIdOrRange_id:
292 *min = aor->u.id; 291 *min = aor->u.id;
@@ -373,7 +372,7 @@ static int ASIdentifierChoice_is_canonical(ASIdentifierChoice *choice)
373int v3_asid_is_canonical(ASIdentifiers *asid) 372int v3_asid_is_canonical(ASIdentifiers *asid)
374{ 373{
375 return (asid == NULL || 374 return (asid == NULL ||
376 (ASIdentifierChoice_is_canonical(asid->asnum) || 375 (ASIdentifierChoice_is_canonical(asid->asnum) &&
377 ASIdentifierChoice_is_canonical(asid->rdi))); 376 ASIdentifierChoice_is_canonical(asid->rdi)));
378} 377}
379 378
@@ -395,7 +394,7 @@ static int ASIdentifierChoice_canonize(ASIdentifierChoice *choice)
395 /* 394 /*
396 * We have a list. Sort it. 395 * We have a list. Sort it.
397 */ 396 */
398 assert(choice->type == ASIdentifierChoice_asIdsOrRanges); 397 OPENSSL_assert(choice->type == ASIdentifierChoice_asIdsOrRanges);
399 sk_ASIdOrRange_sort(choice->u.asIdsOrRanges); 398 sk_ASIdOrRange_sort(choice->u.asIdsOrRanges);
400 399
401 /* 400 /*
@@ -413,7 +412,7 @@ static int ASIdentifierChoice_canonize(ASIdentifierChoice *choice)
413 /* 412 /*
414 * Make sure we're properly sorted (paranoia). 413 * Make sure we're properly sorted (paranoia).
415 */ 414 */
416 assert(ASN1_INTEGER_cmp(a_min, b_min) <= 0); 415 OPENSSL_assert(ASN1_INTEGER_cmp(a_min, b_min) <= 0);
417 416
418 /* 417 /*
419 * Check for overlaps. 418 * Check for overlaps.
@@ -472,7 +471,7 @@ static int ASIdentifierChoice_canonize(ASIdentifierChoice *choice)
472 } 471 }
473 } 472 }
474 473
475 assert(ASIdentifierChoice_is_canonical(choice)); /* Paranoia */ 474 OPENSSL_assert(ASIdentifierChoice_is_canonical(choice)); /* Paranoia */
476 475
477 ret = 1; 476 ret = 1;
478 477
@@ -709,9 +708,9 @@ static int v3_asid_validate_path_internal(X509_STORE_CTX *ctx,
709 int i, ret = 1, inherit_as = 0, inherit_rdi = 0; 708 int i, ret = 1, inherit_as = 0, inherit_rdi = 0;
710 X509 *x; 709 X509 *x;
711 710
712 assert(chain != NULL && sk_X509_num(chain) > 0); 711 OPENSSL_assert(chain != NULL && sk_X509_num(chain) > 0);
713 assert(ctx != NULL || ext != NULL); 712 OPENSSL_assert(ctx != NULL || ext != NULL);
714 assert(ctx == NULL || ctx->verify_cb != NULL); 713 OPENSSL_assert(ctx == NULL || ctx->verify_cb != NULL);
715 714
716 /* 715 /*
717 * Figure out where to start. If we don't have an extension to 716 * Figure out where to start. If we don't have an extension to
@@ -724,7 +723,7 @@ static int v3_asid_validate_path_internal(X509_STORE_CTX *ctx,
724 } else { 723 } else {
725 i = 0; 724 i = 0;
726 x = sk_X509_value(chain, i); 725 x = sk_X509_value(chain, i);
727 assert(x != NULL); 726 OPENSSL_assert(x != NULL);
728 if ((ext = x->rfc3779_asid) == NULL) 727 if ((ext = x->rfc3779_asid) == NULL)
729 goto done; 728 goto done;
730 } 729 }
@@ -757,7 +756,7 @@ static int v3_asid_validate_path_internal(X509_STORE_CTX *ctx,
757 */ 756 */
758 for (i++; i < sk_X509_num(chain); i++) { 757 for (i++; i < sk_X509_num(chain); i++) {
759 x = sk_X509_value(chain, i); 758 x = sk_X509_value(chain, i);
760 assert(x != NULL); 759 OPENSSL_assert(x != NULL);
761 if (x->rfc3779_asid == NULL) { 760 if (x->rfc3779_asid == NULL) {
762 if (child_as != NULL || child_rdi != NULL) 761 if (child_as != NULL || child_rdi != NULL)
763 validation_err(X509_V_ERR_UNNESTED_RESOURCE); 762 validation_err(X509_V_ERR_UNNESTED_RESOURCE);
@@ -800,7 +799,7 @@ static int v3_asid_validate_path_internal(X509_STORE_CTX *ctx,
800 /* 799 /*
801 * Trust anchor can't inherit. 800 * Trust anchor can't inherit.
802 */ 801 */
803 assert(x != NULL); 802 OPENSSL_assert(x != NULL);
804 if (x->rfc3779_asid != NULL) { 803 if (x->rfc3779_asid != NULL) {
805 if (x->rfc3779_asid->asnum != NULL && 804 if (x->rfc3779_asid->asnum != NULL &&
806 x->rfc3779_asid->asnum->type == ASIdentifierChoice_inherit) 805 x->rfc3779_asid->asnum->type == ASIdentifierChoice_inherit)
diff --git a/src/lib/libssl/src/ACKNOWLEDGMENTS b/src/lib/libssl/src/ACKNOWLEDGMENTS
new file mode 100644
index 0000000000..fb6dd912c4
--- /dev/null
+++ b/src/lib/libssl/src/ACKNOWLEDGMENTS
@@ -0,0 +1,25 @@
1The OpenSSL project depends on volunteer efforts and financial support from
2the end user community. That support comes in the form of donations and paid
3sponsorships, software support contracts, paid consulting services
4and commissioned software development.
5
6Since all these activities support the continued development and improvement
7of OpenSSL we consider all these clients and customers as sponsors of the
8OpenSSL project.
9
10We would like to identify and thank the following such sponsors for their past
11or current significant support of the OpenSSL project:
12
13Very significant support:
14
15 OpenGear: www.opengear.com
16
17Significant support:
18
19 PSW Group: www.psw.net
20
21Please note that we ask permission to identify sponsors and that some sponsors
22we consider eligible for inclusion here have requested to remain anonymous.
23
24Additional sponsorship or financial support is always welcome: for more
25information please contact the OpenSSL Software Foundation.
diff --git a/src/lib/libssl/src/Makefile.shared b/src/lib/libssl/src/Makefile.shared
index 3569832f1b..e753f44e18 100644
--- a/src/lib/libssl/src/Makefile.shared
+++ b/src/lib/libssl/src/Makefile.shared
@@ -135,7 +135,7 @@ LINK_SO_A_VIA_O= \
135 ALL=$$ALLSYMSFLAGS; ALLSYMSFLAGS=; NOALLSYMSFLAGS=; \ 135 ALL=$$ALLSYMSFLAGS; ALLSYMSFLAGS=; NOALLSYMSFLAGS=; \
136 ( $(SET_X); \ 136 ( $(SET_X); \
137 ld $(LDFLAGS) -r -o lib$(LIBNAME).o $$ALL lib$(LIBNAME).a $(LIBEXTRAS) ); \ 137 ld $(LDFLAGS) -r -o lib$(LIBNAME).o $$ALL lib$(LIBNAME).a $(LIBEXTRAS) ); \
138 $(LINK_SO) && rm -f $(LIBNAME).o 138 $(LINK_SO) && rm -f lib$(LIBNAME).o
139 139
140LINK_SO_A_UNPACKED= \ 140LINK_SO_A_UNPACKED= \
141 UNPACKDIR=link_tmp.$$$$; rm -rf $$UNPACKDIR; mkdir $$UNPACKDIR; \ 141 UNPACKDIR=link_tmp.$$$$; rm -rf $$UNPACKDIR; mkdir $$UNPACKDIR; \
@@ -207,17 +207,29 @@ link_app.bsd:
207 fi; $(LINK_APP) 207 fi; $(LINK_APP)
208 208
209# For Darwin AKA Mac OS/X (dyld) 209# For Darwin AKA Mac OS/X (dyld)
210# link_o.darwin produces .so, because we let it use dso_dlfcn module, 210# Originally link_o.darwin produced .so, because it was hard-coded
211# which has .so extension hard-coded. One can argue that one should 211# in dso_dlfcn module. At later point dso_dlfcn switched to .dylib
212# develop special dso module for MacOS X. At least manual encourages 212# extension in order to allow for run-time linking with vendor-
213# to use native NSModule(3) API and refers to dlfcn as termporary hack. 213# supplied shared libraries such as libz, so that link_o.darwin had
214# to be harmonized with it. This caused minor controversy, because
215# it was believed that dlopen can't be used to dynamically load
216# .dylib-s, only so called bundle modules (ones linked with -bundle
217# flag). The belief seems to be originating from pre-10.4 release,
218# where dlfcn functionality was emulated by dlcompat add-on. In
219# 10.4 dlopen was rewritten as native part of dyld and is documented
220# to be capable of loading both dynamic libraries and bundles. In
221# order to provide compatibility with pre-10.4 dlopen, modules are
222# linked with -bundle flag, which makes .dylib extension misleading.
223# It works, because dlopen is [and always was] extension-agnostic.
224# Alternative to this heuristic approach is to develop specific
225# MacOS X dso module relying on whichever "native" dyld interface.
214link_o.darwin: 226link_o.darwin:
215 @ $(CALC_VERSIONS); \ 227 @ $(CALC_VERSIONS); \
216 SHLIB=lib$(LIBNAME); \ 228 SHLIB=lib$(LIBNAME); \
217 SHLIB_SUFFIX=.so; \ 229 SHLIB_SUFFIX=.dylib; \
218 ALLSYMSFLAGS='-all_load'; \ 230 ALLSYMSFLAGS='-all_load'; \
219 NOALLSYMSFLAGS=''; \ 231 NOALLSYMSFLAGS=''; \
220 SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS)"; \ 232 SHAREDFLAGS="$(CFLAGS) `echo $(SHARED_LDFLAGS) | sed s/dynamiclib/bundle/`"; \
221 if [ -n "$(LIBVERSION)" ]; then \ 233 if [ -n "$(LIBVERSION)" ]; then \
222 SHAREDFLAGS="$$SHAREDFLAGS -current_version $(LIBVERSION)"; \ 234 SHAREDFLAGS="$$SHAREDFLAGS -current_version $(LIBVERSION)"; \
223 fi; \ 235 fi; \
diff --git a/src/lib/libssl/src/apps/ec.c b/src/lib/libssl/src/apps/ec.c
index 31194b48df..896eabc13f 100644
--- a/src/lib/libssl/src/apps/ec.c
+++ b/src/lib/libssl/src/apps/ec.c
@@ -85,9 +85,6 @@ int MAIN(int, char **);
85 85
86int MAIN(int argc, char **argv) 86int MAIN(int argc, char **argv)
87{ 87{
88#ifndef OPENSSL_NO_ENGINE
89 ENGINE *e = NULL;
90#endif
91 int ret = 1; 88 int ret = 1;
92 EC_KEY *eckey = NULL; 89 EC_KEY *eckey = NULL;
93 const EC_GROUP *group; 90 const EC_GROUP *group;
@@ -254,7 +251,7 @@ bad:
254 ERR_load_crypto_strings(); 251 ERR_load_crypto_strings();
255 252
256#ifndef OPENSSL_NO_ENGINE 253#ifndef OPENSSL_NO_ENGINE
257 e = setup_engine(bio_err, engine, 0); 254 setup_engine(bio_err, engine, 0);
258#endif 255#endif
259 256
260 if(!app_passwd(bio_err, passargin, passargout, &passin, &passout)) 257 if(!app_passwd(bio_err, passargin, passargout, &passin, &passout))
diff --git a/src/lib/libssl/src/apps/ecparam.c b/src/lib/libssl/src/apps/ecparam.c
index e9aa0a184a..465480bedd 100644
--- a/src/lib/libssl/src/apps/ecparam.c
+++ b/src/lib/libssl/src/apps/ecparam.c
@@ -129,9 +129,6 @@ int MAIN(int argc, char **argv)
129 char *infile = NULL, *outfile = NULL, *prog; 129 char *infile = NULL, *outfile = NULL, *prog;
130 BIO *in = NULL, *out = NULL; 130 BIO *in = NULL, *out = NULL;
131 int informat, outformat, noout = 0, C = 0, ret = 1; 131 int informat, outformat, noout = 0, C = 0, ret = 1;
132#ifndef OPENSSL_NO_ENGINE
133 ENGINE *e = NULL;
134#endif
135 char *engine = NULL; 132 char *engine = NULL;
136 133
137 BIGNUM *ec_p = NULL, *ec_a = NULL, *ec_b = NULL, 134 BIGNUM *ec_p = NULL, *ec_a = NULL, *ec_b = NULL,
@@ -340,7 +337,7 @@ bad:
340 } 337 }
341 338
342#ifndef OPENSSL_NO_ENGINE 339#ifndef OPENSSL_NO_ENGINE
343 e = setup_engine(bio_err, engine, 0); 340 setup_engine(bio_err, engine, 0);
344#endif 341#endif
345 342
346 if (list_curves) 343 if (list_curves)
diff --git a/src/lib/libssl/src/apps/pkeyparam.c b/src/lib/libssl/src/apps/pkeyparam.c
index 7f18010f9d..6f7a357a36 100644
--- a/src/lib/libssl/src/apps/pkeyparam.c
+++ b/src/lib/libssl/src/apps/pkeyparam.c
@@ -74,7 +74,6 @@ int MAIN(int argc, char **argv)
74 EVP_PKEY *pkey=NULL; 74 EVP_PKEY *pkey=NULL;
75 int badarg = 0; 75 int badarg = 0;
76#ifndef OPENSSL_NO_ENGINE 76#ifndef OPENSSL_NO_ENGINE
77 ENGINE *e = NULL;
78 char *engine=NULL; 77 char *engine=NULL;
79#endif 78#endif
80 int ret = 1; 79 int ret = 1;
@@ -141,7 +140,7 @@ int MAIN(int argc, char **argv)
141 } 140 }
142 141
143#ifndef OPENSSL_NO_ENGINE 142#ifndef OPENSSL_NO_ENGINE
144 e = setup_engine(bio_err, engine, 0); 143 setup_engine(bio_err, engine, 0);
145#endif 144#endif
146 145
147 if (infile) 146 if (infile)
diff --git a/src/lib/libssl/src/apps/pkeyutl.c b/src/lib/libssl/src/apps/pkeyutl.c
index 22a6c4bf39..7eb3f5c544 100644
--- a/src/lib/libssl/src/apps/pkeyutl.c
+++ b/src/lib/libssl/src/apps/pkeyutl.c
@@ -119,17 +119,17 @@ int MAIN(int argc, char **argv)
119 if (!strcmp(*argv,"-in")) 119 if (!strcmp(*argv,"-in"))
120 { 120 {
121 if (--argc < 1) badarg = 1; 121 if (--argc < 1) badarg = 1;
122 infile= *(++argv); 122 else infile= *(++argv);
123 } 123 }
124 else if (!strcmp(*argv,"-out")) 124 else if (!strcmp(*argv,"-out"))
125 { 125 {
126 if (--argc < 1) badarg = 1; 126 if (--argc < 1) badarg = 1;
127 outfile= *(++argv); 127 else outfile= *(++argv);
128 } 128 }
129 else if (!strcmp(*argv,"-sigfile")) 129 else if (!strcmp(*argv,"-sigfile"))
130 { 130 {
131 if (--argc < 1) badarg = 1; 131 if (--argc < 1) badarg = 1;
132 sigfile= *(++argv); 132 else sigfile= *(++argv);
133 } 133 }
134 else if(!strcmp(*argv, "-inkey")) 134 else if(!strcmp(*argv, "-inkey"))
135 { 135 {
@@ -159,17 +159,17 @@ int MAIN(int argc, char **argv)
159 else if (!strcmp(*argv,"-passin")) 159 else if (!strcmp(*argv,"-passin"))
160 { 160 {
161 if (--argc < 1) badarg = 1; 161 if (--argc < 1) badarg = 1;
162 passargin= *(++argv); 162 else passargin= *(++argv);
163 } 163 }
164 else if (strcmp(*argv,"-peerform") == 0) 164 else if (strcmp(*argv,"-peerform") == 0)
165 { 165 {
166 if (--argc < 1) badarg = 1; 166 if (--argc < 1) badarg = 1;
167 peerform=str2fmt(*(++argv)); 167 else peerform=str2fmt(*(++argv));
168 } 168 }
169 else if (strcmp(*argv,"-keyform") == 0) 169 else if (strcmp(*argv,"-keyform") == 0)
170 { 170 {
171 if (--argc < 1) badarg = 1; 171 if (--argc < 1) badarg = 1;
172 keyform=str2fmt(*(++argv)); 172 else keyform=str2fmt(*(++argv));
173 } 173 }
174#ifndef OPENSSL_NO_ENGINE 174#ifndef OPENSSL_NO_ENGINE
175 else if(!strcmp(*argv, "-engine")) 175 else if(!strcmp(*argv, "-engine"))
diff --git a/src/lib/libssl/src/apps/vms_decc_init.c b/src/lib/libssl/src/apps/vms_decc_init.c
new file mode 100755
index 0000000000..f512c8f1bc
--- /dev/null
+++ b/src/lib/libssl/src/apps/vms_decc_init.c
@@ -0,0 +1,188 @@
1#if defined( __VMS) && !defined( OPENSSL_NO_DECC_INIT) && \
2 defined( __DECC) && !defined( __VAX) && (__CRTL_VER >= 70301000)
3# define USE_DECC_INIT 1
4#endif
5
6#ifdef USE_DECC_INIT
7
8/*
9 * 2010-04-26 SMS.
10 *
11 *----------------------------------------------------------------------
12 *
13 * decc_init()
14 *
15 * On non-VAX systems, uses LIB$INITIALIZE to set a collection of C
16 * RTL features without using the DECC$* logical name method.
17 *
18 *----------------------------------------------------------------------
19 */
20
21#include <stdio.h>
22#include <stdlib.h>
23#include <unixlib.h>
24
25
26/* Global storage. */
27
28/* Flag to sense if decc_init() was called. */
29
30int decc_init_done = -1;
31
32
33/* Structure to hold a DECC$* feature name and its desired value. */
34
35typedef struct
36{
37 char *name;
38 int value;
39} decc_feat_t;
40
41
42/* Array of DECC$* feature names and their desired values.
43 * Note: DECC$ARGV_PARSE_STYLE is the urgent one.
44 */
45
46decc_feat_t decc_feat_array[] =
47{
48 /* Preserve command-line case with SET PROCESS/PARSE_STYLE=EXTENDED */
49 { "DECC$ARGV_PARSE_STYLE", 1 },
50
51 /* Preserve case for file names on ODS5 disks. */
52 { "DECC$EFS_CASE_PRESERVE", 1 },
53
54 /* Enable multiple dots (and most characters) in ODS5 file names,
55 * while preserving VMS-ness of ";version".
56 */
57 { "DECC$EFS_CHARSET", 1 },
58
59 /* List terminator. */
60 { (char *)NULL, 0 }
61};
62
63
64/* LIB$INITIALIZE initialization function. */
65
66static void decc_init( void)
67{
68 char *openssl_debug_decc_init;
69 int verbose = 0;
70 int feat_index;
71 int feat_value;
72 int feat_value_max;
73 int feat_value_min;
74 int i;
75 int sts;
76
77 /* Get debug option. */
78 openssl_debug_decc_init = getenv( "OPENSSL_DEBUG_DECC_INIT");
79 if (openssl_debug_decc_init != NULL)
80 {
81 verbose = strtol( openssl_debug_decc_init, NULL, 10);
82 if (verbose <= 0)
83 {
84 verbose = 1;
85 }
86 }
87
88 /* Set the global flag to indicate that LIB$INITIALIZE worked. */
89 decc_init_done = 1;
90
91 /* Loop through all items in the decc_feat_array[]. */
92
93 for (i = 0; decc_feat_array[ i].name != NULL; i++)
94 {
95 /* Get the feature index. */
96 feat_index = decc$feature_get_index( decc_feat_array[ i].name);
97 if (feat_index >= 0)
98 {
99 /* Valid item. Collect its properties. */
100 feat_value = decc$feature_get_value( feat_index, 1);
101 feat_value_min = decc$feature_get_value( feat_index, 2);
102 feat_value_max = decc$feature_get_value( feat_index, 3);
103
104 /* Check the validity of our desired value. */
105 if ((decc_feat_array[ i].value >= feat_value_min) &&
106 (decc_feat_array[ i].value <= feat_value_max))
107 {
108 /* Valid value. Set it if necessary. */
109 if (feat_value != decc_feat_array[ i].value)
110 {
111 sts = decc$feature_set_value( feat_index,
112 1,
113 decc_feat_array[ i].value);
114
115 if (verbose > 1)
116 {
117 fprintf( stderr, " %s = %d, sts = %d.\n",
118 decc_feat_array[ i].name,
119 decc_feat_array[ i].value,
120 sts);
121 }
122 }
123 }
124 else
125 {
126 /* Invalid DECC feature value. */
127 fprintf( stderr,
128 " INVALID DECC$FEATURE VALUE, %d: %d <= %s <= %d.\n",
129 feat_value,
130 feat_value_min, decc_feat_array[ i].name, feat_value_max);
131 }
132 }
133 else
134 {
135 /* Invalid DECC feature name. */
136 fprintf( stderr,
137 " UNKNOWN DECC$FEATURE: %s.\n", decc_feat_array[ i].name);
138 }
139 }
140
141 if (verbose > 0)
142 {
143 fprintf( stderr, " DECC_INIT complete.\n");
144 }
145}
146
147/* Get "decc_init()" into a valid, loaded LIB$INITIALIZE PSECT. */
148
149#pragma nostandard
150
151/* Establish the LIB$INITIALIZE PSECTs, with proper alignment and
152 * other attributes. Note that "nopic" is significant only on VAX.
153 */
154#pragma extern_model save
155
156#if __INITIAL_POINTER_SIZE == 64
157# define PSECT_ALIGN 3
158#else
159# define PSECT_ALIGN 2
160#endif
161
162#pragma extern_model strict_refdef "LIB$INITIALIZ" PSECT_ALIGN, nopic, nowrt
163const int spare[ 8] = { 0 };
164
165#pragma extern_model strict_refdef "LIB$INITIALIZE" PSECT_ALIGN, nopic, nowrt
166void (*const x_decc_init)() = decc_init;
167
168#pragma extern_model restore
169
170/* Fake reference to ensure loading the LIB$INITIALIZE PSECT. */
171
172#pragma extern_model save
173
174int LIB$INITIALIZE( void);
175
176#pragma extern_model strict_refdef
177int dmy_lib$initialize = (int) LIB$INITIALIZE;
178
179#pragma extern_model restore
180
181#pragma standard
182
183#else /* def USE_DECC_INIT */
184
185/* Dummy code to avoid a %CC-W-EMPTYFILE complaint. */
186int decc_init_dummy( void);
187
188#endif /* def USE_DECC_INIT */
diff --git a/src/lib/libssl/src/crypto/LPdir_vms.c b/src/lib/libssl/src/crypto/LPdir_vms.c
index 85b427a623..7613bd254e 100644
--- a/src/lib/libssl/src/crypto/LPdir_vms.c
+++ b/src/lib/libssl/src/crypto/LPdir_vms.c
@@ -40,22 +40,18 @@
40#ifndef LPDIR_H 40#ifndef LPDIR_H
41#include "LPdir.h" 41#include "LPdir.h"
42#endif 42#endif
43#include "vms_rms.h"
43 44
44/* Because some compiler options hide this macor */ 45/* Some compiler options hide EVMSERR. */
45#ifndef EVMSERR 46#ifndef EVMSERR
46#define EVMSERR 65535 /* error for non-translatable VMS errors */ 47# define EVMSERR 65535 /* error for non-translatable VMS errors */
47#endif 48#endif
48 49
49struct LP_dir_context_st 50struct LP_dir_context_st
50{ 51{
51 unsigned long VMS_context; 52 unsigned long VMS_context;
52#ifdef NAML$C_MAXRSS 53 char filespec[ NAMX_MAXRSS+ 1];
53 char filespec[NAML$C_MAXRSS+1]; 54 char result[ NAMX_MAXRSS+ 1];
54 char result[NAML$C_MAXRSS+1];
55#else
56 char filespec[256];
57 char result[256];
58#endif
59 struct dsc$descriptor_d filespec_dsc; 55 struct dsc$descriptor_d filespec_dsc;
60 struct dsc$descriptor_d result_dsc; 56 struct dsc$descriptor_d result_dsc;
61}; 57};
@@ -66,6 +62,16 @@ const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory)
66 char *p, *r; 62 char *p, *r;
67 size_t l; 63 size_t l;
68 unsigned long flags = 0; 64 unsigned long flags = 0;
65
66/* Arrange 32-bit pointer to (copied) string storage, if needed. */
67#if __INITIAL_POINTER_SIZE == 64
68# pragma pointer_size save
69# pragma pointer_size 32
70 char *ctx_filespec_32p;
71# pragma pointer_size restore
72 char ctx_filespec_32[ NAMX_MAXRSS+ 1];
73#endif /* __INITIAL_POINTER_SIZE == 64 */
74
69#ifdef NAML$C_MAXRSS 75#ifdef NAML$C_MAXRSS
70 flags |= LIB$M_FIL_LONG_NAMES; 76 flags |= LIB$M_FIL_LONG_NAMES;
71#endif 77#endif
@@ -93,13 +99,7 @@ const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory)
93 99
94 filespeclen += 4; /* "*.*;" */ 100 filespeclen += 4; /* "*.*;" */
95 101
96 if (filespeclen > 102 if (filespeclen > NAMX_MAXRSS)
97#ifdef NAML$C_MAXRSS
98 NAML$C_MAXRSS
99#else
100 255
101#endif
102 )
103 { 103 {
104 errno = ENAMETOOLONG; 104 errno = ENAMETOOLONG;
105 return 0; 105 return 0;
@@ -115,14 +115,21 @@ const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory)
115 115
116 strcpy((*ctx)->filespec,directory); 116 strcpy((*ctx)->filespec,directory);
117 strcat((*ctx)->filespec,"*.*;"); 117 strcat((*ctx)->filespec,"*.*;");
118
119/* Arrange 32-bit pointer to (copied) string storage, if needed. */
120#if __INITIAL_POINTER_SIZE == 64
121# define CTX_FILESPEC ctx_filespec_32p
122 /* Copy the file name to storage with a 32-bit pointer. */
123 ctx_filespec_32p = ctx_filespec_32;
124 strcpy( ctx_filespec_32p, (*ctx)->filespec);
125#else /* __INITIAL_POINTER_SIZE == 64 */
126# define CTX_FILESPEC (*ctx)->filespec
127#endif /* __INITIAL_POINTER_SIZE == 64 [else] */
128
118 (*ctx)->filespec_dsc.dsc$w_length = filespeclen; 129 (*ctx)->filespec_dsc.dsc$w_length = filespeclen;
119 (*ctx)->filespec_dsc.dsc$b_dtype = DSC$K_DTYPE_T; 130 (*ctx)->filespec_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
120 (*ctx)->filespec_dsc.dsc$b_class = DSC$K_CLASS_S; 131 (*ctx)->filespec_dsc.dsc$b_class = DSC$K_CLASS_S;
121 (*ctx)->filespec_dsc.dsc$a_pointer = (*ctx)->filespec; 132 (*ctx)->filespec_dsc.dsc$a_pointer = CTX_FILESPEC;
122 (*ctx)->result_dsc.dsc$w_length = 0;
123 (*ctx)->result_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
124 (*ctx)->result_dsc.dsc$b_class = DSC$K_CLASS_D;
125 (*ctx)->result_dsc.dsc$a_pointer = 0;
126 } 133 }
127 134
128 (*ctx)->result_dsc.dsc$w_length = 0; 135 (*ctx)->result_dsc.dsc$w_length = 0;
diff --git a/src/lib/libssl/src/crypto/aes/aes_wrap.c b/src/lib/libssl/src/crypto/aes/aes_wrap.c
index 9feacd65d8..e2d73d37ce 100644
--- a/src/lib/libssl/src/crypto/aes/aes_wrap.c
+++ b/src/lib/libssl/src/crypto/aes/aes_wrap.c
@@ -85,9 +85,9 @@ int AES_wrap_key(AES_KEY *key, const unsigned char *iv,
85 A[7] ^= (unsigned char)(t & 0xff); 85 A[7] ^= (unsigned char)(t & 0xff);
86 if (t > 0xff) 86 if (t > 0xff)
87 { 87 {
88 A[6] ^= (unsigned char)((t & 0xff) >> 8); 88 A[6] ^= (unsigned char)((t >> 8) & 0xff);
89 A[5] ^= (unsigned char)((t & 0xff) >> 16); 89 A[5] ^= (unsigned char)((t >> 16) & 0xff);
90 A[4] ^= (unsigned char)((t & 0xff) >> 24); 90 A[4] ^= (unsigned char)((t >> 24) & 0xff);
91 } 91 }
92 memcpy(R, B + 8, 8); 92 memcpy(R, B + 8, 8);
93 } 93 }
@@ -119,9 +119,9 @@ int AES_unwrap_key(AES_KEY *key, const unsigned char *iv,
119 A[7] ^= (unsigned char)(t & 0xff); 119 A[7] ^= (unsigned char)(t & 0xff);
120 if (t > 0xff) 120 if (t > 0xff)
121 { 121 {
122 A[6] ^= (unsigned char)((t & 0xff) >> 8); 122 A[6] ^= (unsigned char)((t >> 8) & 0xff);
123 A[5] ^= (unsigned char)((t & 0xff) >> 16); 123 A[5] ^= (unsigned char)((t >> 16) & 0xff);
124 A[4] ^= (unsigned char)((t & 0xff) >> 24); 124 A[4] ^= (unsigned char)((t >> 24) & 0xff);
125 } 125 }
126 memcpy(B + 8, R, 8); 126 memcpy(B + 8, R, 8);
127 AES_decrypt(B, B, key); 127 AES_decrypt(B, B, key);
diff --git a/src/lib/libssl/src/crypto/aes/asm/aes-armv4.pl b/src/lib/libssl/src/crypto/aes/asm/aes-armv4.pl
index 690244111a..c51ee1fbf6 100644
--- a/src/lib/libssl/src/crypto/aes/asm/aes-armv4.pl
+++ b/src/lib/libssl/src/crypto/aes/asm/aes-armv4.pl
@@ -16,12 +16,20 @@
16# allows to merge logical or arithmetic operation with shift or rotate 16# allows to merge logical or arithmetic operation with shift or rotate
17# in one instruction and emit combined result every cycle. The module 17# in one instruction and emit combined result every cycle. The module
18# is endian-neutral. The performance is ~42 cycles/byte for 128-bit 18# is endian-neutral. The performance is ~42 cycles/byte for 128-bit
19# key. 19# key [on single-issue Xscale PXA250 core].
20 20
21# May 2007. 21# May 2007.
22# 22#
23# AES_set_[en|de]crypt_key is added. 23# AES_set_[en|de]crypt_key is added.
24 24
25# July 2010.
26#
27# Rescheduling for dual-issue pipeline resulted in 12% improvement on
28# Cortex A8 core and ~25 cycles per byte processed with 128-bit key.
29
30while (($output=shift) && ($output!~/^\w[\w\-]*\.\w+$/)) {}
31open STDOUT,">$output";
32
25$s0="r0"; 33$s0="r0";
26$s1="r1"; 34$s1="r1";
27$s2="r2"; 35$s2="r2";
@@ -164,24 +172,24 @@ AES_encrypt:
164 ldrb $t2,[$rounds,#1] 172 ldrb $t2,[$rounds,#1]
165 ldrb $t3,[$rounds,#0] 173 ldrb $t3,[$rounds,#0]
166 orr $s0,$s0,$t1,lsl#8 174 orr $s0,$s0,$t1,lsl#8
167 orr $s0,$s0,$t2,lsl#16
168 orr $s0,$s0,$t3,lsl#24
169 ldrb $s1,[$rounds,#7] 175 ldrb $s1,[$rounds,#7]
176 orr $s0,$s0,$t2,lsl#16
170 ldrb $t1,[$rounds,#6] 177 ldrb $t1,[$rounds,#6]
178 orr $s0,$s0,$t3,lsl#24
171 ldrb $t2,[$rounds,#5] 179 ldrb $t2,[$rounds,#5]
172 ldrb $t3,[$rounds,#4] 180 ldrb $t3,[$rounds,#4]
173 orr $s1,$s1,$t1,lsl#8 181 orr $s1,$s1,$t1,lsl#8
174 orr $s1,$s1,$t2,lsl#16
175 orr $s1,$s1,$t3,lsl#24
176 ldrb $s2,[$rounds,#11] 182 ldrb $s2,[$rounds,#11]
183 orr $s1,$s1,$t2,lsl#16
177 ldrb $t1,[$rounds,#10] 184 ldrb $t1,[$rounds,#10]
185 orr $s1,$s1,$t3,lsl#24
178 ldrb $t2,[$rounds,#9] 186 ldrb $t2,[$rounds,#9]
179 ldrb $t3,[$rounds,#8] 187 ldrb $t3,[$rounds,#8]
180 orr $s2,$s2,$t1,lsl#8 188 orr $s2,$s2,$t1,lsl#8
181 orr $s2,$s2,$t2,lsl#16
182 orr $s2,$s2,$t3,lsl#24
183 ldrb $s3,[$rounds,#15] 189 ldrb $s3,[$rounds,#15]
190 orr $s2,$s2,$t2,lsl#16
184 ldrb $t1,[$rounds,#14] 191 ldrb $t1,[$rounds,#14]
192 orr $s2,$s2,$t3,lsl#24
185 ldrb $t2,[$rounds,#13] 193 ldrb $t2,[$rounds,#13]
186 ldrb $t3,[$rounds,#12] 194 ldrb $t3,[$rounds,#12]
187 orr $s3,$s3,$t1,lsl#8 195 orr $s3,$s3,$t1,lsl#8
@@ -196,24 +204,24 @@ AES_encrypt:
196 mov $t3,$s0,lsr#8 204 mov $t3,$s0,lsr#8
197 strb $t1,[$rounds,#0] 205 strb $t1,[$rounds,#0]
198 strb $t2,[$rounds,#1] 206 strb $t2,[$rounds,#1]
199 strb $t3,[$rounds,#2]
200 strb $s0,[$rounds,#3]
201 mov $t1,$s1,lsr#24 207 mov $t1,$s1,lsr#24
208 strb $t3,[$rounds,#2]
202 mov $t2,$s1,lsr#16 209 mov $t2,$s1,lsr#16
210 strb $s0,[$rounds,#3]
203 mov $t3,$s1,lsr#8 211 mov $t3,$s1,lsr#8
204 strb $t1,[$rounds,#4] 212 strb $t1,[$rounds,#4]
205 strb $t2,[$rounds,#5] 213 strb $t2,[$rounds,#5]
206 strb $t3,[$rounds,#6]
207 strb $s1,[$rounds,#7]
208 mov $t1,$s2,lsr#24 214 mov $t1,$s2,lsr#24
215 strb $t3,[$rounds,#6]
209 mov $t2,$s2,lsr#16 216 mov $t2,$s2,lsr#16
217 strb $s1,[$rounds,#7]
210 mov $t3,$s2,lsr#8 218 mov $t3,$s2,lsr#8
211 strb $t1,[$rounds,#8] 219 strb $t1,[$rounds,#8]
212 strb $t2,[$rounds,#9] 220 strb $t2,[$rounds,#9]
213 strb $t3,[$rounds,#10]
214 strb $s2,[$rounds,#11]
215 mov $t1,$s3,lsr#24 221 mov $t1,$s3,lsr#24
222 strb $t3,[$rounds,#10]
216 mov $t2,$s3,lsr#16 223 mov $t2,$s3,lsr#16
224 strb $s2,[$rounds,#11]
217 mov $t3,$s3,lsr#8 225 mov $t3,$s3,lsr#8
218 strb $t1,[$rounds,#12] 226 strb $t1,[$rounds,#12]
219 strb $t2,[$rounds,#13] 227 strb $t2,[$rounds,#13]
@@ -230,141 +238,137 @@ AES_encrypt:
230.align 2 238.align 2
231_armv4_AES_encrypt: 239_armv4_AES_encrypt:
232 str lr,[sp,#-4]! @ push lr 240 str lr,[sp,#-4]! @ push lr
233 ldr $t1,[$key],#16 241 ldmia $key!,{$t1-$i1}
234 ldr $t2,[$key,#-12]
235 ldr $t3,[$key,#-8]
236 ldr $i1,[$key,#-4]
237 ldr $rounds,[$key,#240-16]
238 eor $s0,$s0,$t1 242 eor $s0,$s0,$t1
243 ldr $rounds,[$key,#240-16]
239 eor $s1,$s1,$t2 244 eor $s1,$s1,$t2
240 eor $s2,$s2,$t3 245 eor $s2,$s2,$t3
241 eor $s3,$s3,$i1 246 eor $s3,$s3,$i1
242 sub $rounds,$rounds,#1 247 sub $rounds,$rounds,#1
243 mov lr,#255 248 mov lr,#255
244 249
245.Lenc_loop: 250 and $i1,lr,$s0
246 and $i2,lr,$s0,lsr#8 251 and $i2,lr,$s0,lsr#8
247 and $i3,lr,$s0,lsr#16 252 and $i3,lr,$s0,lsr#16
248 and $i1,lr,$s0
249 mov $s0,$s0,lsr#24 253 mov $s0,$s0,lsr#24
254.Lenc_loop:
250 ldr $t1,[$tbl,$i1,lsl#2] @ Te3[s0>>0] 255 ldr $t1,[$tbl,$i1,lsl#2] @ Te3[s0>>0]
251 ldr $s0,[$tbl,$s0,lsl#2] @ Te0[s0>>24]
252 ldr $t2,[$tbl,$i2,lsl#2] @ Te2[s0>>8]
253 ldr $t3,[$tbl,$i3,lsl#2] @ Te1[s0>>16]
254
255 and $i1,lr,$s1,lsr#16 @ i0 256 and $i1,lr,$s1,lsr#16 @ i0
257 ldr $t2,[$tbl,$i2,lsl#2] @ Te2[s0>>8]
256 and $i2,lr,$s1 258 and $i2,lr,$s1
259 ldr $t3,[$tbl,$i3,lsl#2] @ Te1[s0>>16]
257 and $i3,lr,$s1,lsr#8 260 and $i3,lr,$s1,lsr#8
261 ldr $s0,[$tbl,$s0,lsl#2] @ Te0[s0>>24]
258 mov $s1,$s1,lsr#24 262 mov $s1,$s1,lsr#24
263
259 ldr $i1,[$tbl,$i1,lsl#2] @ Te1[s1>>16] 264 ldr $i1,[$tbl,$i1,lsl#2] @ Te1[s1>>16]
260 ldr $s1,[$tbl,$s1,lsl#2] @ Te0[s1>>24]
261 ldr $i2,[$tbl,$i2,lsl#2] @ Te3[s1>>0] 265 ldr $i2,[$tbl,$i2,lsl#2] @ Te3[s1>>0]
262 ldr $i3,[$tbl,$i3,lsl#2] @ Te2[s1>>8] 266 ldr $i3,[$tbl,$i3,lsl#2] @ Te2[s1>>8]
263 eor $s0,$s0,$i1,ror#8 267 eor $s0,$s0,$i1,ror#8
264 eor $s1,$s1,$t1,ror#24 268 ldr $s1,[$tbl,$s1,lsl#2] @ Te0[s1>>24]
265 eor $t2,$t2,$i2,ror#8
266 eor $t3,$t3,$i3,ror#8
267
268 and $i1,lr,$s2,lsr#8 @ i0 269 and $i1,lr,$s2,lsr#8 @ i0
270 eor $t2,$t2,$i2,ror#8
269 and $i2,lr,$s2,lsr#16 @ i1 271 and $i2,lr,$s2,lsr#16 @ i1
272 eor $t3,$t3,$i3,ror#8
270 and $i3,lr,$s2 273 and $i3,lr,$s2
271 mov $s2,$s2,lsr#24 274 eor $s1,$s1,$t1,ror#24
272 ldr $i1,[$tbl,$i1,lsl#2] @ Te2[s2>>8] 275 ldr $i1,[$tbl,$i1,lsl#2] @ Te2[s2>>8]
276 mov $s2,$s2,lsr#24
277
273 ldr $i2,[$tbl,$i2,lsl#2] @ Te1[s2>>16] 278 ldr $i2,[$tbl,$i2,lsl#2] @ Te1[s2>>16]
274 ldr $s2,[$tbl,$s2,lsl#2] @ Te0[s2>>24]
275 ldr $i3,[$tbl,$i3,lsl#2] @ Te3[s2>>0] 279 ldr $i3,[$tbl,$i3,lsl#2] @ Te3[s2>>0]
276 eor $s0,$s0,$i1,ror#16 280 eor $s0,$s0,$i1,ror#16
277 eor $s1,$s1,$i2,ror#8 281 ldr $s2,[$tbl,$s2,lsl#2] @ Te0[s2>>24]
278 eor $s2,$s2,$t2,ror#16
279 eor $t3,$t3,$i3,ror#16
280
281 and $i1,lr,$s3 @ i0 282 and $i1,lr,$s3 @ i0
283 eor $s1,$s1,$i2,ror#8
282 and $i2,lr,$s3,lsr#8 @ i1 284 and $i2,lr,$s3,lsr#8 @ i1
285 eor $t3,$t3,$i3,ror#16
283 and $i3,lr,$s3,lsr#16 @ i2 286 and $i3,lr,$s3,lsr#16 @ i2
284 mov $s3,$s3,lsr#24 287 eor $s2,$s2,$t2,ror#16
285 ldr $i1,[$tbl,$i1,lsl#2] @ Te3[s3>>0] 288 ldr $i1,[$tbl,$i1,lsl#2] @ Te3[s3>>0]
289 mov $s3,$s3,lsr#24
290
286 ldr $i2,[$tbl,$i2,lsl#2] @ Te2[s3>>8] 291 ldr $i2,[$tbl,$i2,lsl#2] @ Te2[s3>>8]
287 ldr $i3,[$tbl,$i3,lsl#2] @ Te1[s3>>16] 292 ldr $i3,[$tbl,$i3,lsl#2] @ Te1[s3>>16]
288 ldr $s3,[$tbl,$s3,lsl#2] @ Te0[s3>>24]
289 eor $s0,$s0,$i1,ror#24 293 eor $s0,$s0,$i1,ror#24
294 ldr $s3,[$tbl,$s3,lsl#2] @ Te0[s3>>24]
290 eor $s1,$s1,$i2,ror#16 295 eor $s1,$s1,$i2,ror#16
296 ldr $i1,[$key],#16
291 eor $s2,$s2,$i3,ror#8 297 eor $s2,$s2,$i3,ror#8
298 ldr $t1,[$key,#-12]
292 eor $s3,$s3,$t3,ror#8 299 eor $s3,$s3,$t3,ror#8
293 300
294 ldr $t1,[$key],#16 301 ldr $t2,[$key,#-8]
295 ldr $t2,[$key,#-12] 302 eor $s0,$s0,$i1
296 ldr $t3,[$key,#-8] 303 ldr $t3,[$key,#-4]
297 ldr $i1,[$key,#-4] 304 and $i1,lr,$s0
298 eor $s0,$s0,$t1 305 eor $s1,$s1,$t1
299 eor $s1,$s1,$t2 306 and $i2,lr,$s0,lsr#8
300 eor $s2,$s2,$t3 307 eor $s2,$s2,$t2
301 eor $s3,$s3,$i1 308 and $i3,lr,$s0,lsr#16
309 eor $s3,$s3,$t3
310 mov $s0,$s0,lsr#24
302 311
303 subs $rounds,$rounds,#1 312 subs $rounds,$rounds,#1
304 bne .Lenc_loop 313 bne .Lenc_loop
305 314
306 add $tbl,$tbl,#2 315 add $tbl,$tbl,#2
307 316
308 and $i1,lr,$s0
309 and $i2,lr,$s0,lsr#8
310 and $i3,lr,$s0,lsr#16
311 mov $s0,$s0,lsr#24
312 ldrb $t1,[$tbl,$i1,lsl#2] @ Te4[s0>>0] 317 ldrb $t1,[$tbl,$i1,lsl#2] @ Te4[s0>>0]
313 ldrb $s0,[$tbl,$s0,lsl#2] @ Te4[s0>>24]
314 ldrb $t2,[$tbl,$i2,lsl#2] @ Te4[s0>>8]
315 ldrb $t3,[$tbl,$i3,lsl#2] @ Te4[s0>>16]
316
317 and $i1,lr,$s1,lsr#16 @ i0 318 and $i1,lr,$s1,lsr#16 @ i0
319 ldrb $t2,[$tbl,$i2,lsl#2] @ Te4[s0>>8]
318 and $i2,lr,$s1 320 and $i2,lr,$s1
321 ldrb $t3,[$tbl,$i3,lsl#2] @ Te4[s0>>16]
319 and $i3,lr,$s1,lsr#8 322 and $i3,lr,$s1,lsr#8
323 ldrb $s0,[$tbl,$s0,lsl#2] @ Te4[s0>>24]
320 mov $s1,$s1,lsr#24 324 mov $s1,$s1,lsr#24
325
321 ldrb $i1,[$tbl,$i1,lsl#2] @ Te4[s1>>16] 326 ldrb $i1,[$tbl,$i1,lsl#2] @ Te4[s1>>16]
322 ldrb $s1,[$tbl,$s1,lsl#2] @ Te4[s1>>24]
323 ldrb $i2,[$tbl,$i2,lsl#2] @ Te4[s1>>0] 327 ldrb $i2,[$tbl,$i2,lsl#2] @ Te4[s1>>0]
324 ldrb $i3,[$tbl,$i3,lsl#2] @ Te4[s1>>8] 328 ldrb $i3,[$tbl,$i3,lsl#2] @ Te4[s1>>8]
325 eor $s0,$i1,$s0,lsl#8 329 eor $s0,$i1,$s0,lsl#8
326 eor $s1,$t1,$s1,lsl#24 330 ldrb $s1,[$tbl,$s1,lsl#2] @ Te4[s1>>24]
327 eor $t2,$i2,$t2,lsl#8
328 eor $t3,$i3,$t3,lsl#8
329
330 and $i1,lr,$s2,lsr#8 @ i0 331 and $i1,lr,$s2,lsr#8 @ i0
332 eor $t2,$i2,$t2,lsl#8
331 and $i2,lr,$s2,lsr#16 @ i1 333 and $i2,lr,$s2,lsr#16 @ i1
334 eor $t3,$i3,$t3,lsl#8
332 and $i3,lr,$s2 335 and $i3,lr,$s2
333 mov $s2,$s2,lsr#24 336 eor $s1,$t1,$s1,lsl#24
334 ldrb $i1,[$tbl,$i1,lsl#2] @ Te4[s2>>8] 337 ldrb $i1,[$tbl,$i1,lsl#2] @ Te4[s2>>8]
338 mov $s2,$s2,lsr#24
339
335 ldrb $i2,[$tbl,$i2,lsl#2] @ Te4[s2>>16] 340 ldrb $i2,[$tbl,$i2,lsl#2] @ Te4[s2>>16]
336 ldrb $s2,[$tbl,$s2,lsl#2] @ Te4[s2>>24]
337 ldrb $i3,[$tbl,$i3,lsl#2] @ Te4[s2>>0] 341 ldrb $i3,[$tbl,$i3,lsl#2] @ Te4[s2>>0]
338 eor $s0,$i1,$s0,lsl#8 342 eor $s0,$i1,$s0,lsl#8
339 eor $s1,$s1,$i2,lsl#16 343 ldrb $s2,[$tbl,$s2,lsl#2] @ Te4[s2>>24]
340 eor $s2,$t2,$s2,lsl#24
341 eor $t3,$i3,$t3,lsl#8
342
343 and $i1,lr,$s3 @ i0 344 and $i1,lr,$s3 @ i0
345 eor $s1,$s1,$i2,lsl#16
344 and $i2,lr,$s3,lsr#8 @ i1 346 and $i2,lr,$s3,lsr#8 @ i1
347 eor $t3,$i3,$t3,lsl#8
345 and $i3,lr,$s3,lsr#16 @ i2 348 and $i3,lr,$s3,lsr#16 @ i2
346 mov $s3,$s3,lsr#24 349 eor $s2,$t2,$s2,lsl#24
347 ldrb $i1,[$tbl,$i1,lsl#2] @ Te4[s3>>0] 350 ldrb $i1,[$tbl,$i1,lsl#2] @ Te4[s3>>0]
351 mov $s3,$s3,lsr#24
352
348 ldrb $i2,[$tbl,$i2,lsl#2] @ Te4[s3>>8] 353 ldrb $i2,[$tbl,$i2,lsl#2] @ Te4[s3>>8]
349 ldrb $i3,[$tbl,$i3,lsl#2] @ Te4[s3>>16] 354 ldrb $i3,[$tbl,$i3,lsl#2] @ Te4[s3>>16]
350 ldrb $s3,[$tbl,$s3,lsl#2] @ Te4[s3>>24]
351 eor $s0,$i1,$s0,lsl#8 355 eor $s0,$i1,$s0,lsl#8
356 ldrb $s3,[$tbl,$s3,lsl#2] @ Te4[s3>>24]
357 ldr $i1,[$key,#0]
352 eor $s1,$s1,$i2,lsl#8 358 eor $s1,$s1,$i2,lsl#8
359 ldr $t1,[$key,#4]
353 eor $s2,$s2,$i3,lsl#16 360 eor $s2,$s2,$i3,lsl#16
361 ldr $t2,[$key,#8]
354 eor $s3,$t3,$s3,lsl#24 362 eor $s3,$t3,$s3,lsl#24
363 ldr $t3,[$key,#12]
355 364
356 ldr lr,[sp],#4 @ pop lr 365 eor $s0,$s0,$i1
357 ldr $t1,[$key,#0] 366 eor $s1,$s1,$t1
358 ldr $t2,[$key,#4] 367 eor $s2,$s2,$t2
359 ldr $t3,[$key,#8] 368 eor $s3,$s3,$t3
360 ldr $i1,[$key,#12]
361 eor $s0,$s0,$t1
362 eor $s1,$s1,$t2
363 eor $s2,$s2,$t3
364 eor $s3,$s3,$i1
365 369
366 sub $tbl,$tbl,#2 370 sub $tbl,$tbl,#2
367 mov pc,lr @ return 371 ldr pc,[sp],#4 @ pop and return
368.size _armv4_AES_encrypt,.-_armv4_AES_encrypt 372.size _armv4_AES_encrypt,.-_armv4_AES_encrypt
369 373
370.global AES_set_encrypt_key 374.global AES_set_encrypt_key
@@ -399,31 +403,31 @@ AES_set_encrypt_key:
399 ldrb $t2,[$rounds,#1] 403 ldrb $t2,[$rounds,#1]
400 ldrb $t3,[$rounds,#0] 404 ldrb $t3,[$rounds,#0]
401 orr $s0,$s0,$t1,lsl#8 405 orr $s0,$s0,$t1,lsl#8
402 orr $s0,$s0,$t2,lsl#16
403 orr $s0,$s0,$t3,lsl#24
404 ldrb $s1,[$rounds,#7] 406 ldrb $s1,[$rounds,#7]
407 orr $s0,$s0,$t2,lsl#16
405 ldrb $t1,[$rounds,#6] 408 ldrb $t1,[$rounds,#6]
409 orr $s0,$s0,$t3,lsl#24
406 ldrb $t2,[$rounds,#5] 410 ldrb $t2,[$rounds,#5]
407 ldrb $t3,[$rounds,#4] 411 ldrb $t3,[$rounds,#4]
408 orr $s1,$s1,$t1,lsl#8 412 orr $s1,$s1,$t1,lsl#8
409 orr $s1,$s1,$t2,lsl#16
410 orr $s1,$s1,$t3,lsl#24
411 ldrb $s2,[$rounds,#11] 413 ldrb $s2,[$rounds,#11]
414 orr $s1,$s1,$t2,lsl#16
412 ldrb $t1,[$rounds,#10] 415 ldrb $t1,[$rounds,#10]
416 orr $s1,$s1,$t3,lsl#24
413 ldrb $t2,[$rounds,#9] 417 ldrb $t2,[$rounds,#9]
414 ldrb $t3,[$rounds,#8] 418 ldrb $t3,[$rounds,#8]
415 orr $s2,$s2,$t1,lsl#8 419 orr $s2,$s2,$t1,lsl#8
416 orr $s2,$s2,$t2,lsl#16
417 orr $s2,$s2,$t3,lsl#24
418 ldrb $s3,[$rounds,#15] 420 ldrb $s3,[$rounds,#15]
421 orr $s2,$s2,$t2,lsl#16
419 ldrb $t1,[$rounds,#14] 422 ldrb $t1,[$rounds,#14]
423 orr $s2,$s2,$t3,lsl#24
420 ldrb $t2,[$rounds,#13] 424 ldrb $t2,[$rounds,#13]
421 ldrb $t3,[$rounds,#12] 425 ldrb $t3,[$rounds,#12]
422 orr $s3,$s3,$t1,lsl#8 426 orr $s3,$s3,$t1,lsl#8
423 orr $s3,$s3,$t2,lsl#16
424 orr $s3,$s3,$t3,lsl#24
425 str $s0,[$key],#16 427 str $s0,[$key],#16
428 orr $s3,$s3,$t2,lsl#16
426 str $s1,[$key,#-12] 429 str $s1,[$key,#-12]
430 orr $s3,$s3,$t3,lsl#24
427 str $s2,[$key,#-8] 431 str $s2,[$key,#-8]
428 str $s3,[$key,#-4] 432 str $s3,[$key,#-4]
429 433
@@ -437,27 +441,26 @@ AES_set_encrypt_key:
437.L128_loop: 441.L128_loop:
438 and $t2,lr,$s3,lsr#24 442 and $t2,lr,$s3,lsr#24
439 and $i1,lr,$s3,lsr#16 443 and $i1,lr,$s3,lsr#16
440 and $i2,lr,$s3,lsr#8
441 and $i3,lr,$s3
442 ldrb $t2,[$tbl,$t2] 444 ldrb $t2,[$tbl,$t2]
445 and $i2,lr,$s3,lsr#8
443 ldrb $i1,[$tbl,$i1] 446 ldrb $i1,[$tbl,$i1]
447 and $i3,lr,$s3
444 ldrb $i2,[$tbl,$i2] 448 ldrb $i2,[$tbl,$i2]
445 ldrb $i3,[$tbl,$i3]
446 ldr $t1,[$t3],#4 @ rcon[i++]
447 orr $t2,$t2,$i1,lsl#24 449 orr $t2,$t2,$i1,lsl#24
450 ldrb $i3,[$tbl,$i3]
448 orr $t2,$t2,$i2,lsl#16 451 orr $t2,$t2,$i2,lsl#16
452 ldr $t1,[$t3],#4 @ rcon[i++]
449 orr $t2,$t2,$i3,lsl#8 453 orr $t2,$t2,$i3,lsl#8
450 eor $t2,$t2,$t1 454 eor $t2,$t2,$t1
451 eor $s0,$s0,$t2 @ rk[4]=rk[0]^... 455 eor $s0,$s0,$t2 @ rk[4]=rk[0]^...
452 eor $s1,$s1,$s0 @ rk[5]=rk[1]^rk[4] 456 eor $s1,$s1,$s0 @ rk[5]=rk[1]^rk[4]
453 eor $s2,$s2,$s1 @ rk[6]=rk[2]^rk[5]
454 eor $s3,$s3,$s2 @ rk[7]=rk[3]^rk[6]
455 str $s0,[$key],#16 457 str $s0,[$key],#16
458 eor $s2,$s2,$s1 @ rk[6]=rk[2]^rk[5]
456 str $s1,[$key,#-12] 459 str $s1,[$key,#-12]
460 eor $s3,$s3,$s2 @ rk[7]=rk[3]^rk[6]
457 str $s2,[$key,#-8] 461 str $s2,[$key,#-8]
458 str $s3,[$key,#-4]
459
460 subs $rounds,$rounds,#1 462 subs $rounds,$rounds,#1
463 str $s3,[$key,#-4]
461 bne .L128_loop 464 bne .L128_loop
462 sub r2,$key,#176 465 sub r2,$key,#176
463 b .Ldone 466 b .Ldone
@@ -468,16 +471,16 @@ AES_set_encrypt_key:
468 ldrb $t2,[$rounds,#17] 471 ldrb $t2,[$rounds,#17]
469 ldrb $t3,[$rounds,#16] 472 ldrb $t3,[$rounds,#16]
470 orr $i2,$i2,$t1,lsl#8 473 orr $i2,$i2,$t1,lsl#8
471 orr $i2,$i2,$t2,lsl#16
472 orr $i2,$i2,$t3,lsl#24
473 ldrb $i3,[$rounds,#23] 474 ldrb $i3,[$rounds,#23]
475 orr $i2,$i2,$t2,lsl#16
474 ldrb $t1,[$rounds,#22] 476 ldrb $t1,[$rounds,#22]
477 orr $i2,$i2,$t3,lsl#24
475 ldrb $t2,[$rounds,#21] 478 ldrb $t2,[$rounds,#21]
476 ldrb $t3,[$rounds,#20] 479 ldrb $t3,[$rounds,#20]
477 orr $i3,$i3,$t1,lsl#8 480 orr $i3,$i3,$t1,lsl#8
478 orr $i3,$i3,$t2,lsl#16 481 orr $i3,$i3,$t2,lsl#16
479 orr $i3,$i3,$t3,lsl#24
480 str $i2,[$key],#8 482 str $i2,[$key],#8
483 orr $i3,$i3,$t3,lsl#24
481 str $i3,[$key,#-4] 484 str $i3,[$key,#-4]
482 485
483 teq lr,#192 486 teq lr,#192
@@ -491,27 +494,26 @@ AES_set_encrypt_key:
491.L192_loop: 494.L192_loop:
492 and $t2,lr,$i3,lsr#24 495 and $t2,lr,$i3,lsr#24
493 and $i1,lr,$i3,lsr#16 496 and $i1,lr,$i3,lsr#16
494 and $i2,lr,$i3,lsr#8
495 and $i3,lr,$i3
496 ldrb $t2,[$tbl,$t2] 497 ldrb $t2,[$tbl,$t2]
498 and $i2,lr,$i3,lsr#8
497 ldrb $i1,[$tbl,$i1] 499 ldrb $i1,[$tbl,$i1]
500 and $i3,lr,$i3
498 ldrb $i2,[$tbl,$i2] 501 ldrb $i2,[$tbl,$i2]
499 ldrb $i3,[$tbl,$i3]
500 ldr $t1,[$t3],#4 @ rcon[i++]
501 orr $t2,$t2,$i1,lsl#24 502 orr $t2,$t2,$i1,lsl#24
503 ldrb $i3,[$tbl,$i3]
502 orr $t2,$t2,$i2,lsl#16 504 orr $t2,$t2,$i2,lsl#16
505 ldr $t1,[$t3],#4 @ rcon[i++]
503 orr $t2,$t2,$i3,lsl#8 506 orr $t2,$t2,$i3,lsl#8
504 eor $i3,$t2,$t1 507 eor $i3,$t2,$t1
505 eor $s0,$s0,$i3 @ rk[6]=rk[0]^... 508 eor $s0,$s0,$i3 @ rk[6]=rk[0]^...
506 eor $s1,$s1,$s0 @ rk[7]=rk[1]^rk[6] 509 eor $s1,$s1,$s0 @ rk[7]=rk[1]^rk[6]
507 eor $s2,$s2,$s1 @ rk[8]=rk[2]^rk[7]
508 eor $s3,$s3,$s2 @ rk[9]=rk[3]^rk[8]
509 str $s0,[$key],#24 510 str $s0,[$key],#24
511 eor $s2,$s2,$s1 @ rk[8]=rk[2]^rk[7]
510 str $s1,[$key,#-20] 512 str $s1,[$key,#-20]
513 eor $s3,$s3,$s2 @ rk[9]=rk[3]^rk[8]
511 str $s2,[$key,#-16] 514 str $s2,[$key,#-16]
512 str $s3,[$key,#-12]
513
514 subs $rounds,$rounds,#1 515 subs $rounds,$rounds,#1
516 str $s3,[$key,#-12]
515 subeq r2,$key,#216 517 subeq r2,$key,#216
516 beq .Ldone 518 beq .Ldone
517 519
@@ -529,16 +531,16 @@ AES_set_encrypt_key:
529 ldrb $t2,[$rounds,#25] 531 ldrb $t2,[$rounds,#25]
530 ldrb $t3,[$rounds,#24] 532 ldrb $t3,[$rounds,#24]
531 orr $i2,$i2,$t1,lsl#8 533 orr $i2,$i2,$t1,lsl#8
532 orr $i2,$i2,$t2,lsl#16
533 orr $i2,$i2,$t3,lsl#24
534 ldrb $i3,[$rounds,#31] 534 ldrb $i3,[$rounds,#31]
535 orr $i2,$i2,$t2,lsl#16
535 ldrb $t1,[$rounds,#30] 536 ldrb $t1,[$rounds,#30]
537 orr $i2,$i2,$t3,lsl#24
536 ldrb $t2,[$rounds,#29] 538 ldrb $t2,[$rounds,#29]
537 ldrb $t3,[$rounds,#28] 539 ldrb $t3,[$rounds,#28]
538 orr $i3,$i3,$t1,lsl#8 540 orr $i3,$i3,$t1,lsl#8
539 orr $i3,$i3,$t2,lsl#16 541 orr $i3,$i3,$t2,lsl#16
540 orr $i3,$i3,$t3,lsl#24
541 str $i2,[$key],#8 542 str $i2,[$key],#8
543 orr $i3,$i3,$t3,lsl#24
542 str $i3,[$key,#-4] 544 str $i3,[$key,#-4]
543 545
544 mov $rounds,#14 546 mov $rounds,#14
@@ -550,52 +552,51 @@ AES_set_encrypt_key:
550.L256_loop: 552.L256_loop:
551 and $t2,lr,$i3,lsr#24 553 and $t2,lr,$i3,lsr#24
552 and $i1,lr,$i3,lsr#16 554 and $i1,lr,$i3,lsr#16
553 and $i2,lr,$i3,lsr#8
554 and $i3,lr,$i3
555 ldrb $t2,[$tbl,$t2] 555 ldrb $t2,[$tbl,$t2]
556 and $i2,lr,$i3,lsr#8
556 ldrb $i1,[$tbl,$i1] 557 ldrb $i1,[$tbl,$i1]
558 and $i3,lr,$i3
557 ldrb $i2,[$tbl,$i2] 559 ldrb $i2,[$tbl,$i2]
558 ldrb $i3,[$tbl,$i3]
559 ldr $t1,[$t3],#4 @ rcon[i++]
560 orr $t2,$t2,$i1,lsl#24 560 orr $t2,$t2,$i1,lsl#24
561 ldrb $i3,[$tbl,$i3]
561 orr $t2,$t2,$i2,lsl#16 562 orr $t2,$t2,$i2,lsl#16
563 ldr $t1,[$t3],#4 @ rcon[i++]
562 orr $t2,$t2,$i3,lsl#8 564 orr $t2,$t2,$i3,lsl#8
563 eor $i3,$t2,$t1 565 eor $i3,$t2,$t1
564 eor $s0,$s0,$i3 @ rk[8]=rk[0]^... 566 eor $s0,$s0,$i3 @ rk[8]=rk[0]^...
565 eor $s1,$s1,$s0 @ rk[9]=rk[1]^rk[8] 567 eor $s1,$s1,$s0 @ rk[9]=rk[1]^rk[8]
566 eor $s2,$s2,$s1 @ rk[10]=rk[2]^rk[9]
567 eor $s3,$s3,$s2 @ rk[11]=rk[3]^rk[10]
568 str $s0,[$key],#32 568 str $s0,[$key],#32
569 eor $s2,$s2,$s1 @ rk[10]=rk[2]^rk[9]
569 str $s1,[$key,#-28] 570 str $s1,[$key,#-28]
571 eor $s3,$s3,$s2 @ rk[11]=rk[3]^rk[10]
570 str $s2,[$key,#-24] 572 str $s2,[$key,#-24]
571 str $s3,[$key,#-20]
572
573 subs $rounds,$rounds,#1 573 subs $rounds,$rounds,#1
574 str $s3,[$key,#-20]
574 subeq r2,$key,#256 575 subeq r2,$key,#256
575 beq .Ldone 576 beq .Ldone
576 577
577 and $t2,lr,$s3 578 and $t2,lr,$s3
578 and $i1,lr,$s3,lsr#8 579 and $i1,lr,$s3,lsr#8
579 and $i2,lr,$s3,lsr#16
580 and $i3,lr,$s3,lsr#24
581 ldrb $t2,[$tbl,$t2] 580 ldrb $t2,[$tbl,$t2]
581 and $i2,lr,$s3,lsr#16
582 ldrb $i1,[$tbl,$i1] 582 ldrb $i1,[$tbl,$i1]
583 and $i3,lr,$s3,lsr#24
583 ldrb $i2,[$tbl,$i2] 584 ldrb $i2,[$tbl,$i2]
584 ldrb $i3,[$tbl,$i3]
585 orr $t2,$t2,$i1,lsl#8 585 orr $t2,$t2,$i1,lsl#8
586 ldrb $i3,[$tbl,$i3]
586 orr $t2,$t2,$i2,lsl#16 587 orr $t2,$t2,$i2,lsl#16
588 ldr $t1,[$key,#-48]
587 orr $t2,$t2,$i3,lsl#24 589 orr $t2,$t2,$i3,lsl#24
588 590
589 ldr $t1,[$key,#-48]
590 ldr $i1,[$key,#-44] 591 ldr $i1,[$key,#-44]
591 ldr $i2,[$key,#-40] 592 ldr $i2,[$key,#-40]
592 ldr $i3,[$key,#-36]
593 eor $t1,$t1,$t2 @ rk[12]=rk[4]^... 593 eor $t1,$t1,$t2 @ rk[12]=rk[4]^...
594 ldr $i3,[$key,#-36]
594 eor $i1,$i1,$t1 @ rk[13]=rk[5]^rk[12] 595 eor $i1,$i1,$t1 @ rk[13]=rk[5]^rk[12]
595 eor $i2,$i2,$i1 @ rk[14]=rk[6]^rk[13]
596 eor $i3,$i3,$i2 @ rk[15]=rk[7]^rk[14]
597 str $t1,[$key,#-16] 596 str $t1,[$key,#-16]
597 eor $i2,$i2,$i1 @ rk[14]=rk[6]^rk[13]
598 str $i1,[$key,#-12] 598 str $i1,[$key,#-12]
599 eor $i3,$i3,$i2 @ rk[15]=rk[7]^rk[14]
599 str $i2,[$key,#-8] 600 str $i2,[$key,#-8]
600 str $i3,[$key,#-4] 601 str $i3,[$key,#-4]
601 b .L256_loop 602 b .L256_loop
@@ -816,24 +817,24 @@ AES_decrypt:
816 ldrb $t2,[$rounds,#1] 817 ldrb $t2,[$rounds,#1]
817 ldrb $t3,[$rounds,#0] 818 ldrb $t3,[$rounds,#0]
818 orr $s0,$s0,$t1,lsl#8 819 orr $s0,$s0,$t1,lsl#8
819 orr $s0,$s0,$t2,lsl#16
820 orr $s0,$s0,$t3,lsl#24
821 ldrb $s1,[$rounds,#7] 820 ldrb $s1,[$rounds,#7]
821 orr $s0,$s0,$t2,lsl#16
822 ldrb $t1,[$rounds,#6] 822 ldrb $t1,[$rounds,#6]
823 orr $s0,$s0,$t3,lsl#24
823 ldrb $t2,[$rounds,#5] 824 ldrb $t2,[$rounds,#5]
824 ldrb $t3,[$rounds,#4] 825 ldrb $t3,[$rounds,#4]
825 orr $s1,$s1,$t1,lsl#8 826 orr $s1,$s1,$t1,lsl#8
826 orr $s1,$s1,$t2,lsl#16
827 orr $s1,$s1,$t3,lsl#24
828 ldrb $s2,[$rounds,#11] 827 ldrb $s2,[$rounds,#11]
828 orr $s1,$s1,$t2,lsl#16
829 ldrb $t1,[$rounds,#10] 829 ldrb $t1,[$rounds,#10]
830 orr $s1,$s1,$t3,lsl#24
830 ldrb $t2,[$rounds,#9] 831 ldrb $t2,[$rounds,#9]
831 ldrb $t3,[$rounds,#8] 832 ldrb $t3,[$rounds,#8]
832 orr $s2,$s2,$t1,lsl#8 833 orr $s2,$s2,$t1,lsl#8
833 orr $s2,$s2,$t2,lsl#16
834 orr $s2,$s2,$t3,lsl#24
835 ldrb $s3,[$rounds,#15] 834 ldrb $s3,[$rounds,#15]
835 orr $s2,$s2,$t2,lsl#16
836 ldrb $t1,[$rounds,#14] 836 ldrb $t1,[$rounds,#14]
837 orr $s2,$s2,$t3,lsl#24
837 ldrb $t2,[$rounds,#13] 838 ldrb $t2,[$rounds,#13]
838 ldrb $t3,[$rounds,#12] 839 ldrb $t3,[$rounds,#12]
839 orr $s3,$s3,$t1,lsl#8 840 orr $s3,$s3,$t1,lsl#8
@@ -848,24 +849,24 @@ AES_decrypt:
848 mov $t3,$s0,lsr#8 849 mov $t3,$s0,lsr#8
849 strb $t1,[$rounds,#0] 850 strb $t1,[$rounds,#0]
850 strb $t2,[$rounds,#1] 851 strb $t2,[$rounds,#1]
851 strb $t3,[$rounds,#2]
852 strb $s0,[$rounds,#3]
853 mov $t1,$s1,lsr#24 852 mov $t1,$s1,lsr#24
853 strb $t3,[$rounds,#2]
854 mov $t2,$s1,lsr#16 854 mov $t2,$s1,lsr#16
855 strb $s0,[$rounds,#3]
855 mov $t3,$s1,lsr#8 856 mov $t3,$s1,lsr#8
856 strb $t1,[$rounds,#4] 857 strb $t1,[$rounds,#4]
857 strb $t2,[$rounds,#5] 858 strb $t2,[$rounds,#5]
858 strb $t3,[$rounds,#6]
859 strb $s1,[$rounds,#7]
860 mov $t1,$s2,lsr#24 859 mov $t1,$s2,lsr#24
860 strb $t3,[$rounds,#6]
861 mov $t2,$s2,lsr#16 861 mov $t2,$s2,lsr#16
862 strb $s1,[$rounds,#7]
862 mov $t3,$s2,lsr#8 863 mov $t3,$s2,lsr#8
863 strb $t1,[$rounds,#8] 864 strb $t1,[$rounds,#8]
864 strb $t2,[$rounds,#9] 865 strb $t2,[$rounds,#9]
865 strb $t3,[$rounds,#10]
866 strb $s2,[$rounds,#11]
867 mov $t1,$s3,lsr#24 866 mov $t1,$s3,lsr#24
867 strb $t3,[$rounds,#10]
868 mov $t2,$s3,lsr#16 868 mov $t2,$s3,lsr#16
869 strb $s2,[$rounds,#11]
869 mov $t3,$s3,lsr#8 870 mov $t3,$s3,lsr#8
870 strb $t1,[$rounds,#12] 871 strb $t1,[$rounds,#12]
871 strb $t2,[$rounds,#13] 872 strb $t2,[$rounds,#13]
@@ -882,146 +883,143 @@ AES_decrypt:
882.align 2 883.align 2
883_armv4_AES_decrypt: 884_armv4_AES_decrypt:
884 str lr,[sp,#-4]! @ push lr 885 str lr,[sp,#-4]! @ push lr
885 ldr $t1,[$key],#16 886 ldmia $key!,{$t1-$i1}
886 ldr $t2,[$key,#-12]
887 ldr $t3,[$key,#-8]
888 ldr $i1,[$key,#-4]
889 ldr $rounds,[$key,#240-16]
890 eor $s0,$s0,$t1 887 eor $s0,$s0,$t1
888 ldr $rounds,[$key,#240-16]
891 eor $s1,$s1,$t2 889 eor $s1,$s1,$t2
892 eor $s2,$s2,$t3 890 eor $s2,$s2,$t3
893 eor $s3,$s3,$i1 891 eor $s3,$s3,$i1
894 sub $rounds,$rounds,#1 892 sub $rounds,$rounds,#1
895 mov lr,#255 893 mov lr,#255
896 894
897.Ldec_loop:
898 and $i1,lr,$s0,lsr#16 895 and $i1,lr,$s0,lsr#16
899 and $i2,lr,$s0,lsr#8 896 and $i2,lr,$s0,lsr#8
900 and $i3,lr,$s0 897 and $i3,lr,$s0
901 mov $s0,$s0,lsr#24 898 mov $s0,$s0,lsr#24
899.Ldec_loop:
902 ldr $t1,[$tbl,$i1,lsl#2] @ Td1[s0>>16] 900 ldr $t1,[$tbl,$i1,lsl#2] @ Td1[s0>>16]
903 ldr $s0,[$tbl,$s0,lsl#2] @ Td0[s0>>24]
904 ldr $t2,[$tbl,$i2,lsl#2] @ Td2[s0>>8]
905 ldr $t3,[$tbl,$i3,lsl#2] @ Td3[s0>>0]
906
907 and $i1,lr,$s1 @ i0 901 and $i1,lr,$s1 @ i0
902 ldr $t2,[$tbl,$i2,lsl#2] @ Td2[s0>>8]
908 and $i2,lr,$s1,lsr#16 903 and $i2,lr,$s1,lsr#16
904 ldr $t3,[$tbl,$i3,lsl#2] @ Td3[s0>>0]
909 and $i3,lr,$s1,lsr#8 905 and $i3,lr,$s1,lsr#8
906 ldr $s0,[$tbl,$s0,lsl#2] @ Td0[s0>>24]
910 mov $s1,$s1,lsr#24 907 mov $s1,$s1,lsr#24
908
911 ldr $i1,[$tbl,$i1,lsl#2] @ Td3[s1>>0] 909 ldr $i1,[$tbl,$i1,lsl#2] @ Td3[s1>>0]
912 ldr $s1,[$tbl,$s1,lsl#2] @ Td0[s1>>24]
913 ldr $i2,[$tbl,$i2,lsl#2] @ Td1[s1>>16] 910 ldr $i2,[$tbl,$i2,lsl#2] @ Td1[s1>>16]
914 ldr $i3,[$tbl,$i3,lsl#2] @ Td2[s1>>8] 911 ldr $i3,[$tbl,$i3,lsl#2] @ Td2[s1>>8]
915 eor $s0,$s0,$i1,ror#24 912 eor $s0,$s0,$i1,ror#24
916 eor $s1,$s1,$t1,ror#8 913 ldr $s1,[$tbl,$s1,lsl#2] @ Td0[s1>>24]
917 eor $t2,$i2,$t2,ror#8
918 eor $t3,$i3,$t3,ror#8
919
920 and $i1,lr,$s2,lsr#8 @ i0 914 and $i1,lr,$s2,lsr#8 @ i0
915 eor $t2,$i2,$t2,ror#8
921 and $i2,lr,$s2 @ i1 916 and $i2,lr,$s2 @ i1
917 eor $t3,$i3,$t3,ror#8
922 and $i3,lr,$s2,lsr#16 918 and $i3,lr,$s2,lsr#16
923 mov $s2,$s2,lsr#24 919 eor $s1,$s1,$t1,ror#8
924 ldr $i1,[$tbl,$i1,lsl#2] @ Td2[s2>>8] 920 ldr $i1,[$tbl,$i1,lsl#2] @ Td2[s2>>8]
921 mov $s2,$s2,lsr#24
922
925 ldr $i2,[$tbl,$i2,lsl#2] @ Td3[s2>>0] 923 ldr $i2,[$tbl,$i2,lsl#2] @ Td3[s2>>0]
926 ldr $s2,[$tbl,$s2,lsl#2] @ Td0[s2>>24]
927 ldr $i3,[$tbl,$i3,lsl#2] @ Td1[s2>>16] 924 ldr $i3,[$tbl,$i3,lsl#2] @ Td1[s2>>16]
928 eor $s0,$s0,$i1,ror#16 925 eor $s0,$s0,$i1,ror#16
929 eor $s1,$s1,$i2,ror#24 926 ldr $s2,[$tbl,$s2,lsl#2] @ Td0[s2>>24]
930 eor $s2,$s2,$t2,ror#8
931 eor $t3,$i3,$t3,ror#8
932
933 and $i1,lr,$s3,lsr#16 @ i0 927 and $i1,lr,$s3,lsr#16 @ i0
928 eor $s1,$s1,$i2,ror#24
934 and $i2,lr,$s3,lsr#8 @ i1 929 and $i2,lr,$s3,lsr#8 @ i1
930 eor $t3,$i3,$t3,ror#8
935 and $i3,lr,$s3 @ i2 931 and $i3,lr,$s3 @ i2
936 mov $s3,$s3,lsr#24 932 eor $s2,$s2,$t2,ror#8
937 ldr $i1,[$tbl,$i1,lsl#2] @ Td1[s3>>16] 933 ldr $i1,[$tbl,$i1,lsl#2] @ Td1[s3>>16]
934 mov $s3,$s3,lsr#24
935
938 ldr $i2,[$tbl,$i2,lsl#2] @ Td2[s3>>8] 936 ldr $i2,[$tbl,$i2,lsl#2] @ Td2[s3>>8]
939 ldr $i3,[$tbl,$i3,lsl#2] @ Td3[s3>>0] 937 ldr $i3,[$tbl,$i3,lsl#2] @ Td3[s3>>0]
940 ldr $s3,[$tbl,$s3,lsl#2] @ Td0[s3>>24]
941 eor $s0,$s0,$i1,ror#8 938 eor $s0,$s0,$i1,ror#8
939 ldr $s3,[$tbl,$s3,lsl#2] @ Td0[s3>>24]
942 eor $s1,$s1,$i2,ror#16 940 eor $s1,$s1,$i2,ror#16
943 eor $s2,$s2,$i3,ror#24 941 eor $s2,$s2,$i3,ror#24
942 ldr $i1,[$key],#16
944 eor $s3,$s3,$t3,ror#8 943 eor $s3,$s3,$t3,ror#8
945 944
946 ldr $t1,[$key],#16 945 ldr $t1,[$key,#-12]
947 ldr $t2,[$key,#-12] 946 ldr $t2,[$key,#-8]
948 ldr $t3,[$key,#-8] 947 eor $s0,$s0,$i1
949 ldr $i1,[$key,#-4] 948 ldr $t3,[$key,#-4]
950 eor $s0,$s0,$t1 949 and $i1,lr,$s0,lsr#16
951 eor $s1,$s1,$t2 950 eor $s1,$s1,$t1
952 eor $s2,$s2,$t3 951 and $i2,lr,$s0,lsr#8
953 eor $s3,$s3,$i1 952 eor $s2,$s2,$t2
953 and $i3,lr,$s0
954 eor $s3,$s3,$t3
955 mov $s0,$s0,lsr#24
954 956
955 subs $rounds,$rounds,#1 957 subs $rounds,$rounds,#1
956 bne .Ldec_loop 958 bne .Ldec_loop
957 959
958 add $tbl,$tbl,#1024 960 add $tbl,$tbl,#1024
959 961
960 ldr $t1,[$tbl,#0] @ prefetch Td4 962 ldr $t2,[$tbl,#0] @ prefetch Td4
961 ldr $t2,[$tbl,#32] 963 ldr $t3,[$tbl,#32]
962 ldr $t3,[$tbl,#64] 964 ldr $t1,[$tbl,#64]
963 ldr $i1,[$tbl,#96] 965 ldr $t2,[$tbl,#96]
964 ldr $i2,[$tbl,#128] 966 ldr $t3,[$tbl,#128]
965 ldr $i3,[$tbl,#160] 967 ldr $t1,[$tbl,#160]
966 ldr $t1,[$tbl,#192] 968 ldr $t2,[$tbl,#192]
967 ldr $t2,[$tbl,#224] 969 ldr $t3,[$tbl,#224]
968 970
969 and $i1,lr,$s0,lsr#16 971 ldrb $s0,[$tbl,$s0] @ Td4[s0>>24]
970 and $i2,lr,$s0,lsr#8
971 and $i3,lr,$s0
972 ldrb $s0,[$tbl,$s0,lsr#24] @ Td4[s0>>24]
973 ldrb $t1,[$tbl,$i1] @ Td4[s0>>16] 972 ldrb $t1,[$tbl,$i1] @ Td4[s0>>16]
974 ldrb $t2,[$tbl,$i2] @ Td4[s0>>8]
975 ldrb $t3,[$tbl,$i3] @ Td4[s0>>0]
976
977 and $i1,lr,$s1 @ i0 973 and $i1,lr,$s1 @ i0
974 ldrb $t2,[$tbl,$i2] @ Td4[s0>>8]
978 and $i2,lr,$s1,lsr#16 975 and $i2,lr,$s1,lsr#16
976 ldrb $t3,[$tbl,$i3] @ Td4[s0>>0]
979 and $i3,lr,$s1,lsr#8 977 and $i3,lr,$s1,lsr#8
978
980 ldrb $i1,[$tbl,$i1] @ Td4[s1>>0] 979 ldrb $i1,[$tbl,$i1] @ Td4[s1>>0]
981 ldrb $s1,[$tbl,$s1,lsr#24] @ Td4[s1>>24] 980 ldrb $s1,[$tbl,$s1,lsr#24] @ Td4[s1>>24]
982 ldrb $i2,[$tbl,$i2] @ Td4[s1>>16] 981 ldrb $i2,[$tbl,$i2] @ Td4[s1>>16]
983 ldrb $i3,[$tbl,$i3] @ Td4[s1>>8]
984 eor $s0,$i1,$s0,lsl#24 982 eor $s0,$i1,$s0,lsl#24
983 ldrb $i3,[$tbl,$i3] @ Td4[s1>>8]
985 eor $s1,$t1,$s1,lsl#8 984 eor $s1,$t1,$s1,lsl#8
986 eor $t2,$t2,$i2,lsl#8
987 eor $t3,$t3,$i3,lsl#8
988
989 and $i1,lr,$s2,lsr#8 @ i0 985 and $i1,lr,$s2,lsr#8 @ i0
986 eor $t2,$t2,$i2,lsl#8
990 and $i2,lr,$s2 @ i1 987 and $i2,lr,$s2 @ i1
991 and $i3,lr,$s2,lsr#16 988 eor $t3,$t3,$i3,lsl#8
992 ldrb $i1,[$tbl,$i1] @ Td4[s2>>8] 989 ldrb $i1,[$tbl,$i1] @ Td4[s2>>8]
990 and $i3,lr,$s2,lsr#16
991
993 ldrb $i2,[$tbl,$i2] @ Td4[s2>>0] 992 ldrb $i2,[$tbl,$i2] @ Td4[s2>>0]
994 ldrb $s2,[$tbl,$s2,lsr#24] @ Td4[s2>>24] 993 ldrb $s2,[$tbl,$s2,lsr#24] @ Td4[s2>>24]
995 ldrb $i3,[$tbl,$i3] @ Td4[s2>>16]
996 eor $s0,$s0,$i1,lsl#8 994 eor $s0,$s0,$i1,lsl#8
995 ldrb $i3,[$tbl,$i3] @ Td4[s2>>16]
997 eor $s1,$i2,$s1,lsl#16 996 eor $s1,$i2,$s1,lsl#16
998 eor $s2,$t2,$s2,lsl#16
999 eor $t3,$t3,$i3,lsl#16
1000
1001 and $i1,lr,$s3,lsr#16 @ i0 997 and $i1,lr,$s3,lsr#16 @ i0
998 eor $s2,$t2,$s2,lsl#16
1002 and $i2,lr,$s3,lsr#8 @ i1 999 and $i2,lr,$s3,lsr#8 @ i1
1003 and $i3,lr,$s3 @ i2 1000 eor $t3,$t3,$i3,lsl#16
1004 ldrb $i1,[$tbl,$i1] @ Td4[s3>>16] 1001 ldrb $i1,[$tbl,$i1] @ Td4[s3>>16]
1002 and $i3,lr,$s3 @ i2
1003
1005 ldrb $i2,[$tbl,$i2] @ Td4[s3>>8] 1004 ldrb $i2,[$tbl,$i2] @ Td4[s3>>8]
1006 ldrb $i3,[$tbl,$i3] @ Td4[s3>>0] 1005 ldrb $i3,[$tbl,$i3] @ Td4[s3>>0]
1007 ldrb $s3,[$tbl,$s3,lsr#24] @ Td4[s3>>24] 1006 ldrb $s3,[$tbl,$s3,lsr#24] @ Td4[s3>>24]
1008 eor $s0,$s0,$i1,lsl#16 1007 eor $s0,$s0,$i1,lsl#16
1008 ldr $i1,[$key,#0]
1009 eor $s1,$s1,$i2,lsl#8 1009 eor $s1,$s1,$i2,lsl#8
1010 ldr $t1,[$key,#4]
1010 eor $s2,$i3,$s2,lsl#8 1011 eor $s2,$i3,$s2,lsl#8
1012 ldr $t2,[$key,#8]
1011 eor $s3,$t3,$s3,lsl#24 1013 eor $s3,$t3,$s3,lsl#24
1014 ldr $t3,[$key,#12]
1012 1015
1013 ldr lr,[sp],#4 @ pop lr 1016 eor $s0,$s0,$i1
1014 ldr $t1,[$key,#0] 1017 eor $s1,$s1,$t1
1015 ldr $t2,[$key,#4] 1018 eor $s2,$s2,$t2
1016 ldr $t3,[$key,#8] 1019 eor $s3,$s3,$t3
1017 ldr $i1,[$key,#12]
1018 eor $s0,$s0,$t1
1019 eor $s1,$s1,$t2
1020 eor $s2,$s2,$t3
1021 eor $s3,$s3,$i1
1022 1020
1023 sub $tbl,$tbl,#1024 1021 sub $tbl,$tbl,#1024
1024 mov pc,lr @ return 1022 ldr pc,[sp],#4 @ pop and return
1025.size _armv4_AES_decrypt,.-_armv4_AES_decrypt 1023.size _armv4_AES_decrypt,.-_armv4_AES_decrypt
1026.asciz "AES for ARMv4, CRYPTOGAMS by <appro\@openssl.org>" 1024.asciz "AES for ARMv4, CRYPTOGAMS by <appro\@openssl.org>"
1027.align 2 1025.align 2
@@ -1029,3 +1027,4 @@ ___
1029 1027
1030$code =~ s/\bbx\s+lr\b/.word\t0xe12fff1e/gm; # make it possible to compile with -march=armv4 1028$code =~ s/\bbx\s+lr\b/.word\t0xe12fff1e/gm; # make it possible to compile with -march=armv4
1031print $code; 1029print $code;
1030close STDOUT; # enforce flush
diff --git a/src/lib/libssl/src/crypto/alphacpuid.pl b/src/lib/libssl/src/crypto/alphacpuid.pl
new file mode 100644
index 0000000000..4b3cbb9827
--- /dev/null
+++ b/src/lib/libssl/src/crypto/alphacpuid.pl
@@ -0,0 +1,126 @@
1#!/usr/bin/env perl
2print <<'___';
3.text
4
5.set noat
6
7.globl OPENSSL_cpuid_setup
8.ent OPENSSL_cpuid_setup
9OPENSSL_cpuid_setup:
10 .frame $30,0,$26
11 .prologue 0
12 ret ($26)
13.end OPENSSL_cpuid_setup
14
15.globl OPENSSL_wipe_cpu
16.ent OPENSSL_wipe_cpu
17OPENSSL_wipe_cpu:
18 .frame $30,0,$26
19 .prologue 0
20 clr $1
21 clr $2
22 clr $3
23 clr $4
24 clr $5
25 clr $6
26 clr $7
27 clr $8
28 clr $16
29 clr $17
30 clr $18
31 clr $19
32 clr $20
33 clr $21
34 clr $22
35 clr $23
36 clr $24
37 clr $25
38 clr $27
39 clr $at
40 clr $29
41 fclr $f0
42 fclr $f1
43 fclr $f10
44 fclr $f11
45 fclr $f12
46 fclr $f13
47 fclr $f14
48 fclr $f15
49 fclr $f16
50 fclr $f17
51 fclr $f18
52 fclr $f19
53 fclr $f20
54 fclr $f21
55 fclr $f22
56 fclr $f23
57 fclr $f24
58 fclr $f25
59 fclr $f26
60 fclr $f27
61 fclr $f28
62 fclr $f29
63 fclr $f30
64 mov $sp,$0
65 ret ($26)
66.end OPENSSL_wipe_cpu
67
68.globl OPENSSL_atomic_add
69.ent OPENSSL_atomic_add
70OPENSSL_atomic_add:
71 .frame $30,0,$26
72 .prologue 0
731: ldl_l $0,0($16)
74 addl $0,$17,$1
75 stl_c $1,0($16)
76 beq $1,1b
77 addl $0,$17,$0
78 ret ($26)
79.end OPENSSL_atomic_add
80
81.globl OPENSSL_rdtsc
82.ent OPENSSL_rdtsc
83OPENSSL_rdtsc:
84 .frame $30,0,$26
85 .prologue 0
86 rpcc $0
87 ret ($26)
88.end OPENSSL_rdtsc
89
90.globl OPENSSL_cleanse
91.ent OPENSSL_cleanse
92OPENSSL_cleanse:
93 .frame $30,0,$26
94 .prologue 0
95 beq $17,.Ldone
96 and $16,7,$0
97 bic $17,7,$at
98 beq $at,.Little
99 beq $0,.Laligned
100
101.Little:
102 subq $0,8,$0
103 ldq_u $1,0($16)
104 mov $16,$2
105.Lalign:
106 mskbl $1,$16,$1
107 lda $16,1($16)
108 subq $17,1,$17
109 addq $0,1,$0
110 beq $17,.Lout
111 bne $0,.Lalign
112.Lout: stq_u $1,0($2)
113 beq $17,.Ldone
114 bic $17,7,$at
115 beq $at,.Little
116
117.Laligned:
118 stq $31,0($16)
119 subq $17,8,$17
120 lda $16,8($16)
121 bic $17,7,$at
122 bne $at,.Laligned
123 bne $17,.Little
124.Ldone: ret ($26)
125.end OPENSSL_cleanse
126___
diff --git a/src/lib/libssl/src/crypto/asn1/ameth_lib.c b/src/lib/libssl/src/crypto/asn1/ameth_lib.c
index 9a8b6cc222..5a581b90ea 100644
--- a/src/lib/libssl/src/crypto/asn1/ameth_lib.c
+++ b/src/lib/libssl/src/crypto/asn1/ameth_lib.c
@@ -172,7 +172,6 @@ static const EVP_PKEY_ASN1_METHOD *pkey_asn1_find(int type)
172const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find(ENGINE **pe, int type) 172const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find(ENGINE **pe, int type)
173 { 173 {
174 const EVP_PKEY_ASN1_METHOD *t; 174 const EVP_PKEY_ASN1_METHOD *t;
175 ENGINE *e;
176 175
177 for (;;) 176 for (;;)
178 { 177 {
@@ -184,6 +183,7 @@ const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find(ENGINE **pe, int type)
184 if (pe) 183 if (pe)
185 { 184 {
186#ifndef OPENSSL_NO_ENGINE 185#ifndef OPENSSL_NO_ENGINE
186 ENGINE *e;
187 /* type will contain the final unaliased type */ 187 /* type will contain the final unaliased type */
188 e = ENGINE_get_pkey_asn1_meth_engine(type); 188 e = ENGINE_get_pkey_asn1_meth_engine(type);
189 if (e) 189 if (e)
diff --git a/src/lib/libssl/src/crypto/asn1/bio_ndef.c b/src/lib/libssl/src/crypto/asn1/bio_ndef.c
index 370389b1e6..b91f97a1b1 100644
--- a/src/lib/libssl/src/crypto/asn1/bio_ndef.c
+++ b/src/lib/libssl/src/crypto/asn1/bio_ndef.c
@@ -57,9 +57,6 @@
57#include <openssl/bio.h> 57#include <openssl/bio.h>
58#include <openssl/err.h> 58#include <openssl/err.h>
59 59
60#ifndef OPENSSL_SYSNAME_NETWARE
61#include <memory.h>
62#endif
63#include <stdio.h> 60#include <stdio.h>
64 61
65/* Experimental NDEF ASN1 BIO support routines */ 62/* Experimental NDEF ASN1 BIO support routines */
diff --git a/src/lib/libssl/src/crypto/bio/bss_dgram.c b/src/lib/libssl/src/crypto/bio/bss_dgram.c
index eb7e365467..71ebe987b6 100644
--- a/src/lib/libssl/src/crypto/bio/bss_dgram.c
+++ b/src/lib/libssl/src/crypto/bio/bss_dgram.c
@@ -57,7 +57,6 @@
57 * 57 *
58 */ 58 */
59 59
60#ifndef OPENSSL_NO_DGRAM
61 60
62#include <stdio.h> 61#include <stdio.h>
63#include <errno.h> 62#include <errno.h>
@@ -65,6 +64,7 @@
65#include "cryptlib.h" 64#include "cryptlib.h"
66 65
67#include <openssl/bio.h> 66#include <openssl/bio.h>
67#ifndef OPENSSL_NO_DGRAM
68 68
69#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS) 69#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS)
70#include <sys/timeb.h> 70#include <sys/timeb.h>
@@ -308,7 +308,6 @@ static int dgram_read(BIO *b, char *out, int outl)
308 OPENSSL_assert(sa.len.s<=sizeof(sa.peer)); 308 OPENSSL_assert(sa.len.s<=sizeof(sa.peer));
309 sa.len.i = (int)sa.len.s; 309 sa.len.i = (int)sa.len.s;
310 } 310 }
311 dgram_reset_rcv_timeout(b);
312 311
313 if ( ! data->connected && ret >= 0) 312 if ( ! data->connected && ret >= 0)
314 BIO_ctrl(b, BIO_CTRL_DGRAM_SET_PEER, 0, &sa.peer); 313 BIO_ctrl(b, BIO_CTRL_DGRAM_SET_PEER, 0, &sa.peer);
@@ -322,6 +321,8 @@ static int dgram_read(BIO *b, char *out, int outl)
322 data->_errno = get_last_socket_error(); 321 data->_errno = get_last_socket_error();
323 } 322 }
324 } 323 }
324
325 dgram_reset_rcv_timeout(b);
325 } 326 }
326 return(ret); 327 return(ret);
327 } 328 }
@@ -340,7 +341,7 @@ static int dgram_write(BIO *b, const char *in, int inl)
340 341
341 if (data->peer.sa.sa_family == AF_INET) 342 if (data->peer.sa.sa_family == AF_INET)
342 peerlen = sizeof(data->peer.sa_in); 343 peerlen = sizeof(data->peer.sa_in);
343#if OPENSSL_USE_IVP6 344#if OPENSSL_USE_IPV6
344 else if (data->peer.sa.sa_family == AF_INET6) 345 else if (data->peer.sa.sa_family == AF_INET6)
345 peerlen = sizeof(data->peer.sa_in6); 346 peerlen = sizeof(data->peer.sa_in6);
346#endif 347#endif
@@ -745,9 +746,13 @@ static int BIO_dgram_should_retry(int i)
745 { 746 {
746 err=get_last_socket_error(); 747 err=get_last_socket_error();
747 748
748#if defined(OPENSSL_SYS_WINDOWS) && 0 /* more microsoft stupidity? perhaps not? Ben 4/1/99 */ 749#if defined(OPENSSL_SYS_WINDOWS)
749 if ((i == -1) && (err == 0)) 750 /* If the socket return value (i) is -1
750 return(1); 751 * and err is unexpectedly 0 at this point,
752 * the error code was overwritten by
753 * another system call before this error
754 * handling is called.
755 */
751#endif 756#endif
752 757
753 return(BIO_dgram_non_fatal_error(err)); 758 return(BIO_dgram_non_fatal_error(err));
@@ -810,7 +815,6 @@ int BIO_dgram_non_fatal_error(int err)
810 } 815 }
811 return(0); 816 return(0);
812 } 817 }
813#endif
814 818
815static void get_current_time(struct timeval *t) 819static void get_current_time(struct timeval *t)
816 { 820 {
@@ -828,3 +832,5 @@ static void get_current_time(struct timeval *t)
828 gettimeofday(t, NULL); 832 gettimeofday(t, NULL);
829#endif 833#endif
830 } 834 }
835
836#endif
diff --git a/src/lib/libssl/src/crypto/bn/asm/alpha-mont.pl b/src/lib/libssl/src/crypto/bn/asm/alpha-mont.pl
index f7e0ca1646..03596e2014 100644
--- a/src/lib/libssl/src/crypto/bn/asm/alpha-mont.pl
+++ b/src/lib/libssl/src/crypto/bn/asm/alpha-mont.pl
@@ -41,8 +41,12 @@ $j="s4";
41$m1="s5"; 41$m1="s5";
42 42
43$code=<<___; 43$code=<<___;
44#ifdef __linux__
45#include <asm/regdef.h>
46#else
44#include <asm.h> 47#include <asm.h>
45#include <regdef.h> 48#include <regdef.h>
49#endif
46 50
47.text 51.text
48 52
@@ -76,7 +80,7 @@ bn_mul_mont:
76 ldq $aj,8($ap) 80 ldq $aj,8($ap)
77 subq sp,AT,sp 81 subq sp,AT,sp
78 ldq $bi,0($bp) # bp[0] 82 ldq $bi,0($bp) # bp[0]
79 mov -4096,AT 83 lda AT,-4096(zero) # mov -4096,AT
80 ldq $n0,0($n0) 84 ldq $n0,0($n0)
81 and sp,AT,sp 85 and sp,AT,sp
82 86
@@ -106,9 +110,9 @@ bn_mul_mont:
106.align 4 110.align 4
107.L1st: 111.L1st:
108 .set noreorder 112 .set noreorder
109 ldq $aj,($aj) 113 ldq $aj,0($aj)
110 addl $j,1,$j 114 addl $j,1,$j
111 ldq $nj,($nj) 115 ldq $nj,0($nj)
112 lda $tp,8($tp) 116 lda $tp,8($tp)
113 117
114 addq $alo,$hi0,$lo0 118 addq $alo,$hi0,$lo0
@@ -159,12 +163,12 @@ bn_mul_mont:
159.align 4 163.align 4
160.Louter: 164.Louter:
161 s8addq $i,$bp,$bi 165 s8addq $i,$bp,$bi
162 ldq $hi0,($ap) 166 ldq $hi0,0($ap)
163 ldq $aj,8($ap) 167 ldq $aj,8($ap)
164 ldq $bi,($bi) 168 ldq $bi,0($bi)
165 ldq $hi1,($np) 169 ldq $hi1,0($np)
166 ldq $nj,8($np) 170 ldq $nj,8($np)
167 ldq $tj,(sp) 171 ldq $tj,0(sp)
168 172
169 mulq $hi0,$bi,$lo0 173 mulq $hi0,$bi,$lo0
170 umulh $hi0,$bi,$hi0 174 umulh $hi0,$bi,$hi0
@@ -195,10 +199,10 @@ bn_mul_mont:
195 .set noreorder 199 .set noreorder
196 ldq $tj,8($tp) #L0 200 ldq $tj,8($tp) #L0
197 nop #U1 201 nop #U1
198 ldq $aj,($aj) #L1 202 ldq $aj,0($aj) #L1
199 s8addq $j,$np,$nj #U0 203 s8addq $j,$np,$nj #U0
200 204
201 ldq $nj,($nj) #L0 205 ldq $nj,0($nj) #L0
202 nop #U1 206 nop #U1
203 addq $alo,$hi0,$lo0 #L1 207 addq $alo,$hi0,$lo0 #L1
204 lda $tp,8($tp) 208 lda $tp,8($tp)
@@ -247,7 +251,7 @@ bn_mul_mont:
247 addq $hi1,v0,$hi1 251 addq $hi1,v0,$hi1
248 252
249 addq $hi1,$hi0,$lo1 253 addq $hi1,$hi0,$lo1
250 stq $j,($tp) 254 stq $j,0($tp)
251 cmpult $lo1,$hi0,$hi1 255 cmpult $lo1,$hi0,$hi1
252 addq $lo1,$tj,$lo1 256 addq $lo1,$tj,$lo1
253 cmpult $lo1,$tj,AT 257 cmpult $lo1,$tj,AT
@@ -265,8 +269,8 @@ bn_mul_mont:
265 mov 0,$hi0 # clear borrow bit 269 mov 0,$hi0 # clear borrow bit
266 270
267.align 4 271.align 4
268.Lsub: ldq $lo0,($tp) 272.Lsub: ldq $lo0,0($tp)
269 ldq $lo1,($np) 273 ldq $lo1,0($np)
270 lda $tp,8($tp) 274 lda $tp,8($tp)
271 lda $np,8($np) 275 lda $np,8($np)
272 subq $lo0,$lo1,$lo1 # tp[i]-np[i] 276 subq $lo0,$lo1,$lo1 # tp[i]-np[i]
@@ -274,7 +278,7 @@ bn_mul_mont:
274 subq $lo1,$hi0,$lo0 278 subq $lo1,$hi0,$lo0
275 cmpult $lo1,$lo0,$hi0 279 cmpult $lo1,$lo0,$hi0
276 or $hi0,AT,$hi0 280 or $hi0,AT,$hi0
277 stq $lo0,($rp) 281 stq $lo0,0($rp)
278 cmpult $tp,$tj,v0 282 cmpult $tp,$tj,v0
279 lda $rp,8($rp) 283 lda $rp,8($rp)
280 bne v0,.Lsub 284 bne v0,.Lsub
@@ -288,7 +292,7 @@ bn_mul_mont:
288 bis $bp,$ap,$ap # ap=borrow?tp:rp 292 bis $bp,$ap,$ap # ap=borrow?tp:rp
289 293
290.align 4 294.align 4
291.Lcopy: ldq $aj,($ap) # copy or in-place refresh 295.Lcopy: ldq $aj,0($ap) # copy or in-place refresh
292 lda $tp,8($tp) 296 lda $tp,8($tp)
293 lda $rp,8($rp) 297 lda $rp,8($rp)
294 lda $ap,8($ap) 298 lda $ap,8($ap)
@@ -309,8 +313,8 @@ bn_mul_mont:
309 lda sp,48(sp) 313 lda sp,48(sp)
310 ret (ra) 314 ret (ra)
311.end bn_mul_mont 315.end bn_mul_mont
312.rdata 316.ascii "Montgomery Multiplication for Alpha, CRYPTOGAMS by <appro\@openssl.org>"
313.asciiz "Montgomery Multiplication for Alpha, CRYPTOGAMS by <appro\@openssl.org>" 317.align 2
314___ 318___
315 319
316print $code; 320print $code;
diff --git a/src/lib/libssl/src/crypto/bn/asm/s390x-mont.pl b/src/lib/libssl/src/crypto/bn/asm/s390x-mont.pl
index d23251033b..f61246f5b6 100644
--- a/src/lib/libssl/src/crypto/bn/asm/s390x-mont.pl
+++ b/src/lib/libssl/src/crypto/bn/asm/s390x-mont.pl
@@ -69,8 +69,8 @@ bn_mul_mont:
69 cghi $num,16 # 69 cghi $num,16 #
70 lghi %r2,0 # 70 lghi %r2,0 #
71 blr %r14 # if($num<16) return 0; 71 blr %r14 # if($num<16) return 0;
72 cghi $num,128 # 72 cghi $num,96 #
73 bhr %r14 # if($num>128) return 0; 73 bhr %r14 # if($num>96) return 0;
74 74
75 stmg %r3,%r15,24($sp) 75 stmg %r3,%r15,24($sp)
76 76
diff --git a/src/lib/libssl/src/crypto/bn/asm/s390x.S b/src/lib/libssl/src/crypto/bn/asm/s390x.S
index 8f45f5d513..43fcb79bc0 100755
--- a/src/lib/libssl/src/crypto/bn/asm/s390x.S
+++ b/src/lib/libssl/src/crypto/bn/asm/s390x.S
@@ -1,4 +1,4 @@
1.ident "s390x.S, version 1.0" 1.ident "s390x.S, version 1.1"
2// ==================================================================== 2// ====================================================================
3// Written by Andy Polyakov <appro@fy.chalmers.se> for the OpenSSL 3// Written by Andy Polyakov <appro@fy.chalmers.se> for the OpenSSL
4// project. 4// project.
@@ -24,67 +24,67 @@ bn_mul_add_words:
24 bler %r14 // if (len<=0) return 0; 24 bler %r14 // if (len<=0) return 0;
25 25
26 stmg %r6,%r10,48(%r15) 26 stmg %r6,%r10,48(%r15)
27 lghi %r10,3
27 lghi %r8,0 // carry = 0 28 lghi %r8,0 // carry = 0
28 srag %r10,%r4,2 // cnt=len/4 29 nr %r10,%r4 // len%4
29 jz .Loop1_madd 30 sra %r4,2 // cnt=len/4
31 jz .Loop1_madd // carry is incidentally cleared if branch taken
32 algr zero,zero // clear carry
30 33
31.Loop4_madd: 34.Loop4_madd:
32 lg %r7,0(%r2,%r3) // ap[i] 35 lg %r7,0(%r2,%r3) // ap[i]
33 mlgr %r6,%r5 // *=w 36 mlgr %r6,%r5 // *=w
34 algr %r7,%r8 // +=carry 37 alcgr %r7,%r8 // +=carry
35 alcgr %r6,zero 38 alcgr %r6,zero
36 alg %r7,0(%r2,%r1) // +=rp[i] 39 alg %r7,0(%r2,%r1) // +=rp[i]
37 alcgr %r6,zero
38 stg %r7,0(%r2,%r1) // rp[i]= 40 stg %r7,0(%r2,%r1) // rp[i]=
39 41
40 lg %r9,8(%r2,%r3) 42 lg %r9,8(%r2,%r3)
41 mlgr %r8,%r5 43 mlgr %r8,%r5
42 algr %r9,%r6 44 alcgr %r9,%r6
43 alcgr %r8,zero 45 alcgr %r8,zero
44 alg %r9,8(%r2,%r1) 46 alg %r9,8(%r2,%r1)
45 alcgr %r8,zero
46 stg %r9,8(%r2,%r1) 47 stg %r9,8(%r2,%r1)
47 48
48 lg %r7,16(%r2,%r3) 49 lg %r7,16(%r2,%r3)
49 mlgr %r6,%r5 50 mlgr %r6,%r5
50 algr %r7,%r8 51 alcgr %r7,%r8
51 alcgr %r6,zero 52 alcgr %r6,zero
52 alg %r7,16(%r2,%r1) 53 alg %r7,16(%r2,%r1)
53 alcgr %r6,zero
54 stg %r7,16(%r2,%r1) 54 stg %r7,16(%r2,%r1)
55 55
56 lg %r9,24(%r2,%r3) 56 lg %r9,24(%r2,%r3)
57 mlgr %r8,%r5 57 mlgr %r8,%r5
58 algr %r9,%r6 58 alcgr %r9,%r6
59 alcgr %r8,zero 59 alcgr %r8,zero
60 alg %r9,24(%r2,%r1) 60 alg %r9,24(%r2,%r1)
61 alcgr %r8,zero
62 stg %r9,24(%r2,%r1) 61 stg %r9,24(%r2,%r1)
63 62
64 la %r2,32(%r2) // i+=4 63 la %r2,32(%r2) // i+=4
65 brct %r10,.Loop4_madd 64 brct %r4,.Loop4_madd
66 65
67 lghi %r10,3 66 la %r10,1(%r10) // see if len%4 is zero ...
68 nr %r4,%r10 // cnt=len%4 67 brct %r10,.Loop1_madd // without touching condition code:-)
69 jz .Lend_madd 68
69.Lend_madd:
70 alcgr %r8,zero // collect carry bit
71 lgr %r2,%r8
72 lmg %r6,%r10,48(%r15)
73 br %r14
70 74
71.Loop1_madd: 75.Loop1_madd:
72 lg %r7,0(%r2,%r3) // ap[i] 76 lg %r7,0(%r2,%r3) // ap[i]
73 mlgr %r6,%r5 // *=w 77 mlgr %r6,%r5 // *=w
74 algr %r7,%r8 // +=carry 78 alcgr %r7,%r8 // +=carry
75 alcgr %r6,zero 79 alcgr %r6,zero
76 alg %r7,0(%r2,%r1) // +=rp[i] 80 alg %r7,0(%r2,%r1) // +=rp[i]
77 alcgr %r6,zero
78 stg %r7,0(%r2,%r1) // rp[i]= 81 stg %r7,0(%r2,%r1) // rp[i]=
79 82
80 lgr %r8,%r6 83 lgr %r8,%r6
81 la %r2,8(%r2) // i++ 84 la %r2,8(%r2) // i++
82 brct %r4,.Loop1_madd 85 brct %r10,.Loop1_madd
83 86
84.Lend_madd: 87 j .Lend_madd
85 lgr %r2,%r8
86 lmg %r6,%r10,48(%r15)
87 br %r14
88.size bn_mul_add_words,.-bn_mul_add_words 88.size bn_mul_add_words,.-bn_mul_add_words
89 89
90// BN_ULONG bn_mul_words(BN_ULONG *r2,BN_ULONG *r3,int r4,BN_ULONG r5); 90// BN_ULONG bn_mul_words(BN_ULONG *r2,BN_ULONG *r3,int r4,BN_ULONG r5);
@@ -99,57 +99,57 @@ bn_mul_words:
99 bler %r14 // if (len<=0) return 0; 99 bler %r14 // if (len<=0) return 0;
100 100
101 stmg %r6,%r10,48(%r15) 101 stmg %r6,%r10,48(%r15)
102 lghi %r10,3
102 lghi %r8,0 // carry = 0 103 lghi %r8,0 // carry = 0
103 srag %r10,%r4,2 // cnt=len/4 104 nr %r10,%r4 // len%4
104 jz .Loop1_mul 105 sra %r4,2 // cnt=len/4
106 jz .Loop1_mul // carry is incidentally cleared if branch taken
107 algr zero,zero // clear carry
105 108
106.Loop4_mul: 109.Loop4_mul:
107 lg %r7,0(%r2,%r3) // ap[i] 110 lg %r7,0(%r2,%r3) // ap[i]
108 mlgr %r6,%r5 // *=w 111 mlgr %r6,%r5 // *=w
109 algr %r7,%r8 // +=carry 112 alcgr %r7,%r8 // +=carry
110 alcgr %r6,zero
111 stg %r7,0(%r2,%r1) // rp[i]= 113 stg %r7,0(%r2,%r1) // rp[i]=
112 114
113 lg %r9,8(%r2,%r3) 115 lg %r9,8(%r2,%r3)
114 mlgr %r8,%r5 116 mlgr %r8,%r5
115 algr %r9,%r6 117 alcgr %r9,%r6
116 alcgr %r8,zero
117 stg %r9,8(%r2,%r1) 118 stg %r9,8(%r2,%r1)
118 119
119 lg %r7,16(%r2,%r3) 120 lg %r7,16(%r2,%r3)
120 mlgr %r6,%r5 121 mlgr %r6,%r5
121 algr %r7,%r8 122 alcgr %r7,%r8
122 alcgr %r6,zero
123 stg %r7,16(%r2,%r1) 123 stg %r7,16(%r2,%r1)
124 124
125 lg %r9,24(%r2,%r3) 125 lg %r9,24(%r2,%r3)
126 mlgr %r8,%r5 126 mlgr %r8,%r5
127 algr %r9,%r6 127 alcgr %r9,%r6
128 alcgr %r8,zero
129 stg %r9,24(%r2,%r1) 128 stg %r9,24(%r2,%r1)
130 129
131 la %r2,32(%r2) // i+=4 130 la %r2,32(%r2) // i+=4
132 brct %r10,.Loop4_mul 131 brct %r4,.Loop4_mul
133 132
134 lghi %r10,3 133 la %r10,1(%r10) // see if len%4 is zero ...
135 nr %r4,%r10 // cnt=len%4 134 brct %r10,.Loop1_mul // without touching condition code:-)
136 jz .Lend_mul 135
136.Lend_mul:
137 alcgr %r8,zero // collect carry bit
138 lgr %r2,%r8
139 lmg %r6,%r10,48(%r15)
140 br %r14
137 141
138.Loop1_mul: 142.Loop1_mul:
139 lg %r7,0(%r2,%r3) // ap[i] 143 lg %r7,0(%r2,%r3) // ap[i]
140 mlgr %r6,%r5 // *=w 144 mlgr %r6,%r5 // *=w
141 algr %r7,%r8 // +=carry 145 alcgr %r7,%r8 // +=carry
142 alcgr %r6,zero
143 stg %r7,0(%r2,%r1) // rp[i]= 146 stg %r7,0(%r2,%r1) // rp[i]=
144 147
145 lgr %r8,%r6 148 lgr %r8,%r6
146 la %r2,8(%r2) // i++ 149 la %r2,8(%r2) // i++
147 brct %r4,.Loop1_mul 150 brct %r10,.Loop1_mul
148 151
149.Lend_mul: 152 j .Lend_mul
150 lgr %r2,%r8
151 lmg %r6,%r10,48(%r15)
152 br %r14
153.size bn_mul_words,.-bn_mul_words 153.size bn_mul_words,.-bn_mul_words
154 154
155// void bn_sqr_words(BN_ULONG *r2,BN_ULONG *r2,int r4) 155// void bn_sqr_words(BN_ULONG *r2,BN_ULONG *r2,int r4)
diff --git a/src/lib/libssl/src/crypto/bn/bn_gf2m.c b/src/lib/libssl/src/crypto/bn/bn_gf2m.c
index 527b0fa15b..432a3aa338 100644
--- a/src/lib/libssl/src/crypto/bn/bn_gf2m.c
+++ b/src/lib/libssl/src/crypto/bn/bn_gf2m.c
@@ -545,6 +545,7 @@ int BN_GF2m_mod_inv(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx)
545 { 545 {
546 while (!BN_is_odd(u)) 546 while (!BN_is_odd(u))
547 { 547 {
548 if (BN_is_zero(u)) goto err;
548 if (!BN_rshift1(u, u)) goto err; 549 if (!BN_rshift1(u, u)) goto err;
549 if (BN_is_odd(b)) 550 if (BN_is_odd(b))
550 { 551 {
diff --git a/src/lib/libssl/src/crypto/bn/bn_nist.c b/src/lib/libssl/src/crypto/bn/bn_nist.c
index 2ca5b01391..c6de032696 100644
--- a/src/lib/libssl/src/crypto/bn/bn_nist.c
+++ b/src/lib/libssl/src/crypto/bn/bn_nist.c
@@ -354,7 +354,7 @@ int BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
354 buf[BN_NIST_192_TOP], 354 buf[BN_NIST_192_TOP],
355 c_d[BN_NIST_192_TOP], 355 c_d[BN_NIST_192_TOP],
356 *res; 356 *res;
357 size_t mask; 357 PTR_SIZE_INT mask;
358 static const BIGNUM _bignum_nist_p_192_sqr = { 358 static const BIGNUM _bignum_nist_p_192_sqr = {
359 (BN_ULONG *)_nist_p_192_sqr, 359 (BN_ULONG *)_nist_p_192_sqr,
360 sizeof(_nist_p_192_sqr)/sizeof(_nist_p_192_sqr[0]), 360 sizeof(_nist_p_192_sqr)/sizeof(_nist_p_192_sqr[0]),
@@ -405,9 +405,10 @@ int BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
405 * 'tmp=result-modulus; if (!carry || !borrow) result=tmp;' 405 * 'tmp=result-modulus; if (!carry || !borrow) result=tmp;'
406 * this is what happens below, but without explicit if:-) a. 406 * this is what happens below, but without explicit if:-) a.
407 */ 407 */
408 mask = 0-(size_t)bn_sub_words(c_d,r_d,_nist_p_192[0],BN_NIST_192_TOP); 408 mask = 0-(PTR_SIZE_INT)bn_sub_words(c_d,r_d,_nist_p_192[0],BN_NIST_192_TOP);
409 mask &= 0-(size_t)carry; 409 mask &= 0-(PTR_SIZE_INT)carry;
410 res = (BN_ULONG *)(((size_t)c_d&~mask) | ((size_t)r_d&mask)); 410 res = (BN_ULONG *)
411 (((PTR_SIZE_INT)c_d&~mask) | ((PTR_SIZE_INT)r_d&mask));
411 nist_cp_bn(r_d, res, BN_NIST_192_TOP); 412 nist_cp_bn(r_d, res, BN_NIST_192_TOP);
412 r->top = BN_NIST_192_TOP; 413 r->top = BN_NIST_192_TOP;
413 bn_correct_top(r); 414 bn_correct_top(r);
@@ -438,8 +439,8 @@ int BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
438 buf[BN_NIST_224_TOP], 439 buf[BN_NIST_224_TOP],
439 c_d[BN_NIST_224_TOP], 440 c_d[BN_NIST_224_TOP],
440 *res; 441 *res;
441 size_t mask; 442 PTR_SIZE_INT mask;
442 union { bn_addsub_f f; size_t p; } u; 443 union { bn_addsub_f f; PTR_SIZE_INT p; } u;
443 static const BIGNUM _bignum_nist_p_224_sqr = { 444 static const BIGNUM _bignum_nist_p_224_sqr = {
444 (BN_ULONG *)_nist_p_224_sqr, 445 (BN_ULONG *)_nist_p_224_sqr,
445 sizeof(_nist_p_224_sqr)/sizeof(_nist_p_224_sqr[0]), 446 sizeof(_nist_p_224_sqr)/sizeof(_nist_p_224_sqr[0]),
@@ -510,16 +511,18 @@ int BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
510 * to be compared to the modulus and conditionally 511 * to be compared to the modulus and conditionally
511 * adjusted by *subtracting* the latter. */ 512 * adjusted by *subtracting* the latter. */
512 carry = (int)bn_add_words(r_d,r_d,_nist_p_224[-carry-1],BN_NIST_224_TOP); 513 carry = (int)bn_add_words(r_d,r_d,_nist_p_224[-carry-1],BN_NIST_224_TOP);
513 mask = 0-(size_t)carry; 514 mask = 0-(PTR_SIZE_INT)carry;
514 u.p = ((size_t)bn_sub_words&mask) | ((size_t)bn_add_words&~mask); 515 u.p = ((PTR_SIZE_INT)bn_sub_words&mask) |
516 ((PTR_SIZE_INT)bn_add_words&~mask);
515 } 517 }
516 else 518 else
517 carry = 1; 519 carry = 1;
518 520
519 /* otherwise it's effectively same as in BN_nist_mod_192... */ 521 /* otherwise it's effectively same as in BN_nist_mod_192... */
520 mask = 0-(size_t)(*u.f)(c_d,r_d,_nist_p_224[0],BN_NIST_224_TOP); 522 mask = 0-(PTR_SIZE_INT)(*u.f)(c_d,r_d,_nist_p_224[0],BN_NIST_224_TOP);
521 mask &= 0-(size_t)carry; 523 mask &= 0-(PTR_SIZE_INT)carry;
522 res = (BN_ULONG *)(((size_t)c_d&~mask) | ((size_t)r_d&mask)); 524 res = (BN_ULONG *)(((PTR_SIZE_INT)c_d&~mask) |
525 ((PTR_SIZE_INT)r_d&mask));
523 nist_cp_bn(r_d, res, BN_NIST_224_TOP); 526 nist_cp_bn(r_d, res, BN_NIST_224_TOP);
524 r->top = BN_NIST_224_TOP; 527 r->top = BN_NIST_224_TOP;
525 bn_correct_top(r); 528 bn_correct_top(r);
@@ -549,8 +552,8 @@ int BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
549 buf[BN_NIST_256_TOP], 552 buf[BN_NIST_256_TOP],
550 c_d[BN_NIST_256_TOP], 553 c_d[BN_NIST_256_TOP],
551 *res; 554 *res;
552 size_t mask; 555 PTR_SIZE_INT mask;
553 union { bn_addsub_f f; size_t p; } u; 556 union { bn_addsub_f f; PTR_SIZE_INT p; } u;
554 static const BIGNUM _bignum_nist_p_256_sqr = { 557 static const BIGNUM _bignum_nist_p_256_sqr = {
555 (BN_ULONG *)_nist_p_256_sqr, 558 (BN_ULONG *)_nist_p_256_sqr,
556 sizeof(_nist_p_256_sqr)/sizeof(_nist_p_256_sqr[0]), 559 sizeof(_nist_p_256_sqr)/sizeof(_nist_p_256_sqr[0]),
@@ -629,15 +632,17 @@ int BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
629 else if (carry < 0) 632 else if (carry < 0)
630 { 633 {
631 carry = (int)bn_add_words(r_d,r_d,_nist_p_256[-carry-1],BN_NIST_256_TOP); 634 carry = (int)bn_add_words(r_d,r_d,_nist_p_256[-carry-1],BN_NIST_256_TOP);
632 mask = 0-(size_t)carry; 635 mask = 0-(PTR_SIZE_INT)carry;
633 u.p = ((size_t)bn_sub_words&mask) | ((size_t)bn_add_words&~mask); 636 u.p = ((PTR_SIZE_INT)bn_sub_words&mask) |
637 ((PTR_SIZE_INT)bn_add_words&~mask);
634 } 638 }
635 else 639 else
636 carry = 1; 640 carry = 1;
637 641
638 mask = 0-(size_t)(*u.f)(c_d,r_d,_nist_p_256[0],BN_NIST_256_TOP); 642 mask = 0-(PTR_SIZE_INT)(*u.f)(c_d,r_d,_nist_p_256[0],BN_NIST_256_TOP);
639 mask &= 0-(size_t)carry; 643 mask &= 0-(PTR_SIZE_INT)carry;
640 res = (BN_ULONG *)(((size_t)c_d&~mask) | ((size_t)r_d&mask)); 644 res = (BN_ULONG *)(((PTR_SIZE_INT)c_d&~mask) |
645 ((PTR_SIZE_INT)r_d&mask));
641 nist_cp_bn(r_d, res, BN_NIST_256_TOP); 646 nist_cp_bn(r_d, res, BN_NIST_256_TOP);
642 r->top = BN_NIST_256_TOP; 647 r->top = BN_NIST_256_TOP;
643 bn_correct_top(r); 648 bn_correct_top(r);
@@ -671,8 +676,8 @@ int BN_nist_mod_384(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
671 buf[BN_NIST_384_TOP], 676 buf[BN_NIST_384_TOP],
672 c_d[BN_NIST_384_TOP], 677 c_d[BN_NIST_384_TOP],
673 *res; 678 *res;
674 size_t mask; 679 PTR_SIZE_INT mask;
675 union { bn_addsub_f f; size_t p; } u; 680 union { bn_addsub_f f; PTR_SIZE_INT p; } u;
676 static const BIGNUM _bignum_nist_p_384_sqr = { 681 static const BIGNUM _bignum_nist_p_384_sqr = {
677 (BN_ULONG *)_nist_p_384_sqr, 682 (BN_ULONG *)_nist_p_384_sqr,
678 sizeof(_nist_p_384_sqr)/sizeof(_nist_p_384_sqr[0]), 683 sizeof(_nist_p_384_sqr)/sizeof(_nist_p_384_sqr[0]),
@@ -754,15 +759,17 @@ int BN_nist_mod_384(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
754 else if (carry < 0) 759 else if (carry < 0)
755 { 760 {
756 carry = (int)bn_add_words(r_d,r_d,_nist_p_384[-carry-1],BN_NIST_384_TOP); 761 carry = (int)bn_add_words(r_d,r_d,_nist_p_384[-carry-1],BN_NIST_384_TOP);
757 mask = 0-(size_t)carry; 762 mask = 0-(PTR_SIZE_INT)carry;
758 u.p = ((size_t)bn_sub_words&mask) | ((size_t)bn_add_words&~mask); 763 u.p = ((PTR_SIZE_INT)bn_sub_words&mask) |
764 ((PTR_SIZE_INT)bn_add_words&~mask);
759 } 765 }
760 else 766 else
761 carry = 1; 767 carry = 1;
762 768
763 mask = 0-(size_t)(*u.f)(c_d,r_d,_nist_p_384[0],BN_NIST_384_TOP); 769 mask = 0-(PTR_SIZE_INT)(*u.f)(c_d,r_d,_nist_p_384[0],BN_NIST_384_TOP);
764 mask &= 0-(size_t)carry; 770 mask &= 0-(PTR_SIZE_INT)carry;
765 res = (BN_ULONG *)(((size_t)c_d&~mask) | ((size_t)r_d&mask)); 771 res = (BN_ULONG *)(((PTR_SIZE_INT)c_d&~mask) |
772 ((PTR_SIZE_INT)r_d&mask));
766 nist_cp_bn(r_d, res, BN_NIST_384_TOP); 773 nist_cp_bn(r_d, res, BN_NIST_384_TOP);
767 r->top = BN_NIST_384_TOP; 774 r->top = BN_NIST_384_TOP;
768 bn_correct_top(r); 775 bn_correct_top(r);
@@ -781,7 +788,7 @@ int BN_nist_mod_521(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
781 BN_ULONG *r_d, *a_d = a->d, 788 BN_ULONG *r_d, *a_d = a->d,
782 t_d[BN_NIST_521_TOP], 789 t_d[BN_NIST_521_TOP],
783 val,tmp,*res; 790 val,tmp,*res;
784 size_t mask; 791 PTR_SIZE_INT mask;
785 static const BIGNUM _bignum_nist_p_521_sqr = { 792 static const BIGNUM _bignum_nist_p_521_sqr = {
786 (BN_ULONG *)_nist_p_521_sqr, 793 (BN_ULONG *)_nist_p_521_sqr,
787 sizeof(_nist_p_521_sqr)/sizeof(_nist_p_521_sqr[0]), 794 sizeof(_nist_p_521_sqr)/sizeof(_nist_p_521_sqr[0]),
@@ -826,8 +833,9 @@ int BN_nist_mod_521(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
826 r_d[i] &= BN_NIST_521_TOP_MASK; 833 r_d[i] &= BN_NIST_521_TOP_MASK;
827 834
828 bn_add_words(r_d,r_d,t_d,BN_NIST_521_TOP); 835 bn_add_words(r_d,r_d,t_d,BN_NIST_521_TOP);
829 mask = 0-(size_t)bn_sub_words(t_d,r_d,_nist_p_521,BN_NIST_521_TOP); 836 mask = 0-(PTR_SIZE_INT)bn_sub_words(t_d,r_d,_nist_p_521,BN_NIST_521_TOP);
830 res = (BN_ULONG *)(((size_t)t_d&~mask) | ((size_t)r_d&mask)); 837 res = (BN_ULONG *)(((PTR_SIZE_INT)t_d&~mask) |
838 ((PTR_SIZE_INT)r_d&mask));
831 nist_cp_bn(r_d,res,BN_NIST_521_TOP); 839 nist_cp_bn(r_d,res,BN_NIST_521_TOP);
832 r->top = BN_NIST_521_TOP; 840 r->top = BN_NIST_521_TOP;
833 bn_correct_top(r); 841 bn_correct_top(r);
diff --git a/src/lib/libssl/src/crypto/dsa/dsa_pmeth.c b/src/lib/libssl/src/crypto/dsa/dsa_pmeth.c
index 4ce91e20c6..e2df54fec6 100644
--- a/src/lib/libssl/src/crypto/dsa/dsa_pmeth.c
+++ b/src/lib/libssl/src/crypto/dsa/dsa_pmeth.c
@@ -187,6 +187,7 @@ static int pkey_dsa_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2)
187 case EVP_PKEY_CTRL_MD: 187 case EVP_PKEY_CTRL_MD:
188 if (EVP_MD_type((const EVP_MD *)p2) != NID_sha1 && 188 if (EVP_MD_type((const EVP_MD *)p2) != NID_sha1 &&
189 EVP_MD_type((const EVP_MD *)p2) != NID_dsa && 189 EVP_MD_type((const EVP_MD *)p2) != NID_dsa &&
190 EVP_MD_type((const EVP_MD *)p2) != NID_dsaWithSHA &&
190 EVP_MD_type((const EVP_MD *)p2) != NID_sha224 && 191 EVP_MD_type((const EVP_MD *)p2) != NID_sha224 &&
191 EVP_MD_type((const EVP_MD *)p2) != NID_sha256) 192 EVP_MD_type((const EVP_MD *)p2) != NID_sha256)
192 { 193 {
diff --git a/src/lib/libssl/src/crypto/ec/ec2_mult.c b/src/lib/libssl/src/crypto/ec/ec2_mult.c
index ab631a50a2..e12b9b284a 100644
--- a/src/lib/libssl/src/crypto/ec/ec2_mult.c
+++ b/src/lib/libssl/src/crypto/ec/ec2_mult.c
@@ -319,6 +319,7 @@ int ec_GF2m_simple_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar,
319 int ret = 0; 319 int ret = 0;
320 size_t i; 320 size_t i;
321 EC_POINT *p=NULL; 321 EC_POINT *p=NULL;
322 EC_POINT *acc = NULL;
322 323
323 if (ctx == NULL) 324 if (ctx == NULL)
324 { 325 {
@@ -338,15 +339,16 @@ int ec_GF2m_simple_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar,
338 } 339 }
339 340
340 if ((p = EC_POINT_new(group)) == NULL) goto err; 341 if ((p = EC_POINT_new(group)) == NULL) goto err;
342 if ((acc = EC_POINT_new(group)) == NULL) goto err;
341 343
342 if (!EC_POINT_set_to_infinity(group, r)) goto err; 344 if (!EC_POINT_set_to_infinity(group, acc)) goto err;
343 345
344 if (scalar) 346 if (scalar)
345 { 347 {
346 if (!ec_GF2m_montgomery_point_multiply(group, p, scalar, group->generator, ctx)) goto err; 348 if (!ec_GF2m_montgomery_point_multiply(group, p, scalar, group->generator, ctx)) goto err;
347 if (BN_is_negative(scalar)) 349 if (BN_is_negative(scalar))
348 if (!group->meth->invert(group, p, ctx)) goto err; 350 if (!group->meth->invert(group, p, ctx)) goto err;
349 if (!group->meth->add(group, r, r, p, ctx)) goto err; 351 if (!group->meth->add(group, acc, acc, p, ctx)) goto err;
350 } 352 }
351 353
352 for (i = 0; i < num; i++) 354 for (i = 0; i < num; i++)
@@ -354,13 +356,16 @@ int ec_GF2m_simple_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar,
354 if (!ec_GF2m_montgomery_point_multiply(group, p, scalars[i], points[i], ctx)) goto err; 356 if (!ec_GF2m_montgomery_point_multiply(group, p, scalars[i], points[i], ctx)) goto err;
355 if (BN_is_negative(scalars[i])) 357 if (BN_is_negative(scalars[i]))
356 if (!group->meth->invert(group, p, ctx)) goto err; 358 if (!group->meth->invert(group, p, ctx)) goto err;
357 if (!group->meth->add(group, r, r, p, ctx)) goto err; 359 if (!group->meth->add(group, acc, acc, p, ctx)) goto err;
358 } 360 }
359 361
362 if (!EC_POINT_copy(r, acc)) goto err;
363
360 ret = 1; 364 ret = 1;
361 365
362 err: 366 err:
363 if (p) EC_POINT_free(p); 367 if (p) EC_POINT_free(p);
368 if (acc) EC_POINT_free(acc);
364 if (new_ctx != NULL) 369 if (new_ctx != NULL)
365 BN_CTX_free(new_ctx); 370 BN_CTX_free(new_ctx);
366 return ret; 371 return ret;
diff --git a/src/lib/libssl/src/crypto/ec/ec2_smpl.c b/src/lib/libssl/src/crypto/ec/ec2_smpl.c
index cf357b462a..af94458ca7 100644
--- a/src/lib/libssl/src/crypto/ec/ec2_smpl.c
+++ b/src/lib/libssl/src/crypto/ec/ec2_smpl.c
@@ -937,6 +937,9 @@ int ec_GF2m_simple_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT
937 { 937 {
938 return EC_POINT_is_at_infinity(group, b) ? 0 : 1; 938 return EC_POINT_is_at_infinity(group, b) ? 0 : 1;
939 } 939 }
940
941 if (EC_POINT_is_at_infinity(group, b))
942 return 1;
940 943
941 if (a->Z_is_one && b->Z_is_one) 944 if (a->Z_is_one && b->Z_is_one)
942 { 945 {
diff --git a/src/lib/libssl/src/crypto/ec/ec_key.c b/src/lib/libssl/src/crypto/ec/ec_key.c
index 12fb0e6d6d..522802c07a 100644
--- a/src/lib/libssl/src/crypto/ec/ec_key.c
+++ b/src/lib/libssl/src/crypto/ec/ec_key.c
@@ -304,7 +304,13 @@ int EC_KEY_check_key(const EC_KEY *eckey)
304 ECerr(EC_F_EC_KEY_CHECK_KEY, ERR_R_PASSED_NULL_PARAMETER); 304 ECerr(EC_F_EC_KEY_CHECK_KEY, ERR_R_PASSED_NULL_PARAMETER);
305 return 0; 305 return 0;
306 } 306 }
307 307
308 if (EC_POINT_is_at_infinity(eckey->group, eckey->pub_key))
309 {
310 ECerr(EC_F_EC_KEY_CHECK_KEY, EC_R_POINT_AT_INFINITY);
311 goto err;
312 }
313
308 if ((ctx = BN_CTX_new()) == NULL) 314 if ((ctx = BN_CTX_new()) == NULL)
309 goto err; 315 goto err;
310 if ((point = EC_POINT_new(eckey->group)) == NULL) 316 if ((point = EC_POINT_new(eckey->group)) == NULL)
diff --git a/src/lib/libssl/src/crypto/ecdh/ech_lib.c b/src/lib/libssl/src/crypto/ecdh/ech_lib.c
index e89b1d4772..4d8ea03d3d 100644
--- a/src/lib/libssl/src/crypto/ecdh/ech_lib.c
+++ b/src/lib/libssl/src/crypto/ecdh/ech_lib.c
@@ -96,7 +96,6 @@ const ECDH_METHOD *ECDH_get_default_method(void)
96 96
97int ECDH_set_method(EC_KEY *eckey, const ECDH_METHOD *meth) 97int ECDH_set_method(EC_KEY *eckey, const ECDH_METHOD *meth)
98 { 98 {
99 const ECDH_METHOD *mtmp;
100 ECDH_DATA *ecdh; 99 ECDH_DATA *ecdh;
101 100
102 ecdh = ecdh_check(eckey); 101 ecdh = ecdh_check(eckey);
@@ -104,8 +103,8 @@ int ECDH_set_method(EC_KEY *eckey, const ECDH_METHOD *meth)
104 if (ecdh == NULL) 103 if (ecdh == NULL)
105 return 0; 104 return 0;
106 105
107 mtmp = ecdh->meth;
108#if 0 106#if 0
107 mtmp = ecdh->meth;
109 if (mtmp->finish) 108 if (mtmp->finish)
110 mtmp->finish(eckey); 109 mtmp->finish(eckey);
111#endif 110#endif
diff --git a/src/lib/libssl/src/crypto/ecdsa/ecdsatest.c b/src/lib/libssl/src/crypto/ecdsa/ecdsatest.c
index aa4e1481a8..26a4a9ee7c 100644
--- a/src/lib/libssl/src/crypto/ecdsa/ecdsatest.c
+++ b/src/lib/libssl/src/crypto/ecdsa/ecdsatest.c
@@ -168,10 +168,9 @@ int fbytes(unsigned char *buf, int num)
168 return 0; 168 return 0;
169 } 169 }
170 fbytes_counter ++; 170 fbytes_counter ++;
171 ret = BN_bn2bin(tmp, buf); 171 if (num != BN_num_bytes(tmp) || !BN_bn2bin(tmp, buf))
172 if (ret == 0 || ret != num)
173 ret = 0; 172 ret = 0;
174 else 173 else
175 ret = 1; 174 ret = 1;
176 if (tmp) 175 if (tmp)
177 BN_free(tmp); 176 BN_free(tmp);
diff --git a/src/lib/libssl/src/crypto/ecdsa/ecs_lib.c b/src/lib/libssl/src/crypto/ecdsa/ecs_lib.c
index 85e8a3a7ed..2ebae3aa27 100644
--- a/src/lib/libssl/src/crypto/ecdsa/ecs_lib.c
+++ b/src/lib/libssl/src/crypto/ecdsa/ecs_lib.c
@@ -83,7 +83,6 @@ const ECDSA_METHOD *ECDSA_get_default_method(void)
83 83
84int ECDSA_set_method(EC_KEY *eckey, const ECDSA_METHOD *meth) 84int ECDSA_set_method(EC_KEY *eckey, const ECDSA_METHOD *meth)
85{ 85{
86 const ECDSA_METHOD *mtmp;
87 ECDSA_DATA *ecdsa; 86 ECDSA_DATA *ecdsa;
88 87
89 ecdsa = ecdsa_check(eckey); 88 ecdsa = ecdsa_check(eckey);
@@ -91,7 +90,6 @@ int ECDSA_set_method(EC_KEY *eckey, const ECDSA_METHOD *meth)
91 if (ecdsa == NULL) 90 if (ecdsa == NULL)
92 return 0; 91 return 0;
93 92
94 mtmp = ecdsa->meth;
95#ifndef OPENSSL_NO_ENGINE 93#ifndef OPENSSL_NO_ENGINE
96 if (ecdsa->engine) 94 if (ecdsa->engine)
97 { 95 {
diff --git a/src/lib/libssl/src/crypto/ecdsa/ecs_ossl.c b/src/lib/libssl/src/crypto/ecdsa/ecs_ossl.c
index 551cf5068f..1bbf328de5 100644
--- a/src/lib/libssl/src/crypto/ecdsa/ecs_ossl.c
+++ b/src/lib/libssl/src/crypto/ecdsa/ecs_ossl.c
@@ -144,6 +144,14 @@ static int ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp,
144 } 144 }
145 while (BN_is_zero(k)); 145 while (BN_is_zero(k));
146 146
147 /* We do not want timing information to leak the length of k,
148 * so we compute G*k using an equivalent scalar of fixed
149 * bit-length. */
150
151 if (!BN_add(k, k, order)) goto err;
152 if (BN_num_bits(k) <= BN_num_bits(order))
153 if (!BN_add(k, k, order)) goto err;
154
147 /* compute r the x-coordinate of generator * k */ 155 /* compute r the x-coordinate of generator * k */
148 if (!EC_POINT_mul(group, tmp_point, k, NULL, NULL, ctx)) 156 if (!EC_POINT_mul(group, tmp_point, k, NULL, NULL, ctx))
149 { 157 {
diff --git a/src/lib/libssl/src/crypto/evp/m_sigver.c b/src/lib/libssl/src/crypto/evp/m_sigver.c
index f0b7f95059..7e2731f4a4 100644
--- a/src/lib/libssl/src/crypto/evp/m_sigver.c
+++ b/src/lib/libssl/src/crypto/evp/m_sigver.c
@@ -137,7 +137,7 @@ int EVP_DigestSignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, size_t *siglen)
137 sctx = 0; 137 sctx = 0;
138 if (sigret) 138 if (sigret)
139 { 139 {
140 MS_STATIC EVP_MD_CTX tmp_ctx; 140 EVP_MD_CTX tmp_ctx;
141 unsigned char md[EVP_MAX_MD_SIZE]; 141 unsigned char md[EVP_MAX_MD_SIZE];
142 unsigned int mdlen; 142 unsigned int mdlen;
143 EVP_MD_CTX_init(&tmp_ctx); 143 EVP_MD_CTX_init(&tmp_ctx);
@@ -173,7 +173,7 @@ int EVP_DigestSignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, size_t *siglen)
173 173
174int EVP_DigestVerifyFinal(EVP_MD_CTX *ctx, unsigned char *sig, size_t siglen) 174int EVP_DigestVerifyFinal(EVP_MD_CTX *ctx, unsigned char *sig, size_t siglen)
175 { 175 {
176 MS_STATIC EVP_MD_CTX tmp_ctx; 176 EVP_MD_CTX tmp_ctx;
177 unsigned char md[EVP_MAX_MD_SIZE]; 177 unsigned char md[EVP_MAX_MD_SIZE];
178 int r; 178 int r;
179 unsigned int mdlen; 179 unsigned int mdlen;
diff --git a/src/lib/libssl/src/crypto/evp/pmeth_lib.c b/src/lib/libssl/src/crypto/evp/pmeth_lib.c
index b2d8de3a8d..5481d4b8a5 100644
--- a/src/lib/libssl/src/crypto/evp/pmeth_lib.c
+++ b/src/lib/libssl/src/crypto/evp/pmeth_lib.c
@@ -134,6 +134,8 @@ static EVP_PKEY_CTX *int_ctx_new(EVP_PKEY *pkey, ENGINE *e, int id)
134 id = pkey->ameth->pkey_id; 134 id = pkey->ameth->pkey_id;
135 } 135 }
136#ifndef OPENSSL_NO_ENGINE 136#ifndef OPENSSL_NO_ENGINE
137 if (pkey && pkey->engine)
138 e = pkey->engine;
137 /* Try to find an ENGINE which implements this method */ 139 /* Try to find an ENGINE which implements this method */
138 if (e) 140 if (e)
139 { 141 {
diff --git a/src/lib/libssl/src/crypto/hmac/hm_pmeth.c b/src/lib/libssl/src/crypto/hmac/hm_pmeth.c
index 985921ca1a..71e8567a14 100644
--- a/src/lib/libssl/src/crypto/hmac/hm_pmeth.c
+++ b/src/lib/libssl/src/crypto/hmac/hm_pmeth.c
@@ -147,6 +147,8 @@ static int int_update(EVP_MD_CTX *ctx,const void *data,size_t count)
147 147
148static int hmac_signctx_init(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx) 148static int hmac_signctx_init(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx)
149 { 149 {
150 HMAC_PKEY_CTX *hctx = ctx->data;
151 HMAC_CTX_set_flags(&hctx->ctx, mctx->flags & ~EVP_MD_CTX_FLAG_NO_INIT);
150 EVP_MD_CTX_set_flags(mctx, EVP_MD_CTX_FLAG_NO_INIT); 152 EVP_MD_CTX_set_flags(mctx, EVP_MD_CTX_FLAG_NO_INIT);
151 mctx->update = int_update; 153 mctx->update = int_update;
152 return 1; 154 return 1;
diff --git a/src/lib/libssl/src/crypto/jpake/jpake.c b/src/lib/libssl/src/crypto/jpake/jpake.c
index 086d9f47e0..8e4b633ccc 100644
--- a/src/lib/libssl/src/crypto/jpake/jpake.c
+++ b/src/lib/libssl/src/crypto/jpake/jpake.c
@@ -282,8 +282,37 @@ int JPAKE_STEP1_generate(JPAKE_STEP1 *send, JPAKE_CTX *ctx)
282 return 1; 282 return 1;
283 } 283 }
284 284
285/* g^x is a legal value */
286static int is_legal(const BIGNUM *gx, const JPAKE_CTX *ctx)
287 {
288 BIGNUM *t;
289 int res;
290
291 if(BN_is_negative(gx) || BN_is_zero(gx) || BN_cmp(gx, ctx->p.p) >= 0)
292 return 0;
293
294 t = BN_new();
295 BN_mod_exp(t, gx, ctx->p.q, ctx->p.p, ctx->ctx);
296 res = BN_is_one(t);
297 BN_free(t);
298
299 return res;
300 }
301
285int JPAKE_STEP1_process(JPAKE_CTX *ctx, const JPAKE_STEP1 *received) 302int JPAKE_STEP1_process(JPAKE_CTX *ctx, const JPAKE_STEP1 *received)
286 { 303 {
304 if(!is_legal(received->p1.gx, ctx))
305 {
306 JPAKEerr(JPAKE_F_JPAKE_STEP1_PROCESS, JPAKE_R_G_TO_THE_X3_IS_NOT_LEGAL);
307 return 0;
308 }
309
310 if(!is_legal(received->p2.gx, ctx))
311 {
312 JPAKEerr(JPAKE_F_JPAKE_STEP1_PROCESS, JPAKE_R_G_TO_THE_X4_IS_NOT_LEGAL);
313 return 0;
314 }
315
287 /* verify their ZKP(xc) */ 316 /* verify their ZKP(xc) */
288 if(!verify_zkp(&received->p1, ctx->p.g, ctx)) 317 if(!verify_zkp(&received->p1, ctx->p.g, ctx))
289 { 318 {
diff --git a/src/lib/libssl/src/crypto/jpake/jpake.h b/src/lib/libssl/src/crypto/jpake/jpake.h
index 693ea188cb..fd143b4d9b 100644
--- a/src/lib/libssl/src/crypto/jpake/jpake.h
+++ b/src/lib/libssl/src/crypto/jpake/jpake.h
@@ -115,6 +115,8 @@ void ERR_load_JPAKE_strings(void);
115#define JPAKE_F_VERIFY_ZKP 100 115#define JPAKE_F_VERIFY_ZKP 100
116 116
117/* Reason codes. */ 117/* Reason codes. */
118#define JPAKE_R_G_TO_THE_X3_IS_NOT_LEGAL 108
119#define JPAKE_R_G_TO_THE_X4_IS_NOT_LEGAL 109
118#define JPAKE_R_G_TO_THE_X4_IS_ONE 105 120#define JPAKE_R_G_TO_THE_X4_IS_ONE 105
119#define JPAKE_R_HASH_OF_HASH_OF_KEY_MISMATCH 106 121#define JPAKE_R_HASH_OF_HASH_OF_KEY_MISMATCH 106
120#define JPAKE_R_HASH_OF_KEY_MISMATCH 107 122#define JPAKE_R_HASH_OF_KEY_MISMATCH 107
diff --git a/src/lib/libssl/src/crypto/jpake/jpake_err.c b/src/lib/libssl/src/crypto/jpake/jpake_err.c
index 1b95067967..a9a9dee75c 100644
--- a/src/lib/libssl/src/crypto/jpake/jpake_err.c
+++ b/src/lib/libssl/src/crypto/jpake/jpake_err.c
@@ -1,6 +1,6 @@
1/* crypto/jpake/jpake_err.c */ 1/* crypto/jpake/jpake_err.c */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1999-2008 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1999-2010 The OpenSSL Project. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
@@ -80,6 +80,8 @@ static ERR_STRING_DATA JPAKE_str_functs[]=
80 80
81static ERR_STRING_DATA JPAKE_str_reasons[]= 81static ERR_STRING_DATA JPAKE_str_reasons[]=
82 { 82 {
83{ERR_REASON(JPAKE_R_G_TO_THE_X3_IS_NOT_LEGAL),"g to the x3 is not legal"},
84{ERR_REASON(JPAKE_R_G_TO_THE_X4_IS_NOT_LEGAL),"g to the x4 is not legal"},
83{ERR_REASON(JPAKE_R_G_TO_THE_X4_IS_ONE) ,"g to the x4 is one"}, 85{ERR_REASON(JPAKE_R_G_TO_THE_X4_IS_ONE) ,"g to the x4 is one"},
84{ERR_REASON(JPAKE_R_HASH_OF_HASH_OF_KEY_MISMATCH),"hash of hash of key mismatch"}, 86{ERR_REASON(JPAKE_R_HASH_OF_HASH_OF_KEY_MISMATCH),"hash of hash of key mismatch"},
85{ERR_REASON(JPAKE_R_HASH_OF_KEY_MISMATCH),"hash of key mismatch"}, 87{ERR_REASON(JPAKE_R_HASH_OF_KEY_MISMATCH),"hash of key mismatch"},
diff --git a/src/lib/libssl/src/crypto/pem/pvkfmt.c b/src/lib/libssl/src/crypto/pem/pvkfmt.c
index d998a67fa5..5f130c4528 100644
--- a/src/lib/libssl/src/crypto/pem/pvkfmt.c
+++ b/src/lib/libssl/src/crypto/pem/pvkfmt.c
@@ -662,7 +662,7 @@ static int do_PVK_header(const unsigned char **in, unsigned int length,
662 662
663 { 663 {
664 const unsigned char *p = *in; 664 const unsigned char *p = *in;
665 unsigned int pvk_magic, keytype, is_encrypted; 665 unsigned int pvk_magic, is_encrypted;
666 if (skip_magic) 666 if (skip_magic)
667 { 667 {
668 if (length < 20) 668 if (length < 20)
@@ -689,7 +689,7 @@ static int do_PVK_header(const unsigned char **in, unsigned int length,
689 } 689 }
690 /* Skip reserved */ 690 /* Skip reserved */
691 p += 4; 691 p += 4;
692 keytype = read_ledword(&p); 692 /*keytype = */read_ledword(&p);
693 is_encrypted = read_ledword(&p); 693 is_encrypted = read_ledword(&p);
694 *psaltlen = read_ledword(&p); 694 *psaltlen = read_ledword(&p);
695 *pkeylen = read_ledword(&p); 695 *pkeylen = read_ledword(&p);
@@ -839,7 +839,7 @@ EVP_PKEY *b2i_PVK_bio(BIO *in, pem_password_cb *cb, void *u)
839static int i2b_PVK(unsigned char **out, EVP_PKEY*pk, int enclevel, 839static int i2b_PVK(unsigned char **out, EVP_PKEY*pk, int enclevel,
840 pem_password_cb *cb, void *u) 840 pem_password_cb *cb, void *u)
841 { 841 {
842 int outlen = 24, noinc, pklen; 842 int outlen = 24, pklen;
843 unsigned char *p, *salt = NULL; 843 unsigned char *p, *salt = NULL;
844 if (enclevel) 844 if (enclevel)
845 outlen += PVK_SALTLEN; 845 outlen += PVK_SALTLEN;
@@ -850,10 +850,7 @@ static int i2b_PVK(unsigned char **out, EVP_PKEY*pk, int enclevel,
850 if (!out) 850 if (!out)
851 return outlen; 851 return outlen;
852 if (*out) 852 if (*out)
853 {
854 p = *out; 853 p = *out;
855 noinc = 0;
856 }
857 else 854 else
858 { 855 {
859 p = OPENSSL_malloc(outlen); 856 p = OPENSSL_malloc(outlen);
@@ -863,7 +860,6 @@ static int i2b_PVK(unsigned char **out, EVP_PKEY*pk, int enclevel,
863 return -1; 860 return -1;
864 } 861 }
865 *out = p; 862 *out = p;
866 noinc = 1;
867 } 863 }
868 864
869 write_ledword(&p, MS_PVKMAGIC); 865 write_ledword(&p, MS_PVKMAGIC);
diff --git a/src/lib/libssl/src/crypto/perlasm/x86_64-xlate.pl b/src/lib/libssl/src/crypto/perlasm/x86_64-xlate.pl
index 354673acc1..e47116b74b 100755
--- a/src/lib/libssl/src/crypto/perlasm/x86_64-xlate.pl
+++ b/src/lib/libssl/src/crypto/perlasm/x86_64-xlate.pl
@@ -167,7 +167,7 @@ my %globals;
167 } elsif ($self->{op} =~ /^(pop|push)f/) { 167 } elsif ($self->{op} =~ /^(pop|push)f/) {
168 $self->{op} .= $self->{sz}; 168 $self->{op} .= $self->{sz};
169 } elsif ($self->{op} eq "call" && $current_segment eq ".CRT\$XCU") { 169 } elsif ($self->{op} eq "call" && $current_segment eq ".CRT\$XCU") {
170 $self->{op} = "ALIGN\t8\n\tDQ"; 170 $self->{op} = "\tDQ";
171 } 171 }
172 $self->{op}; 172 $self->{op};
173 } 173 }
@@ -545,6 +545,8 @@ my %globals;
545 if ($line=~/\.([px])data/) { 545 if ($line=~/\.([px])data/) {
546 $v.=" rdata align="; 546 $v.=" rdata align=";
547 $v.=$1 eq "p"? 4 : 8; 547 $v.=$1 eq "p"? 4 : 8;
548 } elsif ($line=~/\.CRT\$/i) {
549 $v.=" rdata align=8";
548 } 550 }
549 } else { 551 } else {
550 $v="$current_segment\tENDS\n" if ($current_segment); 552 $v="$current_segment\tENDS\n" if ($current_segment);
@@ -552,6 +554,8 @@ my %globals;
552 if ($line=~/\.([px])data/) { 554 if ($line=~/\.([px])data/) {
553 $v.=" READONLY"; 555 $v.=" READONLY";
554 $v.=" ALIGN(".($1 eq "p" ? 4 : 8).")" if ($masm>=$masmref); 556 $v.=" ALIGN(".($1 eq "p" ? 4 : 8).")" if ($masm>=$masmref);
557 } elsif ($line=~/\.CRT\$/i) {
558 $v.=" READONLY DWORD";
555 } 559 }
556 } 560 }
557 $current_segment = $line; 561 $current_segment = $line;
diff --git a/src/lib/libssl/src/crypto/pqueue/pqueue.c b/src/lib/libssl/src/crypto/pqueue/pqueue.c
index 99a6fb874d..eab13a1250 100644
--- a/src/lib/libssl/src/crypto/pqueue/pqueue.c
+++ b/src/lib/libssl/src/crypto/pqueue/pqueue.c
@@ -167,14 +167,13 @@ pqueue_pop(pqueue_s *pq)
167pitem * 167pitem *
168pqueue_find(pqueue_s *pq, unsigned char *prio64be) 168pqueue_find(pqueue_s *pq, unsigned char *prio64be)
169 { 169 {
170 pitem *next, *prev = NULL; 170 pitem *next;
171 pitem *found = NULL; 171 pitem *found = NULL;
172 172
173 if ( pq->items == NULL) 173 if ( pq->items == NULL)
174 return NULL; 174 return NULL;
175 175
176 for ( next = pq->items; next->next != NULL; 176 for ( next = pq->items; next->next != NULL; next = next->next)
177 prev = next, next = next->next)
178 { 177 {
179 if ( memcmp(next->priority, prio64be,8) == 0) 178 if ( memcmp(next->priority, prio64be,8) == 0)
180 { 179 {
diff --git a/src/lib/libssl/src/crypto/rand/rand_nw.c b/src/lib/libssl/src/crypto/rand/rand_nw.c
index f177ffbe82..8d5b8d2e32 100644
--- a/src/lib/libssl/src/crypto/rand/rand_nw.c
+++ b/src/lib/libssl/src/crypto/rand/rand_nw.c
@@ -160,8 +160,8 @@ int RAND_poll(void)
160 rdtsc 160 rdtsc
161 mov tsc, eax 161 mov tsc, eax
162 } 162 }
163#else 163#elif defined(__GNUC__) && __GNUC__>=2 && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM)
164 asm volatile("rdtsc":"=A" (tsc)); 164 asm volatile("rdtsc":"=a"(tsc)::"edx");
165#endif 165#endif
166 166
167 RAND_add(&tsc, sizeof(tsc), 1); 167 RAND_add(&tsc, sizeof(tsc), 1);
diff --git a/src/lib/libssl/src/crypto/sha/asm/sha1-armv4-large.pl b/src/lib/libssl/src/crypto/sha/asm/sha1-armv4-large.pl
index 88861af641..6e65fe3e01 100644
--- a/src/lib/libssl/src/crypto/sha/asm/sha1-armv4-large.pl
+++ b/src/lib/libssl/src/crypto/sha/asm/sha1-armv4-large.pl
@@ -37,9 +37,18 @@
37# modes are limited. As result it takes more instructions to do 37# modes are limited. As result it takes more instructions to do
38# the same job in Thumb, therefore the code is never twice as 38# the same job in Thumb, therefore the code is never twice as
39# small and always slower. 39# small and always slower.
40# [***] which is also ~35% better than compiler generated code. 40# [***] which is also ~35% better than compiler generated code. Dual-
41# issue Cortex A8 core was measured to process input block in
42# ~990 cycles.
41 43
42$output=shift; 44# August 2010.
45#
46# Rescheduling for dual-issue pipeline resulted in 13% improvement on
47# Cortex A8 core and in absolute terms ~870 cycles per input block
48# [or 13.6 cycles per byte].
49
50
51while (($output=shift) && ($output!~/^\w[\w\-]*\.\w+$/)) {}
43open STDOUT,">$output"; 52open STDOUT,">$output";
44 53
45$ctx="r0"; 54$ctx="r0";
@@ -58,43 +67,22 @@ $t3="r12";
58$Xi="r14"; 67$Xi="r14";
59@V=($a,$b,$c,$d,$e); 68@V=($a,$b,$c,$d,$e);
60 69
61# One can optimize this for aligned access on big-endian architecture,
62# but code's endian neutrality makes it too pretty:-)
63sub Xload {
64my ($a,$b,$c,$d,$e)=@_;
65$code.=<<___;
66 ldrb $t0,[$inp],#4
67 ldrb $t1,[$inp,#-3]
68 ldrb $t2,[$inp,#-2]
69 ldrb $t3,[$inp,#-1]
70 add $e,$K,$e,ror#2 @ E+=K_00_19
71 orr $t0,$t1,$t0,lsl#8
72 add $e,$e,$a,ror#27 @ E+=ROR(A,27)
73 orr $t0,$t2,$t0,lsl#8
74 eor $t1,$c,$d @ F_xx_xx
75 orr $t0,$t3,$t0,lsl#8
76 add $e,$e,$t0 @ E+=X[i]
77 str $t0,[$Xi,#-4]!
78___
79}
80sub Xupdate { 70sub Xupdate {
81my ($a,$b,$c,$d,$e,$flag)=@_; 71my ($a,$b,$c,$d,$e,$opt1,$opt2)=@_;
82$code.=<<___; 72$code.=<<___;
83 ldr $t0,[$Xi,#15*4] 73 ldr $t0,[$Xi,#15*4]
84 ldr $t1,[$Xi,#13*4] 74 ldr $t1,[$Xi,#13*4]
85 ldr $t2,[$Xi,#7*4] 75 ldr $t2,[$Xi,#7*4]
86 ldr $t3,[$Xi,#2*4]
87 add $e,$K,$e,ror#2 @ E+=K_xx_xx 76 add $e,$K,$e,ror#2 @ E+=K_xx_xx
77 ldr $t3,[$Xi,#2*4]
88 eor $t0,$t0,$t1 78 eor $t0,$t0,$t1
89 eor $t0,$t0,$t2 79 eor $t2,$t2,$t3
90 eor $t0,$t0,$t3 80 eor $t1,$c,$d @ F_xx_xx
91 add $e,$e,$a,ror#27 @ E+=ROR(A,27)
92___
93$code.=<<___ if (!defined($flag));
94 eor $t1,$c,$d @ F_xx_xx, but not in 40_59
95___
96$code.=<<___;
97 mov $t0,$t0,ror#31 81 mov $t0,$t0,ror#31
82 add $e,$e,$a,ror#27 @ E+=ROR(A,27)
83 eor $t0,$t0,$t2,ror#31
84 $opt1 @ F_xx_xx
85 $opt2 @ F_xx_xx
98 add $e,$e,$t0 @ E+=X[i] 86 add $e,$e,$t0 @ E+=X[i]
99 str $t0,[$Xi,#-4]! 87 str $t0,[$Xi,#-4]!
100___ 88___
@@ -102,19 +90,29 @@ ___
102 90
103sub BODY_00_15 { 91sub BODY_00_15 {
104my ($a,$b,$c,$d,$e)=@_; 92my ($a,$b,$c,$d,$e)=@_;
105 &Xload(@_);
106$code.=<<___; 93$code.=<<___;
94 ldrb $t0,[$inp],#4
95 ldrb $t1,[$inp,#-1]
96 ldrb $t2,[$inp,#-2]
97 add $e,$K,$e,ror#2 @ E+=K_00_19
98 ldrb $t3,[$inp,#-3]
99 add $e,$e,$a,ror#27 @ E+=ROR(A,27)
100 orr $t0,$t1,$t0,lsl#24
101 eor $t1,$c,$d @ F_xx_xx
102 orr $t0,$t0,$t2,lsl#8
103 orr $t0,$t0,$t3,lsl#16
107 and $t1,$b,$t1,ror#2 104 and $t1,$b,$t1,ror#2
105 add $e,$e,$t0 @ E+=X[i]
108 eor $t1,$t1,$d,ror#2 @ F_00_19(B,C,D) 106 eor $t1,$t1,$d,ror#2 @ F_00_19(B,C,D)
107 str $t0,[$Xi,#-4]!
109 add $e,$e,$t1 @ E+=F_00_19(B,C,D) 108 add $e,$e,$t1 @ E+=F_00_19(B,C,D)
110___ 109___
111} 110}
112 111
113sub BODY_16_19 { 112sub BODY_16_19 {
114my ($a,$b,$c,$d,$e)=@_; 113my ($a,$b,$c,$d,$e)=@_;
115 &Xupdate(@_); 114 &Xupdate(@_,"and $t1,$b,$t1,ror#2");
116$code.=<<___; 115$code.=<<___;
117 and $t1,$b,$t1,ror#2
118 eor $t1,$t1,$d,ror#2 @ F_00_19(B,C,D) 116 eor $t1,$t1,$d,ror#2 @ F_00_19(B,C,D)
119 add $e,$e,$t1 @ E+=F_00_19(B,C,D) 117 add $e,$e,$t1 @ E+=F_00_19(B,C,D)
120___ 118___
@@ -122,22 +120,18 @@ ___
122 120
123sub BODY_20_39 { 121sub BODY_20_39 {
124my ($a,$b,$c,$d,$e)=@_; 122my ($a,$b,$c,$d,$e)=@_;
125 &Xupdate(@_); 123 &Xupdate(@_,"eor $t1,$b,$t1,ror#2");
126$code.=<<___; 124$code.=<<___;
127 eor $t1,$b,$t1,ror#2 @ F_20_39(B,C,D)
128 add $e,$e,$t1 @ E+=F_20_39(B,C,D) 125 add $e,$e,$t1 @ E+=F_20_39(B,C,D)
129___ 126___
130} 127}
131 128
132sub BODY_40_59 { 129sub BODY_40_59 {
133my ($a,$b,$c,$d,$e)=@_; 130my ($a,$b,$c,$d,$e)=@_;
134 &Xupdate(@_,1); 131 &Xupdate(@_,"and $t1,$b,$t1,ror#2","and $t2,$c,$d");
135$code.=<<___; 132$code.=<<___;
136 and $t1,$b,$c,ror#2
137 orr $t2,$b,$c,ror#2
138 and $t2,$t2,$d,ror#2
139 orr $t1,$t1,$t2 @ F_40_59(B,C,D)
140 add $e,$e,$t1 @ E+=F_40_59(B,C,D) 133 add $e,$e,$t1 @ E+=F_40_59(B,C,D)
134 add $e,$e,$t2,ror#2
141___ 135___
142} 136}
143 137
diff --git a/src/lib/libssl/src/crypto/sha/asm/sha1-sparcv9.pl b/src/lib/libssl/src/crypto/sha/asm/sha1-sparcv9.pl
index 8306fc88cc..5c161cecd6 100644
--- a/src/lib/libssl/src/crypto/sha/asm/sha1-sparcv9.pl
+++ b/src/lib/libssl/src/crypto/sha/asm/sha1-sparcv9.pl
@@ -276,6 +276,7 @@ $code.=<<___;
276.type sha1_block_data_order,#function 276.type sha1_block_data_order,#function
277.size sha1_block_data_order,(.-sha1_block_data_order) 277.size sha1_block_data_order,(.-sha1_block_data_order)
278.asciz "SHA1 block transform for SPARCv9, CRYPTOGAMS by <appro\@openssl.org>" 278.asciz "SHA1 block transform for SPARCv9, CRYPTOGAMS by <appro\@openssl.org>"
279.align 4
279___ 280___
280 281
281$code =~ s/\`([^\`]*)\`/eval $1/gem; 282$code =~ s/\`([^\`]*)\`/eval $1/gem;
diff --git a/src/lib/libssl/src/crypto/sha/asm/sha1-sparcv9a.pl b/src/lib/libssl/src/crypto/sha/asm/sha1-sparcv9a.pl
index 15eb854bad..85e8d68086 100644
--- a/src/lib/libssl/src/crypto/sha/asm/sha1-sparcv9a.pl
+++ b/src/lib/libssl/src/crypto/sha/asm/sha1-sparcv9a.pl
@@ -539,6 +539,7 @@ $code.=<<___;
539.type sha1_block_data_order,#function 539.type sha1_block_data_order,#function
540.size sha1_block_data_order,(.-sha1_block_data_order) 540.size sha1_block_data_order,(.-sha1_block_data_order)
541.asciz "SHA1 block transform for SPARCv9a, CRYPTOGAMS by <appro\@openssl.org>" 541.asciz "SHA1 block transform for SPARCv9a, CRYPTOGAMS by <appro\@openssl.org>"
542.align 4
542___ 543___
543 544
544# Purpose of these subroutines is to explicitly encode VIS instructions, 545# Purpose of these subroutines is to explicitly encode VIS instructions,
diff --git a/src/lib/libssl/src/crypto/sha/asm/sha256-armv4.pl b/src/lib/libssl/src/crypto/sha/asm/sha256-armv4.pl
index 48d846deec..492cb62bc0 100644
--- a/src/lib/libssl/src/crypto/sha/asm/sha256-armv4.pl
+++ b/src/lib/libssl/src/crypto/sha/asm/sha256-armv4.pl
@@ -11,9 +11,14 @@
11 11
12# Performance is ~2x better than gcc 3.4 generated code and in "abso- 12# Performance is ~2x better than gcc 3.4 generated code and in "abso-
13# lute" terms is ~2250 cycles per 64-byte block or ~35 cycles per 13# lute" terms is ~2250 cycles per 64-byte block or ~35 cycles per
14# byte. 14# byte [on single-issue Xscale PXA250 core].
15 15
16$output=shift; 16# July 2010.
17#
18# Rescheduling for dual-issue pipeline resulted in 22% improvement on
19# Cortex A8 core and ~20 cycles per processed byte.
20
21while (($output=shift) && ($output!~/^\w[\w\-]*\.\w+$/)) {}
17open STDOUT,">$output"; 22open STDOUT,">$output";
18 23
19$ctx="r0"; $t0="r0"; 24$ctx="r0"; $t0="r0";
@@ -52,27 +57,27 @@ $code.=<<___ if ($i<16);
52___ 57___
53$code.=<<___; 58$code.=<<___;
54 ldr $t2,[$Ktbl],#4 @ *K256++ 59 ldr $t2,[$Ktbl],#4 @ *K256++
55 str $T1,[sp,#`$i%16`*4]
56 mov $t0,$e,ror#$Sigma1[0] 60 mov $t0,$e,ror#$Sigma1[0]
61 str $T1,[sp,#`$i%16`*4]
57 eor $t0,$t0,$e,ror#$Sigma1[1] 62 eor $t0,$t0,$e,ror#$Sigma1[1]
58 eor $t0,$t0,$e,ror#$Sigma1[2] @ Sigma1(e)
59 add $T1,$T1,$t0
60 eor $t1,$f,$g 63 eor $t1,$f,$g
64 eor $t0,$t0,$e,ror#$Sigma1[2] @ Sigma1(e)
61 and $t1,$t1,$e 65 and $t1,$t1,$e
66 add $T1,$T1,$t0
62 eor $t1,$t1,$g @ Ch(e,f,g) 67 eor $t1,$t1,$g @ Ch(e,f,g)
63 add $T1,$T1,$t1
64 add $T1,$T1,$h 68 add $T1,$T1,$h
65 add $T1,$T1,$t2
66 mov $h,$a,ror#$Sigma0[0] 69 mov $h,$a,ror#$Sigma0[0]
70 add $T1,$T1,$t1
67 eor $h,$h,$a,ror#$Sigma0[1] 71 eor $h,$h,$a,ror#$Sigma0[1]
72 add $T1,$T1,$t2
68 eor $h,$h,$a,ror#$Sigma0[2] @ Sigma0(a) 73 eor $h,$h,$a,ror#$Sigma0[2] @ Sigma0(a)
69 orr $t0,$a,$b 74 orr $t0,$a,$b
70 and $t0,$t0,$c
71 and $t1,$a,$b 75 and $t1,$a,$b
76 and $t0,$t0,$c
77 add $h,$h,$T1
72 orr $t0,$t0,$t1 @ Maj(a,b,c) 78 orr $t0,$t0,$t1 @ Maj(a,b,c)
73 add $h,$h,$t0
74 add $d,$d,$T1 79 add $d,$d,$T1
75 add $h,$h,$T1 80 add $h,$h,$t0
76___ 81___
77} 82}
78 83
@@ -80,19 +85,19 @@ sub BODY_16_XX {
80my ($i,$a,$b,$c,$d,$e,$f,$g,$h) = @_; 85my ($i,$a,$b,$c,$d,$e,$f,$g,$h) = @_;
81 86
82$code.=<<___; 87$code.=<<___;
83 ldr $t1,[sp,#`($i+1)%16`*4] @ $i 88 ldr $t1,[sp,#`($i+1)%16`*4] @ $i
84 ldr $t2,[sp,#`($i+14)%16`*4] 89 ldr $t2,[sp,#`($i+14)%16`*4]
85 ldr $T1,[sp,#`($i+0)%16`*4] 90 ldr $T1,[sp,#`($i+0)%16`*4]
86 ldr $inp,[sp,#`($i+9)%16`*4]
87 mov $t0,$t1,ror#$sigma0[0] 91 mov $t0,$t1,ror#$sigma0[0]
92 ldr $inp,[sp,#`($i+9)%16`*4]
88 eor $t0,$t0,$t1,ror#$sigma0[1] 93 eor $t0,$t0,$t1,ror#$sigma0[1]
89 eor $t0,$t0,$t1,lsr#$sigma0[2] @ sigma0(X[i+1]) 94 eor $t0,$t0,$t1,lsr#$sigma0[2] @ sigma0(X[i+1])
90 mov $t1,$t2,ror#$sigma1[0] 95 mov $t1,$t2,ror#$sigma1[0]
96 add $T1,$T1,$t0
91 eor $t1,$t1,$t2,ror#$sigma1[1] 97 eor $t1,$t1,$t2,ror#$sigma1[1]
98 add $T1,$T1,$inp
92 eor $t1,$t1,$t2,lsr#$sigma1[2] @ sigma1(X[i+14]) 99 eor $t1,$t1,$t2,lsr#$sigma1[2] @ sigma1(X[i+14])
93 add $T1,$T1,$t0
94 add $T1,$T1,$t1 100 add $T1,$T1,$t1
95 add $T1,$T1,$inp
96___ 101___
97 &BODY_00_15(@_); 102 &BODY_00_15(@_);
98} 103}
diff --git a/src/lib/libssl/src/crypto/sha/asm/sha512-armv4.pl b/src/lib/libssl/src/crypto/sha/asm/sha512-armv4.pl
index 4fbb94a914..3a35861ac6 100644
--- a/src/lib/libssl/src/crypto/sha/asm/sha512-armv4.pl
+++ b/src/lib/libssl/src/crypto/sha/asm/sha512-armv4.pl
@@ -10,7 +10,13 @@
10# SHA512 block procedure for ARMv4. September 2007. 10# SHA512 block procedure for ARMv4. September 2007.
11 11
12# This code is ~4.5 (four and a half) times faster than code generated 12# This code is ~4.5 (four and a half) times faster than code generated
13# by gcc 3.4 and it spends ~72 clock cycles per byte. 13# by gcc 3.4 and it spends ~72 clock cycles per byte [on single-issue
14# Xscale PXA250 core].
15#
16# July 2010.
17#
18# Rescheduling for dual-issue pipeline resulted in 6% improvement on
19# Cortex A8 core and ~40 cycles per processed byte.
14 20
15# Byte order [in]dependence. ========================================= 21# Byte order [in]dependence. =========================================
16# 22#
@@ -22,7 +28,7 @@ $hi=0;
22$lo=4; 28$lo=4;
23# ==================================================================== 29# ====================================================================
24 30
25$output=shift; 31while (($output=shift) && ($output!~/^\w[\w\-]*\.\w+$/)) {}
26open STDOUT,">$output"; 32open STDOUT,">$output";
27 33
28$ctx="r0"; 34$ctx="r0";
@@ -73,33 +79,31 @@ $code.=<<___;
73 eor $t0,$t0,$Elo,lsl#23 79 eor $t0,$t0,$Elo,lsl#23
74 eor $t1,$t1,$Ehi,lsl#23 @ Sigma1(e) 80 eor $t1,$t1,$Ehi,lsl#23 @ Sigma1(e)
75 adds $Tlo,$Tlo,$t0 81 adds $Tlo,$Tlo,$t0
76 adc $Thi,$Thi,$t1 @ T += Sigma1(e)
77 adds $Tlo,$Tlo,$t2
78 adc $Thi,$Thi,$t3 @ T += h
79
80 ldr $t0,[sp,#$Foff+0] @ f.lo 82 ldr $t0,[sp,#$Foff+0] @ f.lo
83 adc $Thi,$Thi,$t1 @ T += Sigma1(e)
81 ldr $t1,[sp,#$Foff+4] @ f.hi 84 ldr $t1,[sp,#$Foff+4] @ f.hi
85 adds $Tlo,$Tlo,$t2
82 ldr $t2,[sp,#$Goff+0] @ g.lo 86 ldr $t2,[sp,#$Goff+0] @ g.lo
87 adc $Thi,$Thi,$t3 @ T += h
83 ldr $t3,[sp,#$Goff+4] @ g.hi 88 ldr $t3,[sp,#$Goff+4] @ g.hi
84 str $Elo,[sp,#$Eoff+0]
85 str $Ehi,[sp,#$Eoff+4]
86 str $Alo,[sp,#$Aoff+0]
87 str $Ahi,[sp,#$Aoff+4]
88 89
89 eor $t0,$t0,$t2 90 eor $t0,$t0,$t2
91 str $Elo,[sp,#$Eoff+0]
90 eor $t1,$t1,$t3 92 eor $t1,$t1,$t3
93 str $Ehi,[sp,#$Eoff+4]
91 and $t0,$t0,$Elo 94 and $t0,$t0,$Elo
95 str $Alo,[sp,#$Aoff+0]
92 and $t1,$t1,$Ehi 96 and $t1,$t1,$Ehi
97 str $Ahi,[sp,#$Aoff+4]
93 eor $t0,$t0,$t2 98 eor $t0,$t0,$t2
94 eor $t1,$t1,$t3 @ Ch(e,f,g)
95
96 ldr $t2,[$Ktbl,#4] @ K[i].lo 99 ldr $t2,[$Ktbl,#4] @ K[i].lo
100 eor $t1,$t1,$t3 @ Ch(e,f,g)
97 ldr $t3,[$Ktbl,#0] @ K[i].hi 101 ldr $t3,[$Ktbl,#0] @ K[i].hi
98 ldr $Elo,[sp,#$Doff+0] @ d.lo
99 ldr $Ehi,[sp,#$Doff+4] @ d.hi
100 102
101 adds $Tlo,$Tlo,$t0 103 adds $Tlo,$Tlo,$t0
104 ldr $Elo,[sp,#$Doff+0] @ d.lo
102 adc $Thi,$Thi,$t1 @ T += Ch(e,f,g) 105 adc $Thi,$Thi,$t1 @ T += Ch(e,f,g)
106 ldr $Ehi,[sp,#$Doff+4] @ d.hi
103 adds $Tlo,$Tlo,$t2 107 adds $Tlo,$Tlo,$t2
104 adc $Thi,$Thi,$t3 @ T += K[i] 108 adc $Thi,$Thi,$t3 @ T += K[i]
105 adds $Elo,$Elo,$Tlo 109 adds $Elo,$Elo,$Tlo
diff --git a/src/lib/libssl/src/crypto/sha/asm/sha512-sparcv9.pl b/src/lib/libssl/src/crypto/sha/asm/sha512-sparcv9.pl
index 54241aab50..ec5d78135e 100644
--- a/src/lib/libssl/src/crypto/sha/asm/sha512-sparcv9.pl
+++ b/src/lib/libssl/src/crypto/sha/asm/sha512-sparcv9.pl
@@ -586,6 +586,7 @@ $code.=<<___;
586.type sha${label}_block_data_order,#function 586.type sha${label}_block_data_order,#function
587.size sha${label}_block_data_order,(.-sha${label}_block_data_order) 587.size sha${label}_block_data_order,(.-sha${label}_block_data_order)
588.asciz "SHA${label} block transform for SPARCv9, CRYPTOGAMS by <appro\@openssl.org>" 588.asciz "SHA${label} block transform for SPARCv9, CRYPTOGAMS by <appro\@openssl.org>"
589.align 4
589___ 590___
590 591
591$code =~ s/\`([^\`]*)\`/eval $1/gem; 592$code =~ s/\`([^\`]*)\`/eval $1/gem;
diff --git a/src/lib/libssl/src/crypto/sparccpuid.S b/src/lib/libssl/src/crypto/sparccpuid.S
index aa8b11efc9..ae61f7f5ce 100644
--- a/src/lib/libssl/src/crypto/sparccpuid.S
+++ b/src/lib/libssl/src/crypto/sparccpuid.S
@@ -225,13 +225,95 @@ _sparcv9_rdtick:
225 xor %o0,%o0,%o0 225 xor %o0,%o0,%o0
226 .word 0x91410000 !rd %tick,%o0 226 .word 0x91410000 !rd %tick,%o0
227 retl 227 retl
228 .word 0x93323020 !srlx %o2,32,%o1 228 .word 0x93323020 !srlx %o0,32,%o1
229.notick: 229.notick:
230 retl 230 retl
231 xor %o1,%o1,%o1 231 xor %o1,%o1,%o1
232.type _sparcv9_rdtick,#function 232.type _sparcv9_rdtick,#function
233.size _sparcv9_rdtick,.-_sparcv9_rdtick 233.size _sparcv9_rdtick,.-_sparcv9_rdtick
234 234
235.global _sparcv9_vis1_probe
236.align 8
237_sparcv9_vis1_probe:
238 .word 0x81b00d80 !fxor %f0,%f0,%f0
239 add %sp,BIAS+2,%o1
240 retl
241 .word 0xc19a5a40 !ldda [%o1]ASI_FP16_P,%f0
242.type _sparcv9_vis1_probe,#function
243.size _sparcv9_vis1_probe,.-_sparcv9_vis1_probe
244
245! Probe and instrument VIS1 instruction. Output is number of cycles it
246! takes to execute rdtick and pair of VIS1 instructions. US-Tx VIS unit
247! is slow (documented to be 6 cycles on T2) and the core is in-order
248! single-issue, it should be possible to distinguish Tx reliably...
249! Observed return values are:
250!
251! UltraSPARC IIe 7
252! UltraSPARC III 7
253! UltraSPARC T1 24
254!
255! Numbers for T2 and SPARC64 V-VII are more than welcomed.
256!
257! It would be possible to detect specifically US-T1 by instrumenting
258! fmul8ulx16, which is emulated on T1 and as such accounts for quite
259! a lot of %tick-s, couple of thousand on Linux...
260.global _sparcv9_vis1_instrument
261.align 8
262_sparcv9_vis1_instrument:
263 .word 0x91410000 !rd %tick,%o0
264 .word 0x81b00d80 !fxor %f0,%f0,%f0
265 .word 0x85b08d82 !fxor %f2,%f2,%f2
266 .word 0x93410000 !rd %tick,%o1
267 .word 0x81b00d80 !fxor %f0,%f0,%f0
268 .word 0x85b08d82 !fxor %f2,%f2,%f2
269 .word 0x95410000 !rd %tick,%o2
270 .word 0x81b00d80 !fxor %f0,%f0,%f0
271 .word 0x85b08d82 !fxor %f2,%f2,%f2
272 .word 0x97410000 !rd %tick,%o3
273 .word 0x81b00d80 !fxor %f0,%f0,%f0
274 .word 0x85b08d82 !fxor %f2,%f2,%f2
275 .word 0x99410000 !rd %tick,%o4
276
277 ! calculate intervals
278 sub %o1,%o0,%o0
279 sub %o2,%o1,%o1
280 sub %o3,%o2,%o2
281 sub %o4,%o3,%o3
282
283 ! find minumum value
284 cmp %o0,%o1
285 .word 0x38680002 !bgu,a %xcc,.+8
286 mov %o1,%o0
287 cmp %o0,%o2
288 .word 0x38680002 !bgu,a %xcc,.+8
289 mov %o2,%o0
290 cmp %o0,%o3
291 .word 0x38680002 !bgu,a %xcc,.+8
292 mov %o3,%o0
293
294 retl
295 nop
296.type _sparcv9_vis1_instrument,#function
297.size _sparcv9_vis1_instrument,.-_sparcv9_vis1_instrument
298
299.global _sparcv9_vis2_probe
300.align 8
301_sparcv9_vis2_probe:
302 retl
303 .word 0x81b00980 !bshuffle %f0,%f0,%f0
304.type _sparcv9_vis2_probe,#function
305.size _sparcv9_vis2_probe,.-_sparcv9_vis2_probe
306
307.global _sparcv9_fmadd_probe
308.align 8
309_sparcv9_fmadd_probe:
310 .word 0x81b00d80 !fxor %f0,%f0,%f0
311 .word 0x85b08d82 !fxor %f2,%f2,%f2
312 retl
313 .word 0x81b80440 !fmaddd %f0,%f0,%f2,%f0
314.type _sparcv9_fmadd_probe,#function
315.size _sparcv9_fmadd_probe,.-_sparcv9_fmadd_probe
316
235.global OPENSSL_cleanse 317.global OPENSSL_cleanse
236.align 32 318.align 32
237OPENSSL_cleanse: 319OPENSSL_cleanse:
diff --git a/src/lib/libssl/src/crypto/sparcv9cap.c b/src/lib/libssl/src/crypto/sparcv9cap.c
index 5f31d20bd0..ed195ab402 100644
--- a/src/lib/libssl/src/crypto/sparcv9cap.c
+++ b/src/lib/libssl/src/crypto/sparcv9cap.c
@@ -1,6 +1,8 @@
1#include <stdio.h> 1#include <stdio.h>
2#include <stdlib.h> 2#include <stdlib.h>
3#include <string.h> 3#include <string.h>
4#include <setjmp.h>
5#include <signal.h>
4#include <sys/time.h> 6#include <sys/time.h>
5#include <openssl/bn.h> 7#include <openssl/bn.h>
6 8
@@ -9,6 +11,7 @@
9#define SPARCV9_VIS1 (1<<2) 11#define SPARCV9_VIS1 (1<<2)
10#define SPARCV9_VIS2 (1<<3) /* reserved */ 12#define SPARCV9_VIS2 (1<<3) /* reserved */
11#define SPARCV9_FMADD (1<<4) /* reserved for SPARC64 V */ 13#define SPARCV9_FMADD (1<<4) /* reserved for SPARC64 V */
14
12static int OPENSSL_sparcv9cap_P=SPARCV9_TICK_PRIVILEGED; 15static int OPENSSL_sparcv9cap_P=SPARCV9_TICK_PRIVILEGED;
13 16
14int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, const BN_ULONG *np,const BN_ULONG *n0, int num) 17int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, const BN_ULONG *np,const BN_ULONG *n0, int num)
@@ -23,10 +26,14 @@ int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, const BN_U
23 return bn_mul_mont_int(rp,ap,bp,np,n0,num); 26 return bn_mul_mont_int(rp,ap,bp,np,n0,num);
24 } 27 }
25 28
29unsigned long _sparcv9_rdtick(void);
30void _sparcv9_vis1_probe(void);
31unsigned long _sparcv9_vis1_instrument(void);
32void _sparcv9_vis2_probe(void);
33void _sparcv9_fmadd_probe(void);
34
26unsigned long OPENSSL_rdtsc(void) 35unsigned long OPENSSL_rdtsc(void)
27 { 36 {
28 unsigned long _sparcv9_rdtick(void);
29
30 if (OPENSSL_sparcv9cap_P&SPARCV9_TICK_PRIVILEGED) 37 if (OPENSSL_sparcv9cap_P&SPARCV9_TICK_PRIVILEGED)
31#if defined(__sun) && defined(__SVR4) 38#if defined(__sun) && defined(__SVR4)
32 return gethrtime(); 39 return gethrtime();
@@ -37,8 +44,11 @@ unsigned long OPENSSL_rdtsc(void)
37 return _sparcv9_rdtick(); 44 return _sparcv9_rdtick();
38 } 45 }
39 46
40#if defined(__sun) && defined(__SVR4) 47#if 0 && defined(__sun) && defined(__SVR4)
41 48/* This code path is disabled, because of incompatibility of
49 * libdevinfo.so.1 and libmalloc.so.1 (see below for details)
50 */
51#include <malloc.h>
42#include <dlfcn.h> 52#include <dlfcn.h>
43#include <libdevinfo.h> 53#include <libdevinfo.h>
44#include <sys/systeminfo.h> 54#include <sys/systeminfo.h>
@@ -110,7 +120,21 @@ void OPENSSL_cpuid_setup(void)
110 return; 120 return;
111 } 121 }
112 } 122 }
113 123#ifdef M_KEEP
124 /*
125 * Solaris libdevinfo.so.1 is effectively incomatible with
126 * libmalloc.so.1. Specifically, if application is linked with
127 * -lmalloc, it crashes upon startup with SIGSEGV in
128 * free(3LIBMALLOC) called by di_fini. Prior call to
129 * mallopt(M_KEEP,0) somehow helps... But not always...
130 */
131 if ((h = dlopen(NULL,RTLD_LAZY)))
132 {
133 union { void *p; int (*f)(int,int); } sym;
134 if ((sym.p = dlsym(h,"mallopt"))) (*sym.f)(M_KEEP,0);
135 dlclose(h);
136 }
137#endif
114 if ((h = dlopen("libdevinfo.so.1",RTLD_LAZY))) do 138 if ((h = dlopen("libdevinfo.so.1",RTLD_LAZY))) do
115 { 139 {
116 di_init_t di_init; 140 di_init_t di_init;
@@ -137,9 +161,19 @@ void OPENSSL_cpuid_setup(void)
137 161
138#else 162#else
139 163
164static sigjmp_buf common_jmp;
165static void common_handler(int sig) { siglongjmp(common_jmp,sig); }
166
140void OPENSSL_cpuid_setup(void) 167void OPENSSL_cpuid_setup(void)
141 { 168 {
142 char *e; 169 char *e;
170 struct sigaction common_act,ill_oact,bus_oact;
171 sigset_t all_masked,oset;
172 int sig;
173 static int trigger=0;
174
175 if (trigger) return;
176 trigger=1;
143 177
144 if ((e=getenv("OPENSSL_sparcv9cap"))) 178 if ((e=getenv("OPENSSL_sparcv9cap")))
145 { 179 {
@@ -147,8 +181,57 @@ void OPENSSL_cpuid_setup(void)
147 return; 181 return;
148 } 182 }
149 183
150 /* For now we assume that the rest supports UltraSPARC-I* only */ 184 /* Initial value, fits UltraSPARC-I&II... */
151 OPENSSL_sparcv9cap_P |= SPARCV9_PREFER_FPU|SPARCV9_VIS1; 185 OPENSSL_sparcv9cap_P = SPARCV9_PREFER_FPU|SPARCV9_TICK_PRIVILEGED;
186
187 sigfillset(&all_masked);
188 sigdelset(&all_masked,SIGILL);
189 sigdelset(&all_masked,SIGTRAP);
190#ifdef SIGEMT
191 sigdelset(&all_masked,SIGEMT);
192#endif
193 sigdelset(&all_masked,SIGFPE);
194 sigdelset(&all_masked,SIGBUS);
195 sigdelset(&all_masked,SIGSEGV);
196 sigprocmask(SIG_SETMASK,&all_masked,&oset);
197
198 memset(&common_act,0,sizeof(common_act));
199 common_act.sa_handler = common_handler;
200 common_act.sa_mask = all_masked;
201
202 sigaction(SIGILL,&common_act,&ill_oact);
203 sigaction(SIGBUS,&common_act,&bus_oact);/* T1 fails 16-bit ldda [on Linux] */
204
205 if (sigsetjmp(common_jmp,1) == 0)
206 {
207 _sparcv9_rdtick();
208 OPENSSL_sparcv9cap_P &= ~SPARCV9_TICK_PRIVILEGED;
209 }
210
211 if (sigsetjmp(common_jmp,1) == 0)
212 {
213 _sparcv9_vis1_probe();
214 OPENSSL_sparcv9cap_P |= SPARCV9_VIS1;
215 /* detect UltraSPARC-Tx, see sparccpud.S for details... */
216 if (_sparcv9_vis1_instrument() >= 12)
217 OPENSSL_sparcv9cap_P &= ~(SPARCV9_VIS1|SPARCV9_PREFER_FPU);
218 else
219 {
220 _sparcv9_vis2_probe();
221 OPENSSL_sparcv9cap_P |= SPARCV9_VIS2;
222 }
223 }
224
225 if (sigsetjmp(common_jmp,1) == 0)
226 {
227 _sparcv9_fmadd_probe();
228 OPENSSL_sparcv9cap_P |= SPARCV9_FMADD;
229 }
230
231 sigaction(SIGBUS,&bus_oact,NULL);
232 sigaction(SIGILL,&ill_oact,NULL);
233
234 sigprocmask(SIG_SETMASK,&oset,NULL);
152 } 235 }
153 236
154#endif 237#endif
diff --git a/src/lib/libssl/src/crypto/ts/ts_verify_ctx.c b/src/lib/libssl/src/crypto/ts/ts_verify_ctx.c
index b079b50fc3..609b7735d4 100644
--- a/src/lib/libssl/src/crypto/ts/ts_verify_ctx.c
+++ b/src/lib/libssl/src/crypto/ts/ts_verify_ctx.c
@@ -56,7 +56,6 @@
56 * 56 *
57 */ 57 */
58 58
59#include <assert.h>
60#include "cryptlib.h" 59#include "cryptlib.h"
61#include <openssl/objects.h> 60#include <openssl/objects.h>
62#include <openssl/ts.h> 61#include <openssl/ts.h>
@@ -74,7 +73,7 @@ TS_VERIFY_CTX *TS_VERIFY_CTX_new(void)
74 73
75void TS_VERIFY_CTX_init(TS_VERIFY_CTX *ctx) 74void TS_VERIFY_CTX_init(TS_VERIFY_CTX *ctx)
76 { 75 {
77 assert(ctx != NULL); 76 OPENSSL_assert(ctx != NULL);
78 memset(ctx, 0, sizeof(TS_VERIFY_CTX)); 77 memset(ctx, 0, sizeof(TS_VERIFY_CTX));
79 } 78 }
80 79
@@ -116,7 +115,7 @@ TS_VERIFY_CTX *TS_REQ_to_TS_VERIFY_CTX(TS_REQ *req, TS_VERIFY_CTX *ctx)
116 ASN1_OCTET_STRING *msg; 115 ASN1_OCTET_STRING *msg;
117 const ASN1_INTEGER *nonce; 116 const ASN1_INTEGER *nonce;
118 117
119 assert(req != NULL); 118 OPENSSL_assert(req != NULL);
120 if (ret) 119 if (ret)
121 TS_VERIFY_CTX_cleanup(ret); 120 TS_VERIFY_CTX_cleanup(ret);
122 else 121 else
diff --git a/src/lib/libssl/src/crypto/vms_rms.h b/src/lib/libssl/src/crypto/vms_rms.h
new file mode 100755
index 0000000000..00a00d993f
--- /dev/null
+++ b/src/lib/libssl/src/crypto/vms_rms.h
@@ -0,0 +1,51 @@
1
2#ifdef NAML$C_MAXRSS
3
4# define CC_RMS_NAMX cc$rms_naml
5# define FAB_NAMX fab$l_naml
6# define FAB_OR_NAML( fab, naml) naml
7# define FAB_OR_NAML_DNA naml$l_long_defname
8# define FAB_OR_NAML_DNS naml$l_long_defname_size
9# define FAB_OR_NAML_FNA naml$l_long_filename
10# define FAB_OR_NAML_FNS naml$l_long_filename_size
11# define NAMX_ESA naml$l_long_expand
12# define NAMX_ESL naml$l_long_expand_size
13# define NAMX_ESS naml$l_long_expand_alloc
14# define NAMX_NOP naml$b_nop
15# define SET_NAMX_NO_SHORT_UPCASE( nam) nam.naml$v_no_short_upcase = 1
16
17# if __INITIAL_POINTER_SIZE == 64
18# define NAMX_DNA_FNA_SET(fab) fab.fab$l_dna = (__char_ptr32) -1; \
19 fab.fab$l_fna = (__char_ptr32) -1;
20# else /* __INITIAL_POINTER_SIZE == 64 */
21# define NAMX_DNA_FNA_SET(fab) fab.fab$l_dna = (char *) -1; \
22 fab.fab$l_fna = (char *) -1;
23# endif /* __INITIAL_POINTER_SIZE == 64 [else] */
24
25# define NAMX_MAXRSS NAML$C_MAXRSS
26# define NAMX_STRUCT NAML
27
28#else /* def NAML$C_MAXRSS */
29
30# define CC_RMS_NAMX cc$rms_nam
31# define FAB_NAMX fab$l_nam
32# define FAB_OR_NAML( fab, naml) fab
33# define FAB_OR_NAML_DNA fab$l_dna
34# define FAB_OR_NAML_DNS fab$b_dns
35# define FAB_OR_NAML_FNA fab$l_fna
36# define FAB_OR_NAML_FNS fab$b_fns
37# define NAMX_ESA nam$l_esa
38# define NAMX_ESL nam$b_esl
39# define NAMX_ESS nam$b_ess
40# define NAMX_NOP nam$b_nop
41# define NAMX_DNA_FNA_SET(fab)
42# define NAMX_MAXRSS NAM$C_MAXRSS
43# define NAMX_STRUCT NAM
44# ifdef NAM$M_NO_SHORT_UPCASE
45# define SET_NAMX_NO_SHORT_UPCASE( nam) naml.naml$v_no_short_upcase = 1
46# else /* def NAM$M_NO_SHORT_UPCASE */
47# define SET_NAMX_NO_SHORT_UPCASE( nam)
48# endif /* def NAM$M_NO_SHORT_UPCASE [else] */
49
50#endif /* def NAML$C_MAXRSS [else] */
51
diff --git a/src/lib/libssl/src/crypto/x509v3/pcy_tree.c b/src/lib/libssl/src/crypto/x509v3/pcy_tree.c
index 92f6b24556..bb9777348f 100644
--- a/src/lib/libssl/src/crypto/x509v3/pcy_tree.c
+++ b/src/lib/libssl/src/crypto/x509v3/pcy_tree.c
@@ -341,9 +341,8 @@ static int tree_link_nodes(X509_POLICY_LEVEL *curr,
341 const X509_POLICY_CACHE *cache) 341 const X509_POLICY_CACHE *cache)
342 { 342 {
343 int i; 343 int i;
344 X509_POLICY_LEVEL *last;
345 X509_POLICY_DATA *data; 344 X509_POLICY_DATA *data;
346 last = curr - 1; 345
347 for (i = 0; i < sk_X509_POLICY_DATA_num(cache->data); i++) 346 for (i = 0; i < sk_X509_POLICY_DATA_num(cache->data); i++)
348 { 347 {
349 data = sk_X509_POLICY_DATA_value(cache->data, i); 348 data = sk_X509_POLICY_DATA_value(cache->data, i);
diff --git a/src/lib/libssl/src/crypto/x509v3/v3_addr.c b/src/lib/libssl/src/crypto/x509v3/v3_addr.c
index 9087d66e0a..0d70e8696d 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3_addr.c
+++ b/src/lib/libssl/src/crypto/x509v3/v3_addr.c
@@ -177,12 +177,18 @@ static int i2r_address(BIO *out,
177 unsigned char addr[ADDR_RAW_BUF_LEN]; 177 unsigned char addr[ADDR_RAW_BUF_LEN];
178 int i, n; 178 int i, n;
179 179
180 if (bs->length < 0)
181 return 0;
180 switch (afi) { 182 switch (afi) {
181 case IANA_AFI_IPV4: 183 case IANA_AFI_IPV4:
184 if (bs->length > 4)
185 return 0;
182 addr_expand(addr, bs, 4, fill); 186 addr_expand(addr, bs, 4, fill);
183 BIO_printf(out, "%d.%d.%d.%d", addr[0], addr[1], addr[2], addr[3]); 187 BIO_printf(out, "%d.%d.%d.%d", addr[0], addr[1], addr[2], addr[3]);
184 break; 188 break;
185 case IANA_AFI_IPV6: 189 case IANA_AFI_IPV6:
190 if (bs->length > 16)
191 return 0;
186 addr_expand(addr, bs, 16, fill); 192 addr_expand(addr, bs, 16, fill);
187 for (n = 16; n > 1 && addr[n-1] == 0x00 && addr[n-2] == 0x00; n -= 2) 193 for (n = 16; n > 1 && addr[n-1] == 0x00 && addr[n-2] == 0x00; n -= 2)
188 ; 194 ;
diff --git a/src/lib/libssl/src/crypto/x509v3/v3_asid.c b/src/lib/libssl/src/crypto/x509v3/v3_asid.c
index 56702f86b9..3f434c0603 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3_asid.c
+++ b/src/lib/libssl/src/crypto/x509v3/v3_asid.c
@@ -61,7 +61,6 @@
61 61
62#include <stdio.h> 62#include <stdio.h>
63#include <string.h> 63#include <string.h>
64#include <assert.h>
65#include "cryptlib.h" 64#include "cryptlib.h"
66#include <openssl/conf.h> 65#include <openssl/conf.h>
67#include <openssl/asn1.h> 66#include <openssl/asn1.h>
@@ -172,11 +171,11 @@ static int ASIdOrRange_cmp(const ASIdOrRange * const *a_,
172{ 171{
173 const ASIdOrRange *a = *a_, *b = *b_; 172 const ASIdOrRange *a = *a_, *b = *b_;
174 173
175 assert((a->type == ASIdOrRange_id && a->u.id != NULL) || 174 OPENSSL_assert((a->type == ASIdOrRange_id && a->u.id != NULL) ||
176 (a->type == ASIdOrRange_range && a->u.range != NULL && 175 (a->type == ASIdOrRange_range && a->u.range != NULL &&
177 a->u.range->min != NULL && a->u.range->max != NULL)); 176 a->u.range->min != NULL && a->u.range->max != NULL));
178 177
179 assert((b->type == ASIdOrRange_id && b->u.id != NULL) || 178 OPENSSL_assert((b->type == ASIdOrRange_id && b->u.id != NULL) ||
180 (b->type == ASIdOrRange_range && b->u.range != NULL && 179 (b->type == ASIdOrRange_range && b->u.range != NULL &&
181 b->u.range->min != NULL && b->u.range->max != NULL)); 180 b->u.range->min != NULL && b->u.range->max != NULL));
182 181
@@ -215,7 +214,7 @@ int v3_asid_add_inherit(ASIdentifiers *asid, int which)
215 if (*choice == NULL) { 214 if (*choice == NULL) {
216 if ((*choice = ASIdentifierChoice_new()) == NULL) 215 if ((*choice = ASIdentifierChoice_new()) == NULL)
217 return 0; 216 return 0;
218 assert((*choice)->u.inherit == NULL); 217 OPENSSL_assert((*choice)->u.inherit == NULL);
219 if (((*choice)->u.inherit = ASN1_NULL_new()) == NULL) 218 if (((*choice)->u.inherit = ASN1_NULL_new()) == NULL)
220 return 0; 219 return 0;
221 (*choice)->type = ASIdentifierChoice_inherit; 220 (*choice)->type = ASIdentifierChoice_inherit;
@@ -250,7 +249,7 @@ int v3_asid_add_id_or_range(ASIdentifiers *asid,
250 if (*choice == NULL) { 249 if (*choice == NULL) {
251 if ((*choice = ASIdentifierChoice_new()) == NULL) 250 if ((*choice = ASIdentifierChoice_new()) == NULL)
252 return 0; 251 return 0;
253 assert((*choice)->u.asIdsOrRanges == NULL); 252 OPENSSL_assert((*choice)->u.asIdsOrRanges == NULL);
254 (*choice)->u.asIdsOrRanges = sk_ASIdOrRange_new(ASIdOrRange_cmp); 253 (*choice)->u.asIdsOrRanges = sk_ASIdOrRange_new(ASIdOrRange_cmp);
255 if ((*choice)->u.asIdsOrRanges == NULL) 254 if ((*choice)->u.asIdsOrRanges == NULL)
256 return 0; 255 return 0;
@@ -286,7 +285,7 @@ static void extract_min_max(ASIdOrRange *aor,
286 ASN1_INTEGER **min, 285 ASN1_INTEGER **min,
287 ASN1_INTEGER **max) 286 ASN1_INTEGER **max)
288{ 287{
289 assert(aor != NULL && min != NULL && max != NULL); 288 OPENSSL_assert(aor != NULL && min != NULL && max != NULL);
290 switch (aor->type) { 289 switch (aor->type) {
291 case ASIdOrRange_id: 290 case ASIdOrRange_id:
292 *min = aor->u.id; 291 *min = aor->u.id;
@@ -373,7 +372,7 @@ static int ASIdentifierChoice_is_canonical(ASIdentifierChoice *choice)
373int v3_asid_is_canonical(ASIdentifiers *asid) 372int v3_asid_is_canonical(ASIdentifiers *asid)
374{ 373{
375 return (asid == NULL || 374 return (asid == NULL ||
376 (ASIdentifierChoice_is_canonical(asid->asnum) || 375 (ASIdentifierChoice_is_canonical(asid->asnum) &&
377 ASIdentifierChoice_is_canonical(asid->rdi))); 376 ASIdentifierChoice_is_canonical(asid->rdi)));
378} 377}
379 378
@@ -395,7 +394,7 @@ static int ASIdentifierChoice_canonize(ASIdentifierChoice *choice)
395 /* 394 /*
396 * We have a list. Sort it. 395 * We have a list. Sort it.
397 */ 396 */
398 assert(choice->type == ASIdentifierChoice_asIdsOrRanges); 397 OPENSSL_assert(choice->type == ASIdentifierChoice_asIdsOrRanges);
399 sk_ASIdOrRange_sort(choice->u.asIdsOrRanges); 398 sk_ASIdOrRange_sort(choice->u.asIdsOrRanges);
400 399
401 /* 400 /*
@@ -413,7 +412,7 @@ static int ASIdentifierChoice_canonize(ASIdentifierChoice *choice)
413 /* 412 /*
414 * Make sure we're properly sorted (paranoia). 413 * Make sure we're properly sorted (paranoia).
415 */ 414 */
416 assert(ASN1_INTEGER_cmp(a_min, b_min) <= 0); 415 OPENSSL_assert(ASN1_INTEGER_cmp(a_min, b_min) <= 0);
417 416
418 /* 417 /*
419 * Check for overlaps. 418 * Check for overlaps.
@@ -472,7 +471,7 @@ static int ASIdentifierChoice_canonize(ASIdentifierChoice *choice)
472 } 471 }
473 } 472 }
474 473
475 assert(ASIdentifierChoice_is_canonical(choice)); /* Paranoia */ 474 OPENSSL_assert(ASIdentifierChoice_is_canonical(choice)); /* Paranoia */
476 475
477 ret = 1; 476 ret = 1;
478 477
@@ -709,9 +708,9 @@ static int v3_asid_validate_path_internal(X509_STORE_CTX *ctx,
709 int i, ret = 1, inherit_as = 0, inherit_rdi = 0; 708 int i, ret = 1, inherit_as = 0, inherit_rdi = 0;
710 X509 *x; 709 X509 *x;
711 710
712 assert(chain != NULL && sk_X509_num(chain) > 0); 711 OPENSSL_assert(chain != NULL && sk_X509_num(chain) > 0);
713 assert(ctx != NULL || ext != NULL); 712 OPENSSL_assert(ctx != NULL || ext != NULL);
714 assert(ctx == NULL || ctx->verify_cb != NULL); 713 OPENSSL_assert(ctx == NULL || ctx->verify_cb != NULL);
715 714
716 /* 715 /*
717 * Figure out where to start. If we don't have an extension to 716 * Figure out where to start. If we don't have an extension to
@@ -724,7 +723,7 @@ static int v3_asid_validate_path_internal(X509_STORE_CTX *ctx,
724 } else { 723 } else {
725 i = 0; 724 i = 0;
726 x = sk_X509_value(chain, i); 725 x = sk_X509_value(chain, i);
727 assert(x != NULL); 726 OPENSSL_assert(x != NULL);
728 if ((ext = x->rfc3779_asid) == NULL) 727 if ((ext = x->rfc3779_asid) == NULL)
729 goto done; 728 goto done;
730 } 729 }
@@ -757,7 +756,7 @@ static int v3_asid_validate_path_internal(X509_STORE_CTX *ctx,
757 */ 756 */
758 for (i++; i < sk_X509_num(chain); i++) { 757 for (i++; i < sk_X509_num(chain); i++) {
759 x = sk_X509_value(chain, i); 758 x = sk_X509_value(chain, i);
760 assert(x != NULL); 759 OPENSSL_assert(x != NULL);
761 if (x->rfc3779_asid == NULL) { 760 if (x->rfc3779_asid == NULL) {
762 if (child_as != NULL || child_rdi != NULL) 761 if (child_as != NULL || child_rdi != NULL)
763 validation_err(X509_V_ERR_UNNESTED_RESOURCE); 762 validation_err(X509_V_ERR_UNNESTED_RESOURCE);
@@ -800,7 +799,7 @@ static int v3_asid_validate_path_internal(X509_STORE_CTX *ctx,
800 /* 799 /*
801 * Trust anchor can't inherit. 800 * Trust anchor can't inherit.
802 */ 801 */
803 assert(x != NULL); 802 OPENSSL_assert(x != NULL);
804 if (x->rfc3779_asid != NULL) { 803 if (x->rfc3779_asid != NULL) {
805 if (x->rfc3779_asid->asnum != NULL && 804 if (x->rfc3779_asid->asnum != NULL &&
806 x->rfc3779_asid->asnum->type == ASIdentifierChoice_inherit) 805 x->rfc3779_asid->asnum->type == ASIdentifierChoice_inherit)
diff --git a/src/lib/libssl/src/crypto/x509v3/v3_ncons.c b/src/lib/libssl/src/crypto/x509v3/v3_ncons.c
index 689df46acd..a01dc64dd2 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3_ncons.c
+++ b/src/lib/libssl/src/crypto/x509v3/v3_ncons.c
@@ -189,7 +189,6 @@ static int do_i2r_name_constraints(const X509V3_EXT_METHOD *method,
189 print_nc_ipadd(bp, tree->base->d.ip); 189 print_nc_ipadd(bp, tree->base->d.ip);
190 else 190 else
191 GENERAL_NAME_print(bp, tree->base); 191 GENERAL_NAME_print(bp, tree->base);
192 tree = sk_GENERAL_SUBTREE_value(trees, i);
193 BIO_puts(bp, "\n"); 192 BIO_puts(bp, "\n");
194 } 193 }
195 return 1; 194 return 1;
diff --git a/src/lib/libssl/src/doc/crypto/EVP_PKEY_verify.pod b/src/lib/libssl/src/doc/crypto/EVP_PKEY_verify.pod
index 10633da3f2..f93e5fc6c3 100644
--- a/src/lib/libssl/src/doc/crypto/EVP_PKEY_verify.pod
+++ b/src/lib/libssl/src/doc/crypto/EVP_PKEY_verify.pod
@@ -69,7 +69,7 @@ Verify signature using PKCS#1 and SHA256 digest:
69 /* Error */ 69 /* Error */
70 70
71 /* Perform operation */ 71 /* Perform operation */
72 ret = EVP_PKEY_verify(ctx, md, mdlen, sig, siglen); 72 ret = EVP_PKEY_verify(ctx, sig, siglen, md, mdlen);
73 73
74 /* ret == 1 indicates success, 0 verify failure and < 0 for some 74 /* ret == 1 indicates success, 0 verify failure and < 0 for some
75 * other error. 75 * other error.
diff --git a/src/lib/libssl/src/engines/Makefile b/src/lib/libssl/src/engines/Makefile
index e0242059b7..2fa9534401 100644
--- a/src/lib/libssl/src/engines/Makefile
+++ b/src/lib/libssl/src/engines/Makefile
@@ -114,7 +114,7 @@ install:
114 if [ "$(PLATFORM)" != "Cygwin" ]; then \ 114 if [ "$(PLATFORM)" != "Cygwin" ]; then \
115 case "$(CFLAGS)" in \ 115 case "$(CFLAGS)" in \
116 *DSO_BEOS*) sfx=".so";; \ 116 *DSO_BEOS*) sfx=".so";; \
117 *DSO_DLFCN*) sfx=".so";; \ 117 *DSO_DLFCN*) sfx=`expr "$(SHLIB_EXT)" : '.*\(\.[a-z][a-z]*\)' \| ".so"`;; \
118 *DSO_DL*) sfx=".sl";; \ 118 *DSO_DL*) sfx=".sl";; \
119 *DSO_WIN32*) sfx="eay32.dll"; pfx=;; \ 119 *DSO_WIN32*) sfx="eay32.dll"; pfx=;; \
120 *) sfx=".bad";; \ 120 *) sfx=".bad";; \
diff --git a/src/lib/libssl/src/engines/ccgost/Makefile b/src/lib/libssl/src/engines/ccgost/Makefile
index 64be962f39..dadb5230ec 100644
--- a/src/lib/libssl/src/engines/ccgost/Makefile
+++ b/src/lib/libssl/src/engines/ccgost/Makefile
@@ -48,7 +48,7 @@ install:
48 if [ "$(PLATFORM)" != "Cygwin" ]; then \ 48 if [ "$(PLATFORM)" != "Cygwin" ]; then \
49 case "$(CFLAGS)" in \ 49 case "$(CFLAGS)" in \
50 *DSO_BEOS*) sfx=".so";; \ 50 *DSO_BEOS*) sfx=".so";; \
51 *DSO_DLFCN*) sfx=".so";; \ 51 *DSO_DLFCN*) sfx=`expr "$(SHLIB_EXT)" : '.*\(\.[a-z][a-z]*\)' \| ".so"`;; \
52 *DSO_DL*) sfx=".sl";; \ 52 *DSO_DL*) sfx=".sl";; \
53 *DSO_WIN32*) sfx="eay32.dll"; pfx=;; \ 53 *DSO_WIN32*) sfx="eay32.dll"; pfx=;; \
54 *) sfx=".bad";; \ 54 *) sfx=".bad";; \
diff --git a/src/lib/libssl/src/engines/ccgost/gost_ameth.c b/src/lib/libssl/src/engines/ccgost/gost_ameth.c
index f620a216c8..e6c2839e5f 100644
--- a/src/lib/libssl/src/engines/ccgost/gost_ameth.c
+++ b/src/lib/libssl/src/engines/ccgost/gost_ameth.c
@@ -39,7 +39,7 @@ static ASN1_STRING *encode_gost_algor_params(const EVP_PKEY *key)
39 ASN1_STRING *params = ASN1_STRING_new(); 39 ASN1_STRING *params = ASN1_STRING_new();
40 GOST_KEY_PARAMS *gkp = GOST_KEY_PARAMS_new(); 40 GOST_KEY_PARAMS *gkp = GOST_KEY_PARAMS_new();
41 int pkey_param_nid = NID_undef; 41 int pkey_param_nid = NID_undef;
42 int cipher_param_nid = NID_undef; 42
43 if (!params || !gkp) 43 if (!params || !gkp)
44 { 44 {
45 GOSTerr(GOST_F_ENCODE_GOST_ALGOR_PARAMS, 45 GOSTerr(GOST_F_ENCODE_GOST_ALGOR_PARAMS,
@@ -52,7 +52,6 @@ static ASN1_STRING *encode_gost_algor_params(const EVP_PKEY *key)
52 { 52 {
53 case NID_id_GostR3410_2001: 53 case NID_id_GostR3410_2001:
54 pkey_param_nid = EC_GROUP_get_curve_name(EC_KEY_get0_group(EVP_PKEY_get0((EVP_PKEY *)key))); 54 pkey_param_nid = EC_GROUP_get_curve_name(EC_KEY_get0_group(EVP_PKEY_get0((EVP_PKEY *)key)));
55 cipher_param_nid = get_encryption_params(NULL)->nid;
56 break; 55 break;
57 case NID_id_GostR3410_94: 56 case NID_id_GostR3410_94:
58 pkey_param_nid = (int) gost94_nid_by_params(EVP_PKEY_get0((EVP_PKEY *)key)); 57 pkey_param_nid = (int) gost94_nid_by_params(EVP_PKEY_get0((EVP_PKEY *)key));
@@ -64,7 +63,6 @@ static ASN1_STRING *encode_gost_algor_params(const EVP_PKEY *key)
64 params=NULL; 63 params=NULL;
65 goto err; 64 goto err;
66 } 65 }
67 cipher_param_nid = get_encryption_params(NULL)->nid;
68 break; 66 break;
69 } 67 }
70 gkp->key_params = OBJ_nid2obj(pkey_param_nid); 68 gkp->key_params = OBJ_nid2obj(pkey_param_nid);
diff --git a/src/lib/libssl/src/engines/ccgost/gost_crypt.c b/src/lib/libssl/src/engines/ccgost/gost_crypt.c
index 4977d1dcf5..cde58c0e9b 100644
--- a/src/lib/libssl/src/engines/ccgost/gost_crypt.c
+++ b/src/lib/libssl/src/engines/ccgost/gost_crypt.c
@@ -495,7 +495,8 @@ int gost89_get_asn1_parameters(EVP_CIPHER_CTX *ctx,ASN1_TYPE *params)
495int gost_imit_init_cpa(EVP_MD_CTX *ctx) 495int gost_imit_init_cpa(EVP_MD_CTX *ctx)
496 { 496 {
497 struct ossl_gost_imit_ctx *c = ctx->md_data; 497 struct ossl_gost_imit_ctx *c = ctx->md_data;
498 memset(c->buffer,0,16); 498 memset(c->buffer,0,sizeof(c->buffer));
499 memset(c->partial_block,0,sizeof(c->partial_block));
499 c->count = 0; 500 c->count = 0;
500 c->bytes_left=0; 501 c->bytes_left=0;
501 c->key_meshing=1; 502 c->key_meshing=1;
diff --git a/src/lib/libssl/src/engines/e_aep.c b/src/lib/libssl/src/engines/e_aep.c
index 742b4f9b18..d7f89e5156 100644
--- a/src/lib/libssl/src/engines/e_aep.c
+++ b/src/lib/libssl/src/engines/e_aep.c
@@ -68,6 +68,8 @@ typedef int pid_t;
68#if defined(OPENSSL_SYS_NETWARE) && defined(NETWARE_CLIB) 68#if defined(OPENSSL_SYS_NETWARE) && defined(NETWARE_CLIB)
69#define getpid GetThreadID 69#define getpid GetThreadID
70extern int GetThreadID(void); 70extern int GetThreadID(void);
71#elif defined(_WIN32) && !defined(__WATCOMC__)
72#define getpid _getpid
71#endif 73#endif
72 74
73#include <openssl/crypto.h> 75#include <openssl/crypto.h>
@@ -867,13 +869,7 @@ static AEP_RV aep_get_connection(AEP_CONNECTION_HNDL_PTR phConnection)
867 869
868 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); 870 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
869 871
870#ifdef NETWARE_CLIB
871 curr_pid = GetThreadID();
872#elif defined(_WIN32)
873 curr_pid = _getpid();
874#else
875 curr_pid = getpid(); 872 curr_pid = getpid();
876#endif
877 873
878 /*Check if this is the first time this is being called from the current 874 /*Check if this is the first time this is being called from the current
879 process*/ 875 process*/
diff --git a/src/lib/libssl/src/engines/e_capi.c b/src/lib/libssl/src/engines/e_capi.c
index e2a7cb58b0..24b620fc07 100644
--- a/src/lib/libssl/src/engines/e_capi.c
+++ b/src/lib/libssl/src/engines/e_capi.c
@@ -76,10 +76,16 @@
76 * CertGetCertificateContextProperty. CERT_KEY_PROV_INFO_PROP_ID is 76 * CertGetCertificateContextProperty. CERT_KEY_PROV_INFO_PROP_ID is
77 * one of possible values you can pass to function in question. By 77 * one of possible values you can pass to function in question. By
78 * checking if it's defined we can see if wincrypt.h and accompanying 78 * checking if it's defined we can see if wincrypt.h and accompanying
79 * crypt32.lib are in shape. Yes, it's rather "weak" test and if 79 * crypt32.lib are in shape. The native MingW32 headers up to and
80 * compilation fails, then re-configure with -DOPENSSL_NO_CAPIENG. 80 * including __W32API_VERSION 3.14 lack of struct DSSPUBKEY and the
81 * defines CERT_STORE_PROV_SYSTEM_A and CERT_STORE_READONLY_FLAG,
82 * so we check for these too and avoid compiling.
83 * Yes, it's rather "weak" test and if compilation fails,
84 * then re-configure with -DOPENSSL_NO_CAPIENG.
81 */ 85 */
82#ifdef CERT_KEY_PROV_INFO_PROP_ID 86#if defined(CERT_KEY_PROV_INFO_PROP_ID) && \
87 defined(CERT_STORE_PROV_SYSTEM_A) && \
88 defined(CERT_STORE_READONLY_FLAG)
83# define __COMPILE_CAPIENG 89# define __COMPILE_CAPIENG
84#endif /* CERT_KEY_PROV_INFO_PROP_ID */ 90#endif /* CERT_KEY_PROV_INFO_PROP_ID */
85#endif /* OPENSSL_NO_CAPIENG */ 91#endif /* OPENSSL_NO_CAPIENG */
@@ -1808,6 +1814,8 @@ static int cert_select_dialog(ENGINE *e, SSL *ssl, STACK_OF(X509) *certs)
1808#include <openssl/engine.h> 1814#include <openssl/engine.h>
1809#ifndef OPENSSL_NO_DYNAMIC_ENGINE 1815#ifndef OPENSSL_NO_DYNAMIC_ENGINE
1810OPENSSL_EXPORT 1816OPENSSL_EXPORT
1817int bind_engine(ENGINE *e, const char *id, const dynamic_fns *fns);
1818OPENSSL_EXPORT
1811int bind_engine(ENGINE *e, const char *id, const dynamic_fns *fns) { return 0; } 1819int bind_engine(ENGINE *e, const char *id, const dynamic_fns *fns) { return 0; }
1812IMPLEMENT_DYNAMIC_CHECK_FN() 1820IMPLEMENT_DYNAMIC_CHECK_FN()
1813#else 1821#else
diff --git a/src/lib/libssl/src/engines/e_capi_err.h b/src/lib/libssl/src/engines/e_capi_err.h
index 4c749ec43d..efa7001038 100644
--- a/src/lib/libssl/src/engines/e_capi_err.h
+++ b/src/lib/libssl/src/engines/e_capi_err.h
@@ -55,6 +55,10 @@
55#ifndef HEADER_CAPI_ERR_H 55#ifndef HEADER_CAPI_ERR_H
56#define HEADER_CAPI_ERR_H 56#define HEADER_CAPI_ERR_H
57 57
58#ifdef __cplusplus
59extern "C" {
60#endif
61
58/* BEGIN ERROR CODES */ 62/* BEGIN ERROR CODES */
59/* The following lines are auto generated by the script mkerr.pl. Any changes 63/* The following lines are auto generated by the script mkerr.pl. Any changes
60 * made after this point may be overwritten when the script is next run. 64 * made after this point may be overwritten when the script is next run.
diff --git a/src/lib/libssl/src/engines/e_chil.c b/src/lib/libssl/src/engines/e_chil.c
index 9c2729c96d..fdc2100e3d 100644
--- a/src/lib/libssl/src/engines/e_chil.c
+++ b/src/lib/libssl/src/engines/e_chil.c
@@ -1077,11 +1077,11 @@ static int hwcrhk_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
1077static int hwcrhk_rsa_finish(RSA *rsa) 1077static int hwcrhk_rsa_finish(RSA *rsa)
1078 { 1078 {
1079 HWCryptoHook_RSAKeyHandle *hptr; 1079 HWCryptoHook_RSAKeyHandle *hptr;
1080 int ret; 1080
1081 hptr = RSA_get_ex_data(rsa, hndidx_rsa); 1081 hptr = RSA_get_ex_data(rsa, hndidx_rsa);
1082 if (hptr) 1082 if (hptr)
1083 { 1083 {
1084 ret = p_hwcrhk_RSAUnloadKey(*hptr, NULL); 1084 p_hwcrhk_RSAUnloadKey(*hptr, NULL);
1085 OPENSSL_free(hptr); 1085 OPENSSL_free(hptr);
1086 RSA_set_ex_data(rsa, hndidx_rsa, NULL); 1086 RSA_set_ex_data(rsa, hndidx_rsa, NULL);
1087 } 1087 }
diff --git a/src/lib/libssl/src/engines/e_cswift.c b/src/lib/libssl/src/engines/e_cswift.c
index bc65179846..2e64ff3277 100644
--- a/src/lib/libssl/src/engines/e_cswift.c
+++ b/src/lib/libssl/src/engines/e_cswift.c
@@ -811,7 +811,6 @@ static DSA_SIG *cswift_dsa_sign(const unsigned char *dgst, int dlen, DSA *dsa)
811 SW_PARAM sw_param; 811 SW_PARAM sw_param;
812 SW_STATUS sw_status; 812 SW_STATUS sw_status;
813 SW_LARGENUMBER arg, res; 813 SW_LARGENUMBER arg, res;
814 unsigned char *ptr;
815 BN_CTX *ctx; 814 BN_CTX *ctx;
816 BIGNUM *dsa_p = NULL; 815 BIGNUM *dsa_p = NULL;
817 BIGNUM *dsa_q = NULL; 816 BIGNUM *dsa_q = NULL;
@@ -899,7 +898,6 @@ static DSA_SIG *cswift_dsa_sign(const unsigned char *dgst, int dlen, DSA *dsa)
899 goto err; 898 goto err;
900 } 899 }
901 /* Convert the response */ 900 /* Convert the response */
902 ptr = (unsigned char *)result->d;
903 if((to_return = DSA_SIG_new()) == NULL) 901 if((to_return = DSA_SIG_new()) == NULL)
904 goto err; 902 goto err;
905 to_return->r = BN_bin2bn((unsigned char *)result->d, 20, NULL); 903 to_return->r = BN_bin2bn((unsigned char *)result->d, 20, NULL);
diff --git a/src/lib/libssl/src/engines/e_gmp.c b/src/lib/libssl/src/engines/e_gmp.c
index c1f5601b62..a3d47151ea 100644
--- a/src/lib/libssl/src/engines/e_gmp.c
+++ b/src/lib/libssl/src/engines/e_gmp.c
@@ -471,6 +471,8 @@ static int bind_fn(ENGINE *e, const char *id)
471IMPLEMENT_DYNAMIC_BIND_FN(bind_fn) 471IMPLEMENT_DYNAMIC_BIND_FN(bind_fn)
472#else 472#else
473OPENSSL_EXPORT 473OPENSSL_EXPORT
474int bind_engine(ENGINE *e, const char *id, const dynamic_fns *fns);
475OPENSSL_EXPORT
474int bind_engine(ENGINE *e, const char *id, const dynamic_fns *fns) { return 0; } 476int bind_engine(ENGINE *e, const char *id, const dynamic_fns *fns) { return 0; }
475#endif 477#endif
476#endif /* !OPENSSL_NO_DYNAMIC_ENGINE */ 478#endif /* !OPENSSL_NO_DYNAMIC_ENGINE */
diff --git a/src/lib/libssl/src/engines/e_padlock.c b/src/lib/libssl/src/engines/e_padlock.c
index 381a746058..7d09419804 100644
--- a/src/lib/libssl/src/engines/e_padlock.c
+++ b/src/lib/libssl/src/engines/e_padlock.c
@@ -108,6 +108,8 @@ static ENGINE *ENGINE_padlock (void);
108# endif 108# endif
109#endif 109#endif
110 110
111#ifdef OPENSSL_NO_DYNAMIC_ENGINE
112
111void ENGINE_load_padlock (void) 113void ENGINE_load_padlock (void)
112{ 114{
113/* On non-x86 CPUs it just returns. */ 115/* On non-x86 CPUs it just returns. */
@@ -120,6 +122,8 @@ void ENGINE_load_padlock (void)
120#endif 122#endif
121} 123}
122 124
125#endif
126
123#ifdef COMPILE_HW_PADLOCK 127#ifdef COMPILE_HW_PADLOCK
124/* We do these includes here to avoid header problems on platforms that 128/* We do these includes here to avoid header problems on platforms that
125 do not have the VIA padlock anyway... */ 129 do not have the VIA padlock anyway... */
@@ -1218,6 +1222,8 @@ static RAND_METHOD padlock_rand = {
1218#else /* !COMPILE_HW_PADLOCK */ 1222#else /* !COMPILE_HW_PADLOCK */
1219#ifndef OPENSSL_NO_DYNAMIC_ENGINE 1223#ifndef OPENSSL_NO_DYNAMIC_ENGINE
1220OPENSSL_EXPORT 1224OPENSSL_EXPORT
1225int bind_engine(ENGINE *e, const char *id, const dynamic_fns *fns);
1226OPENSSL_EXPORT
1221int bind_engine(ENGINE *e, const char *id, const dynamic_fns *fns) { return 0; } 1227int bind_engine(ENGINE *e, const char *id, const dynamic_fns *fns) { return 0; }
1222IMPLEMENT_DYNAMIC_CHECK_FN() 1228IMPLEMENT_DYNAMIC_CHECK_FN()
1223#endif 1229#endif
diff --git a/src/lib/libssl/src/engines/e_ubsec.c b/src/lib/libssl/src/engines/e_ubsec.c
index 9b747b9aea..aa5709bd8c 100644
--- a/src/lib/libssl/src/engines/e_ubsec.c
+++ b/src/lib/libssl/src/engines/e_ubsec.c
@@ -630,10 +630,8 @@ static int ubsec_mod_exp_crt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
630 const BIGNUM *dq, const BIGNUM *qinv, BN_CTX *ctx) 630 const BIGNUM *dq, const BIGNUM *qinv, BN_CTX *ctx)
631 { 631 {
632 int y_len, 632 int y_len,
633 m_len,
634 fd; 633 fd;
635 634
636 m_len = BN_num_bytes(p) + BN_num_bytes(q) + 1;
637 y_len = BN_num_bits(p) + BN_num_bits(q); 635 y_len = BN_num_bits(p) + BN_num_bits(q);
638 636
639 /* Check if hardware can't handle this argument. */ 637 /* Check if hardware can't handle this argument. */
diff --git a/src/lib/libssl/src/ssl/d1_both.c b/src/lib/libssl/src/ssl/d1_both.c
index 4ce4064cc9..2180c6d4da 100644
--- a/src/lib/libssl/src/ssl/d1_both.c
+++ b/src/lib/libssl/src/ssl/d1_both.c
@@ -153,7 +153,7 @@
153#endif 153#endif
154 154
155static unsigned char bitmask_start_values[] = {0xff, 0xfe, 0xfc, 0xf8, 0xf0, 0xe0, 0xc0, 0x80}; 155static unsigned char bitmask_start_values[] = {0xff, 0xfe, 0xfc, 0xf8, 0xf0, 0xe0, 0xc0, 0x80};
156static unsigned char bitmask_end_values[] = {0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f}; 156static unsigned char bitmask_end_values[] = {0xff, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f};
157 157
158/* XDTLS: figure out the right values */ 158/* XDTLS: figure out the right values */
159static unsigned int g_probable_mtu[] = {1500 - 28, 512 - 28, 256 - 28}; 159static unsigned int g_probable_mtu[] = {1500 - 28, 512 - 28, 256 - 28};
@@ -464,20 +464,9 @@ again:
464 464
465 memset(msg_hdr, 0x00, sizeof(struct hm_header_st)); 465 memset(msg_hdr, 0x00, sizeof(struct hm_header_st));
466 466
467 s->d1->handshake_read_seq++; 467 /* Don't change sequence numbers while listening */
468 /* we just read a handshake message from the other side: 468 if (!s->d1->listen)
469 * this means that we don't need to retransmit of the 469 s->d1->handshake_read_seq++;
470 * buffered messages.
471 * XDTLS: may be able clear out this
472 * buffer a little sooner (i.e if an out-of-order
473 * handshake message/record is received at the record
474 * layer.
475 * XDTLS: exception is that the server needs to
476 * know that change cipher spec and finished messages
477 * have been received by the client before clearing this
478 * buffer. this can simply be done by waiting for the
479 * first data segment, but is there a better way? */
480 dtls1_clear_record_buffer(s);
481 470
482 s->init_msg = s->init_buf->data + DTLS1_HM_HEADER_LENGTH; 471 s->init_msg = s->init_buf->data + DTLS1_HM_HEADER_LENGTH;
483 return s->init_num; 472 return s->init_num;
@@ -813,9 +802,11 @@ dtls1_get_message_fragment(SSL *s, int st1, int stn, long max, int *ok)
813 802
814 /* 803 /*
815 * if this is a future (or stale) message it gets buffered 804 * if this is a future (or stale) message it gets buffered
816 * (or dropped)--no further processing at this time 805 * (or dropped)--no further processing at this time
806 * While listening, we accept seq 1 (ClientHello with cookie)
807 * although we're still expecting seq 0 (ClientHello)
817 */ 808 */
818 if ( msg_hdr.seq != s->d1->handshake_read_seq) 809 if (msg_hdr.seq != s->d1->handshake_read_seq && !(s->d1->listen && msg_hdr.seq == 1))
819 return dtls1_process_out_of_seq_message(s, &msg_hdr, ok); 810 return dtls1_process_out_of_seq_message(s, &msg_hdr, ok);
820 811
821 len = msg_hdr.msg_len; 812 len = msg_hdr.msg_len;
@@ -1322,7 +1313,8 @@ unsigned char *
1322dtls1_set_message_header(SSL *s, unsigned char *p, unsigned char mt, 1313dtls1_set_message_header(SSL *s, unsigned char *p, unsigned char mt,
1323 unsigned long len, unsigned long frag_off, unsigned long frag_len) 1314 unsigned long len, unsigned long frag_off, unsigned long frag_len)
1324 { 1315 {
1325 if ( frag_off == 0) 1316 /* Don't change sequence numbers while listening */
1317 if (frag_off == 0 && !s->d1->listen)
1326 { 1318 {
1327 s->d1->handshake_write_seq = s->d1->next_handshake_write_seq; 1319 s->d1->handshake_write_seq = s->d1->next_handshake_write_seq;
1328 s->d1->next_handshake_write_seq++; 1320 s->d1->next_handshake_write_seq++;
diff --git a/src/lib/libssl/src/ssl/d1_clnt.c b/src/lib/libssl/src/ssl/d1_clnt.c
index 5bc9eb6603..089fa4c7f8 100644
--- a/src/lib/libssl/src/ssl/d1_clnt.c
+++ b/src/lib/libssl/src/ssl/d1_clnt.c
@@ -407,7 +407,8 @@ int dtls1_connect(SSL *s)
407 407
408 case SSL3_ST_CW_CHANGE_A: 408 case SSL3_ST_CW_CHANGE_A:
409 case SSL3_ST_CW_CHANGE_B: 409 case SSL3_ST_CW_CHANGE_B:
410 dtls1_start_timer(s); 410 if (!s->hit)
411 dtls1_start_timer(s);
411 ret=dtls1_send_change_cipher_spec(s, 412 ret=dtls1_send_change_cipher_spec(s,
412 SSL3_ST_CW_CHANGE_A,SSL3_ST_CW_CHANGE_B); 413 SSL3_ST_CW_CHANGE_A,SSL3_ST_CW_CHANGE_B);
413 if (ret <= 0) goto end; 414 if (ret <= 0) goto end;
@@ -442,7 +443,8 @@ int dtls1_connect(SSL *s)
442 443
443 case SSL3_ST_CW_FINISHED_A: 444 case SSL3_ST_CW_FINISHED_A:
444 case SSL3_ST_CW_FINISHED_B: 445 case SSL3_ST_CW_FINISHED_B:
445 dtls1_start_timer(s); 446 if (!s->hit)
447 dtls1_start_timer(s);
446 ret=dtls1_send_finished(s, 448 ret=dtls1_send_finished(s,
447 SSL3_ST_CW_FINISHED_A,SSL3_ST_CW_FINISHED_B, 449 SSL3_ST_CW_FINISHED_A,SSL3_ST_CW_FINISHED_B,
448 s->method->ssl3_enc->client_finished_label, 450 s->method->ssl3_enc->client_finished_label,
diff --git a/src/lib/libssl/src/ssl/d1_enc.c b/src/lib/libssl/src/ssl/d1_enc.c
index 8fa57347a9..becbab91c2 100644
--- a/src/lib/libssl/src/ssl/d1_enc.c
+++ b/src/lib/libssl/src/ssl/d1_enc.c
@@ -231,11 +231,7 @@ int dtls1_enc(SSL *s, int send)
231 if (!send) 231 if (!send)
232 { 232 {
233 if (l == 0 || l%bs != 0) 233 if (l == 0 || l%bs != 0)
234 { 234 return -1;
235 SSLerr(SSL_F_DTLS1_ENC,SSL_R_BLOCK_CIPHER_PAD_IS_WRONG);
236 ssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_DECRYPTION_FAILED);
237 return 0;
238 }
239 } 235 }
240 236
241 EVP_Cipher(ds,rec->data,rec->input,l); 237 EVP_Cipher(ds,rec->data,rec->input,l);
diff --git a/src/lib/libssl/src/ssl/d1_lib.c b/src/lib/libssl/src/ssl/d1_lib.c
index 96b220e87c..48e8b6ffbb 100644
--- a/src/lib/libssl/src/ssl/d1_lib.c
+++ b/src/lib/libssl/src/ssl/d1_lib.c
@@ -129,26 +129,33 @@ int dtls1_new(SSL *s)
129 return(1); 129 return(1);
130 } 130 }
131 131
132void dtls1_free(SSL *s) 132static void dtls1_clear_queues(SSL *s)
133 { 133 {
134 pitem *item = NULL; 134 pitem *item = NULL;
135 hm_fragment *frag = NULL; 135 hm_fragment *frag = NULL;
136 136 DTLS1_RECORD_DATA *rdata;
137 ssl3_free(s);
138 137
139 while( (item = pqueue_pop(s->d1->unprocessed_rcds.q)) != NULL) 138 while( (item = pqueue_pop(s->d1->unprocessed_rcds.q)) != NULL)
140 { 139 {
140 rdata = (DTLS1_RECORD_DATA *) item->data;
141 if (rdata->rbuf.buf)
142 {
143 OPENSSL_free(rdata->rbuf.buf);
144 }
141 OPENSSL_free(item->data); 145 OPENSSL_free(item->data);
142 pitem_free(item); 146 pitem_free(item);
143 } 147 }
144 pqueue_free(s->d1->unprocessed_rcds.q);
145 148
146 while( (item = pqueue_pop(s->d1->processed_rcds.q)) != NULL) 149 while( (item = pqueue_pop(s->d1->processed_rcds.q)) != NULL)
147 { 150 {
151 rdata = (DTLS1_RECORD_DATA *) item->data;
152 if (rdata->rbuf.buf)
153 {
154 OPENSSL_free(rdata->rbuf.buf);
155 }
148 OPENSSL_free(item->data); 156 OPENSSL_free(item->data);
149 pitem_free(item); 157 pitem_free(item);
150 } 158 }
151 pqueue_free(s->d1->processed_rcds.q);
152 159
153 while( (item = pqueue_pop(s->d1->buffered_messages)) != NULL) 160 while( (item = pqueue_pop(s->d1->buffered_messages)) != NULL)
154 { 161 {
@@ -157,7 +164,6 @@ void dtls1_free(SSL *s)
157 OPENSSL_free(frag); 164 OPENSSL_free(frag);
158 pitem_free(item); 165 pitem_free(item);
159 } 166 }
160 pqueue_free(s->d1->buffered_messages);
161 167
162 while ( (item = pqueue_pop(s->d1->sent_messages)) != NULL) 168 while ( (item = pqueue_pop(s->d1->sent_messages)) != NULL)
163 { 169 {
@@ -166,7 +172,6 @@ void dtls1_free(SSL *s)
166 OPENSSL_free(frag); 172 OPENSSL_free(frag);
167 pitem_free(item); 173 pitem_free(item);
168 } 174 }
169 pqueue_free(s->d1->sent_messages);
170 175
171 while ( (item = pqueue_pop(s->d1->buffered_app_data.q)) != NULL) 176 while ( (item = pqueue_pop(s->d1->buffered_app_data.q)) != NULL)
172 { 177 {
@@ -175,6 +180,18 @@ void dtls1_free(SSL *s)
175 OPENSSL_free(frag); 180 OPENSSL_free(frag);
176 pitem_free(item); 181 pitem_free(item);
177 } 182 }
183 }
184
185void dtls1_free(SSL *s)
186 {
187 ssl3_free(s);
188
189 dtls1_clear_queues(s);
190
191 pqueue_free(s->d1->unprocessed_rcds.q);
192 pqueue_free(s->d1->processed_rcds.q);
193 pqueue_free(s->d1->buffered_messages);
194 pqueue_free(s->d1->sent_messages);
178 pqueue_free(s->d1->buffered_app_data.q); 195 pqueue_free(s->d1->buffered_app_data.q);
179 196
180 OPENSSL_free(s->d1); 197 OPENSSL_free(s->d1);
@@ -182,6 +199,36 @@ void dtls1_free(SSL *s)
182 199
183void dtls1_clear(SSL *s) 200void dtls1_clear(SSL *s)
184 { 201 {
202 pqueue unprocessed_rcds;
203 pqueue processed_rcds;
204 pqueue buffered_messages;
205 pqueue sent_messages;
206 pqueue buffered_app_data;
207
208 if (s->d1)
209 {
210 unprocessed_rcds = s->d1->unprocessed_rcds.q;
211 processed_rcds = s->d1->processed_rcds.q;
212 buffered_messages = s->d1->buffered_messages;
213 sent_messages = s->d1->sent_messages;
214 buffered_app_data = s->d1->buffered_app_data.q;
215
216 dtls1_clear_queues(s);
217
218 memset(s->d1, 0, sizeof(*(s->d1)));
219
220 if (s->server)
221 {
222 s->d1->cookie_len = sizeof(s->d1->cookie);
223 }
224
225 s->d1->unprocessed_rcds.q = unprocessed_rcds;
226 s->d1->processed_rcds.q = processed_rcds;
227 s->d1->buffered_messages = buffered_messages;
228 s->d1->sent_messages = sent_messages;
229 s->d1->buffered_app_data.q = buffered_app_data;
230 }
231
185 ssl3_clear(s); 232 ssl3_clear(s);
186 if (s->options & SSL_OP_CISCO_ANYCONNECT) 233 if (s->options & SSL_OP_CISCO_ANYCONNECT)
187 s->version=DTLS1_BAD_VER; 234 s->version=DTLS1_BAD_VER;
@@ -330,6 +377,8 @@ void dtls1_stop_timer(SSL *s)
330 memset(&(s->d1->next_timeout), 0, sizeof(struct timeval)); 377 memset(&(s->d1->next_timeout), 0, sizeof(struct timeval));
331 s->d1->timeout_duration = 1; 378 s->d1->timeout_duration = 1;
332 BIO_ctrl(SSL_get_rbio(s), BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT, 0, &(s->d1->next_timeout)); 379 BIO_ctrl(SSL_get_rbio(s), BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT, 0, &(s->d1->next_timeout));
380 /* Clear retransmission buffer */
381 dtls1_clear_record_buffer(s);
333 } 382 }
334 383
335int dtls1_handle_timeout(SSL *s) 384int dtls1_handle_timeout(SSL *s)
@@ -349,7 +398,7 @@ int dtls1_handle_timeout(SSL *s)
349 { 398 {
350 /* fail the connection, enough alerts have been sent */ 399 /* fail the connection, enough alerts have been sent */
351 SSLerr(SSL_F_DTLS1_HANDLE_TIMEOUT,SSL_R_READ_TIMEOUT_EXPIRED); 400 SSLerr(SSL_F_DTLS1_HANDLE_TIMEOUT,SSL_R_READ_TIMEOUT_EXPIRED);
352 return 0; 401 return -1;
353 } 402 }
354 403
355 state->timeout.read_timeouts++; 404 state->timeout.read_timeouts++;
diff --git a/src/lib/libssl/src/ssl/d1_pkt.c b/src/lib/libssl/src/ssl/d1_pkt.c
index a5439d544f..39aac73e10 100644
--- a/src/lib/libssl/src/ssl/d1_pkt.c
+++ b/src/lib/libssl/src/ssl/d1_pkt.c
@@ -296,9 +296,6 @@ dtls1_process_buffered_records(SSL *s)
296 item = pqueue_peek(s->d1->unprocessed_rcds.q); 296 item = pqueue_peek(s->d1->unprocessed_rcds.q);
297 if (item) 297 if (item)
298 { 298 {
299 DTLS1_RECORD_DATA *rdata;
300 rdata = (DTLS1_RECORD_DATA *)item->data;
301
302 /* Check if epoch is current. */ 299 /* Check if epoch is current. */
303 if (s->d1->unprocessed_rcds.epoch != s->d1->r_epoch) 300 if (s->d1->unprocessed_rcds.epoch != s->d1->r_epoch)
304 return(1); /* Nothing to do. */ 301 return(1); /* Nothing to do. */
@@ -412,11 +409,12 @@ dtls1_process_record(SSL *s)
412 enc_err = s->method->ssl3_enc->enc(s,0); 409 enc_err = s->method->ssl3_enc->enc(s,0);
413 if (enc_err <= 0) 410 if (enc_err <= 0)
414 { 411 {
415 if (enc_err == 0) 412 /* decryption failed, silently discard message */
416 /* SSLerr() and ssl3_send_alert() have been called */ 413 if (enc_err < 0)
417 goto err; 414 {
418 415 rr->length = 0;
419 /* otherwise enc_err == -1 */ 416 s->packet_length = 0;
417 }
420 goto err; 418 goto err;
421 } 419 }
422 420
@@ -528,14 +526,12 @@ int dtls1_get_record(SSL *s)
528 int ssl_major,ssl_minor; 526 int ssl_major,ssl_minor;
529 int i,n; 527 int i,n;
530 SSL3_RECORD *rr; 528 SSL3_RECORD *rr;
531 SSL_SESSION *sess;
532 unsigned char *p = NULL; 529 unsigned char *p = NULL;
533 unsigned short version; 530 unsigned short version;
534 DTLS1_BITMAP *bitmap; 531 DTLS1_BITMAP *bitmap;
535 unsigned int is_next_epoch; 532 unsigned int is_next_epoch;
536 533
537 rr= &(s->s3->rrec); 534 rr= &(s->s3->rrec);
538 sess=s->session;
539 535
540 /* The epoch may have changed. If so, process all the 536 /* The epoch may have changed. If so, process all the
541 * pending records. This is a non-blocking operation. */ 537 * pending records. This is a non-blocking operation. */
@@ -662,10 +658,12 @@ again:
662 658
663 /* If this record is from the next epoch (either HM or ALERT), 659 /* If this record is from the next epoch (either HM or ALERT),
664 * and a handshake is currently in progress, buffer it since it 660 * and a handshake is currently in progress, buffer it since it
665 * cannot be processed at this time. */ 661 * cannot be processed at this time. However, do not buffer
662 * anything while listening.
663 */
666 if (is_next_epoch) 664 if (is_next_epoch)
667 { 665 {
668 if (SSL_in_init(s) || s->in_handshake) 666 if ((SSL_in_init(s) || s->in_handshake) && !s->d1->listen)
669 { 667 {
670 dtls1_buffer_record(s, &(s->d1->unprocessed_rcds), rr->seq_num); 668 dtls1_buffer_record(s, &(s->d1->unprocessed_rcds), rr->seq_num);
671 } 669 }
diff --git a/src/lib/libssl/src/ssl/d1_srvr.c b/src/lib/libssl/src/ssl/d1_srvr.c
index 301ceda7a5..a6a4c87ea6 100644
--- a/src/lib/libssl/src/ssl/d1_srvr.c
+++ b/src/lib/libssl/src/ssl/d1_srvr.c
@@ -150,6 +150,7 @@ int dtls1_accept(SSL *s)
150 unsigned long alg_k; 150 unsigned long alg_k;
151 int ret= -1; 151 int ret= -1;
152 int new_state,state,skip=0; 152 int new_state,state,skip=0;
153 int listen;
153 154
154 RAND_add(&Time,sizeof(Time),0); 155 RAND_add(&Time,sizeof(Time),0);
155 ERR_clear_error(); 156 ERR_clear_error();
@@ -159,11 +160,15 @@ int dtls1_accept(SSL *s)
159 cb=s->info_callback; 160 cb=s->info_callback;
160 else if (s->ctx->info_callback != NULL) 161 else if (s->ctx->info_callback != NULL)
161 cb=s->ctx->info_callback; 162 cb=s->ctx->info_callback;
163
164 listen = s->d1->listen;
162 165
163 /* init things to blank */ 166 /* init things to blank */
164 s->in_handshake++; 167 s->in_handshake++;
165 if (!SSL_in_init(s) || SSL_in_before(s)) SSL_clear(s); 168 if (!SSL_in_init(s) || SSL_in_before(s)) SSL_clear(s);
166 169
170 s->d1->listen = listen;
171
167 if (s->cert == NULL) 172 if (s->cert == NULL)
168 { 173 {
169 SSLerr(SSL_F_DTLS1_ACCEPT,SSL_R_NO_CERTIFICATE_SET); 174 SSLerr(SSL_F_DTLS1_ACCEPT,SSL_R_NO_CERTIFICATE_SET);
@@ -273,11 +278,23 @@ int dtls1_accept(SSL *s)
273 278
274 s->init_num=0; 279 s->init_num=0;
275 280
281 /* Reflect ClientHello sequence to remain stateless while listening */
282 if (listen)
283 {
284 memcpy(s->s3->write_sequence, s->s3->read_sequence, sizeof(s->s3->write_sequence));
285 }
286
276 /* If we're just listening, stop here */ 287 /* If we're just listening, stop here */
277 if (s->d1->listen && s->state == SSL3_ST_SW_SRVR_HELLO_A) 288 if (listen && s->state == SSL3_ST_SW_SRVR_HELLO_A)
278 { 289 {
279 ret = 2; 290 ret = 2;
280 s->d1->listen = 0; 291 s->d1->listen = 0;
292 /* Set expected sequence numbers
293 * to continue the handshake.
294 */
295 s->d1->handshake_read_seq = 2;
296 s->d1->handshake_write_seq = 1;
297 s->d1->next_handshake_write_seq = 1;
281 goto end; 298 goto end;
282 } 299 }
283 300
@@ -286,7 +303,6 @@ int dtls1_accept(SSL *s)
286 case DTLS1_ST_SW_HELLO_VERIFY_REQUEST_A: 303 case DTLS1_ST_SW_HELLO_VERIFY_REQUEST_A:
287 case DTLS1_ST_SW_HELLO_VERIFY_REQUEST_B: 304 case DTLS1_ST_SW_HELLO_VERIFY_REQUEST_B:
288 305
289 dtls1_start_timer(s);
290 ret = dtls1_send_hello_verify_request(s); 306 ret = dtls1_send_hello_verify_request(s);
291 if ( ret <= 0) goto end; 307 if ( ret <= 0) goto end;
292 s->state=SSL3_ST_SW_FLUSH; 308 s->state=SSL3_ST_SW_FLUSH;
@@ -736,9 +752,6 @@ int dtls1_send_hello_verify_request(SSL *s)
736 /* number of bytes to write */ 752 /* number of bytes to write */
737 s->init_num=p-buf; 753 s->init_num=p-buf;
738 s->init_off=0; 754 s->init_off=0;
739
740 /* buffer the message to handle re-xmits */
741 dtls1_buffer_message(s, 0);
742 } 755 }
743 756
744 /* s->state = DTLS1_ST_SW_HELLO_VERIFY_REQUEST_B */ 757 /* s->state = DTLS1_ST_SW_HELLO_VERIFY_REQUEST_B */
@@ -1017,12 +1030,11 @@ int dtls1_send_server_key_exchange(SSL *s)
1017 SSLerr(SSL_F_DTLS1_SEND_SERVER_KEY_EXCHANGE,ERR_R_ECDH_LIB); 1030 SSLerr(SSL_F_DTLS1_SEND_SERVER_KEY_EXCHANGE,ERR_R_ECDH_LIB);
1018 goto err; 1031 goto err;
1019 } 1032 }
1020 if (!EC_KEY_up_ref(ecdhp)) 1033 if ((ecdh = EC_KEY_dup(ecdhp)) == NULL)
1021 { 1034 {
1022 SSLerr(SSL_F_DTLS1_SEND_SERVER_KEY_EXCHANGE,ERR_R_ECDH_LIB); 1035 SSLerr(SSL_F_DTLS1_SEND_SERVER_KEY_EXCHANGE,ERR_R_ECDH_LIB);
1023 goto err; 1036 goto err;
1024 } 1037 }
1025 ecdh = ecdhp;
1026 1038
1027 s->s3->tmp.ecdh=ecdh; 1039 s->s3->tmp.ecdh=ecdh;
1028 if ((EC_KEY_get0_public_key(ecdh) == NULL) || 1040 if ((EC_KEY_get0_public_key(ecdh) == NULL) ||
diff --git a/src/lib/libssl/src/test/cms-test.pl b/src/lib/libssl/src/test/cms-test.pl
index 9c50dff3e9..c938bcf00d 100644
--- a/src/lib/libssl/src/test/cms-test.pl
+++ b/src/lib/libssl/src/test/cms-test.pl
@@ -54,9 +54,13 @@
54# OpenSSL PKCS#7 and CMS implementations. 54# OpenSSL PKCS#7 and CMS implementations.
55 55
56my $ossl_path; 56my $ossl_path;
57my $redir = " 2>cms.err 1>cms.out"; 57my $redir = " 2> cms.err > cms.out";
58# Make VMS work
59if ( $^O eq "VMS" && -f "OSSLX:openssl.exe" ) {
60 $ossl_path = "pipe mcr OSSLX:openssl";
61}
58# Make MSYS work 62# Make MSYS work
59if ( $^O eq "MSWin32" && -f "../apps/openssl.exe" ) { 63elsif ( $^O eq "MSWin32" && -f "../apps/openssl.exe" ) {
60 $ossl_path = "cmd /c ..\\apps\\openssl"; 64 $ossl_path = "cmd /c ..\\apps\\openssl";
61} 65}
62elsif ( -f "../apps/openssl$ENV{EXE_EXT}" ) { 66elsif ( -f "../apps/openssl$ENV{EXE_EXT}" ) {
@@ -84,79 +88,79 @@ my @smime_pkcs7_tests = (
84 88
85 [ 89 [
86 "signed content DER format, RSA key", 90 "signed content DER format, RSA key",
87 "-sign -in smcont.txt -outform DER -nodetach" 91 "-sign -in smcont.txt -outform \"DER\" -nodetach"
88 . " -certfile $smdir/smroot.pem" 92 . " -certfile $smdir/smroot.pem"
89 . " -signer $smdir/smrsa1.pem -out test.cms", 93 . " -signer $smdir/smrsa1.pem -out test.cms",
90 "-verify -in test.cms -inform DER " 94 "-verify -in test.cms -inform \"DER\" "
91 . " -CAfile $smdir/smroot.pem -out smtst.txt" 95 . " \"-CAfile\" $smdir/smroot.pem -out smtst.txt"
92 ], 96 ],
93 97
94 [ 98 [
95 "signed detached content DER format, RSA key", 99 "signed detached content DER format, RSA key",
96 "-sign -in smcont.txt -outform DER" 100 "-sign -in smcont.txt -outform \"DER\""
97 . " -signer $smdir/smrsa1.pem -out test.cms", 101 . " -signer $smdir/smrsa1.pem -out test.cms",
98 "-verify -in test.cms -inform DER " 102 "-verify -in test.cms -inform \"DER\" "
99 . " -CAfile $smdir/smroot.pem -out smtst.txt -content smcont.txt" 103 . " \"-CAfile\" $smdir/smroot.pem -out smtst.txt -content smcont.txt"
100 ], 104 ],
101 105
102 [ 106 [
103 "signed content test streaming BER format, RSA", 107 "signed content test streaming BER format, RSA",
104 "-sign -in smcont.txt -outform DER -nodetach" 108 "-sign -in smcont.txt -outform \"DER\" -nodetach"
105 . " -stream -signer $smdir/smrsa1.pem -out test.cms", 109 . " -stream -signer $smdir/smrsa1.pem -out test.cms",
106 "-verify -in test.cms -inform DER " 110 "-verify -in test.cms -inform \"DER\" "
107 . " -CAfile $smdir/smroot.pem -out smtst.txt" 111 . " \"-CAfile\" $smdir/smroot.pem -out smtst.txt"
108 ], 112 ],
109 113
110 [ 114 [
111 "signed content DER format, DSA key", 115 "signed content DER format, DSA key",
112 "-sign -in smcont.txt -outform DER -nodetach" 116 "-sign -in smcont.txt -outform \"DER\" -nodetach"
113 . " -signer $smdir/smdsa1.pem -out test.cms", 117 . " -signer $smdir/smdsa1.pem -out test.cms",
114 "-verify -in test.cms -inform DER " 118 "-verify -in test.cms -inform \"DER\" "
115 . " -CAfile $smdir/smroot.pem -out smtst.txt" 119 . " \"-CAfile\" $smdir/smroot.pem -out smtst.txt"
116 ], 120 ],
117 121
118 [ 122 [
119 "signed detached content DER format, DSA key", 123 "signed detached content DER format, DSA key",
120 "-sign -in smcont.txt -outform DER" 124 "-sign -in smcont.txt -outform \"DER\""
121 . " -signer $smdir/smdsa1.pem -out test.cms", 125 . " -signer $smdir/smdsa1.pem -out test.cms",
122 "-verify -in test.cms -inform DER " 126 "-verify -in test.cms -inform \"DER\" "
123 . " -CAfile $smdir/smroot.pem -out smtst.txt -content smcont.txt" 127 . " \"-CAfile\" $smdir/smroot.pem -out smtst.txt -content smcont.txt"
124 ], 128 ],
125 129
126 [ 130 [
127 "signed detached content DER format, add RSA signer", 131 "signed detached content DER format, add RSA signer",
128 "-resign -inform DER -in test.cms -outform DER" 132 "-resign -inform \"DER\" -in test.cms -outform \"DER\""
129 . " -signer $smdir/smrsa1.pem -out test2.cms", 133 . " -signer $smdir/smrsa1.pem -out test2.cms",
130 "-verify -in test2.cms -inform DER " 134 "-verify -in test2.cms -inform \"DER\" "
131 . " -CAfile $smdir/smroot.pem -out smtst.txt -content smcont.txt" 135 . " \"-CAfile\" $smdir/smroot.pem -out smtst.txt -content smcont.txt"
132 ], 136 ],
133 137
134 [ 138 [
135 "signed content test streaming BER format, DSA key", 139 "signed content test streaming BER format, DSA key",
136 "-sign -in smcont.txt -outform DER -nodetach" 140 "-sign -in smcont.txt -outform \"DER\" -nodetach"
137 . " -stream -signer $smdir/smdsa1.pem -out test.cms", 141 . " -stream -signer $smdir/smdsa1.pem -out test.cms",
138 "-verify -in test.cms -inform DER " 142 "-verify -in test.cms -inform \"DER\" "
139 . " -CAfile $smdir/smroot.pem -out smtst.txt" 143 . " \"-CAfile\" $smdir/smroot.pem -out smtst.txt"
140 ], 144 ],
141 145
142 [ 146 [
143 "signed content test streaming BER format, 2 DSA and 2 RSA keys", 147 "signed content test streaming BER format, 2 DSA and 2 RSA keys",
144 "-sign -in smcont.txt -outform DER -nodetach" 148 "-sign -in smcont.txt -outform \"DER\" -nodetach"
145 . " -signer $smdir/smrsa1.pem -signer $smdir/smrsa2.pem" 149 . " -signer $smdir/smrsa1.pem -signer $smdir/smrsa2.pem"
146 . " -signer $smdir/smdsa1.pem -signer $smdir/smdsa2.pem" 150 . " -signer $smdir/smdsa1.pem -signer $smdir/smdsa2.pem"
147 . " -stream -out test.cms", 151 . " -stream -out test.cms",
148 "-verify -in test.cms -inform DER " 152 "-verify -in test.cms -inform \"DER\" "
149 . " -CAfile $smdir/smroot.pem -out smtst.txt" 153 . " \"-CAfile\" $smdir/smroot.pem -out smtst.txt"
150 ], 154 ],
151 155
152 [ 156 [
153"signed content test streaming BER format, 2 DSA and 2 RSA keys, no attributes", 157"signed content test streaming BER format, 2 DSA and 2 RSA keys, no attributes",
154 "-sign -in smcont.txt -outform DER -noattr -nodetach" 158 "-sign -in smcont.txt -outform \"DER\" -noattr -nodetach"
155 . " -signer $smdir/smrsa1.pem -signer $smdir/smrsa2.pem" 159 . " -signer $smdir/smrsa1.pem -signer $smdir/smrsa2.pem"
156 . " -signer $smdir/smdsa1.pem -signer $smdir/smdsa2.pem" 160 . " -signer $smdir/smdsa1.pem -signer $smdir/smdsa2.pem"
157 . " -stream -out test.cms", 161 . " -stream -out test.cms",
158 "-verify -in test.cms -inform DER " 162 "-verify -in test.cms -inform \"DER\" "
159 . " -CAfile $smdir/smroot.pem -out smtst.txt" 163 . " \"-CAfile\" $smdir/smroot.pem -out smtst.txt"
160 ], 164 ],
161 165
162 [ 166 [
@@ -165,7 +169,7 @@ my @smime_pkcs7_tests = (
165 . " -signer $smdir/smrsa1.pem -signer $smdir/smrsa2.pem" 169 . " -signer $smdir/smrsa1.pem -signer $smdir/smrsa2.pem"
166 . " -signer $smdir/smdsa1.pem -signer $smdir/smdsa2.pem" 170 . " -signer $smdir/smdsa1.pem -signer $smdir/smdsa2.pem"
167 . " -stream -out test.cms", 171 . " -stream -out test.cms",
168 "-verify -in test.cms " . " -CAfile $smdir/smroot.pem -out smtst.txt" 172 "-verify -in test.cms " . " \"-CAfile\" $smdir/smroot.pem -out smtst.txt"
169 ], 173 ],
170 174
171 [ 175 [
@@ -174,7 +178,7 @@ my @smime_pkcs7_tests = (
174 . " -signer $smdir/smrsa1.pem -signer $smdir/smrsa2.pem" 178 . " -signer $smdir/smrsa1.pem -signer $smdir/smrsa2.pem"
175 . " -signer $smdir/smdsa1.pem -signer $smdir/smdsa2.pem" 179 . " -signer $smdir/smdsa1.pem -signer $smdir/smdsa2.pem"
176 . " -stream -out test.cms", 180 . " -stream -out test.cms",
177 "-verify -in test.cms " . " -CAfile $smdir/smroot.pem -out smtst.txt" 181 "-verify -in test.cms " . " \"-CAfile\" $smdir/smroot.pem -out smtst.txt"
178 ], 182 ],
179 183
180 [ 184 [
@@ -215,12 +219,12 @@ my @smime_cms_tests = (
215 219
216 [ 220 [
217 "signed content test streaming BER format, 2 DSA and 2 RSA keys, keyid", 221 "signed content test streaming BER format, 2 DSA and 2 RSA keys, keyid",
218 "-sign -in smcont.txt -outform DER -nodetach -keyid" 222 "-sign -in smcont.txt -outform \"DER\" -nodetach -keyid"
219 . " -signer $smdir/smrsa1.pem -signer $smdir/smrsa2.pem" 223 . " -signer $smdir/smrsa1.pem -signer $smdir/smrsa2.pem"
220 . " -signer $smdir/smdsa1.pem -signer $smdir/smdsa2.pem" 224 . " -signer $smdir/smdsa1.pem -signer $smdir/smdsa2.pem"
221 . " -stream -out test.cms", 225 . " -stream -out test.cms",
222 "-verify -in test.cms -inform DER " 226 "-verify -in test.cms -inform \"DER\" "
223 . " -CAfile $smdir/smroot.pem -out smtst.txt" 227 . " \"-CAfile\" $smdir/smroot.pem -out smtst.txt"
224 ], 228 ],
225 229
226 [ 230 [
@@ -230,7 +234,7 @@ my @smime_cms_tests = (
230 . " -signer $smdir/smdsa1.pem -signer $smdir/smdsa2.pem" 234 . " -signer $smdir/smdsa1.pem -signer $smdir/smdsa2.pem"
231 . " -stream -out test.cms", 235 . " -stream -out test.cms",
232 "-verify -in test.cms -inform PEM " 236 "-verify -in test.cms -inform PEM "
233 . " -CAfile $smdir/smroot.pem -out smtst.txt" 237 . " \"-CAfile\" $smdir/smroot.pem -out smtst.txt"
234 ], 238 ],
235 239
236 [ 240 [
@@ -239,7 +243,7 @@ my @smime_cms_tests = (
239 . " -receipt_request_to test\@openssl.org -receipt_request_all" 243 . " -receipt_request_to test\@openssl.org -receipt_request_all"
240 . " -out test.cms", 244 . " -out test.cms",
241 "-verify -in test.cms " 245 "-verify -in test.cms "
242 . " -CAfile $smdir/smroot.pem -out smtst.txt" 246 . " \"-CAfile\" $smdir/smroot.pem -out smtst.txt"
243 ], 247 ],
244 248
245 [ 249 [
@@ -248,7 +252,7 @@ my @smime_cms_tests = (
248 . " -signer $smdir/smrsa2.pem" 252 . " -signer $smdir/smrsa2.pem"
249 . " -out test2.cms", 253 . " -out test2.cms",
250 "-verify_receipt test2.cms -in test.cms" 254 "-verify_receipt test2.cms -in test.cms"
251 . " -CAfile $smdir/smroot.pem" 255 . " \"-CAfile\" $smdir/smroot.pem"
252 ], 256 ],
253 257
254 [ 258 [
@@ -289,38 +293,38 @@ my @smime_cms_tests = (
289 293
290 [ 294 [
291 "encrypted content test streaming PEM format, 128 bit RC2 key", 295 "encrypted content test streaming PEM format, 128 bit RC2 key",
292 "-EncryptedData_encrypt -in smcont.txt -outform PEM" 296 "\"-EncryptedData_encrypt\" -in smcont.txt -outform PEM"
293 . " -rc2 -secretkey 000102030405060708090A0B0C0D0E0F" 297 . " -rc2 -secretkey 000102030405060708090A0B0C0D0E0F"
294 . " -stream -out test.cms", 298 . " -stream -out test.cms",
295 "-EncryptedData_decrypt -in test.cms -inform PEM " 299 "\"-EncryptedData_decrypt\" -in test.cms -inform PEM "
296 . " -secretkey 000102030405060708090A0B0C0D0E0F -out smtst.txt" 300 . " -secretkey 000102030405060708090A0B0C0D0E0F -out smtst.txt"
297 ], 301 ],
298 302
299 [ 303 [
300 "encrypted content test streaming PEM format, 40 bit RC2 key", 304 "encrypted content test streaming PEM format, 40 bit RC2 key",
301 "-EncryptedData_encrypt -in smcont.txt -outform PEM" 305 "\"-EncryptedData_encrypt\" -in smcont.txt -outform PEM"
302 . " -rc2 -secretkey 0001020304" 306 . " -rc2 -secretkey 0001020304"
303 . " -stream -out test.cms", 307 . " -stream -out test.cms",
304 "-EncryptedData_decrypt -in test.cms -inform PEM " 308 "\"-EncryptedData_decrypt\" -in test.cms -inform PEM "
305 . " -secretkey 0001020304 -out smtst.txt" 309 . " -secretkey 0001020304 -out smtst.txt"
306 ], 310 ],
307 311
308 [ 312 [
309 "encrypted content test streaming PEM format, triple DES key", 313 "encrypted content test streaming PEM format, triple DES key",
310 "-EncryptedData_encrypt -in smcont.txt -outform PEM" 314 "\"-EncryptedData_encrypt\" -in smcont.txt -outform PEM"
311 . " -des3 -secretkey 000102030405060708090A0B0C0D0E0F1011121314151617" 315 . " -des3 -secretkey 000102030405060708090A0B0C0D0E0F1011121314151617"
312 . " -stream -out test.cms", 316 . " -stream -out test.cms",
313 "-EncryptedData_decrypt -in test.cms -inform PEM " 317 "\"-EncryptedData_decrypt\" -in test.cms -inform PEM "
314 . " -secretkey 000102030405060708090A0B0C0D0E0F1011121314151617" 318 . " -secretkey 000102030405060708090A0B0C0D0E0F1011121314151617"
315 . " -out smtst.txt" 319 . " -out smtst.txt"
316 ], 320 ],
317 321
318 [ 322 [
319 "encrypted content test streaming PEM format, 128 bit AES key", 323 "encrypted content test streaming PEM format, 128 bit AES key",
320 "-EncryptedData_encrypt -in smcont.txt -outform PEM" 324 "\"-EncryptedData_encrypt\" -in smcont.txt -outform PEM"
321 . " -aes128 -secretkey 000102030405060708090A0B0C0D0E0F" 325 . " -aes128 -secretkey 000102030405060708090A0B0C0D0E0F"
322 . " -stream -out test.cms", 326 . " -stream -out test.cms",
323 "-EncryptedData_decrypt -in test.cms -inform PEM " 327 "\"-EncryptedData_decrypt\" -in test.cms -inform PEM "
324 . " -secretkey 000102030405060708090A0B0C0D0E0F -out smtst.txt" 328 . " -secretkey 000102030405060708090A0B0C0D0E0F -out smtst.txt"
325 ], 329 ],
326 330