Skip to content

Commit e95cd2a

Browse files
committed
update to OpenSSL 1.0.1g
- also add unittest configuration and travis-ci file
1 parent 7876ed2 commit e95cd2a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+3954
-1160
lines changed

.travis.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
language: d
2+
3+
#compiler:
4+
# - dmd
5+
6+
install:
7+
# dmd
8+
# dub
9+
- DMD_VER=2.065.0
10+
- DMD=dmd_${DMD_VER}-0_amd64.deb
11+
- DUB_VER=0.9.21
12+
- DUB=dub-${DUB_VER}-linux-x86_64
13+
- wget http://downloads.dlang.org/releases/2014/${DMD}
14+
- sudo dpkg -i ${DMD} || true
15+
- sudo apt-get -y update || true
16+
- sudo apt-get -fy install || true
17+
- sudo dpkg -i ${DMD}
18+
- wget http://code.dlang.org/files/${DUB}.tar.gz
19+
- sudo tar -C /usr/local/bin -zxf ${DUB}.tar.gz
20+
21+
script:
22+
- dub test

C/aes.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ int AES_set_encrypt_key(const unsigned char *userKey, const int bits,
9090
int AES_set_decrypt_key(const unsigned char *userKey, const int bits,
9191
AES_KEY *key);
9292

93+
int private_AES_set_encrypt_key(const unsigned char *userKey, const int bits,
94+
AES_KEY *key);
95+
int private_AES_set_decrypt_key(const unsigned char *userKey, const int bits,
96+
AES_KEY *key);
97+
9398
void AES_encrypt(const unsigned char *in, unsigned char *out,
9499
const AES_KEY *key);
95100
void AES_decrypt(const unsigned char *in, unsigned char *out,

C/asn1.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ typedef struct asn1_object_st
235235
*/
236236
#define ASN1_STRING_FLAG_MSTRING 0x040
237237
/* This is the base type that holds just about everything :-) */
238-
typedef struct asn1_string_st
238+
struct asn1_string_st
239239
{
240240
int length;
241241
int type;
@@ -245,7 +245,7 @@ typedef struct asn1_string_st
245245
* input data has a non-zero 'unused bits' value, it will be
246246
* handled correctly */
247247
long flags;
248-
} ASN1_STRING;
248+
};
249249

250250
/* ASN1_ENCODING structure: this is used to save the received
251251
* encoding of an ASN1 type. This is useful to get round
@@ -293,7 +293,6 @@ DECLARE_STACK_OF(ASN1_STRING_TABLE)
293293
* see asn1t.h
294294
*/
295295
typedef struct ASN1_TEMPLATE_st ASN1_TEMPLATE;
296-
typedef struct ASN1_ITEM_st ASN1_ITEM;
297296
typedef struct ASN1_TLC_st ASN1_TLC;
298297
/* This is just an opaque pointer */
299298
typedef struct ASN1_VALUE_st ASN1_VALUE;
@@ -1194,6 +1193,7 @@ void ERR_load_ASN1_strings(void);
11941193
#define ASN1_F_ASN1_ITEM_I2D_FP 193
11951194
#define ASN1_F_ASN1_ITEM_PACK 198
11961195
#define ASN1_F_ASN1_ITEM_SIGN 195
1196+
#define ASN1_F_ASN1_ITEM_SIGN_CTX 220
11971197
#define ASN1_F_ASN1_ITEM_UNPACK 199
11981198
#define ASN1_F_ASN1_ITEM_VERIFY 197
11991199
#define ASN1_F_ASN1_MBSTRING_NCOPY 122
@@ -1266,6 +1266,7 @@ void ERR_load_ASN1_strings(void);
12661266
#define ASN1_F_PKCS5_PBE2_SET_IV 167
12671267
#define ASN1_F_PKCS5_PBE_SET 202
12681268
#define ASN1_F_PKCS5_PBE_SET0_ALGOR 215
1269+
#define ASN1_F_PKCS5_PBKDF2_SET 219
12691270
#define ASN1_F_SMIME_READ_ASN1 212
12701271
#define ASN1_F_SMIME_TEXT 213
12711272
#define ASN1_F_X509_CINF_NEW 168
@@ -1291,6 +1292,7 @@ void ERR_load_ASN1_strings(void);
12911292
#define ASN1_R_BOOLEAN_IS_WRONG_LENGTH 106
12921293
#define ASN1_R_BUFFER_TOO_SMALL 107
12931294
#define ASN1_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER 108
1295+
#define ASN1_R_CONTEXT_NOT_INITIALISED 217
12941296
#define ASN1_R_DATA_IS_WRONG 109
12951297
#define ASN1_R_DECODE_ERROR 110
12961298
#define ASN1_R_DECODING_ERROR 111

C/bio.h

Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@
6868

6969
#include <openssl/crypto.h>
7070

71+
#ifndef OPENSSL_NO_SCTP
72+
# ifndef OPENSSL_SYS_VMS
73+
# include <stdint.h>
74+
# else
75+
# include <inttypes.h>
76+
# endif
77+
#endif
78+
7179
#ifdef __cplusplus
7280
extern "C" {
7381
#endif
@@ -95,6 +103,9 @@ extern "C" {
95103
#define BIO_TYPE_BIO (19|0x0400) /* (half a) BIO pair */
96104
#define BIO_TYPE_LINEBUFFER (20|0x0200) /* filter */
97105
#define BIO_TYPE_DGRAM (21|0x0400|0x0100)
106+
#ifndef OPENSSL_NO_SCTP
107+
#define BIO_TYPE_DGRAM_SCTP (24|0x0400|0x0100)
108+
#endif
98109
#define BIO_TYPE_ASN1 (22|0x0200) /* filter */
99110
#define BIO_TYPE_COMP (23|0x0200) /* filter */
100111

@@ -146,6 +157,7 @@ extern "C" {
146157
/* #endif */
147158

148159
#define BIO_CTRL_DGRAM_QUERY_MTU 40 /* as kernel for current MTU */
160+
#define BIO_CTRL_DGRAM_GET_FALLBACK_MTU 47
149161
#define BIO_CTRL_DGRAM_GET_MTU 41 /* get cached value for MTU */
150162
#define BIO_CTRL_DGRAM_SET_MTU 42 /* set cached value for
151163
* MTU. want to use this
@@ -161,7 +173,22 @@ extern "C" {
161173
#define BIO_CTRL_DGRAM_SET_PEER 44 /* Destination for the data */
162174

163175
#define BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT 45 /* Next DTLS handshake timeout to
164-
* adjust socket timeouts */
176+
* adjust socket timeouts */
177+
178+
#ifndef OPENSSL_NO_SCTP
179+
/* SCTP stuff */
180+
#define BIO_CTRL_DGRAM_SCTP_SET_IN_HANDSHAKE 50
181+
#define BIO_CTRL_DGRAM_SCTP_ADD_AUTH_KEY 51
182+
#define BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY 52
183+
#define BIO_CTRL_DGRAM_SCTP_AUTH_CCS_RCVD 53
184+
#define BIO_CTRL_DGRAM_SCTP_GET_SNDINFO 60
185+
#define BIO_CTRL_DGRAM_SCTP_SET_SNDINFO 61
186+
#define BIO_CTRL_DGRAM_SCTP_GET_RCVINFO 62
187+
#define BIO_CTRL_DGRAM_SCTP_SET_RCVINFO 63
188+
#define BIO_CTRL_DGRAM_SCTP_GET_PRINFO 64
189+
#define BIO_CTRL_DGRAM_SCTP_SET_PRINFO 65
190+
#define BIO_CTRL_DGRAM_SCTP_SAVE_SHUTDOWN 70
191+
#endif
165192

166193
/* modifiers */
167194
#define BIO_FP_READ 0x02
@@ -306,6 +333,15 @@ DECLARE_STACK_OF(BIO)
306333

307334
typedef struct bio_f_buffer_ctx_struct
308335
{
336+
/* Buffers are setup like this:
337+
*
338+
* <---------------------- size ----------------------->
339+
* +---------------------------------------------------+
340+
* | consumed | remaining | free space |
341+
* +---------------------------------------------------+
342+
* <-- off --><------- len ------->
343+
*/
344+
309345
/* BIO *bio; */ /* this is now in the BIO struct */
310346
int ibuf_size; /* how big is the input buffer */
311347
int obuf_size; /* how big is the output buffer */
@@ -322,6 +358,34 @@ typedef struct bio_f_buffer_ctx_struct
322358
/* Prefix and suffix callback in ASN1 BIO */
323359
typedef int asn1_ps_func(BIO *b, unsigned char **pbuf, int *plen, void *parg);
324360

361+
#ifndef OPENSSL_NO_SCTP
362+
/* SCTP parameter structs */
363+
struct bio_dgram_sctp_sndinfo
364+
{
365+
uint16_t snd_sid;
366+
uint16_t snd_flags;
367+
uint32_t snd_ppid;
368+
uint32_t snd_context;
369+
};
370+
371+
struct bio_dgram_sctp_rcvinfo
372+
{
373+
uint16_t rcv_sid;
374+
uint16_t rcv_ssn;
375+
uint16_t rcv_flags;
376+
uint32_t rcv_ppid;
377+
uint32_t rcv_tsn;
378+
uint32_t rcv_cumtsn;
379+
uint32_t rcv_context;
380+
};
381+
382+
struct bio_dgram_sctp_prinfo
383+
{
384+
uint16_t pr_policy;
385+
uint32_t pr_value;
386+
};
387+
#endif
388+
325389
/* connect BIO stuff */
326390
#define BIO_CONN_S_BEFORE 1
327391
#define BIO_CONN_S_GET_IP 2
@@ -619,6 +683,9 @@ BIO_METHOD *BIO_f_linebuffer(void);
619683
BIO_METHOD *BIO_f_nbio_test(void);
620684
#ifndef OPENSSL_NO_DGRAM
621685
BIO_METHOD *BIO_s_datagram(void);
686+
#ifndef OPENSSL_NO_SCTP
687+
BIO_METHOD *BIO_s_datagram_sctp(void);
688+
#endif
622689
#endif
623690

624691
/* BIO_METHOD *BIO_f_ber(void); */
@@ -661,6 +728,15 @@ int BIO_set_tcp_ndelay(int sock,int turn_on);
661728

662729
BIO *BIO_new_socket(int sock, int close_flag);
663730
BIO *BIO_new_dgram(int fd, int close_flag);
731+
#ifndef OPENSSL_NO_SCTP
732+
BIO *BIO_new_dgram_sctp(int fd, int close_flag);
733+
int BIO_dgram_is_sctp(BIO *bio);
734+
int BIO_dgram_sctp_notification_cb(BIO *b,
735+
void (*handle_notifications)(BIO *bio, void *context, void *buf),
736+
void *context);
737+
int BIO_dgram_sctp_wait_for_dry(BIO *b);
738+
int BIO_dgram_sctp_msg_waiting(BIO *b);
739+
#endif
664740
BIO *BIO_new_fd(int fd, int close_flag);
665741
BIO *BIO_new_connect(char *host_port);
666742
BIO *BIO_new_accept(char *host_port);
@@ -725,6 +801,7 @@ void ERR_load_BIO_strings(void);
725801
#define BIO_F_BUFFER_CTRL 114
726802
#define BIO_F_CONN_CTRL 127
727803
#define BIO_F_CONN_STATE 115
804+
#define BIO_F_DGRAM_SCTP_READ 132
728805
#define BIO_F_FILE_CTRL 116
729806
#define BIO_F_FILE_READ 130
730807
#define BIO_F_LINEBUFFER_CTRL 129

C/blowfish.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ typedef struct bf_key_st
104104
BF_LONG S[4*256];
105105
} BF_KEY;
106106

107-
107+
#ifdef OPENSSL_FIPS
108+
void private_BF_set_key(BF_KEY *key, int len, const unsigned char *data);
109+
#endif
108110
void BF_set_key(BF_KEY *key, int len, const unsigned char *data);
109111

110112
void BF_encrypt(BF_LONG *data,const BF_KEY *key);

C/bn.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,8 @@ BIGNUM *BN_mod_inverse(BIGNUM *ret,
538538
BIGNUM *BN_mod_sqrt(BIGNUM *ret,
539539
const BIGNUM *a, const BIGNUM *n,BN_CTX *ctx);
540540

541+
void BN_consttime_swap(BN_ULONG swap, BIGNUM *a, BIGNUM *b, int nwords);
542+
541543
/* Deprecated versions */
542544
#ifndef OPENSSL_NO_DEPRECATED
543545
BIGNUM *BN_generate_prime(BIGNUM *ret,int bits,int safe,
@@ -558,6 +560,17 @@ int BN_is_prime_ex(const BIGNUM *p,int nchecks, BN_CTX *ctx, BN_GENCB *cb);
558560
int BN_is_prime_fasttest_ex(const BIGNUM *p,int nchecks, BN_CTX *ctx,
559561
int do_trial_division, BN_GENCB *cb);
560562

563+
int BN_X931_generate_Xpq(BIGNUM *Xp, BIGNUM *Xq, int nbits, BN_CTX *ctx);
564+
565+
int BN_X931_derive_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2,
566+
const BIGNUM *Xp, const BIGNUM *Xp1, const BIGNUM *Xp2,
567+
const BIGNUM *e, BN_CTX *ctx, BN_GENCB *cb);
568+
int BN_X931_generate_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2,
569+
BIGNUM *Xp1, BIGNUM *Xp2,
570+
const BIGNUM *Xp,
571+
const BIGNUM *e, BN_CTX *ctx,
572+
BN_GENCB *cb);
573+
561574
BN_MONT_CTX *BN_MONT_CTX_new(void );
562575
void BN_MONT_CTX_init(BN_MONT_CTX *ctx);
563576
int BN_mod_mul_montgomery(BIGNUM *r,const BIGNUM *a,const BIGNUM *b,
@@ -612,6 +625,8 @@ int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
612625
int BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m,
613626
BN_RECP_CTX *recp, BN_CTX *ctx);
614627

628+
#ifndef OPENSSL_NO_EC2M
629+
615630
/* Functions for arithmetic over binary polynomials represented by BIGNUMs.
616631
*
617632
* The BIGNUM::neg property of BIGNUMs representing binary polynomials is
@@ -663,6 +678,8 @@ int BN_GF2m_mod_solve_quad_arr(BIGNUM *r, const BIGNUM *a,
663678
int BN_GF2m_poly2arr(const BIGNUM *a, int p[], int max);
664679
int BN_GF2m_arr2poly(const int p[], BIGNUM *a);
665680

681+
#endif
682+
666683
/* faster mod functions for the 'NIST primes'
667684
* 0 <= a < p^2 */
668685
int BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
@@ -759,11 +776,20 @@ int RAND_pseudo_bytes(unsigned char *buf,int num);
759776

760777
#define bn_fix_top(a) bn_check_top(a)
761778

779+
#define bn_check_size(bn, bits) bn_wcheck_size(bn, ((bits+BN_BITS2-1))/BN_BITS2)
780+
#define bn_wcheck_size(bn, words) \
781+
do { \
782+
const BIGNUM *_bnum2 = (bn); \
783+
assert(words <= (_bnum2)->dmax && words >= (_bnum2)->top); \
784+
} while(0)
785+
762786
#else /* !BN_DEBUG */
763787

764788
#define bn_pollute(a)
765789
#define bn_check_top(a)
766790
#define bn_fix_top(a) bn_correct_top(a)
791+
#define bn_check_size(bn, bits)
792+
#define bn_wcheck_size(bn, words)
767793

768794
#endif
769795

C/buffer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ int BUF_MEM_grow_clean(BUF_MEM *str, size_t len);
8888
char * BUF_strdup(const char *str);
8989
char * BUF_strndup(const char *str, size_t siz);
9090
void * BUF_memdup(const void *data, size_t siz);
91-
void BUF_reverse(unsigned char *out, unsigned char *in, size_t siz);
91+
void BUF_reverse(unsigned char *out, const unsigned char *in, size_t siz);
9292

9393
/* safe string functions */
9494
size_t BUF_strlcpy(char *dst,const char *src,size_t siz);

C/camellia.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ struct camellia_key_st
8888
};
8989
typedef struct camellia_key_st CAMELLIA_KEY;
9090

91+
#ifdef OPENSSL_FIPS
92+
int private_Camellia_set_key(const unsigned char *userKey, const int bits,
93+
CAMELLIA_KEY *key);
94+
#endif
9195
int Camellia_set_key(const unsigned char *userKey, const int bits,
9296
CAMELLIA_KEY *key);
9397

C/cast.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ typedef struct cast_key_st
8383
int short_key; /* Use reduced rounds for short key */
8484
} CAST_KEY;
8585

86-
86+
#ifdef OPENSSL_FIPS
87+
void private_CAST_set_key(CAST_KEY *key, int len, const unsigned char *data);
88+
#endif
8789
void CAST_set_key(CAST_KEY *key, int len, const unsigned char *data);
8890
void CAST_ecb_encrypt(const unsigned char *in, unsigned char *out, const CAST_KEY *key,
8991
int enc);

0 commit comments

Comments
 (0)