summaryrefslogtreecommitdiffstats
path: root/crypto/evp
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2015-01-22 03:40:55 +0000
committerMatt Caswell <matt@openssl.org>2015-01-22 09:20:09 +0000
commit0f113f3ee4d629ef9a4a30911b22b224772085e5 (patch)
treee014603da5aed1d0751f587a66d6e270b6bda3de /crypto/evp
parent22b52164aaed31d6e93dbd2d397ace041360e6aa (diff)
Run util/openssl-format-source -v -c .
Reviewed-by: Tim Hudson <tjh@openssl.org>
Diffstat (limited to 'crypto/evp')
-rw-r--r--crypto/evp/bio_b64.c1006
-rw-r--r--crypto/evp/bio_enc.c708
-rw-r--r--crypto/evp/bio_md.c347
-rw-r--r--crypto/evp/bio_ok.c1059
-rw-r--r--crypto/evp/c_all.c44
-rw-r--r--crypto/evp/c_allc.c330
-rw-r--r--crypto/evp/c_alld.c72
-rw-r--r--crypto/evp/digest.c433
-rw-r--r--crypto/evp/e_aes.c4521
-rw-r--r--crypto/evp/e_aes_cbc_hmac_sha1.c1764
-rw-r--r--crypto/evp/e_aes_cbc_hmac_sha256.c1709
-rw-r--r--crypto/evp/e_bf.c47
-rw-r--r--crypto/evp/e_camellia.c565
-rw-r--r--crypto/evp/e_cast.c51
-rw-r--r--crypto/evp/e_des.c326
-rw-r--r--crypto/evp/e_des3.c711
-rw-r--r--crypto/evp/e_dsa.c24
-rw-r--r--crypto/evp/e_idea.c87
-rw-r--r--crypto/evp/e_null.c69
-rw-r--r--crypto/evp/e_old.c129
-rw-r--r--crypto/evp/e_rc2.c303
-rw-r--r--crypto/evp/e_rc4.c120
-rw-r--r--crypto/evp/e_rc4_hmac_md5.c448
-rw-r--r--crypto/evp/e_rc5.c102
-rw-r--r--crypto/evp/e_seed.c35
-rw-r--r--crypto/evp/e_xcbc_d.c122
-rw-r--r--crypto/evp/encode.c685
-rw-r--r--crypto/evp/evp.h2063
-rw-r--r--crypto/evp/evp_acnf.c22
-rw-r--r--crypto/evp/evp_cnf.c92
-rw-r--r--crypto/evp/evp_enc.c1071
-rw-r--r--crypto/evp/evp_err.c349
-rw-r--r--crypto/evp/evp_key.c236
-rw-r--r--crypto/evp/evp_lib.c379
-rw-r--r--crypto/evp/evp_locl.h415
-rw-r--r--crypto/evp/evp_pbe.c418
-rw-r--r--crypto/evp/evp_pkey.c235
-rw-r--r--crypto/evp/evp_test.c963
-rw-r--r--crypto/evp/m_dss.c65
-rw-r--r--crypto/evp/m_dss1.c75
-rw-r--r--crypto/evp/m_ecdsa.c65
-rw-r--r--crypto/evp/m_md2.c77
-rw-r--r--crypto/evp/m_md4.c77
-rw-r--r--crypto/evp/m_md5.c77
-rw-r--r--crypto/evp/m_mdc2.c77
-rw-r--r--crypto/evp/m_null.c65
-rw-r--r--crypto/evp/m_ripemd.c77
-rw-r--r--crypto/evp/m_sha.c75
-rw-r--r--crypto/evp/m_sha1.c272
-rw-r--r--crypto/evp/m_sigver.c318
-rw-r--r--crypto/evp/m_wp.c65
-rw-r--r--crypto/evp/names.c269
-rw-r--r--crypto/evp/openbsd_hw.c548
-rw-r--r--crypto/evp/p5_crpt.c142
-rw-r--r--crypto/evp/p5_crpt2.c508
-rw-r--r--crypto/evp/p5_crpt2_test.c268
-rw-r--r--crypto/evp/p_dec.c40
-rw-r--r--crypto/evp/p_enc.c43
-rw-r--r--crypto/evp/p_lib.c585
-rw-r--r--crypto/evp/p_open.c111
-rw-r--r--crypto/evp/p_seal.c88
-rw-r--r--crypto/evp/p_sign.c155
-rw-r--r--crypto/evp/p_verify.c128
-rw-r--r--crypto/evp/pmeth_fn.c516
-rw-r--r--crypto/evp/pmeth_gn.c268
-rw-r--r--crypto/evp/pmeth_lib.c834
66 files changed, 13876 insertions, 14072 deletions
diff --git a/crypto/evp/bio_b64.c b/crypto/evp/bio_b64.c
index 16863fe23f..538b520264 100644
--- a/crypto/evp/bio_b64.c
+++ b/crypto/evp/bio_b64.c
@@ -5,21 +5,21 @@
* This package is an SSL implementation written
* by Eric Young (eay@cryptsoft.com).
* The implementation was written so as to conform with Netscapes SSL.
- *
+ *
* This library is free for commercial and non-commercial use as long as
* the following conditions are aheared to. The following conditions
* apply to all code found in this distribution, be it the RC4, RSA,
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
* included with this distribution is covered by the same copyright terms
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
- *
+ *
* Copyright remains Eric Young's, and as such any Copyright notices in
* the code are not to be removed.
* If this package is used in a product, Eric Young should be given attribution
* as the author of the parts of the library used.
* This can be in the form of a textual message at program startup or
* in documentation (online or textual) provided with the package.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -34,10 +34,10 @@
* Eric Young (eay@cryptsoft.com)"
* The word 'cryptographic' can be left out if the rouines from the library
* being used are not cryptographic related :-).
- * 4. If you include any Windows specific code (or a derivative thereof) from
+ * 4. If you include any Windows specific code (or a derivative thereof) from
* the apps directory (application code) you must include an acknowledgement:
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
- *
+ *
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -49,7 +49,7 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
+ *
* The licence and distribution terms for any publically available version or
* derivative of this code cannot be changed. i.e. this code cannot simply be
* copied and put under another distribution licence
@@ -65,535 +65,509 @@
static int b64_write(BIO *h, const char *buf, int num);
static int b64_read(BIO *h, char *buf, int size);
static int b64_puts(BIO *h, const char *str);
-/*static int b64_gets(BIO *h, char *str, int size); */
+/*
+ * static int b64_gets(BIO *h, char *str, int size);
+ */
static long b64_ctrl(BIO *h, int cmd, long arg1, void *arg2);
static int b64_new(BIO *h);
static int b64_free(BIO *data);
-static long b64_callback_ctrl(BIO *h,int cmd,bio_info_cb *fp);
-#define B64_BLOCK_SIZE 1024
-#define B64_BLOCK_SIZE2 768
-#define B64_NONE 0
-#define B64_ENCODE 1
-#define B64_DECODE 2
-
-typedef struct b64_struct
- {
- /*BIO *bio; moved to the BIO structure */
- int buf_len;
- int buf_off;
- int tmp_len; /* used to find the start when decoding */
- int tmp_nl; /* If true, scan until '\n' */
- int encode;
- int start; /* have we started decoding yet? */
- int cont; /* <= 0 when finished */
- EVP_ENCODE_CTX base64;
- char buf[EVP_ENCODE_LENGTH(B64_BLOCK_SIZE)+10];
- char tmp[B64_BLOCK_SIZE];
- } BIO_B64_CTX;
-
-static BIO_METHOD methods_b64=
- {
- BIO_TYPE_BASE64,"base64 encoding",
- b64_write,
- b64_read,
- b64_puts,
- NULL, /* b64_gets, */
- b64_ctrl,
- b64_new,
- b64_free,
- b64_callback_ctrl,
- };
+static long b64_callback_ctrl(BIO *h, int cmd, bio_info_cb *fp);
+#define B64_BLOCK_SIZE 1024
+#define B64_BLOCK_SIZE2 768
+#define B64_NONE 0
+#define B64_ENCODE 1
+#define B64_DECODE 2
+
+typedef struct b64_struct {
+ /*
+ * BIO *bio; moved to the BIO structure
+ */
+ int buf_len;
+ int buf_off;
+ int tmp_len; /* used to find the start when decoding */
+ int tmp_nl; /* If true, scan until '\n' */
+ int encode;
+ int start; /* have we started decoding yet? */
+ int cont; /* <= 0 when finished */
+ EVP_ENCODE_CTX base64;
+ char buf[EVP_ENCODE_LENGTH(B64_BLOCK_SIZE) + 10];
+ char tmp[B64_BLOCK_SIZE];
+} BIO_B64_CTX;
+
+static BIO_METHOD methods_b64 = {
+ BIO_TYPE_BASE64, "base64 encoding",
+ b64_write,
+ b64_read,
+ b64_puts,
+ NULL, /* b64_gets, */
+ b64_ctrl,
+ b64_new,
+ b64_free,
+ b64_callback_ctrl,
+};
BIO_METHOD *BIO_f_base64(void)
- {
- return(&methods_b64);
- }
+{
+ return (&methods_b64);
+}
static int b64_new(BIO *bi)
- {
- BIO_B64_CTX *ctx;
-
- ctx=(BIO_B64_CTX *)OPENSSL_malloc(sizeof(BIO_B64_CTX));
- if (ctx == NULL) return(0);
-
- ctx->buf_len=0;
- ctx->tmp_len=0;
- ctx->tmp_nl=0;
- ctx->buf_off=0;
- ctx->cont=1;
- ctx->start=1;
- ctx->encode=0;
-
- bi->init=1;
- bi->ptr=(char *)ctx;
- bi->flags=0;
- bi->num = 0;
- return(1);
- }
+{
+ BIO_B64_CTX *ctx;
+
+ ctx = (BIO_B64_CTX *)OPENSSL_malloc(sizeof(BIO_B64_CTX));
+ if (ctx == NULL)
+ return (0);
+
+ ctx->buf_len = 0;
+ ctx->tmp_len = 0;
+ ctx->tmp_nl = 0;
+ ctx->buf_off = 0;
+ ctx->cont = 1;
+ ctx->start = 1;
+ ctx->encode = 0;
+
+ bi->init = 1;
+ bi->ptr = (char *)ctx;
+ bi->flags = 0;
+ bi->num = 0;
+ return (1);
+}
static int b64_free(BIO *a)
- {
- if (a == NULL) return(0);
- OPENSSL_free(a->ptr);
- a->ptr=NULL;
- a->init=0;
- a->flags=0;
- return(1);
- }
-
+{
+ if (a == NULL)
+ return (0);
+ OPENSSL_free(a->ptr);
+ a->ptr = NULL;
+ a->init = 0;
+ a->flags = 0;
+ return (1);
+}
+
static int b64_read(BIO *b, char *out, int outl)
- {
- int ret=0,i,ii,j,k,x,n,num,ret_code=0;
- BIO_B64_CTX *ctx;
- unsigned char *p,*q;
-
- if (out == NULL) return(0);
- ctx=(BIO_B64_CTX *)b->ptr;
-
- if ((ctx == NULL) || (b->next_bio == NULL)) return(0);
-
- BIO_clear_retry_flags(b);
-
- if (ctx->encode != B64_DECODE)
- {
- ctx->encode=B64_DECODE;
- ctx->buf_len=0;
- ctx->buf_off=0;
- ctx->tmp_len=0;
- EVP_DecodeInit(&(ctx->base64));
- }
-
- /* First check if there are bytes decoded/encoded */
- if (ctx->buf_len > 0)
- {
- OPENSSL_assert(ctx->buf_len >= ctx->buf_off);
- i=ctx->buf_len-ctx->buf_off;
- if (i > outl) i=outl;
- OPENSSL_assert(ctx->buf_off+i < (int)sizeof(ctx->buf));
- memcpy(out,&(ctx->buf[ctx->buf_off]),i);
- ret=i;
- out+=i;
- outl-=i;
- ctx->buf_off+=i;
- if (ctx->buf_len == ctx->buf_off)
- {
- ctx->buf_len=0;
- ctx->buf_off=0;
- }
- }
-
- /* At this point, we have room of outl bytes and an empty
- * buffer, so we should read in some more. */
-
- ret_code=0;
- while (outl > 0)
- {
- if (ctx->cont <= 0)
- break;
-
- i=BIO_read(b->next_bio,&(ctx->tmp[ctx->tmp_len]),
- B64_BLOCK_SIZE-ctx->tmp_len);
-
- if (i <= 0)
- {
- ret_code=i;
-
- /* Should we continue next time we are called? */
- if (!BIO_should_retry(b->next_bio))
- {
- ctx->cont=i;
- /* If buffer empty break */
- if(ctx->tmp_len == 0)
- break;
- /* Fall through and process what we have */
- else
- i = 0;
- }
- /* else we retry and add more data to buffer */
- else
- break;
- }
- i+=ctx->tmp_len;
- ctx->tmp_len = i;
-
- /* We need to scan, a line at a time until we
- * have a valid line if we are starting. */
- if (ctx->start && (BIO_get_flags(b) & BIO_FLAGS_BASE64_NO_NL))
- {
- /* ctx->start=1; */
- ctx->tmp_len=0;
- }
- else if (ctx->start)
- {
- q=p=(unsigned char *)ctx->tmp;
- num = 0;
- for (j=0; j<i; j++)
- {
- if (*(q++) != '\n') continue;
-
- /* due to a previous very long line,
- * we need to keep on scanning for a '\n'
- * before we even start looking for
- * base64 encoded stuff. */
- if (ctx->tmp_nl)
- {
- p=q;
- ctx->tmp_nl=0;
- continue;
- }
-
- k=EVP_DecodeUpdate(&(ctx->base64),
- (unsigned char *)ctx->buf,
- &num,p,q-p);
- if ((k <= 0) && (num == 0) && (ctx->start))
- EVP_DecodeInit(&ctx->base64);
- else
- {
- if (p != (unsigned char *)
- &(ctx->tmp[0]))
- {
- i-=(p- (unsigned char *)
- &(ctx->tmp[0]));
- for (x=0; x < i; x++)
- ctx->tmp[x]=p[x];
- }
- EVP_DecodeInit(&ctx->base64);
- ctx->start=0;
- break;
- }
- p=q;
- }
-
- /* we fell off the end without starting */
- if ((j == i) && (num == 0))
- {
- /* Is this is one long chunk?, if so, keep on
- * reading until a new line. */
- if (p == (unsigned char *)&(ctx->tmp[0]))
- {
- /* Check buffer full */
- if (i == B64_BLOCK_SIZE)
- {
- ctx->tmp_nl=1;
- ctx->tmp_len=0;
- }
- }
- else if (p != q) /* finished on a '\n' */
- {
- n=q-p;
- for (ii=0; ii<n; ii++)
- ctx->tmp[ii]=p[ii];
- ctx->tmp_len=n;
- }
- /* else finished on a '\n' */
- continue;
- }
- else
- {
- ctx->tmp_len=0;
- }
- }
- else if ((i < B64_BLOCK_SIZE) && (ctx->cont > 0))
- {
- /* If buffer isn't full and we can retry then
- * restart to read in more data.
- */
- continue;
- }
-
- if (BIO_get_flags(b) & BIO_FLAGS_BASE64_NO_NL)
- {
- int z,jj;
+{
+ int ret = 0, i, ii, j, k, x, n, num, ret_code = 0;
+ BIO_B64_CTX *ctx;
+ unsigned char *p, *q;
+
+ if (out == NULL)
+ return (0);
+ ctx = (BIO_B64_CTX *)b->ptr;
+
+ if ((ctx == NULL) || (b->next_bio == NULL))
+ return (0);
+
+ BIO_clear_retry_flags(b);
+
+ if (ctx->encode != B64_DECODE) {
+ ctx->encode = B64_DECODE;
+ ctx->buf_len = 0;
+ ctx->buf_off = 0;
+ ctx->tmp_len = 0;
+ EVP_DecodeInit(&(ctx->base64));
+ }
+
+ /* First check if there are bytes decoded/encoded */
+ if (ctx->buf_len > 0) {
+ OPENSSL_assert(ctx->buf_len >= ctx->buf_off);
+ i = ctx->buf_len - ctx->buf_off;
+ if (i > outl)
+ i = outl;
+ OPENSSL_assert(ctx->buf_off + i < (int)sizeof(ctx->buf));
+ memcpy(out, &(ctx->buf[ctx->buf_off]), i);
+ ret = i;
+ out += i;
+ outl -= i;
+ ctx->buf_off += i;
+ if (ctx->buf_len == ctx->buf_off) {
+ ctx->buf_len = 0;
+ ctx->buf_off = 0;
+ }
+ }
+
+ /*
+ * At this point, we have room of outl bytes and an empty buffer, so we
+ * should read in some more.
+ */
+
+ ret_code = 0;
+ while (outl > 0) {
+ if (ctx->cont <= 0)
+ break;
+
+ i = BIO_read(b->next_bio, &(ctx->tmp[ctx->tmp_len]),
+ B64_BLOCK_SIZE - ctx->tmp_len);
+
+ if (i <= 0) {
+ ret_code = i;
+
+ /* Should we continue next time we are called? */
+ if (!BIO_should_retry(b->next_bio)) {
+ ctx->cont = i;
+ /* If buffer empty break */
+ if (ctx->tmp_len == 0)
+ break;
+ /* Fall through and process what we have */
+ else
+ i = 0;
+ }
+ /* else we retry and add more data to buffer */
+ else
+ break;
+ }
+ i += ctx->tmp_len;
+ ctx->tmp_len = i;
+
+ /*
+ * We need to scan, a line at a time until we have a valid line if we
+ * are starting.
+ */
+ if (ctx->start && (BIO_get_flags(b) & BIO_FLAGS_BASE64_NO_NL)) {
+ /* ctx->start=1; */
+ ctx->tmp_len = 0;
+ } else if (ctx->start) {
+ q = p = (unsigned char *)ctx->tmp;
+ num = 0;
+ for (j = 0; j < i; j++) {
+ if (*(q++) != '\n')
+ continue;
+
+ /*
+ * due to a previous very long line, we need to keep on
+ * scanning for a '\n' before we even start looking for
+ * base64 encoded stuff.
+ */
+ if (ctx->tmp_nl) {
+ p = q;
+ ctx->tmp_nl = 0;
+ continue;
+ }
+
+ k = EVP_DecodeUpdate(&(ctx->base64),
+ (unsigned char *)ctx->buf,
+ &num, p, q - p);
+ if ((k <= 0) && (num == 0) && (ctx->start))
+ EVP_DecodeInit(&ctx->base64);
+ else {
+ if (p != (unsigned char *)
+ &(ctx->tmp[0])) {
+ i -= (p - (unsigned char *)
+ &(ctx->tmp[0]));
+ for (x = 0; x < i; x++)
+ ctx->tmp[x] = p[x];
+ }
+ EVP_DecodeInit(&ctx->base64);
+ ctx->start = 0;
+ break;
+ }
+ p = q;
+ }
+
+ /* we fell off the end without starting */
+ if ((j == i) && (num == 0)) {
+ /*
+ * Is this is one long chunk?, if so, keep on reading until a
+ * new line.
+ */
+ if (p == (unsigned char *)&(ctx->tmp[0])) {
+ /* Check buffer full */
+ if (i == B64_BLOCK_SIZE) {
+ ctx->tmp_nl = 1;
+ ctx->tmp_len = 0;
+ }
+ } else if (p != q) { /* finished on a '\n' */
+ n = q - p;
+ for (ii = 0; ii < n; ii++)
+ ctx->tmp[ii] = p[ii];
+ ctx->tmp_len = n;
+ }
+ /* else finished on a '\n' */
+ continue;
+ } else {
+ ctx->tmp_len = 0;
+ }
+ } else if ((i < B64_BLOCK_SIZE) && (ctx->cont > 0)) {
+ /*
+ * If buffer isn't full and we can retry then restart to read in
+ * more data.
+ */
+ continue;
+ }
+
+ if (BIO_get_flags(b) & BIO_FLAGS_BASE64_NO_NL) {
+ int z, jj;
#if 0
- jj=(i>>2)<<2;
+ jj = (i >> 2) << 2;
#else
- jj = i & ~3; /* process per 4 */
+ jj = i & ~3; /* process per 4 */
#endif
- z=EVP_DecodeBlock((unsigned char *)ctx->buf,
- (unsigned char *)ctx->tmp,jj);
- if (jj > 2)
- {
- if (ctx->tmp[jj-1] == '=')
- {
- z--;
- if (ctx->tmp[jj-2] == '=')
- z--;
- }
- }
- /* z is now number of output bytes and jj is the
- * number consumed */
- if (jj != i)
- {
- memmove(ctx->tmp, &ctx->tmp[jj], i-jj);
- ctx->tmp_len=i-jj;
- }
- ctx->buf_len=0;
- if (z > 0)
- {
- ctx->buf_len=z;
- }
- i=z;
- }
- else
- {
- i=EVP_DecodeUpdate(&(ctx->base64),
- (unsigned char *)ctx->buf,&ctx->buf_len,
- (unsigned char *)ctx->tmp,i);
- ctx->tmp_len = 0;
- }
- ctx->buf_off=0;
- if (i < 0)
- {
- ret_code=0;
- ctx->buf_len=0;
- break;
- }
-
- if (ctx->buf_len <= outl)
- i=ctx->buf_len;
- else
- i=outl;
-
- memcpy(out,ctx->buf,i);
- ret+=i;
- ctx->buf_off=i;
- if (ctx->buf_off == ctx->buf_len)
- {
- ctx->buf_len=0;
- ctx->buf_off=0;
- }
- outl-=i;
- out+=i;
- }
- /* BIO_clear_retry_flags(b); */
- BIO_copy_next_retry(b);
- return((ret == 0)?ret_code:ret);
- }
+ z = EVP_DecodeBlock((unsigned char *)ctx->buf,
+ (unsigned char *)ctx->tmp, jj);
+ if (jj > 2) {
+ if (ctx->tmp[jj - 1] == '=') {
+ z--;
+ if (ctx->tmp[jj - 2] == '=')
+