# 32-bit message digests. (For the moment of this writing) HP C
# doesn't seem to "digest" too many local variables (they make "him"
# chew forever:-). For more details look-up MD32_XARRAY comment in
-# crypto/sha/sha_lcl.h.
+# crypto/sha/sha_local.h.
# - originally there were 32-bit hpux-parisc2-* targets. They were
# scrapped, because a) they were not interchangeable with other 32-bit
# targets; b) performance-critical 32-bit assembly modules implement
#include <stdlib.h>
#include <openssl/crypto.h>
#include <openssl/aes.h>
-#include "aes_locl.h"
+#include "aes_local.h"
#ifndef AES_ASM
/*-
#include <assert.h>
#include <openssl/aes.h>
-#include "aes_locl.h"
+#include "aes_local.h"
void AES_ecb_encrypt(const unsigned char *in, unsigned char *out,
const AES_KEY *key, const int enc)
#else
#include <openssl/aes.h>
-#include "aes_locl.h"
+#include "aes_local.h"
#define N_WORDS (AES_BLOCK_SIZE / sizeof(unsigned long))
typedef struct {
--- /dev/null
+/*
+ * Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+#ifndef HEADER_AES_LOCL_H
+# define HEADER_AES_LOCL_H
+
+# include <openssl/e_os2.h>
+# include <stdio.h>
+# include <stdlib.h>
+# include <string.h>
+
+# if defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_AMD64) || defined(_M_X64))
+# define SWAP(x) (_lrotl(x, 8) & 0x00ff00ff | _lrotr(x, 8) & 0xff00ff00)
+# define GETU32(p) SWAP(*((u32 *)(p)))
+# define PUTU32(ct, st) { *((u32 *)(ct)) = SWAP((st)); }
+# else
+# define GETU32(pt) (((u32)(pt)[0] << 24) ^ ((u32)(pt)[1] << 16) ^ ((u32)(pt)[2] << 8) ^ ((u32)(pt)[3]))
+# define PUTU32(ct, st) { (ct)[0] = (u8)((st) >> 24); (ct)[1] = (u8)((st) >> 16); (ct)[2] = (u8)((st) >> 8); (ct)[3] = (u8)(st); }
+# endif
+
+# ifdef AES_LONG
+typedef unsigned long u32;
+# else
+typedef unsigned int u32;
+# endif
+typedef unsigned short u16;
+typedef unsigned char u8;
+
+# define MAXKC (256/32)
+# define MAXKB (256/8)
+# define MAXNR 14
+
+/* This controls loop-unrolling in aes_core.c */
+# undef FULL_UNROLL
+
+#endif /* !HEADER_AES_LOCL_H */
+++ /dev/null
-/*
- * Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-#ifndef HEADER_AES_LOCL_H
-# define HEADER_AES_LOCL_H
-
-# include <openssl/e_os2.h>
-# include <stdio.h>
-# include <stdlib.h>
-# include <string.h>
-
-# if defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_AMD64) || defined(_M_X64))
-# define SWAP(x) (_lrotl(x, 8) & 0x00ff00ff | _lrotr(x, 8) & 0xff00ff00)
-# define GETU32(p) SWAP(*((u32 *)(p)))
-# define PUTU32(ct, st) { *((u32 *)(ct)) = SWAP((st)); }
-# else
-# define GETU32(pt) (((u32)(pt)[0] << 24) ^ ((u32)(pt)[1] << 16) ^ ((u32)(pt)[2] << 8) ^ ((u32)(pt)[3]))
-# define PUTU32(ct, st) { (ct)[0] = (u8)((st) >> 24); (ct)[1] = (u8)((st) >> 16); (ct)[2] = (u8)((st) >> 8); (ct)[3] = (u8)(st); }
-# endif
-
-# ifdef AES_LONG
-typedef unsigned long u32;
-# else
-typedef unsigned int u32;
-# endif
-typedef unsigned short u16;
-typedef unsigned char u8;
-
-# define MAXKC (256/32)
-# define MAXKB (256/8)
-# define MAXNR 14
-
-/* This controls loop-unrolling in aes_core.c */
-# undef FULL_UNROLL
-
-#endif /* !HEADER_AES_LOCL_H */
#include <openssl/opensslv.h>
#include <openssl/aes.h>
-#include "aes_locl.h"
+#include "aes_local.h"
const char *AES_options(void)
{
#include <stdlib.h>
#include <openssl/aes.h>
-#include "aes_locl.h"
+#include "aes_local.h"
/*
* These two parameters control which table, 256-byte or 2KB, is
#include <stdio.h>
#include "internal/cryptlib.h"
#include <openssl/asn1.h>
-#include "asn1_locl.h"
+#include "asn1_local.h"
int ASN1_BIT_STRING_set(ASN1_BIT_STRING *x, unsigned char *d, int len)
{
#include <time.h>
#include "internal/cryptlib.h"
#include <openssl/asn1.h>
-#include "asn1_locl.h"
+#include "asn1_local.h"
/* This is the primary function used to parse ASN1_GENERALIZEDTIME */
int asn1_generalizedtime_to_tm(struct tm *tm, const ASN1_GENERALIZEDTIME *d)
#include <limits.h>
#include <openssl/asn1.h>
#include <openssl/bn.h>
-#include "asn1_locl.h"
+#include "asn1_local.h"
ASN1_INTEGER *ASN1_INTEGER_dup(const ASN1_INTEGER *x)
{
#include <openssl/objects.h>
#include <openssl/bn.h>
#include "crypto/asn1.h"
-#include "asn1_locl.h"
+#include "asn1_local.h"
int i2d_ASN1_OBJECT(const ASN1_OBJECT *a, unsigned char **pp)
{
#include "crypto/ctype.h"
#include "internal/cryptlib.h"
#include <openssl/asn1t.h>
-#include "asn1_locl.h"
+#include "asn1_local.h"
IMPLEMENT_ASN1_MSTRING(ASN1_TIME, B_ASN1_TIME)
#include "internal/cryptlib.h"
#include <openssl/asn1t.h>
#include <openssl/objects.h>
-#include "asn1_locl.h"
+#include "asn1_local.h"
int ASN1_TYPE_get(const ASN1_TYPE *a)
{
#include <time.h>
#include "internal/cryptlib.h"
#include <openssl/asn1.h>
-#include "asn1_locl.h"
+#include "asn1_local.h"
/* This is the primary function used to parse ASN1_UTCTIME */
int asn1_utctime_to_tm(struct tm *tm, const ASN1_UTCTIME *d)
#include <limits.h>
#include "internal/cryptlib.h"
#include <openssl/asn1.h>
-#include "asn1_locl.h"
+#include "asn1_local.h"
static int asn1_get_length(const unsigned char **pp, int *inf, long *rl,
long max);
--- /dev/null
+/*
+ * Copyright 2005-2017 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+/* Internal ASN1 structures and functions: not for application use */
+
+typedef const ASN1_VALUE const_ASN1_VALUE;
+SKM_DEFINE_STACK_OF(const_ASN1_VALUE, const ASN1_VALUE, ASN1_VALUE)
+
+int asn1_time_to_tm(struct tm *tm, const ASN1_TIME *d);
+int asn1_utctime_to_tm(struct tm *tm, const ASN1_UTCTIME *d);
+int asn1_generalizedtime_to_tm(struct tm *tm, const ASN1_GENERALIZEDTIME *d);
+
+/* ASN1 scan context structure */
+
+struct asn1_sctx_st {
+ /* The ASN1_ITEM associated with this field */
+ const ASN1_ITEM *it;
+ /* If ASN1_TEMPLATE associated with this field */
+ const ASN1_TEMPLATE *tt;
+ /* Various flags associated with field and context */
+ unsigned long flags;
+ /* If SEQUENCE OF or SET OF, field index */
+ int skidx;
+ /* ASN1 depth of field */
+ int depth;
+ /* Structure and field name */
+ const char *sname, *fname;
+ /* If a primitive type the type of underlying field */
+ int prim_type;
+ /* The field value itself */
+ ASN1_VALUE **field;
+ /* Callback to pass information to */
+ int (*scan_cb) (ASN1_SCTX *ctx);
+ /* Context specific application data */
+ void *app_data;
+} /* ASN1_SCTX */ ;
+
+typedef struct mime_param_st MIME_PARAM;
+DEFINE_STACK_OF(MIME_PARAM)
+typedef struct mime_header_st MIME_HEADER;
+DEFINE_STACK_OF(MIME_HEADER)
+
+void asn1_string_embed_free(ASN1_STRING *a, int embed);
+
+int asn1_get_choice_selector(ASN1_VALUE **pval, const ASN1_ITEM *it);
+int asn1_get_choice_selector_const(const ASN1_VALUE **pval, const ASN1_ITEM *it);
+int asn1_set_choice_selector(ASN1_VALUE **pval, int value,
+ const ASN1_ITEM *it);
+
+ASN1_VALUE **asn1_get_field_ptr(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt);
+const ASN1_VALUE **asn1_get_const_field_ptr(const ASN1_VALUE **pval,
+ const ASN1_TEMPLATE *tt);
+
+const ASN1_TEMPLATE *asn1_do_adb(const ASN1_VALUE *val, const ASN1_TEMPLATE *tt,
+ int nullerr);
+
+int asn1_do_lock(ASN1_VALUE **pval, int op, const ASN1_ITEM *it);
+
+void asn1_enc_init(ASN1_VALUE **pval, const ASN1_ITEM *it);
+void asn1_enc_free(ASN1_VALUE **pval, const ASN1_ITEM *it);
+int asn1_enc_restore(int *len, unsigned char **out, const ASN1_VALUE **pval,
+ const ASN1_ITEM *it);
+int asn1_enc_save(ASN1_VALUE **pval, const unsigned char *in, int inlen,
+ const ASN1_ITEM *it);
+
+void asn1_item_embed_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed);
+void asn1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed);
+void asn1_template_free(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt);
+
+ASN1_OBJECT *c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp,
+ long length);
+int i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp);
+ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,
+ const unsigned char **pp, long length);
+int i2c_ASN1_INTEGER(ASN1_INTEGER *a, unsigned char **pp);
+ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp,
+ long length);
+
+/* Internal functions used by x_int64.c */
+int c2i_uint64_int(uint64_t *ret, int *neg, const unsigned char **pp, long len);
+int i2c_uint64_int(unsigned char *p, uint64_t r, int neg);
+
+ASN1_TIME *asn1_time_from_tm(ASN1_TIME *s, struct tm *ts, int type);
+++ /dev/null
-/*
- * Copyright 2005-2017 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-/* Internal ASN1 structures and functions: not for application use */
-
-typedef const ASN1_VALUE const_ASN1_VALUE;
-SKM_DEFINE_STACK_OF(const_ASN1_VALUE, const ASN1_VALUE, ASN1_VALUE)
-
-int asn1_time_to_tm(struct tm *tm, const ASN1_TIME *d);
-int asn1_utctime_to_tm(struct tm *tm, const ASN1_UTCTIME *d);
-int asn1_generalizedtime_to_tm(struct tm *tm, const ASN1_GENERALIZEDTIME *d);
-
-/* ASN1 scan context structure */
-
-struct asn1_sctx_st {
- /* The ASN1_ITEM associated with this field */
- const ASN1_ITEM *it;
- /* If ASN1_TEMPLATE associated with this field */
- const ASN1_TEMPLATE *tt;
- /* Various flags associated with field and context */
- unsigned long flags;
- /* If SEQUENCE OF or SET OF, field index */
- int skidx;
- /* ASN1 depth of field */
- int depth;
- /* Structure and field name */
- const char *sname, *fname;
- /* If a primitive type the type of underlying field */
- int prim_type;
- /* The field value itself */
- ASN1_VALUE **field;
- /* Callback to pass information to */
- int (*scan_cb) (ASN1_SCTX *ctx);
- /* Context specific application data */
- void *app_data;
-} /* ASN1_SCTX */ ;
-
-typedef struct mime_param_st MIME_PARAM;
-DEFINE_STACK_OF(MIME_PARAM)
-typedef struct mime_header_st MIME_HEADER;
-DEFINE_STACK_OF(MIME_HEADER)
-
-void asn1_string_embed_free(ASN1_STRING *a, int embed);
-
-int asn1_get_choice_selector(ASN1_VALUE **pval, const ASN1_ITEM *it);
-int asn1_get_choice_selector_const(const ASN1_VALUE **pval, const ASN1_ITEM *it);
-int asn1_set_choice_selector(ASN1_VALUE **pval, int value,
- const ASN1_ITEM *it);
-
-ASN1_VALUE **asn1_get_field_ptr(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt);
-const ASN1_VALUE **asn1_get_const_field_ptr(const ASN1_VALUE **pval,
- const ASN1_TEMPLATE *tt);
-
-const ASN1_TEMPLATE *asn1_do_adb(const ASN1_VALUE *val, const ASN1_TEMPLATE *tt,
- int nullerr);
-
-int asn1_do_lock(ASN1_VALUE **pval, int op, const ASN1_ITEM *it);
-
-void asn1_enc_init(ASN1_VALUE **pval, const ASN1_ITEM *it);
-void asn1_enc_free(ASN1_VALUE **pval, const ASN1_ITEM *it);
-int asn1_enc_restore(int *len, unsigned char **out, const ASN1_VALUE **pval,
- const ASN1_ITEM *it);
-int asn1_enc_save(ASN1_VALUE **pval, const unsigned char *in, int inlen,
- const ASN1_ITEM *it);
-
-void asn1_item_embed_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed);
-void asn1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed);
-void asn1_template_free(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt);
-
-ASN1_OBJECT *c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp,
- long length);
-int i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp);
-ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,
- const unsigned char **pp, long length);
-int i2c_ASN1_INTEGER(ASN1_INTEGER *a, unsigned char **pp);
-ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp,
- long length);
-
-/* Internal functions used by x_int64.c */
-int c2i_uint64_int(uint64_t *ret, int *neg, const unsigned char **pp, long len);
-int i2c_uint64_int(unsigned char *p, uint64_t r, int neg);
-
-ASN1_TIME *asn1_time_from_tm(ASN1_TIME *s, struct tm *ts, int type);
#include <openssl/asn1t.h>
#include "crypto/evp.h"
#include "internal/bio.h"
-#include "asn1_locl.h"
+#include "asn1_local.h"
/*
* Generalised MIME like utilities for streaming ASN1. Although many have a
#include <openssl/buffer.h>
#include <openssl/err.h>
#include "internal/numbers.h"
-#include "asn1_locl.h"
+#include "asn1_local.h"
/*
#include <openssl/asn1t.h>
#include <openssl/objects.h>
#include "crypto/asn1.h"
-#include "asn1_locl.h"
+#include "asn1_local.h"
static int asn1_i2d_ex_primitive(const ASN1_VALUE **pval, unsigned char **out,
const ASN1_ITEM *it, int tag, int aclass);
#include <openssl/asn1.h>
#include <openssl/asn1t.h>
#include <openssl/objects.h>
-#include "asn1_locl.h"
+#include "asn1_local.h"
/* Free up an ASN1 structure */
#include <openssl/err.h>
#include <openssl/asn1t.h>
#include <string.h>
-#include "asn1_locl.h"
+#include "asn1_local.h"
static int asn1_item_embed_new(ASN1_VALUE **pval, const ASN1_ITEM *it,
int embed);
#include <openssl/err.h>
#include <openssl/x509v3.h>
#include "crypto/asn1.h"
-#include "asn1_locl.h"
+#include "asn1_local.h"
/*
* Print routines.
#include <openssl/buffer.h>
#include <openssl/err.h>
#include <openssl/x509v3.h>
-#include "asn1_locl.h"
+#include "asn1_local.h"
/*
* General ASN1 structure recursive scanner: iterate through all fields
#include <openssl/asn1t.h>
#include <openssl/objects.h>
#include <openssl/err.h>
-#include "asn1_locl.h"
+#include "asn1_local.h"
/* Utility functions for manipulating fields and offsets */
#include "internal/numbers.h"
#include <openssl/asn1t.h>
#include <openssl/bn.h>
-#include "asn1_locl.h"
+#include "asn1_local.h"
/*
* Custom primitive types for handling int32_t, int64_t, uint32_t, uint64_t.
*/
/* This must be the first #include file */
-#include "../async_locl.h"
+#include "../async_local.h"
#ifdef ASYNC_NULL
int ASYNC_is_capable(void)
*/
/* This must be the first #include file */
-#include "../async_locl.h"
+#include "../async_local.h"
#ifdef ASYNC_POSIX
*/
/* This must be the first #include file */
-#include "../async_locl.h"
+#include "../async_local.h"
#ifdef ASYNC_WIN
#undef _FORTIFY_SOURCE
/* This must be the first #include file */
-#include "async_locl.h"
+#include "async_local.h"
#include <openssl/err.h>
#include "crypto/cryptlib.h"
--- /dev/null
+/*
+ * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+/*
+ * Must do this before including any header files, because on MacOS/X <stlib.h>
+ * includes <signal.h> which includes <ucontext.h>
+ */
+#if defined(__APPLE__) && defined(__MACH__) && !defined(_XOPEN_SOURCE)
+# define _XOPEN_SOURCE /* Otherwise incomplete ucontext_t structure */
+# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+#endif
+
+#if defined(_WIN32)
+# include <windows.h>
+#endif
+
+#include "crypto/async.h"
+#include <openssl/crypto.h>
+
+typedef struct async_ctx_st async_ctx;
+typedef struct async_pool_st async_pool;
+
+#include "arch/async_win.h"
+#include "arch/async_posix.h"
+#include "arch/async_null.h"
+
+struct async_ctx_st {
+ async_fibre dispatcher;
+ ASYNC_JOB *currjob;
+ unsigned int blocked;
+};
+
+struct async_job_st {
+ async_fibre fibrectx;
+ int (*func) (void *);
+ void *funcargs;
+ int ret;
+ int status;
+ ASYNC_WAIT_CTX *waitctx;
+};
+
+struct fd_lookup_st {
+ const void *key;
+ OSSL_ASYNC_FD fd;
+ void *custom_data;
+ void (*cleanup)(ASYNC_WAIT_CTX *, const void *, OSSL_ASYNC_FD, void *);
+ int add;
+ int del;
+ struct fd_lookup_st *next;
+};
+
+struct async_wait_ctx_st {
+ struct fd_lookup_st *fds;
+ size_t numadd;
+ size_t numdel;
+ ASYNC_callback_fn callback;
+ void *callback_arg;
+ int status;
+};
+
+DEFINE_STACK_OF(ASYNC_JOB)
+
+struct async_pool_st {
+ STACK_OF(ASYNC_JOB) *jobs;
+ size_t curr_size;
+ size_t max_size;
+};
+
+void async_local_cleanup(void);
+void async_start_func(void);
+async_ctx *async_get_ctx(void);
+
+void async_wait_ctx_reset_counts(ASYNC_WAIT_CTX *ctx);
+
+++ /dev/null
-/*
- * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-/*
- * Must do this before including any header files, because on MacOS/X <stlib.h>
- * includes <signal.h> which includes <ucontext.h>
- */
-#if defined(__APPLE__) && defined(__MACH__) && !defined(_XOPEN_SOURCE)
-# define _XOPEN_SOURCE /* Otherwise incomplete ucontext_t structure */
-# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-#endif
-
-#if defined(_WIN32)
-# include <windows.h>
-#endif
-
-#include "crypto/async.h"
-#include <openssl/crypto.h>
-
-typedef struct async_ctx_st async_ctx;
-typedef struct async_pool_st async_pool;
-
-#include "arch/async_win.h"
-#include "arch/async_posix.h"
-#include "arch/async_null.h"
-
-struct async_ctx_st {
- async_fibre dispatcher;
- ASYNC_JOB *currjob;
- unsigned int blocked;
-};
-
-struct async_job_st {
- async_fibre fibrectx;
- int (*func) (void *);
- void *funcargs;
- int ret;
- int status;
- ASYNC_WAIT_CTX *waitctx;
-};
-
-struct fd_lookup_st {
- const void *key;
- OSSL_ASYNC_FD fd;
- void *custom_data;
- void (*cleanup)(ASYNC_WAIT_CTX *, const void *, OSSL_ASYNC_FD, void *);
- int add;
- int del;
- struct fd_lookup_st *next;
-};
-
-struct async_wait_ctx_st {
- struct fd_lookup_st *fds;
- size_t numadd;
- size_t numdel;
- ASYNC_callback_fn callback;
- void *callback_arg;
- int status;
-};
-
-DEFINE_STACK_OF(ASYNC_JOB)
-
-struct async_pool_st {
- STACK_OF(ASYNC_JOB) *jobs;
- size_t curr_size;
- size_t max_size;
-};
-
-void async_local_cleanup(void);
-void async_start_func(void);
-async_ctx *async_get_ctx(void);
-
-void async_wait_ctx_reset_counts(ASYNC_WAIT_CTX *ctx);
-
*/
/* This must be the first #include file */
-#include "async_locl.h"
+#include "async_local.h"
#include <openssl/err.h>
*/
#include <openssl/blowfish.h>
-#include "bf_locl.h"
+#include "bf_local.h"
/*
* The input and output encrypted as though 64bit cfb mode is being used.
*/
#include <openssl/blowfish.h>
-#include "bf_locl.h"
+#include "bf_local.h"
#include <openssl/opensslv.h>
/*
*/
#include <openssl/blowfish.h>
-#include "bf_locl.h"
+#include "bf_local.h"
/*
* Blowfish as implemented from 'Blowfish: Springer-Verlag paper' (From
--- /dev/null
+/*
+ * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+#ifndef HEADER_BF_LOCL_H
+# define HEADER_BF_LOCL_H
+# include <openssl/opensslconf.h>
+
+/* NOTE - c is not incremented as per n2l */
+# define n2ln(c,l1,l2,n) { \
+ c+=n; \
+ l1=l2=0; \
+ switch (n) { \
+ case 8: l2 =((unsigned long)(*(--(c)))) ; \
+ /* fall thru */ \
+ case 7: l2|=((unsigned long)(*(--(c))))<< 8; \
+ /* fall thru */ \
+ case 6: l2|=((unsigned long)(*(--(c))))<<16; \
+ /* fall thru */ \
+ case 5: l2|=((unsigned long)(*(--(c))))<<24; \
+ /* fall thru */ \
+ case 4: l1 =((unsigned long)(*(--(c)))) ; \
+ /* fall thru */ \
+ case 3: l1|=((unsigned long)(*(--(c))))<< 8; \
+ /* fall thru */ \
+ case 2: l1|=((unsigned long)(*(--(c))))<<16; \
+ /* fall thru */ \
+ case 1: l1|=((unsigned long)(*(--(c))))<<24; \
+ } \
+ }
+
+/* NOTE - c is not incremented as per l2n */
+# define l2nn(l1,l2,c,n) { \
+ c+=n; \
+ switch (n) { \
+ case 8: *(--(c))=(unsigned char)(((l2) )&0xff); \
+ /* fall thru */ \
+ case 7: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \
+ /* fall thru */ \
+ case 6: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \
+ /* fall thru */ \
+ case 5: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \
+ /* fall thru */ \
+ case 4: *(--(c))=(unsigned char)(((l1) )&0xff); \
+ /* fall thru */ \
+ case 3: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \
+ /* fall thru */ \
+ case 2: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \
+ /* fall thru */ \
+ case 1: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \
+ } \
+ }
+
+# undef n2l
+# define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24L, \
+ l|=((unsigned long)(*((c)++)))<<16L, \
+ l|=((unsigned long)(*((c)++)))<< 8L, \
+ l|=((unsigned long)(*((c)++))))
+
+# undef l2n
+# define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \
+ *((c)++)=(unsigned char)(((l)>>16L)&0xff), \
+ *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
+ *((c)++)=(unsigned char)(((l) )&0xff))
+
+/*
+ * This is actually a big endian algorithm, the most significant byte is used
+ * to lookup array 0
+ */
+
+# define BF_ENC(LL,R,S,P) ( \
+ LL^=P, \
+ LL^=((( S[ ((R>>24)&0xff)] + \
+ S[0x0100+((R>>16)&0xff)])^ \
+ S[0x0200+((R>> 8)&0xff)])+ \
+ S[0x0300+((R )&0xff)])&0xffffffffU \
+ )
+
+#endif
+++ /dev/null
-/*
- * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-#ifndef HEADER_BF_LOCL_H
-# define HEADER_BF_LOCL_H
-# include <openssl/opensslconf.h>
-
-/* NOTE - c is not incremented as per n2l */
-# define n2ln(c,l1,l2,n) { \
- c+=n; \
- l1=l2=0; \
- switch (n) { \
- case 8: l2 =((unsigned long)(*(--(c)))) ; \
- /* fall thru */ \
- case 7: l2|=((unsigned long)(*(--(c))))<< 8; \
- /* fall thru */ \
- case 6: l2|=((unsigned long)(*(--(c))))<<16; \
- /* fall thru */ \
- case 5: l2|=((unsigned long)(*(--(c))))<<24; \
- /* fall thru */ \
- case 4: l1 =((unsigned long)(*(--(c)))) ; \
- /* fall thru */ \
- case 3: l1|=((unsigned long)(*(--(c))))<< 8; \
- /* fall thru */ \
- case 2: l1|=((unsigned long)(*(--(c))))<<16; \
- /* fall thru */ \
- case 1: l1|=((unsigned long)(*(--(c))))<<24; \
- } \
- }
-
-/* NOTE - c is not incremented as per l2n */
-# define l2nn(l1,l2,c,n) { \
- c+=n; \
- switch (n) { \
- case 8: *(--(c))=(unsigned char)(((l2) )&0xff); \
- /* fall thru */ \
- case 7: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \
- /* fall thru */ \
- case 6: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \
- /* fall thru */ \
- case 5: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \
- /* fall thru */ \
- case 4: *(--(c))=(unsigned char)(((l1) )&0xff); \
- /* fall thru */ \
- case 3: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \
- /* fall thru */ \
- case 2: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \
- /* fall thru */ \
- case 1: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \
- } \
- }
-
-# undef n2l
-# define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24L, \
- l|=((unsigned long)(*((c)++)))<<16L, \
- l|=((unsigned long)(*((c)++)))<< 8L, \
- l|=((unsigned long)(*((c)++))))
-
-# undef l2n
-# define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \
- *((c)++)=(unsigned char)(((l)>>16L)&0xff), \
- *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
- *((c)++)=(unsigned char)(((l) )&0xff))
-
-/*
- * This is actually a big endian algorithm, the most significant byte is used
- * to lookup array 0
- */
-
-# define BF_ENC(LL,R,S,P) ( \
- LL^=P, \
- LL^=((( S[ ((R>>24)&0xff)] + \
- S[0x0100+((R>>16)&0xff)])^ \
- S[0x0200+((R>> 8)&0xff)])+ \
- S[0x0300+((R )&0xff)])&0xffffffffU \
- )
-
-#endif
*/
#include <openssl/blowfish.h>
-#include "bf_locl.h"
+#include "bf_local.h"
/*
* The input and output encrypted as though 64bit ofb mode is being used.
#include <stdio.h>
#include <string.h>
#include <openssl/blowfish.h>
-#include "bf_locl.h"
+#include "bf_local.h"
#include "bf_pi.h"
void BF_set_key(BF_KEY *key, int len, const unsigned char *data)
#include <assert.h>
#include <string.h>
-#include "bio_lcl.h"
+#include "bio_local.h"
#include <openssl/crypto.h>
#ifndef OPENSSL_NO_SOCK
static CRYPTO_ONCE bio_lookup_init = CRYPTO_ONCE_STATIC_INIT;
/*
- * Throughout this file and bio_lcl.h, the existence of the macro
+ * Throughout this file and bio_local.h, the existence of the macro
* AI_PASSIVE is used to detect the availability of struct addrinfo,
* getnameinfo() and getaddrinfo(). If that macro doesn't exist,
* we use our own implementation instead, using gethostbyname,
hints.ai_flags |= AI_PASSIVE;
/* Note that |res| SHOULD be a 'struct addrinfo **' thanks to
- * macro magic in bio_lcl.h
+ * macro magic in bio_local.h
*/
retry:
switch ((gai_ret = getaddrinfo(host, service, &hints, res))) {
*/
#include <stdio.h>
-#include "bio_lcl.h"
+#include "bio_local.h"
#define DUMP_WIDTH 16
#define DUMP_WIDTH_LESS_INDENT(i) (DUMP_WIDTH - ((i - (i > 6 ? 6 : i) + 3) / 4))
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
-#include "bio_lcl.h"
+#include "bio_local.h"
#ifndef OPENSSL_NO_SOCK
# define SOCKET_PROTOCOL IPPROTO_TCP
# ifdef SO_MAXCONN
#include <stdlib.h>
#include <errno.h>
-#include "bio_lcl.h"
+#include "bio_local.h"
#include <openssl/err.h>
#include <stdio.h>
#include <errno.h>
-#include "bio_lcl.h"
+#include "bio_local.h"
#include "internal/cryptlib.h"
static int buffer_write(BIO *h, const char *buf, int num);
#include <stdio.h>
#include <errno.h>
-#include "bio_lcl.h"
+#include "bio_local.h"
#include "internal/cryptlib.h"
#include <openssl/evp.h>
#include <stdio.h>
#include <errno.h>
-#include "bio_lcl.h"
+#include "bio_local.h"
#include "internal/cryptlib.h"
#include <openssl/rand.h>
#include <stdio.h>
#include <errno.h>
-#include "bio_lcl.h"
+#include "bio_local.h"
#include "internal/cryptlib.h"
/*
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
-#include "bio_lcl.h"
+#include "bio_local.h"
#include "internal/cryptlib.h"
#include <openssl/err.h>
+++ /dev/null
-/*
- * Copyright 2005-2016 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-#include "e_os.h"
-#include "internal/sockets.h"
-#include "internal/refcount.h"
-
-/* BEGIN BIO_ADDRINFO/BIO_ADDR stuff. */
-
-#ifndef OPENSSL_NO_SOCK
-/*
- * Throughout this file and b_addr.c, the existence of the macro
- * AI_PASSIVE is used to detect the availability of struct addrinfo,
- * getnameinfo() and getaddrinfo(). If that macro doesn't exist,
- * we use our own implementation instead.
- */
-
-/*
- * It's imperative that these macros get defined before openssl/bio.h gets
- * included. Otherwise, the AI_PASSIVE hack will not work properly.
- * For clarity, we check for internal/cryptlib.h since it's a common header
- * that also includes bio.h.
- */
-# ifdef HEADER_CRYPTLIB_H
-# error internal/cryptlib.h included before bio_lcl.h
-# endif
-# ifdef HEADER_BIO_H
-# error openssl/bio.h included before bio_lcl.h
-# endif
-
-/*
- * Undefine AF_UNIX on systems that define it but don't support it.
- */
-# if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_VMS)
-# undef AF_UNIX
-# endif
-
-# ifdef AI_PASSIVE
-
-/*
- * There's a bug in VMS C header file netdb.h, where struct addrinfo
- * always is the P32 variant, but the functions that handle that structure,
- * such as getaddrinfo() and freeaddrinfo() adapt to the initial pointer
- * size. The easiest workaround is to force struct addrinfo to be the
- * 64-bit variant when compiling in P64 mode.
- */
-# if defined(OPENSSL_SYS_VMS) && __INITIAL_POINTER_SIZE == 64
-# define addrinfo __addrinfo64
-# endif
-
-# define bio_addrinfo_st addrinfo
-# define bai_family ai_family
-# define bai_socktype ai_socktype
-# define bai_protocol ai_protocol
-# define bai_addrlen ai_addrlen
-# define bai_addr ai_addr
-# define bai_next ai_next
-# else
-struct bio_addrinfo_st {
- int bai_family;
- int bai_socktype;
- int bai_protocol;
- size_t bai_addrlen;
- struct sockaddr *bai_addr;
- struct bio_addrinfo_st *bai_next;
-};
-# endif
-
-union bio_addr_st {
- struct sockaddr sa;
-# ifdef AF_INET6
- struct sockaddr_in6 s_in6;
-# endif
- struct sockaddr_in s_in;
-# ifdef AF_UNIX
- struct sockaddr_un s_un;
-# endif
-};
-#endif
-
-/* END BIO_ADDRINFO/BIO_ADDR stuff. */
-
-#include "internal/cryptlib.h"
-#include "internal/bio.h"
-
-typedef struct bio_f_buffer_ctx_struct {
- /*-
- * Buffers are setup like this:
- *
- * <---------------------- size ----------------------->
- * +---------------------------------------------------+
- * | consumed | remaining | free space |
- * +---------------------------------------------------+
- * <-- off --><------- len ------->
- */
- /*- BIO *bio; *//*
- * this is now in the BIO struct
- */
- int ibuf_size; /* how big is the input buffer */
- int obuf_size; /* how big is the output buffer */
- char *ibuf; /* the char array */
- int ibuf_len; /* how many bytes are in it */
- int ibuf_off; /* write/read offset */
- char *obuf; /* the char array */
- int obuf_len; /* how many bytes are in it */
- int obuf_off; /* write/read offset */
-} BIO_F_BUFFER_CTX;
-
-struct bio_st {
- const BIO_METHOD *method;
- /* bio, mode, argp, argi, argl, ret */
- BIO_callback_fn callback;
- BIO_callback_fn_ex callback_ex;
- char *cb_arg; /* first argument for the callback */
- int init;
- int shutdown;
- int flags; /* extra storage */
- int retry_reason;
- int num;
- void *ptr;
- struct bio_st *next_bio; /* used by filter BIOs */
- struct bio_st *prev_bio; /* used by filter BIOs */
- CRYPTO_REF_COUNT references;
- uint64_t num_read;
- uint64_t num_write;
- CRYPTO_EX_DATA ex_data;
- CRYPTO_RWLOCK *lock;
-};
-
-#ifndef OPENSSL_NO_SOCK
-# ifdef OPENSSL_SYS_VMS
-typedef unsigned int socklen_t;
-# endif
-
-extern CRYPTO_RWLOCK *bio_lookup_lock;
-
-int BIO_ADDR_make(BIO_ADDR *ap, const struct sockaddr *sa);
-const struct sockaddr *BIO_ADDR_sockaddr(const BIO_ADDR *ap);
-struct sockaddr *BIO_ADDR_sockaddr_noconst(BIO_ADDR *ap);
-socklen_t BIO_ADDR_sockaddr_size(const BIO_ADDR *ap);
-socklen_t BIO_ADDRINFO_sockaddr_size(const BIO_ADDRINFO *bai);
-const struct sockaddr *BIO_ADDRINFO_sockaddr(const BIO_ADDRINFO *bai);
-#endif
-
-extern CRYPTO_RWLOCK *bio_type_lock;
-
-void bio_sock_cleanup_int(void);
-
-#if BIO_FLAGS_UPLINK_INTERNAL==0
-/* Shortcut UPLINK calls on most platforms... */
-# define UP_stdin stdin
-# define UP_stdout stdout
-# define UP_stderr stderr
-# define UP_fprintf fprintf
-# define UP_fgets fgets
-# define UP_fread fread
-# define UP_fwrite fwrite
-# undef UP_fsetmod
-# define UP_feof feof
-# define UP_fclose fclose
-
-# define UP_fopen fopen
-# define UP_fseek fseek
-# define UP_ftell ftell
-# define UP_fflush fflush
-# define UP_ferror ferror
-# ifdef _WIN32
-# define UP_fileno _fileno
-# define UP_open _open
-# define UP_read _read
-# define UP_write _write
-# define UP_lseek _lseek
-# define UP_close _close
-# else
-# define UP_fileno fileno
-# define UP_open open
-# define UP_read read
-# define UP_write write
-# define UP_lseek lseek
-# define UP_close close
-# endif
-
-#endif
-
#include <stdio.h>
#include <errno.h>
#include <openssl/crypto.h>
-#include "bio_lcl.h"
+#include "bio_local.h"
#include "internal/cryptlib.h"
--- /dev/null
+/*
+ * Copyright 2005-2016 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+#include "e_os.h"
+#include "internal/sockets.h"
+#include "internal/refcount.h"
+
+/* BEGIN BIO_ADDRINFO/BIO_ADDR stuff. */
+
+#ifndef OPENSSL_NO_SOCK
+/*
+ * Throughout this file and b_addr.c, the existence of the macro
+ * AI_PASSIVE is used to detect the availability of struct addrinfo,
+ * getnameinfo() and getaddrinfo(). If that macro doesn't exist,
+ * we use our own implementation instead.
+ */
+
+/*
+ * It's imperative that these macros get defined before openssl/bio.h gets
+ * included. Otherwise, the AI_PASSIVE hack will not work properly.
+ * For clarity, we check for internal/cryptlib.h since it's a common header
+ * that also includes bio.h.
+ */
+# ifdef HEADER_CRYPTLIB_H
+# error internal/cryptlib.h included before bio_local.h
+# endif
+# ifdef HEADER_BIO_H
+# error openssl/bio.h included before bio_local.h
+# endif
+
+/*
+ * Undefine AF_UNIX on systems that define it but don't support it.
+ */
+# if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_VMS)
+# undef AF_UNIX
+# endif
+
+# ifdef AI_PASSIVE
+
+/*
+ * There's a bug in VMS C header file netdb.h, where struct addrinfo
+ * always is the P32 variant, but the functions that handle that structure,
+ * such as getaddrinfo() and freeaddrinfo() adapt to the initial pointer
+ * size. The easiest workaround is to force struct addrinfo to be the
+ * 64-bit variant when compiling in P64 mode.
+ */
+# if defined(OPENSSL_SYS_VMS) && __INITIAL_POINTER_SIZE == 64
+# define addrinfo __addrinfo64
+# endif
+
+# define bio_addrinfo_st addrinfo
+# define bai_family ai_family
+# define bai_socktype ai_socktype
+# define bai_protocol ai_protocol
+# define bai_addrlen ai_addrlen
+# define bai_addr ai_addr
+# define bai_next ai_next
+# else
+struct bio_addrinfo_st {
+ int bai_family;
+ int bai_socktype;
+ int bai_protocol;
+ size_t bai_addrlen;
+ struct sockaddr *bai_addr;
+ struct bio_addrinfo_st *bai_next;
+};
+# endif
+
+union bio_addr_st {
+ struct sockaddr sa;
+# ifdef AF_INET6
+ struct sockaddr_in6 s_in6;
+# endif
+ struct sockaddr_in s_in;
+# ifdef AF_UNIX
+ struct sockaddr_un s_un;
+# endif
+};
+#endif
+
+/* END BIO_ADDRINFO/BIO_ADDR stuff. */
+
+#include "internal/cryptlib.h"
+#include "internal/bio.h"
+
+typedef struct bio_f_buffer_ctx_struct {
+ /*-
+ * Buffers are setup like this:
+ *
+ * <---------------------- size ----------------------->
+ * +---------------------------------------------------+
+ * | consumed | remaining | free space |
+ * +---------------------------------------------------+
+ * <-- off --><------- len ------->
+ */
+ /*- BIO *bio; *//*
+ * this is now in the BIO struct
+ */
+ int ibuf_size; /* how big is the input buffer */
+ int obuf_size; /* how big is the output buffer */
+ char *ibuf; /* the char array */
+ int ibuf_len; /* how many bytes are in it */
+ int ibuf_off; /* write/read offset */
+ char *obuf; /* the char array */
+ int obuf_len; /* how many bytes are in it */
+ int obuf_off; /* write/read offset */
+} BIO_F_BUFFER_CTX;
+
+struct bio_st {
+ const BIO_METHOD *method;
+ /* bio, mode, argp, argi, argl, ret */
+ BIO_callback_fn callback;
+ BIO_callback_fn_ex callback_ex;
+ char *cb_arg; /* first argument for the callback */
+ int init;
+ int shutdown;
+ int flags; /* extra storage */
+ int retry_reason;
+ int num;
+ void *ptr;
+ struct bio_st *next_bio; /* used by filter BIOs */
+ struct bio_st *prev_bio; /* used by filter BIOs */
+ CRYPTO_REF_COUNT references;
+ uint64_t num_read;
+ uint64_t num_write;
+ CRYPTO_EX_DATA ex_data;
+ CRYPTO_RWLOCK *lock;
+};
+
+#ifndef OPENSSL_NO_SOCK
+# ifdef OPENSSL_SYS_VMS
+typedef unsigned int socklen_t;
+# endif
+
+extern CRYPTO_RWLOCK *bio_lookup_lock;
+
+int BIO_ADDR_make(BIO_ADDR *ap, const struct sockaddr *sa);
+const struct sockaddr *BIO_ADDR_sockaddr(const BIO_ADDR *ap);
+struct sockaddr *BIO_ADDR_sockaddr_noconst(BIO_ADDR *ap);
+socklen_t BIO_ADDR_sockaddr_size(const BIO_ADDR *ap);
+socklen_t BIO_ADDRINFO_sockaddr_size(const BIO_ADDRINFO *bai);
+const struct sockaddr *BIO_ADDRINFO_sockaddr(const BIO_ADDRINFO *bai);
+#endif
+
+extern CRYPTO_RWLOCK *bio_type_lock;
+
+void bio_sock_cleanup_int(void);
+
+#if BIO_FLAGS_UPLINK_INTERNAL==0
+/* Shortcut UPLINK calls on most platforms... */
+# define UP_stdin stdin
+# define UP_stdout stdout
+# define UP_stderr stderr
+# define UP_fprintf fprintf
+# define UP_fgets fgets
+# define UP_fread fread
+# define UP_fwrite fwrite
+# undef UP_fsetmod
+# define UP_feof feof
+# define UP_fclose fclose
+
+# define UP_fopen fopen
+# define UP_fseek fseek
+# define UP_ftell ftell
+# define UP_fflush fflush
+# define UP_ferror ferror
+# ifdef _WIN32
+# define UP_fileno _fileno
+# define UP_open _open
+# define UP_read _read
+# define UP_write _write
+# define UP_lseek _lseek
+# define UP_close _close
+# else
+# define UP_fileno fileno
+# define UP_open open
+# define UP_read read
+# define UP_write write
+# define UP_lseek lseek
+# define UP_close close
+# endif
+
+#endif
+
* https://www.openssl.org/source/license.html
*/
-#include "bio_lcl.h"
+#include "bio_local.h"
#include "internal/thread_once.h"
CRYPTO_RWLOCK *bio_type_lock = NULL;
#include <stdio.h>
#include <errno.h>
-#include "bio_lcl.h"
+#include "bio_local.h"
#ifndef OPENSSL_NO_SOCK
#include <stdlib.h>
#include <string.h>
-#include "bio_lcl.h"
+#include "bio_local.h"
#include <openssl/err.h>
#include <openssl/crypto.h>
#include <stdio.h>
#include <errno.h>
-#include "bio_lcl.h"
+#include "bio_local.h"
#ifndef OPENSSL_NO_SOCK
#include <stdio.h>
#include <errno.h>
-#include "bio_lcl.h"
+#include "bio_local.h"
#ifndef OPENSSL_NO_DGRAM
# ifndef OPENSSL_NO_SCTP
#include <stdio.h>
#include <errno.h>
-#include "bio_lcl.h"
+#include "bio_local.h"
#if defined(OPENSSL_NO_POSIX_IO)
/*
#include <stdio.h>
#include <errno.h>
-#include "bio_lcl.h"
+#include "bio_local.h"
#include <openssl/err.h>
#if !defined(OPENSSL_NO_STDIO)
#include <stdio.h>
#include <errno.h>
-#include "bio_lcl.h"
+#include "bio_local.h"
#include "internal/cryptlib.h"
#if defined(OPENSSL_SYS_WINCE)
#include <stdio.h>
#include <errno.h>
-#include "bio_lcl.h"
+#include "bio_local.h"
#include "internal/cryptlib.h"
static int mem_write(BIO *h, const char *buf, int num);
#include <stdio.h>
#include <errno.h>
-#include "bio_lcl.h"
+#include "bio_local.h"
#include "internal/cryptlib.h"
static int null_write(BIO *h, const char *buf, int num);
#include <stdio.h>
#include <errno.h>
-#include "bio_lcl.h"
+#include "bio_local.h"
#include "internal/cryptlib.h"
#include "internal/ktls.h"
The implementations use the following macros which, depending on the
architecture, may use "long long" C operations or inline assembler.
-They are defined in C<bn_lcl.h>.
+They are defined in C<bn_local.h>.
mul(B<r>, B<a>, B<w>, B<c>) computes B<w>*B<a>+B<c> and places the
low word of the result in B<r> and the high word in B<c>.
* https://www.openssl.org/source/license.html
*/
-#include "../bn_lcl.h"
+#include "../bn_local.h"
#if !(defined(__GNUC__) && __GNUC__>=2)
# include "../bn_asm.c" /* kind of dirty hack for Sun Studio */
#else
*/
#include "internal/cryptlib.h"
-#include "bn_lcl.h"
+#include "bn_local.h"
/* signed add of b to a. */
int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)
#include <assert.h>
#include <openssl/crypto.h>
#include "internal/cryptlib.h"
-#include "bn_lcl.h"
+#include "bn_local.h"
#if defined(BN_LLONG) || defined(BN_UMULT_HIGH)
#include <openssl/opensslconf.h>
#include "internal/cryptlib.h"
-#include "bn_lcl.h"
+#include "bn_local.h"
#define BN_BLINDING_COUNTER 32
#include <openssl/err.h>
#include "crypto/ctype.h"
-#include "bn_lcl.h"
+#include "bn_local.h"
static const char Hex[] = "0123456789ABCDEF";
#include <openssl/trace.h>
#include "internal/cryptlib.h"
-#include "bn_lcl.h"
+#include "bn_local.h"
/*-
* TODO list
# include <stdio.h>
# include <time.h>
# include "internal/cryptlib.h"
-# include "bn_lcl.h"
+# include "bn_local.h"
BIGNUM *BN_generate_prime(BIGNUM *ret, int bits, int safe,
const BIGNUM *add, const BIGNUM *rem,
* https://www.openssl.org/source/license.html
*/
-#include "bn_lcl.h"
+#include "bn_local.h"
#include "internal/nelem.h"
#ifndef OPENSSL_NO_DH
#include <assert.h>
#include <openssl/bn.h>
#include "internal/cryptlib.h"
-#include "bn_lcl.h"
+#include "bn_local.h"
/* The old slow way */
#if 0
*/
#include "internal/cryptlib.h"
-#include "internal/constant_time_locl.h"
-#include "bn_lcl.h"
+#include "internal/constant_time.h"
+#include "bn_local.h"
#include <stdlib.h>
#ifdef _WIN32
#include <stdio.h>
#include "internal/cryptlib.h"
-#include "bn_lcl.h"
+#include "bn_local.h"
#define TABLE_SIZE 32
*/
#include "internal/cryptlib.h"
-#include "bn_lcl.h"
+#include "bn_local.h"
static BIGNUM *euclid(BIGNUM *a, BIGNUM *b);
#include <limits.h>
#include <stdio.h>
#include "internal/cryptlib.h"
-#include "bn_lcl.h"
+#include "bn_local.h"
#ifndef OPENSSL_NO_EC2M
*/
#include "internal/cryptlib.h"
-#include "bn_lcl.h"
+#include "bn_local.h"
/*
* Determine the modified width-(w+1) Non-Adjacent Form (wNAF) of 'scalar'.
*/
#include "internal/cryptlib.h"
-#include "bn_lcl.h"
+#include "bn_local.h"
/* least significant word */
#define BN_lsw(n) (((n)->top == 0) ? (BN_ULONG) 0 : (n)->d[0])
+++ /dev/null
-/*
- * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-#ifndef HEADER_BN_LCL_H
-# define HEADER_BN_LCL_H
-
-/*
- * The EDK2 build doesn't use bn_conf.h; it sets THIRTY_TWO_BIT or
- * SIXTY_FOUR_BIT in its own environment since it doesn't re-run our
- * Configure script and needs to support both 32-bit and 64-bit.
- */
-# include <openssl/opensslconf.h>
-
-# if !defined(OPENSSL_SYS_UEFI)
-# include "crypto/bn_conf.h"
-# endif
-
-# include "crypto/bn.h"
-
-/*
- * These preprocessor symbols control various aspects of the bignum headers
- * and library code. They're not defined by any "normal" configuration, as
- * they are intended for development and testing purposes. NB: defining all
- * three can be useful for debugging application code as well as openssl
- * itself. BN_DEBUG - turn on various debugging alterations to the bignum
- * code BN_DEBUG_RAND - uses random poisoning of unused words to trip up
- * mismanagement of bignum internals. You must also define BN_DEBUG.
- */
-/* #define BN_DEBUG */
-/* #define BN_DEBUG_RAND */
-
-# ifndef OPENSSL_SMALL_FOOTPRINT
-# define BN_MUL_COMBA
-# define BN_SQR_COMBA
-# define BN_RECURSION
-# endif
-
-/*
- * This next option uses the C libraries (2 word)/(1 word) function. If it is
- * not defined, I use my C version (which is slower). The reason for this
- * flag is that when the particular C compiler library routine is used, and
- * the library is linked with a different compiler, the library is missing.
- * This mostly happens when the library is built with gcc and then linked
- * using normal cc. This would be a common occurrence because gcc normally
- * produces code that is 2 times faster than system compilers for the big
- * number stuff. For machines with only one compiler (or shared libraries),
- * this should be on. Again this in only really a problem on machines using
- * "long long's", are 32bit, and are not using my assembler code.
- */
-# if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WINDOWS) || \
- defined(OPENSSL_SYS_WIN32) || defined(linux)
-# define BN_DIV2W
-# endif
-
-/*
- * 64-bit processor with LP64 ABI
- */
-# ifdef SIXTY_FOUR_BIT_LONG
-# define BN_ULLONG unsigned long long
-# define BN_BITS4 32
-# define BN_MASK2 (0xffffffffffffffffL)
-# define BN_MASK2l (0xffffffffL)
-# define BN_MASK2h (0xffffffff00000000L)
-# define BN_MASK2h1 (0xffffffff80000000L)
-# define BN_DEC_CONV (10000000000000000000UL)
-# define BN_DEC_NUM 19
-# define BN_DEC_FMT1 "%lu"
-# define BN_DEC_FMT2 "%019lu"
-# endif
-
-/*
- * 64-bit processor other than LP64 ABI
- */
-# ifdef SIXTY_FOUR_BIT
-# undef BN_LLONG
-# undef BN_ULLONG
-# define BN_BITS4 32
-# define BN_MASK2 (0xffffffffffffffffLL)
-# define BN_MASK2l (0xffffffffL)
-# define BN_MASK2h (0xffffffff00000000LL)
-# define BN_MASK2h1 (0xffffffff80000000LL)
-# define BN_DEC_CONV (10000000000000000000ULL)
-# define BN_DEC_NUM 19
-# define BN_DEC_FMT1 "%llu"
-# define BN_DEC_FMT2 "%019llu"
-# endif
-
-# ifdef THIRTY_TWO_BIT
-# ifdef BN_LLONG
-# if defined(_WIN32) && !defined(__GNUC__)
-# define BN_ULLONG unsigned __int64
-# else
-# define BN_ULLONG unsigned long long
-# endif
-# endif
-# define BN_BITS4 16
-# define BN_MASK2 (0xffffffffL)
-# define BN_MASK2l (0xffff)
-# define BN_MASK2h1 (0xffff8000L)
-# define BN_MASK2h (0xffff0000L)
-# define BN_DEC_CONV (1000000000L)
-# define BN_DEC_NUM 9
-# define BN_DEC_FMT1 "%u"
-# define BN_DEC_FMT2 "%09u"
-# endif
-
-
-/*-
- * Bignum consistency macros
- * There is one "API" macro, bn_fix_top(), for stripping leading zeroes from
- * bignum data after direct manipulations on the data. There is also an
- * "internal" macro, bn_check_top(), for verifying that there are no leading
- * zeroes. Unfortunately, some auditing is required due to the fact that
- * bn_fix_top() has become an overabused duct-tape because bignum data is
- * occasionally passed around in an inconsistent state. So the following
- * changes have been made to sort this out;
- * - bn_fix_top()s implementation has been moved to bn_correct_top()
- * - if BN_DEBUG isn't defined, bn_fix_top() maps to bn_correct_top(), and
- * bn_check_top() is as before.
- * - if BN_DEBUG *is* defined;
- * - bn_check_top() tries to pollute unused words even if the bignum 'top' is
- * consistent. (ed: only if BN_DEBUG_RAND is defined)
- * - bn_fix_top() maps to bn_check_top() rather than "fixing" anything.
- * The idea is to have debug builds flag up inconsistent bignums when they
- * occur. If that occurs in a bn_fix_top(), we examine the code in question; if
- * the use of bn_fix_top() was appropriate (ie. it follows directly after code
- * that manipulates the bignum) it is converted to bn_correct_top(), and if it
- * was not appropriate, we convert it permanently to bn_check_top() and track
- * down the cause of the bug. Eventually, no internal code should be using the
- * bn_fix_top() macro. External applications and libraries should try this with
- * their own code too, both in terms of building against the openssl headers
- * with BN_DEBUG defined *and* linking with a version of OpenSSL built with it
- * defined. This not only improves external code, it provides more test
- * coverage for openssl's own code.
- */
-
-# ifdef BN_DEBUG
-/*
- * The new BN_FLG_FIXED_TOP flag marks vectors that were not treated with
- * bn_correct_top, in other words such vectors are permitted to have zeros
- * in most significant limbs. Such vectors are used internally to achieve
- * execution time invariance for critical operations with private keys.
- * It's BN_DEBUG-only flag, because user application is not supposed to
- * observe it anyway. Moreover, optimizing compiler would actually remove
- * all operations manipulating the bit in question in non-BN_DEBUG build.
- */
-# define BN_FLG_FIXED_TOP 0x10000
-# ifdef BN_DEBUG_RAND
-# define bn_pollute(a) \
- do { \
- const BIGNUM *_bnum1 = (a); \
- if (_bnum1->top < _bnum1->dmax) { \
- unsigned char _tmp_char; \
- /* We cast away const without the compiler knowing, any \
- * *genuinely* constant variables that aren't mutable \
- * wouldn't be constructed with top!=dmax. */ \
- BN_ULONG *_not_const; \
- memcpy(&_not_const, &_bnum1->d, sizeof(_not_const)); \
- RAND_bytes(&_tmp_char, 1); /* Debug only - safe to ignore error return */\
- memset(_not_const + _bnum1->top, _tmp_char, \
- sizeof(*_not_const) * (_bnum1->dmax - _bnum1->top)); \
- } \
- } while(0)
-# else
-# define bn_pollute(a)
-# endif
-# define bn_check_top(a) \
- do { \
- const BIGNUM *_bnum2 = (a); \
- if (_bnum2 != NULL) { \
- int _top = _bnum2->top; \
- (void)ossl_assert((_top == 0 && !_bnum2->neg) || \
- (_top && ((_bnum2->flags & BN_FLG_FIXED_TOP) \
- || _bnum2->d[_top - 1] != 0))); \
- bn_pollute(_bnum2); \
- } \
- } while(0)
-
-# define bn_fix_top(a) bn_check_top(a)
-
-# define bn_check_size(bn, bits) bn_wcheck_size(bn, ((bits+BN_BITS2-1))/BN_BITS2)
-# define bn_wcheck_size(bn, words) \
- do { \
- const BIGNUM *_bnum2 = (bn); \
- assert((words) <= (_bnum2)->dmax && \
- (words) >= (_bnum2)->top); \
- /* avoid unused variable warning with NDEBUG */ \
- (void)(_bnum2); \
- } while(0)
-
-# else /* !BN_DEBUG */
-
-# define BN_FLG_FIXED_TOP 0
-# define bn_pollute(a)
-# define bn_check_top(a)
-# define bn_fix_top(a) bn_correct_top(a)
-# define bn_check_size(bn, bits)
-# define bn_wcheck_size(bn, words)
-
-# endif
-
-BN_ULONG bn_mul_add_words(BN_ULONG *rp, const BN_ULONG *ap, int num,
- BN_ULONG w);
-BN_ULONG bn_mul_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w);
-void bn_sqr_words(BN_ULONG *rp, const BN_ULONG *ap, int num);
-BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d);
-BN_ULONG bn_add_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,
- int num);
-BN_ULONG bn_sub_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,
- int num);
-
-struct bignum_st {
- BN_ULONG *d; /* Pointer to an array of 'BN_BITS2' bit
- * chunks. */
- int top; /* Index of last used d +1. */
- /* The next are internal book keeping for bn_expand. */
- int dmax; /* Size of the d array. */
- int neg; /* one if the number is negative */
- int flags;
-};
-
-/* Used for montgomery multiplication */
-struct bn_mont_ctx_st {
- int ri; /* number of bits in R */
- BIGNUM RR; /* used to convert to montgomery form,
- possibly zero-padded */
- BIGNUM N; /* The modulus */
- BIGNUM Ni; /* R*(1/R mod N) - N*Ni = 1 (Ni is only
- * stored for bignum algorithm) */
- BN_ULONG n0[2]; /* least significant word(s) of Ni; (type
- * changed with 0.9.9, was "BN_ULONG n0;"
- * before) */
- int flags;
-};
-
-/*
- * Used for reciprocal division/mod functions It cannot be shared between
- * threads
- */
-struct bn_recp_ctx_st {
- BIGNUM N; /* the divisor */
- BIGNUM Nr; /* the reciprocal */
- int num_bits;
- int shift;
- int flags;
-};
-
-/* Used for slow "generation" functions. */
-struct bn_gencb_st {
- unsigned int ver; /* To handle binary (in)compatibility */
- void *arg; /* callback-specific data */
- union {
- /* if (ver==1) - handles old style callbacks */
- void (*cb_1) (int, int, void *);
- /* if (ver==2) - new callback style */
- int (*cb_2) (int, int, BN_GENCB *);
- } cb;
-};
-
-/*-
- * BN_window_bits_for_exponent_size -- macro for sliding window mod_exp functions
- *
- *
- * For window size 'w' (w >= 2) and a random 'b' bits exponent,
- * the number of multiplications is a constant plus on average
- *
- * 2^(w-1) + (b-w)/(w+1);
- *
- * here 2^(w-1) is for precomputing the table (we actually need
- * entries only for windows that have the lowest bit set), and
- * (b-w)/(w+1) is an approximation for the expected number of
- * w-bit windows, not counting the first one.
- *
- * Thus we should use
- *
- * w >= 6 if b > 671
- * w = 5 if 671 > b > 239
- * w = 4 if 239 > b > 79
- * w = 3 if 79 > b > 23
- * w <= 2 if 23 > b
- *
- * (with draws in between). Very small exponents are often selected
- * with low Hamming weight, so we use w = 1 for b <= 23.
- */
-# define BN_window_bits_for_exponent_size(b) \
- ((b) > 671 ? 6 : \
- (b) > 239 ? 5 : \
- (b) > 79 ? 4 : \
- (b) > 23 ? 3 : 1)
-
-/*
- * BN_mod_exp_mont_consttime is based on the assumption that the L1 data cache
- * line width of the target processor is at least the following value.
- */
-# define MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH ( 64 )
-# define MOD_EXP_CTIME_MIN_CACHE_LINE_MASK (MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH - 1)
-
-/*
- * Window sizes optimized for fixed window size modular exponentiation
- * algorithm (BN_mod_exp_mont_consttime). To achieve the security goals of
- * BN_mode_exp_mont_consttime, the maximum size of the window must not exceed
- * log_2(MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH). Window size thresholds are
- * defined for cache line sizes of 32 and 64, cache line sizes where
- * log_2(32)=5 and log_2(64)=6 respectively. A window size of 7 should only be
- * used on processors that have a 128 byte or greater cache line size.
- */
-# if MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH == 64
-
-# define BN_window_bits_for_ctime_exponent_size(b) \
- ((b) > 937 ? 6 : \
- (b) > 306 ? 5 : \
- (b) > 89 ? 4 : \
- (b) > 22 ? 3 : 1)
-# define BN_MAX_WINDOW_BITS_FOR_CTIME_EXPONENT_SIZE (6)
-
-# elif MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH == 32
-
-# define BN_window_bits_for_ctime_exponent_size(b) \
- ((b) > 306 ? 5 : \
- (b) > 89 ? 4 : \
- (b) > 22 ? 3 : 1)
-# define BN_MAX_WINDOW_BITS_FOR_CTIME_EXPONENT_SIZE (5)
-
-# endif
-
-/* Pentium pro 16,16,16,32,64 */
-/* Alpha 16,16,16,16.64 */
-# define BN_MULL_SIZE_NORMAL (16)/* 32 */
-# define BN_MUL_RECURSIVE_SIZE_NORMAL (16)/* 32 less than */
-# define BN_SQR_RECURSIVE_SIZE_NORMAL (16)/* 32 */
-# define BN_MUL_LOW_RECURSIVE_SIZE_NORMAL (32)/* 32 */
-# define BN_MONT_CTX_SET_SIZE_WORD (64)/* 32 */
-
-/*
- * 2011-02-22 SMS. In various places, a size_t variable or a type cast to
- * size_t was used to perform integer-only operations on pointers. This
- * failed on VMS with 64-bit pointers (CC /POINTER_SIZE = 64) because size_t
- * is still only 32 bits. What's needed in these cases is an integer type
- * with the same size as a pointer, which size_t is not certain to be. The
- * only fix here is VMS-specific.
- */
-# if defined(OPENSSL_SYS_VMS)
-# if __INITIAL_POINTER_SIZE == 64
-# define PTR_SIZE_INT long long
-# else /* __INITIAL_POINTER_SIZE == 64 */
-# define PTR_SIZE_INT int
-# endif /* __INITIAL_POINTER_SIZE == 64 [else] */
-# elif !defined(PTR_SIZE_INT) /* defined(OPENSSL_SYS_VMS) */
-# define PTR_SIZE_INT size_t
-# endif /* defined(OPENSSL_SYS_VMS) [else] */
-
-# if !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) && !defined(PEDANTIC)
-/*
- * BN_UMULT_HIGH section.
- * If the compiler doesn't support 2*N integer type, then you have to
- * replace every N*N multiplication with 4 (N/2)*(N/2) accompanied by some
- * shifts and additions which unavoidably results in severe performance
- * penalties. Of course provided that the hardware is capable of producing
- * 2*N result... That's when you normally start considering assembler
- * implementation. However! It should be pointed out that some CPUs (e.g.,
- * PowerPC, Alpha, and IA-64) provide *separate* instruction calculating
- * the upper half of the product placing the result into a general
- * purpose register. Now *if* the compiler supports inline assembler,
- * then it's not impossible to implement the "bignum" routines (and have
- * the compiler optimize 'em) exhibiting "native" performance in C. That's
- * what BN_UMULT_HIGH macro is about:-) Note that more recent compilers do
- * support 2*64 integer type, which is also used here.
- */
-# if defined(__SIZEOF_INT128__) && __SIZEOF_INT128__==16 && \
- (defined(SIXTY_FOUR_BIT) || defined(SIXTY_FOUR_BIT_LONG))
-# define BN_UMULT_HIGH(a,b) (((__uint128_t)(a)*(b))>>64)
-# define BN_UMULT_LOHI(low,high,a,b) ({ \
- __uint128_t ret=(__uint128_t)(a)*(b); \
- (high)=ret>>64; (low)=ret; })
-# elif defined(__alpha) && (defined(SIXTY_FOUR_BIT_LONG) || defined(SIXTY_FOUR_BIT))
-# if defined(__DECC)
-# include <c_asm.h>
-# define BN_UMULT_HIGH(a,b) (BN_ULONG)asm("umulh %a0,%a1,%v0",(a),(b))
-# elif defined(__GNUC__) && __GNUC__>=2
-# define BN_UMULT_HIGH(a,b) ({ \
- register BN_ULONG ret; \
- asm ("umulh %1,%2,%0" \
- : "=r"(ret) \
- : "r"(a), "r"(b)); \
- ret; })
-# endif /* compiler */
-# elif defined(_ARCH_PPC64) && defined(SIXTY_FOUR_BIT_LONG)
-# if defined(__GNUC__) && __GNUC__>=2
-# define BN_UMULT_HIGH(a,b) ({ \
- register BN_ULONG ret; \
- asm ("mulhdu %0,%1,%2" \
- : "=r"(ret) \
- : "r"(a), "r"(b)); \
- ret; })
-# endif /* compiler */
-# elif (defined(__x86_64) || defined(__x86_64__)) && \
- (defined(SIXTY_FOUR_BIT_LONG) || defined(SIXTY_FOUR_BIT))
-# if defined(__GNUC__) && __GNUC__>=2
-# define BN_UMULT_HIGH(a,b) ({ \
- register BN_ULONG ret,discard; \
- asm ("mulq %3" \
- : "=a"(discard),"=d"(ret) \
- : "a"(a), "g"(b) \
- : "cc"); \
- ret; })
-# define BN_UMULT_LOHI(low,high,a,b) \
- asm ("mulq %3" \
- : "=a"(low),"=d"(high) \
- : "a"(a),"g"(b) \
- : "cc");
-# endif
-# elif (defined(_M_AMD64) || defined(_M_X64)) && defined(SIXTY_FOUR_BIT)
-# if defined(_MSC_VER) && _MSC_VER>=1400
-unsigned __int64 __umulh(unsigned __int64 a, unsigned __int64 b);
-unsigned __int64 _umul128(unsigned __int64 a, unsigned __int64 b,
- unsigned __int64 *h);
-# pragma intrinsic(__umulh,_umul128)
-# define BN_UMULT_HIGH(a,b) __umulh((a),(b))
-# define BN_UMULT_LOHI(low,high,a,b) ((low)=_umul128((a),(b),&(high)))
-# endif
-# elif defined(__mips) && (defined(SIXTY_FOUR_BIT) || defined(SIXTY_FOUR_BIT_LONG))
-# if defined(__GNUC__) && __GNUC__>=2
-# define BN_UMULT_HIGH(a,b) ({ \
- register BN_ULONG ret; \
- asm ("dmultu %1,%2" \
- : "=h"(ret) \
- : "r"(a), "r"(b) : "l"); \
- ret; })
-# define BN_UMULT_LOHI(low,high,a,b) \
- asm ("dmultu %2,%3" \
- : "=l"(low),"=h"(high) \
- : "r"(a), "r"(b));
-# endif
-# elif defined(__aarch64__) && defined(SIXTY_FOUR_BIT_LONG)
-# if defined(__GNUC__) && __GNUC__>=2
-# define BN_UMULT_HIGH(a,b) ({ \
- register BN_ULONG ret; \
- asm ("umulh %0,%1,%2" \
- : "=r"(ret) \
- : "r"(a), "r"(b)); \
- ret; })
-# endif
-# endif /* cpu */
-# endif /* OPENSSL_NO_ASM */
-
-# ifdef BN_DEBUG_RAND
-# define bn_clear_top2max(a) \
- { \
- int ind = (a)->dmax - (a)->top; \
- BN_ULONG *ftl = &(a)->d[(a)->top-1]; \
- for (; ind != 0; ind--) \
- *(++ftl) = 0x0; \
- }
-# else
-# define bn_clear_top2max(a)
-# endif
-
-# ifdef BN_LLONG
-/*******************************************************************
- * Using the long long type, has to be twice as wide as BN_ULONG...
- */
-# define Lw(t) (((BN_ULONG)(t))&BN_MASK2)
-# define Hw(t) (((BN_ULONG)((t)>>BN_BITS2))&BN_MASK2)
-
-# define mul_add(r,a,w,c) { \
- BN_ULLONG t; \
- t=(BN_ULLONG)w * (a) + (r) + (c); \
- (r)= Lw(t); \
- (c)= Hw(t); \
- }
-
-# define mul(r,a,w,c) { \
- BN_ULLONG t; \
- t=(BN_ULLONG)w * (a) + (c); \
- (r)= Lw(t); \
- (c)= Hw(t); \
- }
-
-# define sqr(r0,r1,a) { \
- BN_ULLONG t; \
- t=(BN_ULLONG)(a)*(a); \
- (r0)=Lw(t); \
- (r1)=Hw(t); \
- }
-
-# elif defined(BN_UMULT_LOHI)
-# define mul_add(r,a,w,c) { \
- BN_ULONG high,low,ret,tmp=(a); \
- ret = (r); \
- BN_UMULT_LOHI(low,high,w,tmp); \
- ret += (c); \
- (c) = (ret<(c))?1:0; \
- (c) += high; \
- ret += low; \
- (c) += (ret<low)?1:0; \
- (r) = ret; \
- }
-
-# define mul(r,a,w,c) { \
- BN_ULONG high,low,ret,ta=(a); \
- BN_UMULT_LOHI(low,high,w,ta); \
- ret = low + (c); \
- (c) = high; \
- (c) += (ret<low)?1:0; \
- (r) = ret; \
- }
-
-# define sqr(r0,r1,a) { \
- BN_ULONG tmp=(a); \
- BN_UMULT_LOHI(r0,r1,tmp,tmp); \
- }
-
-# elif defined(BN_UMULT_HIGH)
-# define mul_add(r,a,w,c) { \
- BN_ULONG high,low,ret,tmp=(a); \
- ret = (r); \
- high= BN_UMULT_HIGH(w,tmp); \
- ret += (c); \
- low = (w) * tmp; \
- (c) = (ret<(c))?1:0; \
- (c) += high; \
- ret += low; \
- (c) += (ret<low)?1:0; \
- (r) = ret; \
- }
-
-# define mul(r,a,w,c) { \
- BN_ULONG high,low,ret,ta=(a); \
- low = (w) * ta; \
- high= BN_UMULT_HIGH(w,ta); \
- ret = low + (c); \
- (c) = high; \
- (c) += (ret<low)?1:0; \
- (r) = ret; \
- }
-
-# define sqr(r0,r1,a) { \
- BN_ULONG tmp=(a); \
- (r0) = tmp * tmp; \
- (r1) = BN_UMULT_HIGH(tmp,tmp); \
- }
-
-# else
-/*************************************************************
- * No long long type
- */
-
-# define LBITS(a) ((a)&BN_MASK2l)
-# define HBITS(a) (((a)>>BN_BITS4)&BN_MASK2l)
-# define L2HBITS(a) (((a)<<BN_BITS4)&BN_MASK2)
-
-# define LLBITS(a) ((a)&BN_MASKl)
-# define LHBITS(a) (((a)>>BN_BITS2)&BN_MASKl)
-# define LL2HBITS(a) ((BN_ULLONG)((a)&BN_MASKl)<<BN_BITS2)
-
-# define mul64(l,h,bl,bh) \
- { \
- BN_ULONG m,m1,lt,ht; \
- \
- lt=l; \
- ht=h; \
- m =(bh)*(lt); \
- lt=(bl)*(lt); \
- m1=(bl)*(ht); \
- ht =(bh)*(ht); \
- m=(m+m1)&BN_MASK2; if (m < m1) ht+=L2HBITS((BN_ULONG)1); \
- ht+=HBITS(m); \
- m1=L2HBITS(m); \
- lt=(lt+m1)&BN_MASK2; if (lt < m1) ht++; \
- (l)=lt; \
- (h)=ht; \
- }
-
-# define sqr64(lo,ho,in) \
- { \
- BN_ULONG l,h,m; \
- \
- h=(in); \
- l=LBITS(h); \
- h=HBITS(h); \
- m =(l)*(h); \
- l*=l; \
- h*=h; \
- h+=(m&BN_MASK2h1)>>(BN_BITS4-1); \
- m =(m&BN_MASK2l)<<(BN_BITS4+1); \
- l=(l+m)&BN_MASK2; if (l < m) h++; \
- (lo)=l; \
- (ho)=h; \
- }
-
-# define mul_add(r,a,bl,bh,c) { \
- BN_ULONG l,h; \
- \
- h= (a); \
- l=LBITS(h); \
- h=HBITS(h); \
- mul64(l,h,(bl),(bh)); \
- \
- /* non-multiply part */ \
- l=(l+(c))&BN_MASK2; if (l < (c)) h++; \
- (c)=(r); \
- l=(l+(c))&BN_MASK2; if (l < (c)) h++; \
- (c)=h&BN_MASK2; \
- (r)=l; \
- }
-
-# define mul(r,a,bl,bh,c) { \
- BN_ULONG l,h; \
- \
- h= (a); \
- l=LBITS(h); \
- h=HBITS(h); \
- mul64(l,h,(bl),(bh)); \
- \
- /* non-multiply part */ \
- l+=(c); if ((l&BN_MASK2) < (c)) h++; \
- (c)=h&BN_MASK2; \
- (r)=l&BN_MASK2; \
- }
-# endif /* !BN_LLONG */
-
-void BN_RECP_CTX_init(BN_RECP_CTX *recp);
-void BN_MONT_CTX_init(BN_MONT_CTX *ctx);
-
-void bn_init(BIGNUM *a);
-void bn_mul_normal(BN_ULONG *r, BN_ULONG *a, int na, BN_ULONG *b, int nb);
-void bn_mul_comba8(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b);
-void bn_mul_comba4(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b);
-void bn_sqr_normal(BN_ULONG *r, const BN_ULONG *a, int n, BN_ULONG *tmp);
-void bn_sqr_comba8(BN_ULONG *r, const BN_ULONG *a);
-void bn_sqr_comba4(BN_ULONG *r, const BN_ULONG *a);
-int bn_cmp_words(const BN_ULONG *a, const BN_ULONG *b, int n);
-int bn_cmp_part_words(const BN_ULONG *a, const BN_ULONG *b, int cl, int dl);
-void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
- int dna, int dnb, BN_ULONG *t);
-void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b,
- int n, int tna, int tnb, BN_ULONG *t);
-void bn_sqr_recursive(BN_ULONG *r, const BN_ULONG *a, int n2, BN_ULONG *t);
-void bn_mul_low_normal(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n);
-void bn_mul_low_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
- BN_ULONG *t);
-BN_ULONG bn_sub_part_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
- int cl, int dl);
-int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,
- const BN_ULONG *np, const BN_ULONG *n0, int num);
-
-BIGNUM *int_bn_mod_inverse(BIGNUM *in,
- const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx,
- int *noinv);
-
-static ossl_inline BIGNUM *bn_expand(BIGNUM *a, int bits)
-{
- if (bits > (INT_MAX - BN_BITS2 + 1))
- return NULL;
-
- if (((bits+BN_BITS2-1)/BN_BITS2) <= (a)->dmax)
- return a;
-
- return bn_expand2((a),(bits+BN_BITS2-1)/BN_BITS2);
-}
-
-#endif
#include <assert.h>
#include <limits.h>
#include "internal/cryptlib.h"
-#include "bn_lcl.h"
+#include "bn_local.h"
#include <openssl/opensslconf.h>
-#include "internal/constant_time_locl.h"
+#include "internal/constant_time.h"
/* This stuff appears to be completely unused, so is deprecated */
#if !OPENSSL_API_0_9_8
--- /dev/null
+/*
+ * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+#ifndef HEADER_BN_LCL_H
+# define HEADER_BN_LCL_H
+
+/*
+ * The EDK2 build doesn't use bn_conf.h; it sets THIRTY_TWO_BIT or
+ * SIXTY_FOUR_BIT in its own environment since it doesn't re-run our
+ * Configure script and needs to support both 32-bit and 64-bit.
+ */
+# include <openssl/opensslconf.h>
+
+# if !defined(OPENSSL_SYS_UEFI)
+# include "crypto/bn_conf.h"
+# endif
+
+# include "crypto/bn.h"
+
+/*
+ * These preprocessor symbols control various aspects of the bignum headers
+ * and library code. They're not defined by any "normal" configuration, as
+ * they are intended for development and testing purposes. NB: defining all
+ * three can be useful for debugging application code as well as openssl
+ * itself. BN_DEBUG - turn on various debugging alterations to the bignum
+ * code BN_DEBUG_RAND - uses random poisoning of unused words to trip up
+ * mismanagement of bignum internals. You must also define BN_DEBUG.
+ */
+/* #define BN_DEBUG */
+/* #define BN_DEBUG_RAND */
+
+# ifndef OPENSSL_SMALL_FOOTPRINT
+# define BN_MUL_COMBA
+# define BN_SQR_COMBA
+# define BN_RECURSION
+# endif
+
+/*
+ * This next option uses the C libraries (2 word)/(1 word) function. If it is
+ * not defined, I use my C version (which is slower). The reason for this
+ * flag is that when the particular C compiler library routine is used, and
+ * the library is linked with a different compiler, the library is missing.
+ * This mostly happens when the library is built with gcc and then linked
+ * using normal cc. This would be a common occurrence because gcc normally
+ * produces code that is 2 times faster than system compilers for the big
+ * number stuff. For machines with only one compiler (or shared libraries),
+ * this should be on. Again this in only really a problem on machines using
+ * "long long's", are 32bit, and are not using my assembler code.
+ */
+# if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WINDOWS) || \
+ defined(OPENSSL_SYS_WIN32) || defined(linux)
+# define BN_DIV2W
+# endif
+
+/*
+ * 64-bit processor with LP64 ABI
+ */
+# ifdef SIXTY_FOUR_BIT_LONG
+# define BN_ULLONG unsigned long long
+# define BN_BITS4 32
+# define BN_MASK2 (0xffffffffffffffffL)
+# define BN_MASK2l (0xffffffffL)
+# define BN_MASK2h (0xffffffff00000000L)
+# define BN_MASK2h1 (0xffffffff80000000L)
+# define BN_DEC_CONV (10000000000000000000UL)
+# define BN_DEC_NUM 19
+# define BN_DEC_FMT1 "%lu"
+# define BN_DEC_FMT2 "%019lu"
+# endif
+
+/*
+ * 64-bit processor other than LP64 ABI
+ */
+# ifdef SIXTY_FOUR_BIT
+# undef BN_LLONG
+# undef BN_ULLONG
+# define BN_BITS4 32
+# define BN_MASK2 (0xffffffffffffffffLL)
+# define BN_MASK2l (0xffffffffL)
+# define BN_MASK2h (0xffffffff00000000LL)
+# define BN_MASK2h1 (0xffffffff80000000LL)
+# define BN_DEC_CONV (10000000000000000000ULL)
+# define BN_DEC_NUM 19
+# define BN_DEC_FMT1 "%llu"
+# define BN_DEC_FMT2 "%019llu"
+# endif
+
+# ifdef THIRTY_TWO_BIT
+# ifdef BN_LLONG
+# if defined(_WIN32) && !defined(__GNUC__)
+# define BN_ULLONG unsigned __int64
+# else
+# define BN_ULLONG unsigned long long
+# endif
+# endif
+# define BN_BITS4 16
+# define BN_MASK2 (0xffffffffL)
+# define BN_MASK2l (0xffff)
+# define BN_MASK2h1 (0xffff8000L)
+# define BN_MASK2h (0xffff0000L)
+# define BN_DEC_CONV (1000000000L)
+# define BN_DEC_NUM 9
+# define BN_DEC_FMT1 "%u"
+# define BN_DEC_FMT2 "%09u"
+# endif
+
+
+/*-
+ * Bignum consistency macros
+ * There is one "API" macro, bn_fix_top(), for stripping leading zeroes from
+ * bignum data after direct manipulations on the data. There is also an
+ * "internal" macro, bn_check_top(), for verifying that there are no leading
+ * zeroes. Unfortunately, some auditing is required due to the fact that
+ * bn_fix_top() has become an overabused duct-tape because bignum data is
+ * occasionally passed around in an inconsistent state. So the following
+ * changes have been made to sort this out;
+ * - bn_fix_top()s implementation has been moved to bn_correct_top()
+ * - if BN_DEBUG isn't defined, bn_fix_top() maps to bn_correct_top(), and
+ * bn_check_top() is as before.
+ * - if BN_DEBUG *is* defined;
+ * - bn_check_top() tries to pollute unused words even if the bignum 'top' is
+ * consistent. (ed: only if BN_DEBUG_RAND is defined)
+ * - bn_fix_top() maps to bn_check_top() rather than "fixing" anything.
+ * The idea is to have debug builds flag up inconsistent bignums when they
+ * occur. If that occurs in a bn_fix_top(), we examine the code in question; if
+ * the use of bn_fix_top() was appropriate (ie. it follows directly after code
+ * that manipulates the bignum) it is converted to bn_correct_top(), and if it
+ * was not appropriate, we convert it permanently to bn_check_top() and track
+ * down the cause of the bug. Eventually, no internal code should be using the
+ * bn_fix_top() macro. External applications and libraries should try this with
+ * their own code too, both in terms of building against the openssl headers
+ * with BN_DEBUG defined *and* linking with a version of OpenSSL built with it
+ * defined. This not only improves external code, it provides more test
+ * coverage for openssl's own code.
+ */
+
+# ifdef BN_DEBUG
+/*
+ * The new BN_FLG_FIXED_TOP flag marks vectors that were not treated with
+ * bn_correct_top, in other words such vectors are permitted to have zeros
+ * in most significant limbs. Such vectors are used internally to achieve
+ * execution time invariance for critical operations with private keys.
+ * It's BN_DEBUG-only flag, because user application is not supposed to
+ * observe it anyway. Moreover, optimizing compiler would actually remove
+ * all operations manipulating the bit in question in non-BN_DEBUG build.
+ */
+# define BN_FLG_FIXED_TOP 0x10000
+# ifdef BN_DEBUG_RAND
+# define bn_pollute(a) \
+ do { \
+ const BIGNUM *_bnum1 = (a); \
+ if (_bnum1->top < _bnum1->dmax) { \
+ unsigned char _tmp_char; \
+ /* We cast away const without the compiler knowing, any \
+ * *genuinely* constant variables that aren't mutable \
+ * wouldn't be constructed with top!=dmax. */ \
+ BN_ULONG *_not_const; \
+ memcpy(&_not_const, &_bnum1->d, sizeof(_not_const)); \
+ RAND_bytes(&_tmp_char, 1); /* Debug only - safe to ignore error return */\
+ memset(_not_const + _bnum1->top, _tmp_char, \
+ sizeof(*_not_const) * (_bnum1->dmax - _bnum1->top)); \
+ } \
+ } while(0)
+# else
+# define bn_pollute(a)
+# endif
+# define bn_check_top(a) \
+ do { \
+ const BIGNUM *_bnum2 = (a); \
+ if (_bnum2 != NULL) { \
+ int _top = _bnum2->top; \
+ (void)ossl_assert((_top == 0 && !_bnum2->neg) || \
+ (_top && ((_bnum2->flags & BN_FLG_FIXED_TOP) \
+ || _bnum2->d[_top - 1] != 0))); \
+ bn_pollute(_bnum2); \
+ } \
+ } while(0)
+
+# define bn_fix_top(a) bn_check_top(a)
+
+# define bn_check_size(bn, bits) bn_wcheck_size(bn, ((bits+BN_BITS2-1))/BN_BITS2)
+# define bn_wcheck_size(bn, words) \
+ do { \
+ const BIGNUM *_bnum2 = (bn); \
+ assert((words) <= (_bnum2)->dmax && \
+ (words) >= (_bnum2)->top); \
+ /* avoid unused variable warning with NDEBUG */ \
+ (void)(_bnum2); \
+ } while(0)
+
+# else /* !BN_DEBUG */
+
+# define BN_FLG_FIXED_TOP 0
+# define bn_pollute(a)
+# define bn_check_top(a)
+# define bn_fix_top(a) bn_correct_top(a)
+# define bn_check_size(bn, bits)
+# define bn_wcheck_size(bn, words)
+
+# endif
+
+BN_ULONG bn_mul_add_words(BN_ULONG *rp, const BN_ULONG *ap, int num,
+ BN_ULONG w);
+BN_ULONG bn_mul_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w);
+void bn_sqr_words(BN_ULONG *rp, const BN_ULONG *ap, int num);
+BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d);
+BN_ULONG bn_add_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,
+ int num);
+BN_ULONG bn_sub_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,
+ int num);
+
+struct bignum_st {
+ BN_ULONG *d; /* Pointer to an array of 'BN_BITS2' bit
+ * chunks. */
+ int top; /* Index of last used d +1. */
+ /* The next are internal book keeping for bn_expand. */
+ int dmax; /* Size of the d array. */
+ int neg; /* one if the number is negative */
+ int flags;
+};
+
+/* Used for montgomery multiplication */
+struct bn_mont_ctx_st {
+ int ri; /* number of bits in R */
+ BIGNUM RR; /* used to convert to montgomery form,
+ possibly zero-padded */
+ BIGNUM N; /* The modulus */
+ BIGNUM Ni; /* R*(1/R mod N) - N*Ni = 1 (Ni is only
+ * stored for bignum algorithm) */
+ BN_ULONG n0[2]; /* least significant word(s) of Ni; (type
+ * changed with 0.9.9, was "BN_ULONG n0;"
+ * before) */
+ int flags;
+};
+
+/*
+ * Used for reciprocal division/mod functions It cannot be shared between
+ * threads
+ */
+struct bn_recp_ctx_st {
+ BIGNUM N; /* the divisor */
+ BIGNUM Nr; /* the reciprocal */
+ int num_bits;
+ int shift;
+ int flags;
+};
+
+/* Used for slow "generation" functions. */
+struct bn_gencb_st {
+ unsigned int ver; /* To handle binary (in)compatibility */
+ void *arg; /* callback-specific data */
+ union {
+ /* if (ver==1) - handles old style callbacks */
+ void (*cb_1) (int, int, void *);
+ /* if (ver==2) - new callback style */
+ int (*cb_2) (int, int, BN_GENCB *);
+ } cb;
+};
+
+/*-
+ * BN_window_bits_for_exponent_size -- macro for sliding window mod_exp functions
+ *
+ *
+ * For window size 'w' (w >= 2) and a random 'b' bits exponent,
+ * the number of multiplications is a constant plus on average
+ *
+ * 2^(w-1) + (b-w)/(w+1);
+ *
+ * here 2^(w-1) is for precomputing the table (we actually need
+ * entries only for windows that have the lowest bit set), and
+ * (b-w)/(w+1) is an approximation for the expected number of
+ * w-bit windows, not counting the first one.
+ *
+ * Thus we should use
+ *
+ * w >= 6 if b > 671
+ * w = 5 if 671 > b > 239
+ * w = 4 if 239 > b > 79
+ * w = 3 if 79 > b > 23
+ * w <= 2 if 23 > b
+ *
+ * (with draws in between). Very small exponents are often selected
+ * with low Hamming weight, so we use w = 1 for b <= 23.
+ */
+# define BN_window_bits_for_exponent_size(b) \
+ ((b) > 671 ? 6 : \
+ (b) > 239 ? 5 : \
+ (b) > 79 ? 4 : \
+ (b) > 23 ? 3 : 1)
+
+/*
+ * BN_mod_exp_mont_consttime is based on the assumption that the L1 data cache
+ * line width of the target processor is at least the following value.
+ */
+# define MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH ( 64 )
+# define MOD_EXP_CTIME_MIN_CACHE_LINE_MASK (MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH - 1)
+
+/*
+ * Window sizes optimized for fixed window size modular exponentiation
+ * algorithm (BN_mod_exp_mont_consttime). To achieve the security goals of
+ * BN_mode_exp_mont_consttime, the maximum size of the window must not exceed
+ * log_2(MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH). Window size thresholds are
+ * defined for cache line sizes of 32 and 64, cache line sizes where
+ * log_2(32)=5 and log_2(64)=6 respectively. A window size of 7 should only be
+ * used on processors that have a 128 byte or greater cache line size.
+ */
+# if MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH == 64
+
+# define BN_window_bits_for_ctime_exponent_size(b) \
+ ((b) > 937 ? 6 : \
+ (b) > 306 ? 5 : \
+ (b) > 89 ? 4 : \
+ (b) > 22 ? 3 : 1)
+# define BN_MAX_WINDOW_BITS_FOR_CTIME_EXPONENT_SIZE (6)
+
+# elif MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH == 32
+
+# define BN_window_bits_for_ctime_exponent_size(b) \
+ ((b) > 306 ? 5 : \
+ (b) > 89 ? 4 : \
+ (b) > 22 ? 3 : 1)
+# define BN_MAX_WINDOW_BITS_FOR_CTIME_EXPONENT_SIZE (5)
+
+# endif
+
+/* Pentium pro 16,16,16,32,64 */
+/* Alpha 16,16,16,16.64 */
+# define BN_MULL_SIZE_NORMAL (16)/* 32 */
+# define BN_MUL_RECURSIVE_SIZE_NORMAL (16)/* 32 less than */
+# define BN_SQR_RECURSIVE_SIZE_NORMAL (16)/* 32 */
+# define BN_MUL_LOW_RECURSIVE_SIZE_NORMAL (32)/* 32 */
+# define BN_MONT_CTX_SET_SIZE_WORD (64)/* 32 */
+
+/*
+ * 2011-02-22 SMS. In various places, a size_t variable or a type cast to
+ * size_t was used to perform integer-only operations on pointers. This
+ * failed on VMS with 64-bit pointers (CC /POINTER_SIZE = 64) because size_t
+ * is still only 32 bits. What's needed in these cases is an integer type
+ * with the same size as a pointer, which size_t is not certain to be. The
+ * only fix here is VMS-specific.
+ */
+# if defined(OPENSSL_SYS_VMS)
+# if __INITIAL_POINTER_SIZE == 64
+# define PTR_SIZE_INT long long
+# else /* __INITIAL_POINTER_SIZE == 64 */
+# define PTR_SIZE_INT int
+# endif /* __INITIAL_POINTER_SIZE == 64 [else] */
+# elif !defined(PTR_SIZE_INT) /* defined(OPENSSL_SYS_VMS) */
+# define PTR_SIZE_INT size_t
+# endif /* defined(OPENSSL_SYS_VMS) [else] */
+
+# if !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) && !defined(PEDANTIC)
+/*
+ * BN_UMULT_HIGH section.
+ * If the compiler doesn't support 2*N integer type, then you have to
+ * replace every N*N multiplication with 4 (N/2)*(N/2) accompanied by some
+ * shifts and additions which unavoidably results in severe performance
+ * penalties. Of course provided that the hardware is capable of producing
+ * 2*N result... That's when you normally start considering assembler
+ * implementation. However! It should be pointed out that some CPUs (e.g.,
+ * PowerPC, Alpha, and IA-64) provide *separate* instruction calculating
+ * the upper half of the product placing the result into a general
+ * purpose register. Now *if* the compiler supports inline assembler,
+ * then it's not impossible to implement the "bignum" routines (and have
+ * the compiler optimize 'em) exhibiting "native" performance in C. That's
+ * what BN_UMULT_HIGH macro is about:-) Note that more recent compilers do
+ * support 2*64 integer type, which is also used here.
+ */
+# if defined(__SIZEOF_INT128__) && __SIZEOF_INT128__==16 && \
+ (defined(SIXTY_FOUR_BIT) || defined(SIXTY_FOUR_BIT_LONG))
+# define BN_UMULT_HIGH(a,b) (((__uint128_t)(a)*(b))>>64)
+# define BN_UMULT_LOHI(low,high,a,b) ({ \
+ __uint128_t ret=(__uint128_t)(a)*(b); \
+ (high)=ret>>64; (low)=ret; })
+# elif defined(__alpha) && (defined(SIXTY_FOUR_BIT_LONG) || defined(SIXTY_FOUR_BIT))
+# if defined(__DECC)
+# include <c_asm.h>
+# define BN_UMULT_HIGH(a,b) (BN_ULONG)asm("umulh %a0,%a1,%v0",(a),(b))
+# elif defined(__GNUC__) && __GNUC__>=2
+# define BN_UMULT_HIGH(a,b) ({ \
+ register BN_ULONG ret; \
+ asm ("umulh %1,%2,%0" \
+ : "=r"(ret) \
+ : "r"(a), "r"(b)); \
+ ret; })
+# endif /* compiler */
+# elif defined(_ARCH_PPC64) && defined(SIXTY_FOUR_BIT_LONG)
+# if defined(__GNUC__) && __GNUC__>=2
+# define BN_UMULT_HIGH(a,b) ({ \
+ register BN_ULONG ret; \
+ asm ("mulhdu %0,%1,%2" \
+ : "=r"(ret) \
+ : "r"(a), "r"(b)); \
+ ret; })
+# endif /* compiler */
+# elif (defined(__x86_64) || defined(__x86_64__)) && \
+ (defined(SIXTY_FOUR_BIT_LONG) || defined(SIXTY_FOUR_BIT))
+# if defined(__GNUC__) && __GNUC__>=2
+# define BN_UMULT_HIGH(a,b) ({ \
+ register BN_ULONG ret,discard; \
+ asm ("mulq %3" \
+ : "=a"(discard),"=d"(ret) \
+ : "a"(a), "g"(b) \
+ : "cc"); \
+ ret; })
+# define BN_UMULT_LOHI(low,high,a,b) \
+ asm ("mulq %3" \
+ : "=a"(low),"=d"(high) \
+ : "a"(a),"g"(b) \
+ : "cc");
+# endif
+# elif (defined(_M_AMD64) || defined(_M_X64)) && defined(SIXTY_FOUR_BIT)
+# if defined(_MSC_VER) && _MSC_VER>=1400
+unsigned __int64 __umulh(unsigned __int64 a, unsigned __int64 b);
+unsigned __int64 _umul128(unsigned __int64 a, unsigned __int64 b,
+ unsigned __int64 *h);
+# pragma intrinsic(__umulh,_umul128)
+# define BN_UMULT_HIGH(a,b) __umulh((a),(b))
+# define BN_UMULT_LOHI(low,high,a,b) ((low)=_umul128((a),(b),&(high)))
+# endif
+# elif defined(__mips) && (defined(SIXTY_FOUR_BIT) || defined(SIXTY_FOUR_BIT_LONG))
+# if defined(__GNUC__) && __GNUC__>=2
+# define BN_UMULT_HIGH(a,b) ({ \
+ register BN_ULONG ret; \
+ asm ("dmultu %1,%2" \
+ : "=h"(ret) \
+ : "r"(a), "r"(b) : "l"); \
+ ret; })
+# define BN_UMULT_LOHI(low,high,a,b) \
+ asm ("dmultu %2,%3" \
+ : "=l"(low),"=h"(high) \
+ : "r"(a), "r"(b));
+# endif
+# elif defined(__aarch64__) && defined(SIXTY_FOUR_BIT_LONG)
+# if defined(__GNUC__) && __GNUC__>=2
+# define BN_UMULT_HIGH(a,b) ({ \
+ register BN_ULONG ret; \
+ asm ("umulh %0,%1,%2" \
+ : "=r"(ret) \
+ : "r"(a), "r"(b)); \
+ ret; })
+# endif
+# endif /* cpu */
+# endif /* OPENSSL_NO_ASM */
+
+# ifdef BN_DEBUG_RAND
+# define bn_clear_top2max(a) \
+ { \
+ int ind = (a)->dmax - (a)->top; \
+ BN_ULONG *ftl = &(a)->d[(a)->top-1]; \
+ for (; ind != 0; ind--) \
+ *(++ftl) = 0x0; \
+ }
+# else
+# define bn_clear_top2max(a)
+# endif
+
+# ifdef BN_LLONG
+/*******************************************************************
+ * Using the long long type, has to be twice as wide as BN_ULONG...
+ */
+# define Lw(t) (((BN_ULONG)(t))&BN_MASK2)
+# define Hw(t) (((BN_ULONG)((t)>>BN_BITS2))&BN_MASK2)
+
+# define mul_add(r,a,w,c) { \
+ BN_ULLONG t; \
+ t=(BN_ULLONG)w * (a) + (r) + (c); \
+ (r)= Lw(t); \
+ (c)= Hw(t); \
+ }
+
+# define mul(r,a,w,c) { \
+ BN_ULLONG t; \
+ t=(BN_ULLONG)w * (a) + (c); \
+ (r)= Lw(t); \
+ (c)= Hw(t); \
+ }
+
+# define sqr(r0,r1,a) { \
+ BN_ULLONG t; \
+ t=(BN_ULLONG)(a)*(a); \
+ (r0)=Lw(t); \
+ (r1)=Hw(t); \
+ }
+
+# elif defined(BN_UMULT_LOHI)
+# define mul_add(r,a,w,c) { \
+ BN_ULONG high,low,ret,tmp=(a); \
+ ret = (r); \
+ BN_UMULT_LOHI(low,high,w,tmp); \
+ ret += (c); \
+ (c) = (ret<(c))?1:0; \
+ (c) += high; \
+ ret += low; \
+ (c) += (ret<low)?1:0; \
+ (r) = ret; \
+ }
+
+# define mul(r,a,w,c) { \
+ BN_ULONG high,low,ret,ta=(a); \
+ BN_UMULT_LOHI(low,high,w,ta); \
+ ret = low + (c); \
+ (c) = high; \
+ (c) += (ret<low)?1:0; \
+ (r) = ret; \
+ }
+
+# define sqr(r0,r1,a) { \
+ BN_ULONG tmp=(a); \
+ BN_UMULT_LOHI(r0,r1,tmp,tmp); \
+ }
+
+# elif defined(BN_UMULT_HIGH)
+# define mul_add(r,a,w,c) { \
+ BN_ULONG high,low,ret,tmp=(a); \
+ ret = (r); \
+ high= BN_UMULT_HIGH(w,tmp); \
+ ret += (c); \
+ low = (w) * tmp; \
+ (c) = (ret<(c))?1:0; \
+ (c) += high; \
+ ret += low; \
+ (c) += (ret<low)?1:0; \
+ (r) = ret; \
+ }
+
+# define mul(r,a,w,c) { \
+ BN_ULONG high,low,ret,ta=(a); \
+ low = (w) * ta; \
+ high= BN_UMULT_HIGH(w,ta); \
+ ret = low + (c); \
+ (c) = high; \
+ (c) += (ret<low)?1:0; \
+ (r) = ret; \
+ }
+
+# define sqr(r0,r1,a) { \
+ BN_ULONG tmp=(a); \
+ (r0) = tmp * tmp; \
+ (r1) = BN_UMULT_HIGH(tmp,tmp); \
+ }
+
+# else
+/*************************************************************
+ * No long long type
+ */
+
+# define LBITS(a) ((a)&BN_MASK2l)
+# define HBITS(a) (((a)>>BN_BITS4)&BN_MASK2l)
+# define L2HBITS(a) (((a)<<BN_BITS4)&BN_MASK2)
+
+# define LLBITS(a) ((a)&BN_MASKl)
+# define LHBITS(a) (((a)>>BN_BITS2)&BN_MASKl)
+# define LL2HBITS(a) ((BN_ULLONG)((a)&BN_MASKl)<<BN_BITS2)
+
+# define mul64(l,h,bl,bh) \
+ { \
+ BN_ULONG m,m1,lt,ht; \
+ \
+ lt=l; \
+ ht=h; \
+ m =(bh)*(lt); \
+ lt=(bl)*(lt); \
+ m1=(bl)*(ht); \
+ ht =(bh)*(ht); \
+ m=(m+m1)&BN_MASK2; if (m < m1) ht+=L2HBITS((BN_ULONG)1); \
+ ht+=HBITS(m); \
+ m1=L2HBITS(m); \
+ lt=(lt+m1)&BN_MASK2; if (lt < m1) ht++; \
+ (l)=lt; \
+ (h)=ht; \
+ }
+
+# define sqr64(lo,ho,in) \
+ { \
+ BN_ULONG l,h,m; \
+ \
+ h=(in); \
+ l=LBITS(h); \
+ h=HBITS(h); \
+ m =(l)*(h); \
+ l*=l; \
+ h*=h; \
+ h+=(m&BN_MASK2h1)>>(BN_BITS4-1); \
+ m =(m&BN_MASK2l)<<(BN_BITS4+1); \
+ l=(l+m)&BN_MASK2; if (l < m) h++; \
+ (lo)=l; \
+ (ho)=h; \
+ }
+
+# define mul_add(r,a,bl,bh,c) { \
+ BN_ULONG l,h; \
+ \
+ h= (a); \
+ l=LBITS(h); \
+ h=HBITS(h); \
+ mul64(l,h,(bl),(bh)); \
+ \
+ /* non-multiply part */ \
+ l=(l+(c))&BN_MASK2; if (l < (c)) h++; \
+ (c)=(r); \
+ l=(l+(c))&BN_MASK2; if (l < (c)) h++; \
+ (c)=h&BN_MASK2; \
+ (r)=l; \
+ }
+
+# define mul(r,a,bl,bh,c) { \
+ BN_ULONG l,h; \
+ \
+ h= (a); \
+ l=LBITS(h); \
+ h=HBITS(h); \
+ mul64(l,h,(bl),(bh)); \
+ \
+ /* non-multiply part */ \
+ l+=(c); if ((l&BN_MASK2) < (c)) h++; \
+ (c)=h&BN_MASK2; \
+ (r)=l&BN_MASK2; \
+ }
+# endif /* !BN_LLONG */
+
+void BN_RECP_CTX_init(BN_RECP_CTX *recp);
+void BN_MONT_CTX_init(BN_MONT_CTX *ctx);
+
+void bn_init(BIGNUM *a);
+void bn_mul_normal(BN_ULONG *r, BN_ULONG *a, int na, BN_ULONG *b, int nb);
+void bn_mul_comba8(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b);
+void bn_mul_comba4(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b);
+void bn_sqr_normal(BN_ULONG *r, const BN_ULONG *a, int n, BN_ULONG *tmp);
+void bn_sqr_comba8(BN_ULONG *r, const BN_ULONG *a);
+void bn_sqr_comba4(BN_ULONG *r, const BN_ULONG *a);
+int bn_cmp_words(const BN_ULONG *a, const BN_ULONG *b, int n);
+int bn_cmp_part_words(const BN_ULONG *a, const BN_ULONG *b, int cl, int dl);
+void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
+ int dna, int dnb, BN_ULONG *t);
+void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b,
+ int n, int tna, int tnb, BN_ULONG *t);
+void bn_sqr_recursive(BN_ULONG *r, const BN_ULONG *a, int n2, BN_ULONG *t);
+void bn_mul_low_normal(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n);
+void bn_mul_low_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
+ BN_ULONG *t);
+BN_ULONG bn_sub_part_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
+ int cl, int dl);
+int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,
+ const BN_ULONG *np, const BN_ULONG *n0, int num);
+
+BIGNUM *int_bn_mod_inverse(BIGNUM *in,
+ const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx,
+ int *noinv);
+
+static ossl_inline BIGNUM *bn_expand(BIGNUM *a, int bits)
+{
+ if (bits > (INT_MAX - BN_BITS2 + 1))
+ return NULL;
+
+ if (((bits+BN_BITS2-1)/BN_BITS2) <= (a)->dmax)
+ return a;
+
+ return bn_expand2((a),(bits+BN_BITS2-1)/BN_BITS2);
+}
+
+#endif
*/
#include "internal/cryptlib.h"
-#include "bn_lcl.h"
+#include "bn_local.h"
int BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx)
{
*/
#include "internal/cryptlib.h"
-#include "bn_lcl.h"
+#include "bn_local.h"
#define MONT_WORD /* use the faster word-based algorithm */
#include <stdio.h>
#include "internal/cryptlib.h"
-#include "bn_lcl.h"
+#include "bn_local.h"
int BN_bn2mpi(const BIGNUM *a, unsigned char *d)
{
#include <assert.h>
#include "internal/cryptlib.h"
-#include "bn_lcl.h"
+#include "bn_local.h"
#if defined(OPENSSL_NO_ASM) || !defined(OPENSSL_BN_ASM_PART_WORDS)
/*
* https://www.openssl.org/source/license.html
*/
-#include "bn_lcl.h"
+#include "bn_local.h"
#include "internal/cryptlib.h"
#define BN_NIST_192_TOP (192+BN_BITS2-1)/BN_BITS2
#include <stdio.h>
#include <time.h>
#include "internal/cryptlib.h"
-#include "bn_lcl.h"
+#include "bn_local.h"
/*
* The quick sieve algorithm approach to weeding out primes is Philip
#include <stdio.h>
#include <openssl/bio.h>
-#include "bn_lcl.h"
+#include "bn_local.h"
static const char Hex[] = "0123456789ABCDEF";
#include <time.h>
#include "internal/cryptlib.h"
#include "crypto/rand.h"
-#include "bn_lcl.h"
+#include "bn_local.h"
#include <openssl/rand.h>
#include <openssl/sha.h>
#include <openssl/evp.h>
*/
#include "internal/cryptlib.h"
-#include "bn_lcl.h"
+#include "bn_local.h"
void BN_RECP_CTX_init(BN_RECP_CTX *recp)
{
*/
#include <stdio.h>
#include <openssl/bn.h>
-#include "bn_lcl.h"
+#include "bn_local.h"
#include "crypto/bn.h"
/*
#include <assert.h>
#include "internal/cryptlib.h"
-#include "bn_lcl.h"
+#include "bn_local.h"
int BN_lshift1(BIGNUM *r, const BIGNUM *a)
{
*/
#include "internal/cryptlib.h"
-#include "bn_lcl.h"
+#include "bn_local.h"
/* r must not be a */
/*
*/
#include "internal/cryptlib.h"
-#include "bn_lcl.h"
+#include "bn_local.h"
BIGNUM *BN_mod_sqrt(BIGNUM *in, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx)
/*
* https://www.openssl.org/source/license.html
*/
-#include "bn_lcl.h"
+#include "bn_local.h"
#include "internal/nelem.h"
#ifndef OPENSSL_NO_SRP
*/
#include "internal/cryptlib.h"
-#include "bn_lcl.h"
+#include "bn_local.h"
BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w)
{
#include <stdio.h>
#include <openssl/bn.h>
-#include "bn_lcl.h"
+#include "bn_local.h"
/* X9.31 routines for prime derivation */
*/
#include <openssl/camellia.h>
-#include "cmll_locl.h"
+#include "cmll_local.h"
#include <string.h>
#include <stdlib.h>
*/
#include <openssl/camellia.h>
-#include "cmll_locl.h"
+#include "cmll_local.h"
void Camellia_ecb_encrypt(const unsigned char *in, unsigned char *out,
const CAMELLIA_KEY *key, const int enc)
--- /dev/null
+/*
+ * Copyright 2006-2016 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+/* ====================================================================
+ * Copyright 2006 NTT (Nippon Telegraph and Telephone Corporation) .
+ * ALL RIGHTS RESERVED.
+ *
+ * Intellectual Property information for Camellia:
+ * http://info.isl.ntt.co.jp/crypt/eng/info/chiteki.html
+ *
+ * News Release for Announcement of Camellia open source:
+ * http://www.ntt.co.jp/news/news06e/0604/060413a.html
+ *
+ * The Camellia Code included herein is developed by
+ * NTT (Nippon Telegraph and Telephone Corporation), and is contributed
+ * to the OpenSSL project.
+ */
+
+#ifndef HEADER_CAMELLIA_LOCL_H
+# define HEADER_CAMELLIA_LOCL_H
+
+typedef unsigned int u32;
+typedef unsigned char u8;
+
+int Camellia_Ekeygen(int keyBitLength, const u8 *rawKey,
+ KEY_TABLE_TYPE keyTable);
+void Camellia_EncryptBlock_Rounds(int grandRounds, const u8 plaintext[],
+ const KEY_TABLE_TYPE keyTable,
+ u8 ciphertext[]);
+void Camellia_DecryptBlock_Rounds(int grandRounds, const u8 ciphertext[],
+ const KEY_TABLE_TYPE keyTable,
+ u8 plaintext[]);
+void Camellia_EncryptBlock(int keyBitLength, const u8 plaintext[],
+ const KEY_TABLE_TYPE keyTable, u8 ciphertext[]);
+void Camellia_DecryptBlock(int keyBitLength, const u8 ciphertext[],
+ const KEY_TABLE_TYPE keyTable, u8 plaintext[]);
+#endif /* #ifndef HEADER_CAMELLIA_LOCL_H */
+++ /dev/null
-/*
- * Copyright 2006-2016 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-/* ====================================================================
- * Copyright 2006 NTT (Nippon Telegraph and Telephone Corporation) .
- * ALL RIGHTS RESERVED.
- *
- * Intellectual Property information for Camellia:
- * http://info.isl.ntt.co.jp/crypt/eng/info/chiteki.html
- *
- * News Release for Announcement of Camellia open source:
- * http://www.ntt.co.jp/news/news06e/0604/060413a.html
- *
- * The Camellia Code included herein is developed by
- * NTT (Nippon Telegraph and Telephone Corporation), and is contributed
- * to the OpenSSL project.
- */
-
-#ifndef HEADER_CAMELLIA_LOCL_H
-# define HEADER_CAMELLIA_LOCL_H
-
-typedef unsigned int u32;
-typedef unsigned char u8;
-
-int Camellia_Ekeygen(int keyBitLength, const u8 *rawKey,
- KEY_TABLE_TYPE keyTable);
-void Camellia_EncryptBlock_Rounds(int grandRounds, const u8 plaintext[],
- const KEY_TABLE_TYPE keyTable,
- u8 ciphertext[]);
-void Camellia_DecryptBlock_Rounds(int grandRounds, const u8 ciphertext[],
- const KEY_TABLE_TYPE keyTable,
- u8 plaintext[]);
-void Camellia_EncryptBlock(int keyBitLength, const u8 plaintext[],
- const KEY_TABLE_TYPE keyTable, u8 ciphertext[]);
-void Camellia_DecryptBlock(int keyBitLength, const u8 ciphertext[],
- const KEY_TABLE_TYPE keyTable, u8 plaintext[]);
-#endif /* #ifndef HEADER_CAMELLIA_LOCL_H */
#include <openssl/opensslv.h>
#include <openssl/camellia.h>
-#include "cmll_locl.h"
+#include "cmll_local.h"
int Camellia_set_key(const unsigned char *userKey, const int bits,
CAMELLIA_KEY *key)
*/
#include <openssl/cast.h>
-#include "cast_lcl.h"
+#include "cast_local.h"
/*
* The input and output encrypted as though 64bit cfb mode is being used.
*/
#include <openssl/cast.h>
-#include "cast_lcl.h"
+#include "cast_local.h"
#include <openssl/opensslv.h>
void CAST_ecb_encrypt(const unsigned char *in, unsigned char *out,
*/
#include <openssl/cast.h>
-#include "cast_lcl.h"
+#include "cast_local.h"
void CAST_encrypt(CAST_LONG *data, const CAST_KEY *key)
{
*/
#include <openssl/cast.h>
-#include "cast_lcl.h"
+#include "cast_local.h"
/*
* The input and output encrypted as though 64bit ofb mode is being used.
*/
#include <openssl/cast.h>
-#include "cast_lcl.h"
+#include "cast_local.h"
#include "cast_s.h"
#define CAST_exp(l,A,a,n) \
+++ /dev/null
-/*
- * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-#ifdef OPENSSL_SYS_WIN32
-# include <stdlib.h>
-#endif
-
-#undef c2l
-#define c2l(c,l) (l =((unsigned long)(*((c)++))) , \
- l|=((unsigned long)(*((c)++)))<< 8L, \
- l|=((unsigned long)(*((c)++)))<<16L, \
- l|=((unsigned long)(*((c)++)))<<24L)
-
-/* NOTE - c is not incremented as per c2l */
-#undef c2ln
-#define c2ln(c,l1,l2,n) { \
- c+=n; \
- l1=l2=0; \
- switch (n) { \
- case 8: l2 =((unsigned long)(*(--(c))))<<24L; \
- case 7: l2|=((unsigned long)(*(--(c))))<<16L; \
- case 6: l2|=((unsigned long)(*(--(c))))<< 8L; \
- case 5: l2|=((unsigned long)(*(--(c)))); \
- case 4: l1 =((unsigned long)(*(--(c))))<<24L; \
- case 3: l1|=((unsigned long)(*(--(c))))<<16L; \
- case 2: l1|=((unsigned long)(*(--(c))))<< 8L; \
- case 1: l1|=((unsigned long)(*(--(c)))); \
- } \
- }
-
-#undef l2c
-#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \
- *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
- *((c)++)=(unsigned char)(((l)>>16L)&0xff), \
- *((c)++)=(unsigned char)(((l)>>24L)&0xff))
-
-/* NOTE - c is not incremented as per l2c */
-#undef l2cn
-#define l2cn(l1,l2,c,n) { \
- c+=n; \
- switch (n) { \
- case 8: *(--(c))=(unsigned char)(((l2)>>24L)&0xff); \
- case 7: *(--(c))=(unsigned char)(((l2)>>16L)&0xff); \
- case 6: *(--(c))=(unsigned char)(((l2)>> 8L)&0xff); \
- case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \
- case 4: *(--(c))=(unsigned char)(((l1)>>24L)&0xff); \
- case 3: *(--(c))=(unsigned char)(((l1)>>16L)&0xff); \
- case 2: *(--(c))=(unsigned char)(((l1)>> 8L)&0xff); \
- case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \
- } \
- }
-
-/* NOTE - c is not incremented as per n2l */
-#define n2ln(c,l1,l2,n) { \
- c+=n; \
- l1=l2=0; \
- switch (n) { \
- case 8: l2 =((unsigned long)(*(--(c)))) ; \
- /* fall thru */ \
- case 7: l2|=((unsigned long)(*(--(c))))<< 8; \
- /* fall thru */ \
- case 6: l2|=((unsigned long)(*(--(c))))<<16; \
- /* fall thru */ \
- case 5: l2|=((unsigned long)(*(--(c))))<<24; \
- /* fall thru */ \
- case 4: l1 =((unsigned long)(*(--(c)))) ; \
- /* fall thru */ \
- case 3: l1|=((unsigned long)(*(--(c))))<< 8; \
- /* fall thru */ \
- case 2: l1|=((unsigned long)(*(--(c))))<<16; \
- /* fall thru */ \
- case 1: l1|=((unsigned long)(*(--(c))))<<24; \
- } \
- }
-
-/* NOTE - c is not incremented as per l2n */
-#define l2nn(l1,l2,c,n) { \
- c+=n; \
- switch (n) { \
- case 8: *(--(c))=(unsigned char)(((l2) )&0xff); \
- /* fall thru */ \
- case 7: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \
- /* fall thru */ \
- case 6: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \
- /* fall thru */ \
- case 5: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \
- /* fall thru */ \
- case 4: *(--(c))=(unsigned char)(((l1) )&0xff); \
- /* fall thru */ \
- case 3: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \
- /* fall thru */ \
- case 2: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \
- /* fall thru */ \
- case 1: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \
- } \
- }
-
-#undef n2l
-#define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24L, \
- l|=((unsigned long)(*((c)++)))<<16L, \
- l|=((unsigned long)(*((c)++)))<< 8L, \
- l|=((unsigned long)(*((c)++))))
-
-#undef l2n
-#define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \
- *((c)++)=(unsigned char)(((l)>>16L)&0xff), \
- *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
- *((c)++)=(unsigned char)(((l) )&0xff))
-
-#if defined(OPENSSL_SYS_WIN32) && defined(_MSC_VER)
-# define ROTL(a,n) (_lrotl(a,n))
-#else
-# define ROTL(a,n) ((((a)<<(n))&0xffffffffL)|((a)>>((32-(n))&31)))
-#endif
-
-#define C_M 0x3fc
-#define C_0 22L
-#define C_1 14L
-#define C_2 6L
-#define C_3 2L /* left shift */
-
-/* The rotate has an extra 16 added to it to help the x86 asm */
-#if defined(CAST_PTR)
-# define E_CAST(n,key,L,R,OP1,OP2,OP3) \
- { \
- int i; \
- t=(key[n*2] OP1 R)&0xffffffffL; \
- i=key[n*2+1]; \
- t=ROTL(t,i); \
- L^= (((((*(CAST_LONG *)((unsigned char *) \
- CAST_S_table0+((t>>C_2)&C_M)) OP2 \
- *(CAST_LONG *)((unsigned char *) \
- CAST_S_table1+((t<<C_3)&C_M)))&0xffffffffL) OP3 \
- *(CAST_LONG *)((unsigned char *) \
- CAST_S_table2+((t>>C_0)&C_M)))&0xffffffffL) OP1 \
- *(CAST_LONG *)((unsigned char *) \
- CAST_S_table3+((t>>C_1)&C_M)))&0xffffffffL; \
- }
-#elif defined(CAST_PTR2)
-# define E_CAST(n,key,L,R,OP1,OP2,OP3) \
- { \
- int i; \
- CAST_LONG u,v,w; \
- w=(key[n*2] OP1 R)&0xffffffffL; \
- i=key[n*2+1]; \
- w=ROTL(w,i); \
- u=w>>C_2; \
- v=w<<C_3; \
- u&=C_M; \
- v&=C_M; \
- t= *(CAST_LONG *)((unsigned char *)CAST_S_table0+u); \
- u=w>>C_0; \
- t=(t OP2 *(CAST_LONG *)((unsigned char *)CAST_S_table1+v))&0xffffffffL;\
- v=w>>C_1; \
- u&=C_M; \
- v&=C_M; \
- t=(t OP3 *(CAST_LONG *)((unsigned char *)CAST_S_table2+u)&0xffffffffL);\
- t=(t OP1 *(CAST_LONG *)((unsigned char *)CAST_S_table3+v)&0xffffffffL);\
- L^=(t&0xffffffff); \
- }
-#else
-# define E_CAST(n,key,L,R,OP1,OP2,OP3) \
- { \
- CAST_LONG a,b,c,d; \
- t=(key[n*2] OP1 R)&0xffffffff; \
- t=ROTL(t,(key[n*2+1])); \
- a=CAST_S_table0[(t>> 8)&0xff]; \
- b=CAST_S_table1[(t )&0xff]; \
- c=CAST_S_table2[(t>>24)&0xff]; \
- d=CAST_S_table3[(t>>16)&0xff]; \
- L^=(((((a OP2 b)&0xffffffffL) OP3 c)&0xffffffffL) OP1 d)&0xffffffffL; \
- }
-#endif
-
-extern const CAST_LONG CAST_S_table0[256];
-extern const CAST_LONG CAST_S_table1[256];
-extern const CAST_LONG CAST_S_table2[256];
-extern const CAST_LONG CAST_S_table3[256];
-extern const CAST_LONG CAST_S_table4[256];
-extern const CAST_LONG CAST_S_table5[256];
-extern const CAST_LONG CAST_S_table6[256];
-extern const CAST_LONG CAST_S_table7[256];
--- /dev/null
+/*
+ * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+#ifdef OPENSSL_SYS_WIN32
+# include <stdlib.h>
+#endif
+
+#undef c2l
+#define c2l(c,l) (l =((unsigned long)(*((c)++))) , \
+ l|=((unsigned long)(*((c)++)))<< 8L, \
+ l|=((unsigned long)(*((c)++)))<<16L, \
+ l|=((unsigned long)(*((c)++)))<<24L)
+
+/* NOTE - c is not incremented as per c2l */
+#undef c2ln
+#define c2ln(c,l1,l2,n) { \
+ c+=n; \
+ l1=l2=0; \
+ switch (n) { \
+ case 8: l2 =((unsigned long)(*(--(c))))<<24L; \
+ case 7: l2|=((unsigned long)(*(--(c))))<<16L; \
+ case 6: l2|=((unsigned long)(*(--(c))))<< 8L; \
+ case 5: l2|=((unsigned long)(*(--(c)))); \
+ case 4: l1 =((unsigned long)(*(--(c))))<<24L; \
+ case 3: l1|=((unsigned long)(*(--(c))))<<16L; \
+ case 2: l1|=((unsigned long)(*(--(c))))<< 8L; \
+ case 1: l1|=((unsigned long)(*(--(c)))); \
+ } \
+ }
+
+#undef l2c
+#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \
+ *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
+ *((c)++)=(unsigned char)(((l)>>16L)&0xff), \
+ *((c)++)=(unsigned char)(((l)>>24L)&0xff))
+
+/* NOTE - c is not incremented as per l2c */
+#undef l2cn
+#define l2cn(l1,l2,c,n) { \
+ c+=n; \
+ switch (n) { \
+ case 8: *(--(c))=(unsigned char)(((l2)>>24L)&0xff); \
+ case 7: *(--(c))=(unsigned char)(((l2)>>16L)&0xff); \
+ case 6: *(--(c))=(unsigned char)(((l2)>> 8L)&0xff); \
+ case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \
+ case 4: *(--(c))=(unsigned char)(((l1)>>24L)&0xff); \
+ case 3: *(--(c))=(unsigned char)(((l1)>>16L)&0xff); \
+ case 2: *(--(c))=(unsigned char)(((l1)>> 8L)&0xff); \
+ case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \
+ } \
+ }
+
+/* NOTE - c is not incremented as per n2l */
+#define n2ln(c,l1,l2,n) { \
+ c+=n; \
+ l1=l2=0; \
+ switch (n) { \
+ case 8: l2 =((unsigned long)(*(--(c)))) ; \
+ /* fall thru */ \
+ case 7: l2|=((unsigned long)(*(--(c))))<< 8; \
+ /* fall thru */ \
+ case 6: l2|=((unsigned long)(*(--(c))))<<16; \
+ /* fall thru */ \
+ case 5: l2|=((unsigned long)(*(--(c))))<<24; \
+ /* fall thru */ \
+ case 4: l1 =((unsigned long)(*(--(c)))) ; \
+ /* fall thru */ \
+ case 3: l1|=((unsigned long)(*(--(c))))<< 8; \
+ /* fall thru */ \
+ case 2: l1|=((unsigned long)(*(--(c))))<<16; \
+ /* fall thru */ \
+ case 1: l1|=((unsigned long)(*(--(c))))<<24; \
+ } \
+ }
+
+/* NOTE - c is not incremented as per l2n */
+#define l2nn(l1,l2,c,n) { \
+ c+=n; \
+ switch (n) { \
+ case 8: *(--(c))=(unsigned char)(((l2) )&0xff); \
+ /* fall thru */ \
+ case 7: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \
+ /* fall thru */ \
+ case 6: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \
+ /* fall thru */ \
+ case 5: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \
+ /* fall thru */ \
+ case 4: *(--(c))=(unsigned char)(((l1) )&0xff); \
+ /* fall thru */ \
+ case 3: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \
+ /* fall thru */ \
+ case 2: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \
+ /* fall thru */ \
+ case 1: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \
+ } \
+ }
+
+#undef n2l
+#define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24L, \
+ l|=((unsigned long)(*((c)++)))<<16L, \
+ l|=((unsigned long)(*((c)++)))<< 8L, \
+ l|=((unsigned long)(*((c)++))))
+
+#undef l2n
+#define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \
+ *((c)++)=(unsigned char)(((l)>>16L)&0xff), \
+ *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
+ *((c)++)=(unsigned char)(((l) )&0xff))
+
+#if defined(OPENSSL_SYS_WIN32) && defined(_MSC_VER)
+# define ROTL(a,n) (_lrotl(a,n))
+#else
+# define ROTL(a,n) ((((a)<<(n))&0xffffffffL)|((a)>>((32-(n))&31)))
+#endif
+
+#define C_M 0x3fc
+#define C_0 22L
+#define C_1 14L
+#define C_2 6L
+#define C_3 2L /* left shift */
+
+/* The rotate has an extra 16 added to it to help the x86 asm */
+#if defined(CAST_PTR)
+# define E_CAST(n,key,L,R,OP1,OP2,OP3) \
+ { \
+ int i; \
+ t=(key[n*2] OP1 R)&0xffffffffL; \
+ i=key[n*2+1]; \
+ t=ROTL(t,i); \
+ L^= (((((*(CAST_LONG *)((unsigned char *) \
+ CAST_S_table0+((t>>C_2)&C_M)) OP2 \
+ *(CAST_LONG *)((unsigned char *) \
+ CAST_S_table1+((t<<C_3)&C_M)))&0xffffffffL) OP3 \
+ *(CAST_LONG *)((unsigned char *) \
+ CAST_S_table2+((t>>C_0)&C_M)))&0xffffffffL) OP1 \
+ *(CAST_LONG *)((unsigned char *) \
+ CAST_S_table3+((t>>C_1)&C_M)))&0xffffffffL; \
+ }
+#elif defined(CAST_PTR2)
+# define E_CAST(n,key,L,R,OP1,OP2,OP3) \
+ { \
+ int i; \
+ CAST_LONG u,v,w; \
+ w=(key[n*2] OP1 R)&0xffffffffL; \
+ i=key[n*2+1]; \
+ w=ROTL(w,i); \
+ u=w>>C_2; \
+ v=w<<C_3; \
+ u&=C_M; \
+ v&=C_M; \
+ t= *(CAST_LONG *)((unsigned char *)CAST_S_table0+u); \
+ u=w>>C_0; \
+ t=(t OP2 *(CAST_LONG *)((unsigned char *)CAST_S_table1+v))&0xffffffffL;\
+ v=w>>C_1; \
+ u&=C_M; \
+ v&=C_M; \
+ t=(t OP3 *(CAST_LONG *)((unsigned char *)CAST_S_table2+u)&0xffffffffL);\
+ t=(t OP1 *(CAST_LONG *)((unsigned char *)CAST_S_table3+v)&0xffffffffL);\
+ L^=(t&0xffffffff); \
+ }
+#else
+# define E_CAST(n,key,L,R,OP1,OP2,OP3) \
+ { \
+ CAST_LONG a,b,c,d; \
+ t=(key[n*2] OP1 R)&0xffffffff; \
+ t=ROTL(t,(key[n*2+1])); \
+ a=CAST_S_table0[(t>> 8)&0xff]; \
+ b=CAST_S_table1[(t )&0xff]; \
+ c=CAST_S_table2[(t>>24)&0xff]; \
+ d=CAST_S_table3[(t>>16)&0xff]; \
+ L^=(((((a OP2 b)&0xffffffffL) OP3 c)&0xffffffffL) OP1 d)&0xffffffffL; \
+ }
+#endif
+
+extern const CAST_LONG CAST_S_table0[256];
+extern const CAST_LONG CAST_S_table1[256];
+extern const CAST_LONG CAST_S_table2[256];
+extern const CAST_LONG CAST_S_table3[256];
+extern const CAST_LONG CAST_S_table4[256];
+extern const CAST_LONG CAST_S_table5[256];
+extern const CAST_LONG CAST_S_table6[256];
+extern const CAST_LONG CAST_S_table7[256];
#include <openssl/asn1t.h>
-#include "cmp_int.h"
+#include "cmp_local.h"
/* explicit #includes not strictly needed since implied by the above: */
#include <openssl/cmp.h>
#include <openssl/bio.h>
#include <openssl/ocsp.h> /* for OCSP_REVOKED_STATUS_* */
-#include "cmp_int.h"
+#include "cmp_local.h"
/* explicit #includes not strictly needed since implied by the above: */
#include <openssl/cmp.h>
+++ /dev/null
-/*
- * Copyright 2007-2019 The OpenSSL Project Authors. All Rights Reserved.
- * Copyright Nokia 2007-2019
- * Copyright Siemens AG 2015-2019
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-#ifndef OSSL_HEADER_CMP_INT_H
-# define OSSL_HEADER_CMP_INT_H
-
-# include "internal/cryptlib.h"
-
-# include <openssl/cmp.h>
-# include <openssl/err.h>
-
-/* explicit #includes not strictly needed since implied by the above: */
-# include <openssl/crmf.h>
-# include <openssl/ossl_typ.h>
-# include <openssl/safestack.h>
-# include <openssl/x509.h>
-# include <openssl/x509v3.h>
-
-/*
- * this structure is used to store the context for CMP sessions
- */
-struct ossl_cmp_ctx_st {
- OSSL_cmp_log_cb_t log_cb; /* log callback for error/debug/etc. output */
- OSSL_CMP_severity log_verbosity; /* level of verbosity of log output */
-
- /* message transfer */
- OSSL_cmp_transfer_cb_t transfer_cb; /* default: OSSL_CMP_MSG_http_perform */
- void *transfer_cb_arg; /* allows to store optional argument to cb */
- /* HTTP-based transfer */
- char *serverPath;
- char *serverName;
- int serverPort;
- char *proxyName;
- int proxyPort;
- int msgtimeout; /* max seconds to wait for each CMP message round trip */
- int totaltimeout; /* maximum number seconds an enrollment may take, incl. */
- /* attempts polling for a response if a 'waiting' PKIStatus is received */
- time_t end_time; /* session start time + totaltimeout */
- OSSL_cmp_http_cb_t http_cb;
- void *http_cb_arg; /* allows to store optional argument to cb */
-
- /* server authentication */
- int unprotectedErrors; /* accept neg. response with no/invalid protection */
- /* to cope with broken server */
- X509 *srvCert; /* certificate used to identify the server */
- X509 *validatedSrvCert; /* caches any already validated server cert */
- X509_NAME *expected_sender; /* expected sender in pkiheader of response */
- X509_STORE *trusted; /* trust store maybe w CRLs and cert verify callback */
- STACK_OF(X509) *untrusted_certs; /* untrusted (intermediate) certs */
- int ignore_keyusage; /* ignore key usage entry when validating certs */
- int permitTAInExtraCertsForIR; /* allow use of root certs in extracerts */
- /* when validating message protection; used for 3GPP-style E.7 */
-
- /* client authentication */
- int unprotectedSend; /* send unprotected PKI messages */
- X509 *clCert; /* client cert used to identify and sign for MSG_SIG_ALG */
- EVP_PKEY *pkey; /* the key pair corresponding to clCert */
- ASN1_OCTET_STRING *referenceValue; /* optional user name for MSG_MAC_ALG */
- ASN1_OCTET_STRING *secretValue; /* password/shared secret for MSG_MAC_ALG */
- /* PBMParameters for MSG_MAC_ALG */
- size_t pbm_slen; /* currently fixed to 16 */
- int pbm_owf; /* NID of one-way function (OWF), default: SHA256 */
- int pbm_itercnt; /* currently fixed to 500 */
- int pbm_mac; /* NID of MAC algorithm, default: HMAC-SHA1 as per RFC 4210 */
-
- /* CMP message header and extra certificates */
- X509_NAME *recipient; /* to set in recipient in pkiheader */
- int digest; /* NID of digest used in MSG_SIG_ALG and POPO, default SHA256 */
- ASN1_OCTET_STRING *transactionID; /* the current transaction ID */
- ASN1_OCTET_STRING *senderNonce; /* last nonce sent */
- ASN1_OCTET_STRING *recipNonce; /* last nonce received */
- STACK_OF(OSSL_CMP_ITAV) *geninfo_ITAVs;
- int implicitConfirm; /* set implicitConfirm in IR/KUR/CR messages */
- int disableConfirm; /* disable certConf in IR/KUR/CR for broken servers */
- STACK_OF(X509) *extraCertsOut; /* to be included in request messages */
-
- /* certificate template */
- EVP_PKEY *newPkey; /* explicit new private/public key for cert enrollment */
- int newPkey_priv; /* flag indicating if newPkey contains private key */
- X509_NAME *issuer; /* issuer name to used in cert template */
- int days; /* Number of days new certificates are asked to be valid for */
- X509_NAME *subjectName; /* subject name to be used in the cert template */
- STACK_OF(GENERAL_NAME) *subjectAltNames; /* to add to the cert template */
- int SubjectAltName_nodefault;
- int setSubjectAltNameCritical;
- X509_EXTENSIONS *reqExtensions; /* exts to be added to cert template */
- CERTIFICATEPOLICIES *policies; /* policies to be included in extensions */
- int setPoliciesCritical;
- int popoMethod; /* Proof-of-possession mechanism; default: signature */
- X509 *oldCert; /* cert to be updated (via KUR) or to be revoked (via RR) */
- X509_REQ *p10CSR; /* for P10CR: PKCS#10 CSR to be sent */
-
- /* misc body contents */
- int revocationReason; /* revocation reason code to be included in RR */
- STACK_OF(OSSL_CMP_ITAV) *genm_ITAVs; /* content of general message */
-
- /* result returned in responses */
- int status; /* PKIStatus of last received IP/CP/KUP/RP/error or -1 */
- /* TODO: this should be a stack since there could be more than one */
- OSSL_CMP_PKIFREETEXT *statusString; /* of last IP/CP/KUP/RP/error */
- int failInfoCode; /* failInfoCode of last received IP/CP/KUP/error, or -1 */
- /* TODO: this should be a stack since there could be more than one */
- X509 *newCert; /* newly enrolled cert received from the CA */
- /* TODO: this should be a stack since there could be more than one */
- STACK_OF(X509) *caPubs; /* CA certs received from server (in IP message) */
- STACK_OF(X509) *extraCertsIn; /* extraCerts received from server */
-
- /* certificate confirmation */
- OSSL_cmp_certConf_cb_t certConf_cb; /* callback for app checking new cert */
- void *certConf_cb_arg; /* allows to store an argument individual to cb */
-} /* OSSL_CMP_CTX */;
-
-/*
- * ##########################################################################
- * ASN.1 DECLARATIONS
- * ##########################################################################
- */
-
-/*-
- * RevAnnContent ::= SEQUENCE {
- * status PKIStatus,
- * certId CertId,
- * willBeRevokedAt GeneralizedTime,
- * badSinceDate GeneralizedTime,
- * crlDetails Extensions OPTIONAL
- * -- extra CRL details (e.g., crl number, reason, location, etc.)
- * }
- */
-typedef struct ossl_cmp_revanncontent_st {
- ASN1_INTEGER *status;
- OSSL_CRMF_CERTID *certId;
- ASN1_GENERALIZEDTIME *willBeRevokedAt;
- ASN1_GENERALIZEDTIME *badSinceDate;
- X509_EXTENSIONS *crlDetails;
-} OSSL_CMP_REVANNCONTENT;
-DECLARE_ASN1_FUNCTIONS(OSSL_CMP_REVANNCONTENT)
-
-/*-
- * Challenge ::= SEQUENCE {
- * owf AlgorithmIdentifier OPTIONAL,
- *
- * -- MUST be present in the first Challenge; MAY be omitted in
- * -- any subsequent Challenge in POPODecKeyChallContent (if
- * -- omitted, then the owf used in the immediately preceding
- * -- Challenge is to be used).
- *
- * witness OCTET STRING,
- * -- the result of applying the one-way function (owf) to a
- * -- randomly-generated INTEGER, A. [Note that a different
- * -- INTEGER MUST be used for each Challenge.]
- * challenge OCTET STRING
- * -- the encryption (under the public key for which the cert.
- * -- request is being made) of Rand, where Rand is specified as
- * -- Rand ::= SEQUENCE {
- * -- int INTEGER,
- * -- - the randomly-generated INTEGER A (above)
- * -- sender GeneralName
- * -- - the sender's name (as included in PKIHeader)
- * -- }
- * }
- */
-typedef struct ossl_cmp_challenge_st {
- X509_ALGOR *owf;
- ASN1_OCTET_STRING *witness;
- ASN1_OCTET_STRING *challenge;
-} OSSL_CMP_CHALLENGE;
-DECLARE_ASN1_FUNCTIONS(OSSL_CMP_CHALLENGE)
-
-/*-
- * CAKeyUpdAnnContent ::= SEQUENCE {
- * oldWithNew Certificate,
- * newWithOld Certificate,
- * newWithNew Certificate
- * }
- */
-typedef struct ossl_cmp_cakeyupdanncontent_st {
- X509 *oldWithNew;
- X509 *newWithOld;
- X509 *newWithNew;
-} OSSL_CMP_CAKEYUPDANNCONTENT;
-DECLARE_ASN1_FUNCTIONS(OSSL_CMP_CAKEYUPDANNCONTENT)
-
-/*-
- * declared already here as it will be used in OSSL_CMP_MSG (nested) and
- * infoType and infoValue
- */
-typedef STACK_OF(OSSL_CMP_MSG) OSSL_CMP_MSGS;
-DECLARE_ASN1_FUNCTIONS(OSSL_CMP_MSGS)
-
-/*-
- * InfoTypeAndValue ::= SEQUENCE {
- * infoType OBJECT IDENTIFIER,
- * infoValue ANY DEFINED BY infoType OPTIONAL
- * }
- */
-struct ossl_cmp_itav_st {
- ASN1_OBJECT *infoType;
- union {
- char *ptr;
- /* NID_id_it_caProtEncCert - CA Protocol Encryption Certificate */
- X509 *caProtEncCert;
- /* NID_id_it_signKeyPairTypes - Signing Key Pair Types */
- STACK_OF(X509_ALGOR) *signKeyPairTypes;
- /* NID_id_it_encKeyPairTypes - Encryption/Key Agreement Key Pair Types */
- STACK_OF(X509_ALGOR) *encKeyPairTypes;
- /* NID_id_it_preferredSymmAlg - Preferred Symmetric Algorithm */
- X509_ALGOR *preferredSymmAlg;
- /* NID_id_it_caKeyUpdateInfo - Updated CA Key Pair */
- OSSL_CMP_CAKEYUPDANNCONTENT *caKeyUpdateInfo;
- /* NID_id_it_currentCRL - CRL */
- X509_CRL *currentCRL;
- /* NID_id_it_unsupportedOIDs - Unsupported Object Identifiers */
- STACK_OF(ASN1_OBJECT) *unsupportedOIDs;
- /* NID_id_it_keyPairParamReq - Key Pair Parameters Request */
- ASN1_OBJECT *keyPairParamReq;
- /* NID_id_it_keyPairParamRep - Key Pair Parameters Response */
- X509_ALGOR *keyPairParamRep;
- /* NID_id_it_revPassphrase - Revocation Passphrase */
- OSSL_CRMF_ENCRYPTEDVALUE *revPassphrase;
- /* NID_id_it_implicitConfirm - ImplicitConfirm */
- ASN1_NULL *implicitConfirm;
- /* NID_id_it_confirmWaitTime - ConfirmWaitTime */
- ASN1_GENERALIZEDTIME *confirmWaitTime;
- /* NID_id_it_origPKIMessage - origPKIMessage */
- OSSL_CMP_MSGS *origPKIMessage;
- /* NID_id_it_suppLangTags - Supported Language Tags */
- STACK_OF(ASN1_UTF8STRING) *suppLangTagsValue;
- /* this is to be used for so far undeclared objects */
- ASN1_TYPE *other;
- } infoValue;
-} /* OSSL_CMP_ITAV */;
-DECLARE_ASN1_FUNCTIONS(OSSL_CMP_ITAV)
-DECLARE_ASN1_DUP_FUNCTION(OSSL_CMP_ITAV)
-
-typedef struct ossl_cmp_certorenccert_st {
- int type;
- union {
- X509 *certificate;
- OSSL_CRMF_ENCRYPTEDVALUE *encryptedCert;
- } value;
-} OSSL_CMP_CERTORENCCERT;
-DECLARE_ASN1_FUNCTIONS(OSSL_CMP_CERTORENCCERT)
-
-/*-
- * CertifiedKeyPair ::= SEQUENCE {
- * certOrEncCert CertOrEncCert,
- * privateKey [0] EncryptedValue OPTIONAL,
- * -- see [CRMF] for comment on encoding
- * publicationInfo [1] PKIPublicationInfo OPTIONAL
- * }
- */
-typedef struct ossl_cmp_certifiedkeypair_st {
- OSSL_CMP_CERTORENCCERT *certOrEncCert;
- OSSL_CRMF_ENCRYPTEDVALUE *privateKey;
- OSSL_CRMF_PKIPUBLICATIONINFO *publicationInfo;
-} OSSL_CMP_CERTIFIEDKEYPAIR;
-DECLARE_ASN1_FUNCTIONS(OSSL_CMP_CERTIFIEDKEYPAIR)
-
-/*-
- * PKIStatusInfo ::= SEQUENCE {
- * status PKIStatus,
- * statusString PKIFreeText OPTIONAL,
- * failInfo PKIFailureInfo OPTIONAL
- * }
- */
-struct ossl_cmp_pkisi_st {
- OSSL_CMP_PKISTATUS *status;
- OSSL_CMP_PKIFREETEXT *statusString;
- OSSL_CMP_PKIFAILUREINFO *failInfo;
-} /* OSSL_CMP_PKISI */;
-DECLARE_ASN1_FUNCTIONS(OSSL_CMP_PKISI)
-DECLARE_ASN1_DUP_FUNCTION(OSSL_CMP_PKISI)
-
-/*-
- * RevReqContent ::= SEQUENCE OF RevDetails
- *
- * RevDetails ::= SEQUENCE {
- * certDetails CertTemplate,
- * crlEntryDetails Extensions OPTIONAL
- * }
- */
-typedef struct ossl_cmp_revdetails_st {
- OSSL_CRMF_CERTTEMPLATE *certDetails;
- X509_EXTENSIONS *crlEntryDetails;
-} OSSL_CMP_REVDETAILS;
-DECLARE_ASN1_FUNCTIONS(OSSL_CMP_REVDETAILS)
-DEFINE_STACK_OF(OSSL_CMP_REVDETAILS)
-
-/*-
- * RevRepContent ::= SEQUENCE {
- * status SEQUENCE SIZE (1..MAX) OF PKIStatusInfo,
- * -- in same order as was sent in RevReqContent
- * revCerts [0] SEQUENCE SIZE (1..MAX) OF CertId
- * OPTIONAL,
- * -- IDs for which revocation was requested
- * -- (same order as status)
- * crls [1] SEQUENCE SIZE (1..MAX) OF CertificateList
- * OPTIONAL
- * -- the resulting CRLs (there may be more than one)
- * }
- */
-struct ossl_cmp_revrepcontent_st {
- STACK_OF(OSSL_CMP_PKISI) *status;
- STACK_OF(OSSL_CRMF_CERTID) *revCerts;
- STACK_OF(X509_CRL) *crls;
-} /* OSSL_CMP_REVREPCONTENT */;
-DECLARE_ASN1_FUNCTIONS(OSSL_CMP_REVREPCONTENT)
-
-/*-
- * KeyRecRepContent ::= SEQUENCE {
- * status PKIStatusInfo,
- * newSigCert [0] Certificate OPTIONAL,
- * caCerts [1] SEQUENCE SIZE (1..MAX) OF
- * Certificate OPTIONAL,
- * keyPairHist [2] SEQUENCE SIZE (1..MAX) OF
- * CertifiedKeyPair OPTIONAL
- * }
- */
-typedef struct ossl_cmp_keyrecrepcontent_st {
- OSSL_CMP_PKISI *status;
- X509 *newSigCert;
- STACK_OF(X509) *caCerts;
- STACK_OF(OSSL_CMP_CERTIFIEDKEYPAIR) *keyPairHist;
-} OSSL_CMP_KEYRECREPCONTENT;
-DECLARE_ASN1_FUNCTIONS(OSSL_CMP_KEYRECREPCONTENT)
-
-/*-
- * ErrorMsgContent ::= SEQUENCE {
- * pKIStatusInfo PKIStatusInfo,
- * errorCode INTEGER OPTIONAL,
- * -- implementation-specific error codes
- * errorDetails PKIFreeText OPTIONAL
- * -- implementation-specific error details
- * }
- */
-typedef struct ossl_cmp_errormsgcontent_st {
- OSSL_CMP_PKISI *pKIStatusInfo;
- ASN1_INTEGER *errorCode;
- OSSL_CMP_PKIFREETEXT *errorDetails;
-} OSSL_CMP_ERRORMSGCONTENT;
-DECLARE_ASN1_FUNCTIONS(OSSL_CMP_ERRORMSGCONTENT)
-
-/*-
- * CertConfirmContent ::= SEQUENCE OF CertStatus
- *
- * CertStatus ::= SEQUENCE {
- * certHash OCTET STRING,
- * -- the hash of the certificate, using the same hash algorithm
- * -- as is used to create and verify the certificate signature
- * certReqId INTEGER,
- * -- to match this confirmation with the corresponding req/rep
- * statusInfo PKIStatusInfo OPTIONAL
- * }
- */
-struct ossl_cmp_certstatus_st {
- ASN1_OCTET_STRING *certHash;
- ASN1_INTEGER *certReqId;
- OSSL_CMP_PKISI *statusInfo;
-} /* OSSL_CMP_CERTSTATUS */;
-DECLARE_ASN1_FUNCTIONS(OSSL_CMP_CERTSTATUS)
-
-typedef STACK_OF(OSSL_CMP_CERTSTATUS) OSSL_CMP_CERTCONFIRMCONTENT;
-DECLARE_ASN1_FUNCTIONS(OSSL_CMP_CERTCONFIRMCONTENT)
-
-/*-
- * CertResponse ::= SEQUENCE {
- * certReqId INTEGER,
- * -- to match this response with corresponding request (a value
- * -- of -1 is to be used if certReqId is not specified in the
- * -- corresponding request)
- * status PKIStatusInfo,
- * certifiedKeyPair CertifiedKeyPair OPTIONAL,
- * rspInfo OCTET STRING OPTIONAL
- * -- analogous to the id-regInfo-utf8Pairs string defined
- * -- for regInfo in CertReqMsg [CRMF]
- * }
- */
-struct ossl_cmp_certresponse_st {
- ASN1_INTEGER *certReqId;
- OSSL_CMP_PKISI *status;
- OSSL_CMP_CERTIFIEDKEYPAIR *certifiedKeyPair;
- ASN1_OCTET_STRING *rspInfo;
-} /* OSSL_CMP_CERTRESPONSE */;
-DECLARE_ASN1_FUNCTIONS(OSSL_CMP_CERTRESPONSE)
-
-/*-
- * CertRepMessage ::= SEQUENCE {
- * caPubs [1] SEQUENCE SIZE (1..MAX) OF CMPCertificate
- * OPTIONAL,
- * response SEQUENCE OF CertResponse
- * }
- */
-struct ossl_cmp_certrepmessage_st {
- STACK_OF(X509) *caPubs;
- STACK_OF(OSSL_CMP_CERTRESPONSE) *response;
-} /* OSSL_CMP_CERTREPMESSAGE */;
-DECLARE_ASN1_FUNCTIONS(OSSL_CMP_CERTREPMESSAGE)
-
-/*-
- * PollReqContent ::= SEQUENCE OF SEQUENCE {
- * certReqId INTEGER
- * }
- */
-typedef struct ossl_cmp_pollreq_st {
- ASN1_INTEGER *certReqId;
-} OSSL_CMP_POLLREQ;
-DECLARE_ASN1_FUNCTIONS(OSSL_CMP_POLLREQ)
-DEFINE_STACK_OF(OSSL_CMP_POLLREQ)
-typedef STACK_OF(OSSL_CMP_POLLREQ) OSSL_CMP_POLLREQCONTENT;
-DECLARE_ASN1_FUNCTIONS(OSSL_CMP_POLLREQCONTENT)
-
-/*-
- * PollRepContent ::= SEQUENCE OF SEQUENCE {
- * certReqId INTEGER,
- * checkAfter INTEGER, -- time in seconds
- * reason PKIFreeText OPTIONAL
- * }
- */
-struct ossl_cmp_pollrep_st {
- ASN1_INTEGER *certReqId;
- ASN1_INTEGER *checkAfter;
- OSSL_CMP_PKIFREETEXT *reason;
-} /* OSSL_CMP_POLLREP */;
-DECLARE_ASN1_FUNCTIONS(OSSL_CMP_POLLREP)
-DEFINE_STACK_OF(OSSL_CMP_POLLREP)
-DECLARE_ASN1_FUNCTIONS(OSSL_CMP_POLLREPCONTENT)
-
-/*-
- * PKIHeader ::= SEQUENCE {
- * pvno INTEGER { cmp1999(1), cmp2000(2) },
- * sender GeneralName,
- * -- identifies the sender
- * recipient GeneralName,
- * -- identifies the intended recipient
- * messageTime [0] GeneralizedTime OPTIONAL,
- * -- time of production of this message (used when sender
- * -- believes that the transport will be "suitable"; i.e.,
- * -- that the time will still be meaningful upon receipt)
- * protectionAlg [1] AlgorithmIdentifier OPTIONAL,
- * -- algorithm used for calculation of protection bits
- * senderKID [2] KeyIdentifier OPTIONAL,
- * recipKID [3] KeyIdentifier OPTIONAL,
- * -- to identify specific keys used for protection
- * transactionID [4] OCTET STRING OPTIONAL,
- * -- identifies the transaction; i.e., this will be the same in
- * -- corresponding request, response, certConf, and PKIConf
- * -- messages
- * senderNonce [5] OCTET STRING OPTIONAL,
- * recipNonce [6] OCTET STRING OPTIONAL,
- * -- nonces used to provide replay protection, senderNonce
- * -- is inserted by the creator of this message; recipNonce
- * -- is a nonce previously inserted in a related message by
- * -- the intended recipient of this message
- * freeText [7] PKIFreeText OPTIONAL,
- * -- this may be used to indicate context-specific instructions
- * -- (this field is intended for human consumption)
- * generalInfo [8] SEQUENCE SIZE (1..MAX) OF
- * InfoTypeAndValue OPTIONAL
- * -- this may be used to convey context-specific information
- * -- (this field not primarily intended for human consumption)
- * }
- */
-struct ossl_cmp_pkiheader_st {
- ASN1_INTEGER *pvno;
- GENERAL_NAME *sender;
- GENERAL_NAME *recipient;
- ASN1_GENERALIZEDTIME *messageTime; /* 0 */
- X509_ALGOR *protectionAlg; /* 1 */
- ASN1_OCTET_STRING *senderKID; /* 2 */
- ASN1_OCTET_STRING *recipKID; /* 3 */
- ASN1_OCTET_STRING *transactionID; /* 4 */
- ASN1_OCTET_STRING *senderNonce; /* 5 */
- ASN1_OCTET_STRING *recipNonce; /* 6 */
- OSSL_CMP_PKIFREETEXT *freeText; /* 7 */
- STACK_OF(OSSL_CMP_ITAV) *generalInfo; /* 8 */
-} /* OSSL_CMP_PKIHEADER */;
-
-typedef STACK_OF(OSSL_CMP_CHALLENGE) OSSL_CMP_POPODECKEYCHALLCONTENT;
-DECLARE_ASN1_FUNCTIONS(OSSL_CMP_POPODECKEYCHALLCONTENT)
-typedef STACK_OF(ASN1_INTEGER) OSSL_CMP_POPODECKEYRESPCONTENT;
-DECLARE_ASN1_FUNCTIONS(OSSL_CMP_POPODECKEYRESPCONTENT)
-typedef STACK_OF(OSSL_CMP_REVDETAILS) OSSL_CMP_REVREQCONTENT;
-DECLARE_ASN1_FUNCTIONS(OSSL_CMP_REVREQCONTENT)
-typedef STACK_OF(X509_CRL) OSSL_CMP_CRLANNCONTENT;
-DECLARE_ASN1_FUNCTIONS(OSSL_CMP_CRLANNCONTENT)
-typedef STACK_OF(OSSL_CMP_ITAV) OSSL_CMP_GENMSGCONTENT;
-DECLARE_ASN1_FUNCTIONS(OSSL_CMP_GENMSGCONTENT)
-typedef STACK_OF(OSSL_CMP_ITAV) OSSL_CMP_GENREPCONTENT;
-DECLARE_ASN1_FUNCTIONS(OSSL_CMP_GENREPCONTENT)
-
-/*-
- * PKIBody ::= CHOICE { -- message-specific body elements
- * ir [0] CertReqMessages, --Initialization Request
- * ip [1] CertRepMessage, --Initialization Response
- * cr [2] CertReqMessages, --Certification Request
- * cp [3] CertRepMessage, --Certification Response
- * p10cr [4] CertificationRequest, --imported from [PKCS10]
- * popdecc [5] POPODecKeyChallContent, --pop Challenge
- * popdecr [6] POPODecKeyRespContent, --pop Response
- * kur [7] CertReqMessages, --Key Update Request
- * kup [8] CertRepMessage, --Key Update Response
- * krr [9] CertReqMessages, --Key Recovery Request
- * krp [10] KeyRecRepContent, --Key Recovery Response
- * rr [11] RevReqContent, --Revocation Request
- * rp [12] RevRepContent, --Revocation Response
- * ccr [13] CertReqMessages, --Cross-Cert. Request
- * ccp [14] CertRepMessage, --Cross-Cert. Response
- * ckuann [15] CAKeyUpdAnnContent, --CA Key Update Ann.
- * cann [16] CertAnnContent, --Certificate Ann.
- * rann [17] RevAnnContent, --Revocation Ann.
- * crlann [18] CRLAnnContent, --CRL Announcement
- * pkiconf [19] PKIConfirmContent, --Confirmation
- * nested [20] NestedMessageContent, --Nested Message
- * genm [21] GenMsgContent, --General Message
- * genp [22] GenRepContent, --General Response
- * error [23] ErrorMsgContent, --Error Message
- * certConf [24] CertConfirmContent, --Certificate confirm
- * pollReq [25] PollReqContent, --Polling request
- * pollRep [26] PollRepContent --Polling response
- */
-typedef struct ossl_cmp_pkibody_st {
- int type;
- union {
- OSSL_CRMF_MSGS *ir; /* 0 */
- OSSL_CMP_CERTREPMESSAGE *ip; /* 1 */
- OSSL_CRMF_MSGS *cr; /* 2 */
- OSSL_CMP_CERTREPMESSAGE *cp; /* 3 */
- /* p10cr [4] CertificationRequest, --imported from [PKCS10] */
- /*
- * PKCS10_CERTIFICATIONREQUEST is effectively X509_REQ
- * so it is used directly
- */
- X509_REQ *p10cr; /* 4 */
- /* popdecc [5] POPODecKeyChallContent, --pop Challenge */
- /* POPODecKeyChallContent ::= SEQUENCE OF Challenge */
- OSSL_CMP_POPODECKEYCHALLCONTENT *popdecc; /* 5 */
- /* popdecr [6] POPODecKeyRespContent, --pop Response */
- /* POPODecKeyRespContent ::= SEQUENCE OF INTEGER */
- OSSL_CMP_POPODECKEYRESPCONTENT *popdecr; /* 6 */
- OSSL_CRMF_MSGS *kur; /* 7 */
- OSSL_CMP_CERTREPMESSAGE *kup; /* 8 */
- OSSL_CRMF_MSGS *krr; /* 9 */
-
- /* krp [10] KeyRecRepContent, --Key Recovery Response */
- OSSL_CMP_KEYRECREPCONTENT *krp; /* 10 */
- /* rr [11] RevReqContent, --Revocation Request */
- OSSL_CMP_REVREQCONTENT *rr; /* 11 */
- /* rp [12] RevRepContent, --Revocation Response */
- OSSL_CMP_REVREPCONTENT *rp; /* 12 */
- /* ccr [13] CertReqMessages, --Cross-Cert. Request */
- OSSL_CRMF_MSGS *ccr; /* 13 */
- /* ccp [14] CertRepMessage, --Cross-Cert. Response */
- OSSL_CMP_CERTREPMESSAGE *ccp; /* 14 */
- /* ckuann [15] CAKeyUpdAnnContent, --CA Key Update Ann. */
- OSSL_CMP_CAKEYUPDANNCONTENT *ckuann; /* 15 */
- /* cann [16] CertAnnContent, --Certificate Ann. */
- /* OSSL_CMP_CMPCERTIFICATE is effectively X509 so it is used directly */
- X509 *cann; /* 16 */
- /* rann [17] RevAnnContent, --Revocation Ann. */
- OSSL_CMP_REVANNCONTENT *rann; /* 17 */
- /* crlann [18] CRLAnnContent, --CRL Announcement */
- /* CRLAnnContent ::= SEQUENCE OF CertificateList */
- OSSL_CMP_CRLANNCONTENT *crlann;
- /* PKIConfirmContent ::= NULL */
- /* pkiconf [19] PKIConfirmContent, --Confirmation */
- /* OSSL_CMP_PKICONFIRMCONTENT would be only a typedef of ASN1_NULL */
- /* OSSL_CMP_CONFIRMCONTENT *pkiconf; */
- /*
- * NOTE: this should ASN1_NULL according to the RFC
- * but there might be a struct in it when sent from faulty servers...
- */
- ASN1_TYPE *pkiconf; /* 19 */
- /* nested [20] NestedMessageContent, --Nested Message */
- /* NestedMessageContent ::= PKIMessages */
- OSSL_CMP_MSGS *nested; /* 20 */
- /* genm [21] GenMsgContent, --General Message */
- /* GenMsgContent ::= SEQUENCE OF InfoTypeAndValue */
- OSSL_CMP_GENMSGCONTENT *genm; /* 21 */
- /* genp [22] GenRepContent, --General Response */
- /* GenRepContent ::= SEQUENCE OF InfoTypeAndValue */
- OSSL_CMP_GENREPCONTENT *genp; /* 22 */
- /* error [23] ErrorMsgContent, --Error Message */
- OSSL_CMP_ERRORMSGCONTENT *error; /* 23 */
- /* certConf [24] CertConfirmContent, --Certificate confirm */
- OSSL_CMP_CERTCONFIRMCONTENT *certConf; /* 24 */
- /* pollReq [25] PollReqContent, --Polling request */
- OSSL_CMP_POLLREQCONTENT *pollReq;
- /* pollRep [26] PollRepContent --Polling response */
- OSSL_CMP_POLLREPCONTENT *pollRep;
- } value;
-} OSSL_CMP_PKIBODY;
-DECLARE_ASN1_FUNCTIONS(OSSL_CMP_PKIBODY)
-
-/*-
- * PKIProtection ::= BIT STRING
- *
- * PKIMessages ::= SEQUENCE SIZE (1..MAX) OF PKIMessage
- *
- * PKIMessage ::= SEQUENCE {
- * header PKIHeader,
- * body PKIBody,
- * protection [0] PKIProtection OPTIONAL,
- * extraCerts [1] SEQUENCE SIZE (1..MAX) OF CMPCertificate
- * OPTIONAL
- * }
- */
-struct ossl_cmp_msg_st {
- OSSL_CMP_PKIHEADER *header;
- OSSL_CMP_PKIBODY *body;
- ASN1_BIT_STRING *protection; /* 0 */
- /* OSSL_CMP_CMPCERTIFICATE is effectively X509 so it is used directly */
- STACK_OF(X509) *extraCerts; /* 1 */
-} /* OSSL_CMP_MSG */;
-DECLARE_ASN1_FUNCTIONS(OSSL_CMP_MSG)
-DECLARE_ASN1_DUP_FUNCTION(OSSL_CMP_MSG)
-
-/*-
- * ProtectedPart ::= SEQUENCE {
- * header PKIHeader,
- * body PKIBody
- * }
- */
-typedef struct cmp_protectedpart_st {
- OSSL_CMP_PKIHEADER *header;
- OSSL_CMP_PKIBODY *body;
-} CMP_PROTECTEDPART;
-DECLARE_ASN1_FUNCTIONS(CMP_PROTECTEDPART)
-
-/*-
- * this is not defined here as it is already in CRMF:
- * id-PasswordBasedMac OBJECT IDENTIFIER ::= {1 2 840 113533 7 66 13}
- * PBMParameter ::= SEQUENCE {
- * salt OCTET STRING,
- * -- note: implementations MAY wish to limit acceptable sizes
- * -- of this string to values appropriate for their environment
- * -- in order to reduce the risk of denial-of-service attacks
- * owf AlgorithmIdentifier,
- * -- AlgId for a One-Way Function (SHA-1 recommended)
- * iterationCount INTEGER,
- * -- number of times the OWF is applied
- * -- note: implementations MAY wish to limit acceptable sizes
- * -- of this integer to values appropriate for their environment
- * -- in order to reduce the risk of denial-of-service attacks
- * mac AlgorithmIdentifier
- * -- the MAC AlgId (e.g., DES-MAC, Triple-DES-MAC [PKCS11],
- * } -- or HMAC [RFC2104, RFC2202])
- */
-/*-
- * TODO: this is not yet defined here - but DH is anyway not used yet
- *
- * id-DHBasedMac OBJECT IDENTIFIER ::= {1 2 840 113533 7 66 30}
- * DHBMParameter ::= SEQUENCE {
- * owf AlgorithmIdentifier,
- * -- AlgId for a One-Way Function (SHA-1 recommended)
- * mac AlgorithmIdentifier
- * -- the MAC AlgId (e.g., DES-MAC, Triple-DES-MAC [PKCS11],
- * } -- or HMAC [RFC2104, RFC2202])
- */
-/*-
- * The following is not cared for, because it is described in section 5.2.5
- * that this is beyond the scope of CMP
- * OOBCert ::= CMPCertificate
- *
- * OOBCertHash ::= SEQUENCE {
- * hashAlg [0] AlgorithmIdentifier OPTIONAL,
- * certId [1] CertId OPTIONAL,
- * hashVal BIT STRING
- * -- hashVal is calculated over the DER encoding of the
- * -- self-signed certificate with the identifier certID.
- * }
- */
-
-/*
- * functions
- */
-
-/* from cmp_asn.c */
-int ossl_cmp_asn1_get_int(const ASN1_INTEGER *a);
-
-/* from cmp_util.c */
-const char *ossl_cmp_log_parse_metadata(const char *buf,
- OSSL_CMP_severity *level, char **func,
- char **file, int *line);
-/* workaround for 4096 bytes limitation of ERR_print_errors_cb() */
-void ossl_cmp_add_error_txt(const char *separator, const char *txt);
-# define ossl_cmp_add_error_data(txt) ossl_cmp_add_error_txt(" : ", txt)
-# define ossl_cmp_add_error_line(txt) ossl_cmp_add_error_txt("\n", txt)
-/* functions manipulating lists of certificates etc could be generally useful */
-int ossl_cmp_sk_X509_add1_cert (STACK_OF(X509) *sk, X509 *cert,
- int no_dup, int prepend);
-int ossl_cmp_sk_X509_add1_certs(STACK_OF(X509) *sk, STACK_OF(X509) *certs,
- int no_self_signed, int no_dups, int prepend);
-int ossl_cmp_X509_STORE_add1_certs(X509_STORE *store, STACK_OF(X509) *certs,
- int only_self_signed);
-STACK_OF(X509) *ossl_cmp_X509_STORE_get1_certs(X509_STORE *store);
-int ossl_cmp_asn1_octet_string_set1(ASN1_OCTET_STRING **tgt,
- const ASN1_OCTET_STRING *src);
-int ossl_cmp_asn1_octet_string_set1_bytes(ASN1_OCTET_STRING **tgt,
- const unsigned char *bytes, int len);
-STACK_OF(X509) *ossl_cmp_build_cert_chain(STACK_OF(X509) *certs, X509 *cert);
-
-/* from cmp_ctx.c */
-int ossl_cmp_ctx_set0_validatedSrvCert(OSSL_CMP_CTX *ctx, X509 *cert);
-int ossl_cmp_ctx_set_status(OSSL_CMP_CTX *ctx, int status);
-int ossl_cmp_ctx_set0_statusString(OSSL_CMP_CTX *ctx,
- OSSL_CMP_PKIFREETEXT *text);
-int ossl_cmp_ctx_set_failInfoCode(OSSL_CMP_CTX *ctx, int fail_info);
-int ossl_cmp_ctx_set0_newCert(OSSL_CMP_CTX *ctx, X509 *cert);
-int ossl_cmp_ctx_set1_caPubs(OSSL_CMP_CTX *ctx, STACK_OF(X509) *caPubs);
-int ossl_cmp_ctx_set1_extraCertsIn(OSSL_CMP_CTX *ctx,
- STACK_OF(X509) *extraCertsIn);
-int ossl_cmp_ctx_set1_recipNonce(OSSL_CMP_CTX *ctx,
- const ASN1_OCTET_STRING *nonce);
-
-# define OSSL_CMP_TRANSACTIONID_LENGTH 16
-
-#endif /* !defined OSSL_HEADER_CMP_INT_H */
--- /dev/null
+/*
+ * Copyright 2007-2019 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright Nokia 2007-2019
+ * Copyright Siemens AG 2015-2019
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+#ifndef OSSL_HEADER_CMP_INT_H
+# define OSSL_HEADER_CMP_INT_H
+
+# include "internal/cryptlib.h"
+
+# include <openssl/cmp.h>
+# include <openssl/err.h>
+
+/* explicit #includes not strictly needed since implied by the above: */
+# include <openssl/crmf.h>
+# include <openssl/ossl_typ.h>
+# include <openssl/safestack.h>
+# include <openssl/x509.h>
+# include <openssl/x509v3.h>
+
+/*
+ * this structure is used to store the context for CMP sessions
+ */
+struct ossl_cmp_ctx_st {
+ OSSL_cmp_log_cb_t log_cb; /* log callback for error/debug/etc. output */
+ OSSL_CMP_severity log_verbosity; /* level of verbosity of log output */
+
+ /* message transfer */
+ OSSL_cmp_transfer_cb_t transfer_cb; /* default: OSSL_CMP_MSG_http_perform */
+ void *transfer_cb_arg; /* allows to store optional argument to cb */
+ /* HTTP-based transfer */
+ char *serverPath;
+ char *serverName;
+ int serverPort;
+ char *proxyName;
+ int proxyPort;
+ int msgtimeout; /* max seconds to wait for each CMP message round trip */
+ int totaltimeout; /* maximum number seconds an enrollment may take, incl. */
+ /* attempts polling for a response if a 'waiting' PKIStatus is received */
+ time_t end_time; /* session start time + totaltimeout */
+ OSSL_cmp_http_cb_t http_cb;
+ void *http_cb_arg; /* allows to store optional argument to cb */
+
+ /* server authentication */
+ int unprotectedErrors; /* accept neg. response with no/invalid protection */
+ /* to cope with broken server */
+ X509 *srvCert; /* certificate used to identify the server */
+ X509 *validatedSrvCert; /* caches any already validated server cert */
+ X509_NAME *expected_sender; /* expected sender in pkiheader of response */
+ X509_STORE *trusted; /* trust store maybe w CRLs and cert verify callback */
+ STACK_OF(X509) *untrusted_certs; /* untrusted (intermediate) certs */
+ int ignore_keyusage; /* ignore key usage entry when validating certs */
+ int permitTAInExtraCertsForIR; /* allow use of root certs in extracerts */
+ /* when validating message protection; used for 3GPP-style E.7 */
+
+ /* client authentication */
+ int unprotectedSend; /* send unprotected PKI messages */
+ X509 *clCert; /* client cert used to identify and sign for MSG_SIG_ALG */
+ EVP_PKEY *pkey; /* the key pair corresponding to clCert */
+ ASN1_OCTET_STRING *referenceValue; /* optional user name for MSG_MAC_ALG */
+ ASN1_OCTET_STRING *secretValue; /* password/shared secret for MSG_MAC_ALG */
+ /* PBMParameters for MSG_MAC_ALG */
+ size_t pbm_slen; /* currently fixed to 16 */
+ int pbm_owf; /* NID of one-way function (OWF), default: SHA256 */
+ int pbm_itercnt; /* currently fixed to 500 */
+ int pbm_mac; /* NID of MAC algorithm, default: HMAC-SHA1 as per RFC 4210 */
+
+ /* CMP message header and extra certificates */
+ X509_NAME *recipient; /* to set in recipient in pkiheader */
+ int digest; /* NID of digest used in MSG_SIG_ALG and POPO, default SHA256 */
+ ASN1_OCTET_STRING *transactionID; /* the current transaction ID */
+ ASN1_OCTET_STRING *senderNonce; /* last nonce sent */
+ ASN1_OCTET_STRING *recipNonce; /* last nonce received */
+ STACK_OF(OSSL_CMP_ITAV) *geninfo_ITAVs;
+ int implicitConfirm; /* set implicitConfirm in IR/KUR/CR messages */
+ int disableConfirm; /* disable certConf in IR/KUR/CR for broken servers */
+ STACK_OF(X509) *extraCertsOut; /* to be included in request messages */
+
+ /* certificate template */
+ EVP_PKEY *newPkey; /* explicit new private/public key for cert enrollment */
+ int newPkey_priv; /* flag indicating if newPkey contains private key */
+ X509_NAME *issuer; /* issuer name to used in cert template */
+ int days; /* Number of days new certificates are asked to be valid for */
+ X509_NAME *subjectName; /* subject name to be used in the cert template */
+ STACK_OF(GENERAL_NAME) *subjectAltNames; /* to add to the cert template */
+ int SubjectAltName_nodefault;
+ int setSubjectAltNameCritical;
+ X509_EXTENSIONS *reqExtensions; /* exts to be added to cert template */
+ CERTIFICATEPOLICIES *policies; /* policies to be included in extensions */
+ int setPoliciesCritical;
+ int popoMethod; /* Proof-of-possession mechanism; default: signature */
+ X509 *oldCert; /* cert to be updated (via KUR) or to be revoked (via RR) */
+ X509_REQ *p10CSR; /* for P10CR: PKCS#10 CSR to be sent */
+
+ /* misc body contents */
+ int revocationReason; /* revocation reason code to be included in RR */
+ STACK_OF(OSSL_CMP_ITAV) *genm_ITAVs; /* content of general message */
+
+ /* result returned in responses */
+ int status; /* PKIStatus of last received IP/CP/KUP/RP/error or -1 */
+ /* TODO: this should be a stack since there could be more than one */
+ OSSL_CMP_PKIFREETEXT *statusString; /* of last IP/CP/KUP/RP/error */
+ int failInfoCode; /* failInfoCode of last received IP/CP/KUP/error, or -1 */
+ /* TODO: this should be a stack since there could be more than one */
+ X509 *newCert; /* newly enrolled cert received from the CA */
+ /* TODO: this should be a stack since there could be more than one */
+ STACK_OF(X509) *caPubs; /* CA certs received from server (in IP message) */
+ STACK_OF(X509) *extraCertsIn; /* extraCerts received from server */
+
+ /* certificate confirmation */
+ OSSL_cmp_certConf_cb_t certConf_cb; /* callback for app checking new cert */
+ void *certConf_cb_arg; /* allows to store an argument individual to cb */
+} /* OSSL_CMP_CTX */;
+
+/*
+ * ##########################################################################
+ * ASN.1 DECLARATIONS
+ * ##########################################################################
+ */
+
+/*-
+ * RevAnnContent ::= SEQUENCE {
+ * status PKIStatus,
+ * certId CertId,
+ * willBeRevokedAt GeneralizedTime,
+ * badSinceDate GeneralizedTime,
+ * crlDetails Extensions OPTIONAL
+ * -- extra CRL details (e.g., crl number, reason, location, etc.)
+ * }
+ */
+typedef struct ossl_cmp_revanncontent_st {
+ ASN1_INTEGER *status;
+ OSSL_CRMF_CERTID *certId;
+ ASN1_GENERALIZEDTIME *willBeRevokedAt;
+ ASN1_GENERALIZEDTIME *badSinceDate;
+ X509_EXTENSIONS *crlDetails;
+} OSSL_CMP_REVANNCONTENT;
+DECLARE_ASN1_FUNCTIONS(OSSL_CMP_REVANNCONTENT)
+
+/*-
+ * Challenge ::= SEQUENCE {
+ * owf AlgorithmIdentifier OPTIONAL,
+ *
+ * -- MUST be present in the first Challenge; MAY be omitted in
+ * -- any subsequent Challenge in POPODecKeyChallContent (if
+ * -- omitted, then the owf used in the immediately preceding
+ * -- Challenge is to be used).
+ *
+ * witness OCTET STRING,
+ * -- the result of applying the one-way function (owf) to a
+ * -- randomly-generated INTEGER, A. [Note that a different
+ * -- INTEGER MUST be used for each Challenge.]
+ * challenge OCTET STRING
+ * -- the encryption (under the public key for which the cert.
+ * -- request is being made) of Rand, where Rand is specified as
+ * -- Rand ::= SEQUENCE {
+ * -- int INTEGER,
+ * -- - the randomly-generated INTEGER A (above)
+ * -- sender GeneralName
+ * -- - the sender's name (as included in PKIHeader)
+ * -- }
+ * }
+ */
+typedef struct ossl_cmp_challenge_st {
+ X509_ALGOR *owf;
+ ASN1_OCTET_STRING *witness;
+ ASN1_OCTET_STRING *challenge;
+} OSSL_CMP_CHALLENGE;
+DECLARE_ASN1_FUNCTIONS(OSSL_CMP_CHALLENGE)
+
+/*-
+ * CAKeyUpdAnnContent ::= SEQUENCE {
+ * oldWithNew Certificate,
+ * newWithOld Certificate,
+ * newWithNew Certificate
+ * }
+ */
+typedef struct ossl_cmp_cakeyupdanncontent_st {
+ X509 *oldWithNew;
+ X509 *newWithOld;
+ X509 *newWithNew;
+} OSSL_CMP_CAKEYUPDANNCONTENT;
+DECLARE_ASN1_FUNCTIONS(OSSL_CMP_CAKEYUPDANNCONTENT)
+
+/*-
+ * declared already here as it will be used in OSSL_CMP_MSG (nested) and
+ * infoType and infoValue
+ */
+typedef STACK_OF(OSSL_CMP_MSG) OSSL_CMP_MSGS;
+DECLARE_ASN1_FUNCTIONS(OSSL_CMP_MSGS)
+
+/*-
+ * InfoTypeAndValue ::= SEQUENCE {
+ * infoType OBJECT IDENTIFIER,
+ * infoValue ANY DEFINED BY infoType OPTIONAL
+ * }
+ */
+struct ossl_cmp_itav_st {
+ ASN1_OBJECT *infoType;
+ union {
+ char *ptr;
+ /* NID_id_it_caProtEncCert - CA Protocol Encryption Certificate */
+ X509 *caProtEncCert;
+ /* NID_id_it_signKeyPairTypes - Signing Key Pair Types */
+ STACK_OF(X509_ALGOR) *signKeyPairTypes;
+ /* NID_id_it_encKeyPairTypes - Encryption/Key Agreement Key Pair Types */
+ STACK_OF(X509_ALGOR) *encKeyPairTypes;
+ /* NID_id_it_preferredSymmAlg - Preferred Symmetric Algorithm */
+ X509_ALGOR *preferredSymmAlg;
+ /* NID_id_it_caKeyUpdateInfo - Updated CA Key Pair */
+ OSSL_CMP_CAKEYUPDANNCONTENT *caKeyUpdateInfo;
+ /* NID_id_it_currentCRL - CRL */
+ X509_CRL *currentCRL;
+ /* NID_id_it_unsupportedOIDs - Unsupported Object Identifiers */
+ STACK_OF(ASN1_OBJECT) *unsupportedOIDs;
+ /* NID_id_it_keyPairParamReq - Key Pair Parameters Request */
+ ASN1_OBJECT *keyPairParamReq;
+ /* NID_id_it_keyPairParamRep - Key Pair Parameters Response */
+ X509_ALGOR *keyPairParamRep;
+ /* NID_id_it_revPassphrase - Revocation Passphrase */
+ OSSL_CRMF_ENCRYPTEDVALUE *revPassphrase;
+ /* NID_id_it_implicitConfirm - ImplicitConfirm */
+ ASN1_NULL *implicitConfirm;
+ /* NID_id_it_confirmWaitTime - ConfirmWaitTime */
+ ASN1_GENERALIZEDTIME *confirmWaitTime;
+ /* NID_id_it_origPKIMessage - origPKIMessage */
+ OSSL_CMP_MSGS *origPKIMessage;
+ /* NID_id_it_suppLangTags - Supported Language Tags */
+ STACK_OF(ASN1_UTF8STRING) *suppLangTagsValue;
+ /* this is to be used for so far undeclared objects */
+ ASN1_TYPE *other;
+ } infoValue;
+} /* OSSL_CMP_ITAV */;
+DECLARE_ASN1_FUNCTIONS(OSSL_CMP_ITAV)
+DECLARE_ASN1_DUP_FUNCTION(OSSL_CMP_ITAV)
+
+typedef struct ossl_cmp_certorenccert_st {
+ int type;
+ union {
+ X509 *certificate;
+ OSSL_CRMF_ENCRYPTEDVALUE *encryptedCert;
+ } value;
+} OSSL_CMP_CERTORENCCERT;
+DECLARE_ASN1_FUNCTIONS(OSSL_CMP_CERTORENCCERT)
+
+/*-
+ * CertifiedKeyPair ::= SEQUENCE {
+ * certOrEncCert CertOrEncCert,
+ * privateKey [0] EncryptedValue OPTIONAL,
+ * -- see [CRMF] for comment on encoding
+ * publicationInfo [1] PKIPublicationInfo OPTIONAL
+ * }
+ */
+typedef struct ossl_cmp_certifiedkeypair_st {
+ OSSL_CMP_CERTORENCCERT *certOrEncCert;
+ OSSL_CRMF_ENCRYPTEDVALUE *privateKey;
+ OSSL_CRMF_PKIPUBLICATIONINFO *publicationInfo;
+} OSSL_CMP_CERTIFIEDKEYPAIR;
+DECLARE_ASN1_FUNCTIONS(OSSL_CMP_CERTIFIEDKEYPAIR)
+
+/*-
+ * PKIStatusInfo ::= SEQUENCE {
+ * status PKIStatus,
+ * statusString PKIFreeText OPTIONAL,
+ * failInfo PKIFailureInfo OPTIONAL
+ * }
+ */
+struct ossl_cmp_pkisi_st {
+ OSSL_CMP_PKISTATUS *status;
+ OSSL_CMP_PKIFREETEXT *statusString;
+ OSSL_CMP_PKIFAILUREINFO *failInfo;
+} /* OSSL_CMP_PKISI */;
+DECLARE_ASN1_FUNCTIONS(OSSL_CMP_PKISI)
+DECLARE_ASN1_DUP_FUNCTION(OSSL_CMP_PKISI)
+
+/*-
+ * RevReqContent ::= SEQUENCE OF RevDetails
+ *
+ * RevDetails ::= SEQUENCE {
+ * certDetails CertTemplate,
+ * crlEntryDetails Extensions OPTIONAL
+ * }
+ */
+typedef struct ossl_cmp_revdetails_st {
+ OSSL_CRMF_CERTTEMPLATE *certDetails;
+ X509_EXTENSIONS *crlEntryDetails;
+} OSSL_CMP_REVDETAILS;
+DECLARE_ASN1_FUNCTIONS(OSSL_CMP_REVDETAILS)
+DEFINE_STACK_OF(OSSL_CMP_REVDETAILS)
+
+/*-
+ * RevRepContent ::= SEQUENCE {
+ * status SEQUENCE SIZE (1..MAX) OF PKIStatusInfo,
+ * -- in same order as was sent in RevReqContent
+ * revCerts [0] SEQUENCE SIZE (1..MAX) OF CertId
+ * OPTIONAL,
+ * -- IDs for which revocation was requested
+ * -- (same order as status)
+ * crls [1] SEQUENCE SIZE (1..MAX) OF CertificateList
+ * OPTIONAL
+ * -- the resulting CRLs (there may be more than one)
+ * }
+ */
+struct ossl_cmp_revrepcontent_st {
+ STACK_OF(OSSL_CMP_PKISI) *status;
+ STACK_OF(OSSL_CRMF_CERTID) *revCerts;
+ STACK_OF(X509_CRL) *crls;
+} /* OSSL_CMP_REVREPCONTENT */;
+DECLARE_ASN1_FUNCTIONS(OSSL_CMP_REVREPCONTENT)
+
+/*-
+ * KeyRecRepContent ::= SEQUENCE {
+ * status PKIStatusInfo,
+ * newSigCert [0] Certificate OPTIONAL,
+ * caCerts [1] SEQUENCE SIZE (1..MAX) OF
+ * Certificate OPTIONAL,
+ * keyPairHist [2] SEQUENCE SIZE (1..MAX) OF
+ * CertifiedKeyPair OPTIONAL
+ * }
+ */
+typedef struct ossl_cmp_keyrecrepcontent_st {
+ OSSL_CMP_PKISI *status;
+ X509 *newSigCert;
+ STACK_OF(X509) *caCerts;
+ STACK_OF(OSSL_CMP_CERTIFIEDKEYPAIR) *keyPairHist;
+} OSSL_CMP_KEYRECREPCONTENT;
+DECLARE_ASN1_FUNCTIONS(OSSL_CMP_KEYRECREPCONTENT)
+
+/*-
+ * ErrorMsgContent ::= SEQUENCE {
+ * pKIStatusInfo PKIStatusInfo,
+ * errorCode INTEGER OPTIONAL,
+ * -- implementation-specific error codes
+ * errorDetails PKIFreeText OPTIONAL
+ * -- implementation-specific error details
+ * }
+ */
+typedef struct ossl_cmp_errormsgcontent_st {
+ OSSL_CMP_PKISI *pKIStatusInfo;
+ ASN1_INTEGER *errorCode;
+ OSSL_CMP_PKIFREETEXT *errorDetails;
+} OSSL_CMP_ERRORMSGCONTENT;
+DECLARE_ASN1_FUNCTIONS(OSSL_CMP_ERRORMSGCONTENT)
+
+/*-
+ * CertConfirmContent ::= SEQUENCE OF CertStatus
+ *
+ * CertStatus ::= SEQUENCE {
+ * certHash OCTET STRING,
+ * -- the hash of the certificate, using the same hash algorithm
+ * -- as is used to create and verify the certificate signature
+ * certReqId INTEGER,
+ * -- to match this confirmation with the corresponding req/rep
+ * statusInfo PKIStatusInfo OPTIONAL
+ * }
+ */
+struct ossl_cmp_certstatus_st {
+ ASN1_OCTET_STRING *certHash;
+ ASN1_INTEGER *certReqId;
+ OSSL_CMP_PKISI *statusInfo;
+} /* OSSL_CMP_CERTSTATUS */;
+DECLARE_ASN1_FUNCTIONS(OSSL_CMP_CERTSTATUS)
+
+typedef STACK_OF(OSSL_CMP_CERTSTATUS) OSSL_CMP_CERTCONFIRMCONTENT;
+DECLARE_ASN1_FUNCTIONS(OSSL_CMP_CERTCONFIRMCONTENT)
+
+/*-
+ * CertResponse ::= SEQUENCE {
+ * certReqId INTEGER,
+ * -- to match this response with corresponding request (a value
+ * -- of -1 is to be used if certReqId is not specified in the
+ * -- corresponding request)
+ * status PKIStatusInfo,
+ * certifiedKeyPair CertifiedKeyPair OPTIONAL,
+ * rspInfo OCTET STRING OPTIONAL
+ * -- analogous to the id-regInfo-utf8Pairs string defined
+ * -- for regInfo in CertReqMsg [CRMF]
+ * }
+ */
+struct ossl_cmp_certresponse_st {
+ ASN1_INTEGER *certReqId;
+ OSSL_CMP_PKISI *status;
+ OSSL_CMP_CERTIFIEDKEYPAIR *certifiedKeyPair;
+ ASN1_OCTET_STRING *rspInfo;
+} /* OSSL_CMP_CERTRESPONSE */;
+DECLARE_ASN1_FUNCTIONS(OSSL_CMP_CERTRESPONSE)
+
+/*-
+ * CertRepMessage ::= SEQUENCE {
+ * caPubs [1] SEQUENCE SIZE (1..MAX) OF CMPCertificate
+ * OPTIONAL,
+ * response SEQUENCE OF CertResponse
+ * }
+ */
+struct ossl_cmp_certrepmessage_st {
+ STACK_OF(X509) *caPubs;
+ STACK_OF(OSSL_CMP_CERTRESPONSE) *response;
+} /* OSSL_CMP_CERTREPMESSAGE */;
+DECLARE_ASN1_FUNCTIONS(OSSL_CMP_CERTREPMESSAGE)
+
+/*-
+ * PollReqContent ::= SEQUENCE OF SEQUENCE {
+ * certReqId INTEGER
+ * }
+ */
+typedef struct ossl_cmp_pollreq_st {
+ ASN1_INTEGER *certReqId;
+} OSSL_CMP_POLLREQ;
+DECLARE_ASN1_FUNCTIONS(OSSL_CMP_POLLREQ)
+DEFINE_STACK_OF(OSSL_CMP_POLLREQ)
+typedef STACK_OF(OSSL_CMP_POLLREQ) OSSL_CMP_POLLREQCONTENT;
+DECLARE_ASN1_FUNCTIONS(OSSL_CMP_POLLREQCONTENT)
+
+/*-
+ * PollRepContent ::= SEQUENCE OF SEQUENCE {
+ * certReqId INTEGER,
+ * checkAfter INTEGER, -- time in seconds
+ * reason PKIFreeText OPTIONAL
+ * }
+ */
+struct ossl_cmp_pollrep_st {
+ ASN1_INTEGER *certReqId;
+ ASN1_INTEGER *checkAfter;
+ OSSL_CMP_PKIFREETEXT *reason;
+} /* OSSL_CMP_POLLREP */;
+DECLARE_ASN1_FUNCTIONS(OSSL_CMP_POLLREP)
+DEFINE_STACK_OF(OSSL_CMP_POLLREP)
+DECLARE_ASN1_FUNCTIONS(OSSL_CMP_POLLREPCONTENT)
+
+/*-
+ * PKIHeader ::= SEQUENCE {
+ * pvno INTEGER { cmp1999(1), cmp2000(2) },
+ * sender GeneralName,
+ * -- identifies the sender
+ * recipient GeneralName,
+ * -- identifies the intended recipient
+ * messageTime [0] GeneralizedTime OPTIONAL,
+ * -- time of production of this message (used when sender
+ * -- believes that the transport will be "suitable"; i.e.,
+ * -- that the time will still be meaningful upon receipt)
+ * protectionAlg [1] AlgorithmIdentifier OPTIONAL,
+ * -- algorithm used for calculation of protection bits
+ * senderKID [2] KeyIdentifier OPTIONAL,
+ * recipKID [3] KeyIdentifier OPTIONAL,
+ * -- to identify specific keys used for protection
+ * transactionID [4] OCTET STRING OPTIONAL,
+ * -- identifies the transaction; i.e., this will be the same in
+ * -- corresponding request, response, certConf, and PKIConf
+ * -- messages
+ * senderNonce [5] OCTET STRING OPTIONAL,
+ * recipNonce [6] OCTET STRING OPTIONAL,
+ * -- nonces used to provide replay protection, senderNonce
+ * -- is inserted by the creator of this message; recipNonce
+ * -- is a nonce previously inserted in a related message by
+ * -- the intended recipient of this message
+ * freeText [7] PKIFreeText OPTIONAL,
+ * -- this may be used to indicate context-specific instructions
+ * -- (this field is intended for human consumption)
+ * generalInfo [8] SEQUENCE SIZE (1..MAX) OF
+ * InfoTypeAndValue OPTIONAL
+ * -- this may be used to convey context-specific information
+ * -- (this field not primarily intended for human consumption)
+ * }
+ */
+struct ossl_cmp_pkiheader_st {
+ ASN1_INTEGER *pvno;
+ GENERAL_NAME *sender;
+ GENERAL_NAME *recipient;
+ ASN1_GENERALIZEDTIME *messageTime; /* 0 */
+ X509_ALGOR *protectionAlg; /* 1 */
+ ASN1_OCTET_STRING *senderKID; /* 2 */
+ ASN1_OCTET_STRING *recipKID; /* 3 */
+ ASN1_OCTET_STRING *transactionID; /* 4 */
+ ASN1_OCTET_STRING *senderNonce; /* 5 */
+ ASN1_OCTET_STRING *recipNonce; /* 6 */
+ OSSL_CMP_PKIFREETEXT *freeText; /* 7 */
+ STACK_OF(OSSL_CMP_ITAV) *generalInfo; /* 8 */
+} /* OSSL_CMP_PKIHEADER */;
+
+typedef STACK_OF(OSSL_CMP_CHALLENGE) OSSL_CMP_POPODECKEYCHALLCONTENT;
+DECLARE_ASN1_FUNCTIONS(OSSL_CMP_POPODECKEYCHALLCONTENT)
+typedef STACK_OF(ASN1_INTEGER) OSSL_CMP_POPODECKEYRESPCONTENT;
+DECLARE_ASN1_FUNCTIONS(OSSL_CMP_POPODECKEYRESPCONTENT)
+typedef STACK_OF(OSSL_CMP_REVDETAILS) OSSL_CMP_REVREQCONTENT;
+DECLARE_ASN1_FUNCTIONS(OSSL_CMP_REVREQCONTENT)
+typedef STACK_OF(X509_CRL) OSSL_CMP_CRLANNCONTENT;
+DECLARE_ASN1_FUNCTIONS(OSSL_CMP_CRLANNCONTENT)
+typedef STACK_OF(OSSL_CMP_ITAV) OSSL_CMP_GENMSGCONTENT;
+DECLARE_ASN1_FUNCTIONS(OSSL_CMP_GENMSGCONTENT)
+typedef STACK_OF(OSSL_CMP_ITAV) OSSL_CMP_GENREPCONTENT;
+DECLARE_ASN1_FUNCTIONS(OSSL_CMP_GENREPCONTENT)
+
+/*-
+ * PKIBody ::= CHOICE { -- message-specific body elements
+ * ir [0] CertReqMessages, --Initialization Request
+ * ip [1] CertRepMessage, --Initialization Response
+ * cr [2] CertReqMessages, --Certification Request
+ * cp [3] CertRepMessage, --Certification Response
+ * p10cr [4] CertificationRequest, --imported from [PKCS10]
+ * popdecc [5] POPODecKeyChallContent, --pop Challenge
+ * popdecr [6] POPODecKeyRespContent, --pop Response
+ * kur [7] CertReqMessages, --Key Update Request
+ * kup [8] CertRepMessage, --Key Update Response
+ * krr [9] CertReqMessages, --Key Recovery Request
+ * krp [10] KeyRecRepContent, --Key Recovery Response
+ * rr [11] RevReqContent, --Revocation Request
+ * rp [12] RevRepContent, --Revocation Response
+ * ccr [13] CertReqMessages, --Cross-Cert. Request
+ * ccp [14] CertRepMessage, --Cross-Cert. Response
+ * ckuann [15] CAKeyUpdAnnContent, --CA Key Update Ann.
+ * cann [16] CertAnnContent, --Certificate Ann.
+ * rann [17] RevAnnContent, --Revocation Ann.
+ * crlann [18] CRLAnnContent, --CRL Announcement
+ * pkiconf [19] PKIConfirmContent, --Confirmation
+ * nested [20] NestedMessageContent, --Nested Message
+ * genm [21] GenMsgContent, --General Message
+ * genp [22] GenRepContent, --General Response
+ * error [23] ErrorMsgContent, --Error Message
+ * certConf [24] CertConfirmContent, --Certificate confirm
+ * pollReq [25] PollReqContent, --Polling request
+ * pollRep [26] PollRepContent --Polling response
+ */
+typedef struct ossl_cmp_pkibody_st {
+ int type;
+ union {
+ OSSL_CRMF_MSGS *ir; /* 0 */
+ OSSL_CMP_CERTREPMESSAGE *ip; /* 1 */
+ OSSL_CRMF_MSGS *cr; /* 2 */
+ OSSL_CMP_CERTREPMESSAGE *cp; /* 3 */
+ /* p10cr [4] CertificationRequest, --imported from [PKCS10] */
+ /*
+ * PKCS10_CERTIFICATIONREQUEST is effectively X509_REQ
+ * so it is used directly
+ */
+ X509_REQ *p10cr; /* 4 */
+ /* popdecc [5] POPODecKeyChallContent, --pop Challenge */
+ /* POPODecKeyChallContent ::= SEQUENCE OF Challenge */
+ OSSL_CMP_POPODECKEYCHALLCONTENT *popdecc; /* 5 */
+ /* popdecr [6] POPODecKeyRespContent, --pop Response */
+ /* POPODecKeyRespContent ::= SEQUENCE OF INTEGER */
+ OSSL_CMP_POPODECKEYRESPCONTENT *popdecr; /* 6 */
+ OSSL_CRMF_MSGS *kur; /* 7 */
+ OSSL_CMP_CERTREPMESSAGE *kup; /* 8 */
+ OSSL_CRMF_MSGS *krr; /* 9 */
+
+ /* krp [10] KeyRecRepContent, --Key Recovery Response */
+ OSSL_CMP_KEYRECREPCONTENT *krp; /* 10 */
+ /* rr [11] RevReqContent, --Revocation Request */
+ OSSL_CMP_REVREQCONTENT *rr; /* 11 */
+ /* rp [12] RevRepContent, --Revocation Response */
+ OSSL_CMP_REVREPCONTENT *rp; /* 12 */
+ /* ccr [13] CertReqMessages, --Cross-Cert. Request */
+ OSSL_CRMF_MSGS *ccr; /* 13 */
+ /* ccp [14] CertRepMessage, --Cross-Cert. Response */
+ OSSL_CMP_CERTREPMESSAGE *ccp; /* 14 */
+ /* ckuann [15] CAKeyUpdAnnContent, --CA Key Update Ann. */
+ OSSL_CMP_CAKEYUPDANNCONTENT *ckuann; /* 15 */
+ /* cann [16] CertAnnContent, --Certificate Ann. */
+ /* OSSL_CMP_CMPCERTIFICATE is effectively X509 so it is used directly */
+ X509 *cann; /* 16 */
+ /* rann [17] RevAnnContent, --Revocation Ann. */
+ OSSL_CMP_REVANNCONTENT *rann; /* 17 */
+ /* crlann [18] CRLAnnContent, --CRL Announcement */
+ /* CRLAnnContent ::= SEQUENCE OF CertificateList */
+ OSSL_CMP_CRLANNCONTENT *crlann;
+ /* PKIConfirmContent ::= NULL */
+ /* pkiconf [19] PKIConfirmContent, --Confirmation */
+ /* OSSL_CMP_PKICONFIRMCONTENT would be only a typedef of ASN1_NULL */
+ /* OSSL_CMP_CONFIRMCONTENT *pkiconf; */
+ /*
+ * NOTE: this should ASN1_NULL according to the RFC
+ * but there might be a struct in it when sent from faulty servers...
+ */
+ ASN1_TYPE *pkiconf; /* 19 */
+ /* nested [20] NestedMessageContent, --Nested Message */
+ /* NestedMessageContent ::= PKIMessages */
+ OSSL_CMP_MSGS *nested; /* 20 */
+ /* genm [21] GenMsgContent, --General Message */
+ /* GenMsgContent ::= SEQUENCE OF InfoTypeAndValue */
+ OSSL_CMP_GENMSGCONTENT *genm; /* 21 */
+ /* genp [22] GenRepContent, --General Response */
+ /* GenRepContent ::= SEQUENCE OF InfoTypeAndValue */
+ OSSL_CMP_GENREPCONTENT *genp; /* 22 */
+ /* error [23] ErrorMsgContent, --Error Message */
+ OSSL_CMP_ERRORMSGCONTENT *error; /* 23 */
+ /* certConf [24] CertConfirmContent, --Certificate confirm */
+ OSSL_CMP_CERTCONFIRMCONTENT *certConf; /* 24 */
+ /* pollReq [25] PollReqContent, --Polling request */
+ OSSL_CMP_POLLREQCONTENT *pollReq;
+ /* pollRep [26] PollRepContent --Polling response */
+ OSSL_CMP_POLLREPCONTENT *pollRep;
+ } value;
+} OSSL_CMP_PKIBODY;
+DECLARE_ASN1_FUNCTIONS(OSSL_CMP_PKIBODY)
+
+/*-
+ * PKIProtection ::= BIT STRING
+ *
+ * PKIMessages ::= SEQUENCE SIZE (1..MAX) OF PKIMessage
+ *
+ * PKIMessage ::= SEQUENCE {
+ * header PKIHeader,
+ * body PKIBody,
+ * protection [0] PKIProtection OPTIONAL,
+ * extraCerts [1] SEQUENCE SIZE (1..MAX) OF CMPCertificate
+ * OPTIONAL
+ * }
+ */
+struct ossl_cmp_msg_st {
+ OSSL_CMP_PKIHEADER *header;
+ OSSL_CMP_PKIBODY *body;
+ ASN1_BIT_STRING *protection; /* 0 */
+ /* OSSL_CMP_CMPCERTIFICATE is effectively X509 so it is used directly */
+ STACK_OF(X509) *extraCerts; /* 1 */
+} /* OSSL_CMP_MSG */;
+DECLARE_ASN1_FUNCTIONS(OSSL_CMP_MSG)
+DECLARE_ASN1_DUP_FUNCTION(OSSL_CMP_MSG)
+
+/*-
+ * ProtectedPart ::= SEQUENCE {
+ * header PKIHeader,
+ * body PKIBody
+ * }
+ */
+typedef struct cmp_protectedpart_st {
+ OSSL_CMP_PKIHEADER *header;
+ OSSL_CMP_PKIBODY *body;
+} CMP_PROTECTEDPART;
+DECLARE_ASN1_FUNCTIONS(CMP_PROTECTEDPART)
+
+/*-
+ * this is not defined here as it is already in CRMF:
+ * id-PasswordBasedMac OBJECT IDENTIFIER ::= {1 2 840 113533 7 66 13}
+ * PBMParameter ::= SEQUENCE {
+ * salt OCTET STRING,
+ * -- note: implementations MAY wish to limit acceptable sizes
+ * -- of this string to values appropriate for their environment
+ * -- in order to reduce the risk of denial-of-service attacks
+ * owf AlgorithmIdentifier,
+ * -- AlgId for a One-Way Function (SHA-1 recommended)
+ * iterationCount INTEGER,
+ * -- number of times the OWF is applied
+ * -- note: implementations MAY wish to limit acceptable sizes
+ * -- of this integer to values appropriate for their environment
+ * -- in order to reduce the risk of denial-of-service attacks
+ * mac AlgorithmIdentifier
+ * -- the MAC AlgId (e.g., DES-MAC, Triple-DES-MAC [PKCS11],
+ * } -- or HMAC [RFC2104, RFC2202])
+ */
+/*-
+ * TODO: this is not yet defined here - but DH is anyway not used yet
+ *
+ * id-DHBasedMac OBJECT IDENTIFIER ::= {1 2 840 113533 7 66 30}
+ * DHBMParameter ::= SEQUENCE {
+ * owf AlgorithmIdentifier,
+ * -- AlgId for a One-Way Function (SHA-1 recommended)
+ * mac AlgorithmIdentifier
+ * -- the MAC AlgId (e.g., DES-MAC, Triple-DES-MAC [PKCS11],
+ * } -- or HMAC [RFC2104, RFC2202])
+ */
+/*-
+ * The following is not cared for, because it is described in section 5.2.5
+ * that this is beyond the scope of CMP
+ * OOBCert ::= CMPCertificate
+ *
+ * OOBCertHash ::= SEQUENCE {
+ * hashAlg [0] AlgorithmIdentifier OPTIONAL,
+ * certId [1] CertId OPTIONAL,
+ * hashVal BIT STRING
+ * -- hashVal is calculated over the DER encoding of the
+ * -- self-signed certificate with the identifier certID.
+ * }
+ */
+
+/*
+ * functions
+ */
+
+/* from cmp_asn.c */
+int ossl_cmp_asn1_get_int(const ASN1_INTEGER *a);
+
+/* from cmp_util.c */
+const char *ossl_cmp_log_parse_metadata(const char *buf,
+ OSSL_CMP_severity *level, char **func,
+ char **file, int *line);
+/* workaround for 4096 bytes limitation of ERR_print_errors_cb() */
+void ossl_cmp_add_error_txt(const char *separator, const char *txt);
+# define ossl_cmp_add_error_data(txt) ossl_cmp_add_error_txt(" : ", txt)
+# define ossl_cmp_add_error_line(txt) ossl_cmp_add_error_txt("\n", txt)
+/* functions manipulating lists of certificates etc could be generally useful */
+int ossl_cmp_sk_X509_add1_cert (STACK_OF(X509) *sk, X509 *cert,
+ int no_dup, int prepend);
+int ossl_cmp_sk_X509_add1_certs(STACK_OF(X509) *sk, STACK_OF(X509) *certs,
+ int no_self_signed, int no_dups, int prepend);
+int ossl_cmp_X509_STORE_add1_certs(X509_STORE *store, STACK_OF(X509) *certs,
+ int only_self_signed);
+STACK_OF(X509) *ossl_cmp_X509_STORE_get1_certs(X509_STORE *store);
+int ossl_cmp_asn1_octet_string_set1(ASN1_OCTET_STRING **tgt,
+ const ASN1_OCTET_STRING *src);
+int ossl_cmp_asn1_octet_string_set1_bytes(ASN1_OCTET_STRING **tgt,
+ const unsigned char *bytes, int len);
+STACK_OF(X509) *ossl_cmp_build_cert_chain(STACK_OF(X509) *certs, X509 *cert);
+
+/* from cmp_ctx.c */
+int ossl_cmp_ctx_set0_validatedSrvCert(OSSL_CMP_CTX *ctx, X509 *cert);
+int ossl_cmp_ctx_set_status(OSSL_CMP_CTX *ctx, int status);
+int ossl_cmp_ctx_set0_statusString(OSSL_CMP_CTX *ctx,
+ OSSL_CMP_PKIFREETEXT *text);
+int ossl_cmp_ctx_set_failInfoCode(OSSL_CMP_CTX *ctx, int fail_info);
+int ossl_cmp_ctx_set0_newCert(OSSL_CMP_CTX *ctx, X509 *cert);
+int ossl_cmp_ctx_set1_caPubs(OSSL_CMP_CTX *ctx, STACK_OF(X509) *caPubs);
+int ossl_cmp_ctx_set1_extraCertsIn(OSSL_CMP_CTX *ctx,
+ STACK_OF(X509) *extraCertsIn);
+int ossl_cmp_ctx_set1_recipNonce(OSSL_CMP_CTX *ctx,
+ const ASN1_OCTET_STRING *nonce);
+
+# define OSSL_CMP_TRANSACTIONID_LENGTH 16
+
+#endif /* !defined OSSL_HEADER_CMP_INT_H */
#include <string.h>
#include <openssl/cmp_util.h>
-#include "cmp_int.h" /* just for decls of internal functions defined here */
+#include "cmp_local.h" /* just for decls of internal functions defined here */
#include <openssl/cmperr.h>
#include <openssl/err.h> /* should be implied by cmperr.h */
#include <openssl/x509v3.h>
#include <openssl/pem.h>
#include <openssl/x509v3.h>
#include <openssl/cms.h>
-#include "cms_lcl.h"
+#include "cms_local.h"
ASN1_SEQUENCE(CMS_IssuerAndSerialNumber) = {
#include <openssl/x509v3.h>
#include <openssl/err.h>
#include <openssl/cms.h>
-#include "cms_lcl.h"
+#include "cms_local.h"
#include "internal/nelem.h"
/*-
#include <openssl/cms.h>
#include <openssl/bio.h>
#include <openssl/comp.h>
-#include "cms_lcl.h"
+#include "cms_local.h"
#ifdef ZLIB
#include <openssl/x509v3.h>
#include <openssl/err.h>
#include <openssl/cms.h>
-#include "cms_lcl.h"
+#include "cms_local.h"
/* CMS DigestedData Utilities */
#include <openssl/err.h>
#include <openssl/cms.h>
#include <openssl/rand.h>
-#include "cms_lcl.h"
+#include "cms_local.h"
/* CMS EncryptedData Utilities */
#include <openssl/err.h>
#include <openssl/cms.h>
#include <openssl/aes.h>
-#include "cms_lcl.h"
+#include "cms_local.h"
#include "crypto/asn1.h"
#include "crypto/evp.h"
#include <openssl/err.h>
#include <openssl/cms.h>
#include <openssl/ess.h>
-#include "cms_lcl.h"
+#include "cms_local.h"
#include "crypto/ess.h"
#include "crypto/cms.h"
#include <openssl/err.h>
#include <openssl/pem.h>
#include <openssl/cms.h>
-#include "cms_lcl.h"
+#include "cms_local.h"
/* unfortunately cannot constify BIO_new_NDEF() due to this and PKCS7_stream() */
int CMS_stream(unsigned char ***boundary, CMS_ContentInfo *cms)
#include <openssl/err.h>
#include <openssl/cms.h>
#include <openssl/aes.h>
-#include "cms_lcl.h"
+#include "cms_local.h"
#include "crypto/asn1.h"
/* Key Agreement Recipient Info (KARI) routines */
+++ /dev/null
-/*
- * Copyright 2008-2018 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-#ifndef HEADER_CMS_LCL_H
-# define HEADER_CMS_LCL_H
-
-# include <openssl/x509.h>
-
-/*
- * Cryptographic message syntax (CMS) structures: taken from RFC3852
- */
-
-/* Forward references */
-
-typedef struct CMS_IssuerAndSerialNumber_st CMS_IssuerAndSerialNumber;
-typedef struct CMS_EncapsulatedContentInfo_st CMS_EncapsulatedContentInfo;
-typedef struct CMS_SignerIdentifier_st CMS_SignerIdentifier;
-typedef struct CMS_SignedData_st CMS_SignedData;
-typedef struct CMS_OtherRevocationInfoFormat_st CMS_OtherRevocationInfoFormat;
-typedef struct CMS_OriginatorInfo_st CMS_OriginatorInfo;
-typedef struct CMS_EncryptedContentInfo_st CMS_EncryptedContentInfo;
-typedef struct CMS_EnvelopedData_st CMS_EnvelopedData;
-typedef struct CMS_DigestedData_st CMS_DigestedData;
-typedef struct CMS_EncryptedData_st CMS_EncryptedData;
-typedef struct CMS_AuthenticatedData_st CMS_AuthenticatedData;
-typedef struct CMS_CompressedData_st CMS_CompressedData;
-typedef struct CMS_OtherCertificateFormat_st CMS_OtherCertificateFormat;
-typedef struct CMS_KeyTransRecipientInfo_st CMS_KeyTransRecipientInfo;
-typedef struct CMS_OriginatorPublicKey_st CMS_OriginatorPublicKey;
-typedef struct CMS_OriginatorIdentifierOrKey_st CMS_OriginatorIdentifierOrKey;
-typedef struct CMS_KeyAgreeRecipientInfo_st CMS_KeyAgreeRecipientInfo;
-typedef struct CMS_RecipientKeyIdentifier_st CMS_RecipientKeyIdentifier;
-typedef struct CMS_KeyAgreeRecipientIdentifier_st
- CMS_KeyAgreeRecipientIdentifier;
-typedef struct CMS_KEKIdentifier_st CMS_KEKIdentifier;
-typedef struct CMS_KEKRecipientInfo_st CMS_KEKRecipientInfo;
-typedef struct CMS_PasswordRecipientInfo_st CMS_PasswordRecipientInfo;
-typedef struct CMS_OtherRecipientInfo_st CMS_OtherRecipientInfo;
-typedef struct CMS_ReceiptsFrom_st CMS_ReceiptsFrom;
-
-struct CMS_ContentInfo_st {
- ASN1_OBJECT *contentType;
- union {
- ASN1_OCTET_STRING *data;
- CMS_SignedData *signedData;
- CMS_EnvelopedData *envelopedData;
- CMS_DigestedData *digestedData;
- CMS_EncryptedData *encryptedData;
- CMS_AuthenticatedData *authenticatedData;
- CMS_CompressedData *compressedData;
- ASN1_TYPE *other;
- /* Other types ... */
- void *otherData;
- } d;
-};
-
-DEFINE_STACK_OF(CMS_CertificateChoices)
-
-struct CMS_SignedData_st {
- int32_t version;
- STACK_OF(X509_ALGOR) *digestAlgorithms;
- CMS_EncapsulatedContentInfo *encapContentInfo;
- STACK_OF(CMS_CertificateChoices) *certificates;
- STACK_OF(CMS_RevocationInfoChoice) *crls;
- STACK_OF(CMS_SignerInfo) *signerInfos;
-};
-
-struct CMS_EncapsulatedContentInfo_st {
- ASN1_OBJECT *eContentType;
- ASN1_OCTET_STRING *eContent;
- /* Set to 1 if incomplete structure only part set up */
- int partial;
-};
-
-struct CMS_SignerInfo_st {
- int32_t version;
- CMS_SignerIdentifier *sid;
- X509_ALGOR *digestAlgorithm;
- STACK_OF(X509_ATTRIBUTE) *signedAttrs;
- X509_ALGOR *signatureAlgorithm;
- ASN1_OCTET_STRING *signature;
- STACK_OF(X509_ATTRIBUTE) *unsignedAttrs;
- /* Signing certificate and key */
- X509 *signer;
- EVP_PKEY *pkey;
- /* Digest and public key context for alternative parameters */
- EVP_MD_CTX *mctx;
- EVP_PKEY_CTX *pctx;
-};
-
-struct CMS_SignerIdentifier_st {
- int type;
- union {
- CMS_IssuerAndSerialNumber *issuerAndSerialNumber;
- ASN1_OCTET_STRING *subjectKeyIdentifier;
- } d;
-};
-
-struct CMS_EnvelopedData_st {
- int32_t version;
- CMS_OriginatorInfo *originatorInfo;
- STACK_OF(CMS_RecipientInfo) *recipientInfos;
- CMS_EncryptedContentInfo *encryptedContentInfo;
- STACK_OF(X509_ATTRIBUTE) *unprotectedAttrs;
-};
-
-struct CMS_OriginatorInfo_st {
- STACK_OF(CMS_CertificateChoices) *certificates;
- STACK_OF(CMS_RevocationInfoChoice) *crls;
-};
-
-struct CMS_EncryptedContentInfo_st {
- ASN1_OBJECT *contentType;
- X509_ALGOR *contentEncryptionAlgorithm;
- ASN1_OCTET_STRING *encryptedContent;
- /* Content encryption algorithm and key */
- const EVP_CIPHER *cipher;
- unsigned char *key;
- size_t keylen;
- /* Set to 1 if we are debugging decrypt and don't fake keys for MMA */
- int debug;
- /* Set to 1 if we have no cert and need extra safety measures for MMA */
- int havenocert;
-};
-
-struct CMS_RecipientInfo_st {
- int type;
- union {
- CMS_KeyTransRecipientInfo *ktri;
- CMS_KeyAgreeRecipientInfo *kari;
- CMS_KEKRecipientInfo *kekri;
- CMS_PasswordRecipientInfo *pwri;
- CMS_OtherRecipientInfo *ori;
- } d;
-};
-
-typedef CMS_SignerIdentifier CMS_RecipientIdentifier;
-
-struct CMS_KeyTransRecipientInfo_st {
- int32_t version;
- CMS_RecipientIdentifier *rid;
- X509_ALGOR *keyEncryptionAlgorithm;
- ASN1_OCTET_STRING *encryptedKey;
- /* Recipient Key and cert */
- X509 *recip;
- EVP_PKEY *pkey;
- /* Public key context for this operation */
- EVP_PKEY_CTX *pctx;
-};
-
-struct CMS_KeyAgreeRecipientInfo_st {
- int32_t version;
- CMS_OriginatorIdentifierOrKey *originator;
- ASN1_OCTET_STRING *ukm;
- X509_ALGOR *keyEncryptionAlgorithm;
- STACK_OF(CMS_RecipientEncryptedKey) *recipientEncryptedKeys;
- /* Public key context associated with current operation */
- EVP_PKEY_CTX *pctx;
- /* Cipher context for CEK wrapping */
- EVP_CIPHER_CTX *ctx;
-};
-
-struct CMS_OriginatorIdentifierOrKey_st {
- int type;
- union {
- CMS_IssuerAndSerialNumber *issuerAndSerialNumber;
- ASN1_OCTET_STRING *subjectKeyIdentifier;
- CMS_OriginatorPublicKey *originatorKey;
- } d;
-};
-
-struct CMS_OriginatorPublicKey_st {
- X509_ALGOR *algorithm;
- ASN1_BIT_STRING *publicKey;
-};
-
-struct CMS_RecipientEncryptedKey_st {
- CMS_KeyAgreeRecipientIdentifier *rid;
- ASN1_OCTET_STRING *encryptedKey;
- /* Public key associated with this recipient */
- EVP_PKEY *pkey;
-};
-
-struct CMS_KeyAgreeRecipientIdentifier_st {
- int type;
- union {
- CMS_IssuerAndSerialNumber *issuerAndSerialNumber;
- CMS_RecipientKeyIdentifier *rKeyId;
- } d;
-};
-
-struct CMS_RecipientKeyIdentifier_st {
- ASN1_OCTET_STRING *subjectKeyIdentifier;
- ASN1_GENERALIZEDTIME *date;
- CMS_OtherKeyAttribute *other;
-};
-
-struct CMS_KEKRecipientInfo_st {
- int32_t version;
- CMS_KEKIdentifier *kekid;
- X509_ALGOR *keyEncryptionAlgorithm;
- ASN1_OCTET_STRING *encryptedKey;
- /* Extra info: symmetric key to use */
- unsigned char *key;
- size_t keylen;
-};
-
-struct CMS_KEKIdentifier_st {
- ASN1_OCTET_STRING *keyIdentifier;
- ASN1_GENERALIZEDTIME *date;
- CMS_OtherKeyAttribute *other;
-};
-
-struct CMS_PasswordRecipientInfo_st {
- int32_t version;
- X509_ALGOR *keyDerivationAlgorithm;
- X509_ALGOR *keyEncryptionAlgorithm;
- ASN1_OCTET_STRING *encryptedKey;
- /* Extra info: password to use */
- unsigned char *pass;
- size_t passlen;
-};
-
-struct CMS_OtherRecipientInfo_st {
- ASN1_OBJECT *oriType;
- ASN1_TYPE *oriValue;
-};
-
-struct CMS_DigestedData_st {
- int32_t version;
- X509_ALGOR *digestAlgorithm;
- CMS_EncapsulatedContentInfo *encapContentInfo;
- ASN1_OCTET_STRING *digest;
-};
-
-struct CMS_EncryptedData_st {
- int32_t version;
- CMS_EncryptedContentInfo *encryptedContentInfo;
- STACK_OF(X509_ATTRIBUTE) *unprotectedAttrs;
-};
-
-struct CMS_AuthenticatedData_st {
- int32_t version;
- CMS_OriginatorInfo *originatorInfo;
- STACK_OF(CMS_RecipientInfo) *recipientInfos;
- X509_ALGOR *macAlgorithm;
- X509_ALGOR *digestAlgorithm;
- CMS_EncapsulatedContentInfo *encapContentInfo;
- STACK_OF(X509_ATTRIBUTE) *authAttrs;
- ASN1_OCTET_STRING *mac;
- STACK_OF(X509_ATTRIBUTE) *unauthAttrs;
-};
-
-struct CMS_CompressedData_st {
- int32_t version;
- X509_ALGOR *compressionAlgorithm;
- STACK_OF(CMS_RecipientInfo) *recipientInfos;
- CMS_EncapsulatedContentInfo *encapContentInfo;
-};
-
-struct CMS_RevocationInfoChoice_st {
- int type;
- union {
- X509_CRL *crl;
- CMS_OtherRevocationInfoFormat *other;
- } d;
-};
-
-# define CMS_REVCHOICE_CRL 0
-# define CMS_REVCHOICE_OTHER 1
-
-struct CMS_OtherRevocationInfoFormat_st {
- ASN1_OBJECT *otherRevInfoFormat;
- ASN1_TYPE *otherRevInfo;
-};
-
-struct CMS_CertificateChoices {
- int type;
- union {
- X509 *certificate;
- ASN1_STRING *extendedCertificate; /* Obsolete */
- ASN1_STRING *v1AttrCert; /* Left encoded for now */
- ASN1_STRING *v2AttrCert; /* Left encoded for now */
- CMS_OtherCertificateFormat *other;
- } d;
-};
-
-# define CMS_CERTCHOICE_CERT 0
-# define CMS_CERTCHOICE_EXCERT 1
-# define CMS_CERTCHOICE_V1ACERT 2
-# define CMS_CERTCHOICE_V2ACERT 3
-# define CMS_CERTCHOICE_OTHER 4
-
-struct CMS_OtherCertificateFormat_st {
- ASN1_OBJECT *otherCertFormat;
- ASN1_TYPE *otherCert;
-};
-
-/*
- * This is also defined in pkcs7.h but we duplicate it to allow the CMS code
- * to be independent of PKCS#7
- */
-
-struct CMS_IssuerAndSerialNumber_st {
- X509_NAME *issuer;
- ASN1_INTEGER *serialNumber;
-};
-
-struct CMS_OtherKeyAttribute_st {
- ASN1_OBJECT *keyAttrId;
- ASN1_TYPE *keyAttr;
-};
-
-/* ESS structures */
-
-struct CMS_ReceiptRequest_st {
- ASN1_OCTET_STRING *signedContentIdentifier;
- CMS_ReceiptsFrom *receiptsFrom;
- STACK_OF(GENERAL_NAMES) *receiptsTo;
-};
-
-struct CMS_ReceiptsFrom_st {
- int type;
- union {
- int32_t allOrFirstTier;
- STACK_OF(GENERAL_NAMES) *receiptList;
- } d;
-};
-
-struct CMS_Receipt_st {
- int32_t version;
- ASN1_OBJECT *contentType;
- ASN1_OCTET_STRING *signedContentIdentifier;
- ASN1_OCTET_STRING *originatorSignatureValue;
-};
-
-DECLARE_ASN1_FUNCTIONS(CMS_ContentInfo)
-DECLARE_ASN1_ITEM(CMS_SignerInfo)
-DECLARE_ASN1_ITEM(CMS_IssuerAndSerialNumber)
-DECLARE_ASN1_ITEM(CMS_Attributes_Sign)
-DECLARE_ASN1_ITEM(CMS_Attributes_Verify)
-DECLARE_ASN1_ITEM(CMS_RecipientInfo)
-DECLARE_ASN1_ITEM(CMS_PasswordRecipientInfo)
-DECLARE_ASN1_ALLOC_FUNCTIONS(CMS_IssuerAndSerialNumber)
-
-# define CMS_SIGNERINFO_ISSUER_SERIAL 0
-# define CMS_SIGNERINFO_KEYIDENTIFIER 1
-
-# define CMS_RECIPINFO_ISSUER_SERIAL 0
-# define CMS_RECIPINFO_KEYIDENTIFIER 1
-
-# define CMS_REK_ISSUER_SERIAL 0
-# define CMS_REK_KEYIDENTIFIER 1
-
-# define CMS_OIK_ISSUER_SERIAL 0
-# define CMS_OIK_KEYIDENTIFIER 1
-# define CMS_OIK_PUBKEY 2
-
-BIO *cms_content_bio(CMS_ContentInfo *cms);
-
-CMS_ContentInfo *cms_Data_create(void);
-
-CMS_ContentInfo *cms_DigestedData_create(const EVP_MD *md);
-BIO *cms_DigestedData_init_bio(const CMS_ContentInfo *cms);
-int cms_DigestedData_do_final(const CMS_ContentInfo *cms, BIO *chain, int verify);
-
-BIO *cms_SignedData_init_bio(CMS_ContentInfo *cms);
-int cms_SignedData_final(CMS_ContentInfo *cms, BIO *chain);
-int cms_set1_SignerIdentifier(CMS_SignerIdentifier *sid, X509 *cert,
- int type);
-int cms_SignerIdentifier_get0_signer_id(CMS_SignerIdentifier *sid,
- ASN1_OCTET_STRING **keyid,
- X509_NAME **issuer,
- ASN1_INTEGER **sno);
-int cms_SignerIdentifier_cert_cmp(CMS_SignerIdentifier *sid, X509 *cert);
-
-CMS_ContentInfo *cms_CompressedData_create(int comp_nid);
-BIO *cms_CompressedData_init_bio(const CMS_ContentInfo *cms);
-
-BIO *cms_DigestAlgorithm_init_bio(X509_ALGOR *digestAlgorithm);
-int cms_DigestAlgorithm_find_ctx(EVP_MD_CTX *mctx, BIO *chain,
- X509_ALGOR *mdalg);
-
-int cms_ias_cert_cmp(CMS_IssuerAndSerialNumber *ias, X509 *cert);
-int cms_keyid_cert_cmp(ASN1_OCTET_STRING *keyid, X509 *cert);
-int cms_set1_ias(CMS_IssuerAndSerialNumber **pias, X509 *cert);
-int cms_set1_keyid(ASN1_OCTET_STRING **pkeyid, X509 *cert);
-
-BIO *cms_EncryptedContent_init_bio(CMS_EncryptedContentInfo *ec);
-BIO *cms_EncryptedData_init_bio(const CMS_ContentInfo *cms);
-int cms_EncryptedContent_init(CMS_EncryptedContentInfo *ec,
- const EVP_CIPHER *cipher,
- const unsigned char *key, size_t keylen);
-
-int cms_Receipt_verify(CMS_ContentInfo *cms, CMS_ContentInfo *req_cms);
-int cms_msgSigDigest_add1(CMS_SignerInfo *dest, CMS_SignerInfo *src);
-ASN1_OCTET_STRING *cms_encode_Receipt(CMS_SignerInfo *si);
-
-BIO *cms_EnvelopedData_init_bio(const CMS_ContentInfo *cms);
-CMS_EnvelopedData *cms_get0_enveloped(CMS_ContentInfo *cms);
-int cms_env_asn1_ctrl(CMS_RecipientInfo *ri, int cmd);
-int cms_pkey_get_ri_type(EVP_PKEY *pk);
-/* KARI routines */
-int cms_RecipientInfo_kari_init(CMS_RecipientInfo *ri, X509 *recip,
- EVP_PKEY *pk, unsigned int flags);
-int cms_RecipientInfo_kari_encrypt(const CMS_ContentInfo *cms,
- CMS_RecipientInfo *ri);
-
-/* PWRI routines */
-int cms_RecipientInfo_pwri_crypt(const CMS_ContentInfo *cms, CMS_RecipientInfo *ri,
- int en_de);
-/* SignerInfo routines */
-int CMS_si_check_attributes(const CMS_SignerInfo *si);
-
-DECLARE_ASN1_ITEM(CMS_CertificateChoices)
-DECLARE_ASN1_ITEM(CMS_DigestedData)
-DECLARE_ASN1_ITEM(CMS_EncryptedData)
-DECLARE_ASN1_ITEM(CMS_EnvelopedData)
-DECLARE_ASN1_ITEM(CMS_KEKRecipientInfo)
-DECLARE_ASN1_ITEM(CMS_KeyAgreeRecipientInfo)
-DECLARE_ASN1_ITEM(CMS_KeyTransRecipientInfo)
-DECLARE_ASN1_ITEM(CMS_OriginatorPublicKey)
-DECLARE_ASN1_ITEM(CMS_OtherKeyAttribute)
-DECLARE_ASN1_ITEM(CMS_Receipt)
-DECLARE_ASN1_ITEM(CMS_ReceiptRequest)
-DECLARE_ASN1_ITEM(CMS_RecipientEncryptedKey)
-DECLARE_ASN1_ITEM(CMS_RecipientKeyIdentifier)
-DECLARE_ASN1_ITEM(CMS_RevocationInfoChoice)
-DECLARE_ASN1_ITEM(CMS_SignedData)
-DECLARE_ASN1_ITEM(CMS_CompressedData)
-
-#endif
#include <openssl/bio.h>
#include <openssl/asn1.h>
#include <openssl/cms.h>
-#include "cms_lcl.h"
+#include "cms_local.h"
IMPLEMENT_ASN1_FUNCTIONS(CMS_ContentInfo)
IMPLEMENT_ASN1_PRINT_FUNCTION(CMS_ContentInfo)
--- /dev/null
+/*
+ * Copyright 2008-2018 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+#ifndef HEADER_CMS_LCL_H
+# define HEADER_CMS_LCL_H
+
+# include <openssl/x509.h>
+
+/*
+ * Cryptographic message syntax (CMS) structures: taken from RFC3852
+ */
+
+/* Forward references */
+
+typedef struct CMS_IssuerAndSerialNumber_st CMS_IssuerAndSerialNumber;
+typedef struct CMS_EncapsulatedContentInfo_st CMS_EncapsulatedContentInfo;
+typedef struct CMS_SignerIdentifier_st CMS_SignerIdentifier;
+typedef struct CMS_SignedData_st CMS_SignedData;
+typedef struct CMS_OtherRevocationInfoFormat_st CMS_OtherRevocationInfoFormat;
+typedef struct CMS_OriginatorInfo_st CMS_OriginatorInfo;
+typedef struct CMS_EncryptedContentInfo_st CMS_EncryptedContentInfo;
+typedef struct CMS_EnvelopedData_st CMS_EnvelopedData;
+typedef struct CMS_DigestedData_st CMS_DigestedData;
+typedef struct CMS_EncryptedData_st CMS_EncryptedData;
+typedef struct CMS_AuthenticatedData_st CMS_AuthenticatedData;
+typedef struct CMS_CompressedData_st CMS_CompressedData;
+typedef struct CMS_OtherCertificateFormat_st CMS_OtherCertificateFormat;
+typedef struct CMS_KeyTransRecipientInfo_st CMS_KeyTransRecipientInfo;
+typedef struct CMS_OriginatorPublicKey_st CMS_OriginatorPublicKey;
+typedef struct CMS_OriginatorIdentifierOrKey_st CMS_OriginatorIdentifierOrKey;
+typedef struct CMS_KeyAgreeRecipientInfo_st CMS_KeyAgreeRecipientInfo;
+typedef struct CMS_RecipientKeyIdentifier_st CMS_RecipientKeyIdentifier;
+typedef struct CMS_KeyAgreeRecipientIdentifier_st
+ CMS_KeyAgreeRecipientIdentifier;
+typedef struct CMS_KEKIdentifier_st CMS_KEKIdentifier;
+typedef struct CMS_KEKRecipientInfo_st CMS_KEKRecipientInfo;
+typedef struct CMS_PasswordRecipientInfo_st CMS_PasswordRecipientInfo;
+typedef struct CMS_OtherRecipientInfo_st CMS_OtherRecipientInfo;
+typedef struct CMS_ReceiptsFrom_st CMS_ReceiptsFrom;
+
+struct CMS_ContentInfo_st {
+ ASN1_OBJECT *contentType;
+ union {
+ ASN1_OCTET_STRING *data;
+ CMS_SignedData *signedData;
+ CMS_EnvelopedData *envelopedData;
+ CMS_DigestedData *digestedData;
+ CMS_EncryptedData *encryptedData;
+ CMS_AuthenticatedData *authenticatedData;
+ CMS_CompressedData *compressedData;
+ ASN1_TYPE *other;
+ /* Other types ... */
+ void *otherData;
+ } d;
+};
+
+DEFINE_STACK_OF(CMS_CertificateChoices)
+
+struct CMS_SignedData_st {
+ int32_t version;
+ STACK_OF(X509_ALGOR) *digestAlgorithms;
+ CMS_EncapsulatedContentInfo *encapContentInfo;
+ STACK_OF(CMS_CertificateChoices) *certificates;
+ STACK_OF(CMS_RevocationInfoChoice) *crls;
+ STACK_OF(CMS_SignerInfo) *signerInfos;
+};
+
+struct CMS_EncapsulatedContentInfo_st {
+ ASN1_OBJECT *eContentType;
+ ASN1_OCTET_STRING *eContent;
+ /* Set to 1 if incomplete structure only part set up */
+ int partial;
+};
+
+struct CMS_SignerInfo_st {
+ int32_t version;
+ CMS_SignerIdentifier *sid;
+ X509_ALGOR *digestAlgorithm;
+ STACK_OF(X509_ATTRIBUTE) *signedAttrs;
+ X509_ALGOR *signatureAlgorithm;
+ ASN1_OCTET_STRING *signature;
+ STACK_OF(X509_ATTRIBUTE) *unsignedAttrs;
+ /* Signing certificate and key */
+ X509 *signer;
+ EVP_PKEY *pkey;
+ /* Digest and public key context for alternative parameters */
+ EVP_MD_CTX *mctx;
+ EVP_PKEY_CTX *pctx;
+};
+
+struct CMS_SignerIdentifier_st {
+ int type;
+ union {
+ CMS_IssuerAndSerialNumber *issuerAndSerialNumber;
+ ASN1_OCTET_STRING *subjectKeyIdentifier;
+ } d;
+};
+
+struct CMS_EnvelopedData_st {
+ int32_t version;
+ CMS_OriginatorInfo *originatorInfo;
+ STACK_OF(CMS_RecipientInfo) *recipientInfos;
+ CMS_EncryptedContentInfo *encryptedContentInfo;
+ STACK_OF(X509_ATTRIBUTE) *unprotectedAttrs;
+};
+
+struct CMS_OriginatorInfo_st {
+ STACK_OF(CMS_CertificateChoices) *certificates;
+ STACK_OF(CMS_RevocationInfoChoice) *crls;
+};
+
+struct CMS_EncryptedContentInfo_st {
+ ASN1_OBJECT *contentType;
+ X509_ALGOR *contentEncryptionAlgorithm;
+ ASN1_OCTET_STRING *encryptedContent;
+ /* Content encryption algorithm and key */
+ const EVP_CIPHER *cipher;
+ unsigned char *key;
+ size_t keylen;
+ /* Set to 1 if we are debugging decrypt and don't fake keys for MMA */
+ int debug;
+ /* Set to 1 if we have no cert and need extra safety measures for MMA */
+ int havenocert;
+};
+
+struct CMS_RecipientInfo_st {
+ int type;
+ union {
+ CMS_KeyTransRecipientInfo *ktri;
+ CMS_KeyAgreeRecipientInfo *kari;
+ CMS_KEKRecipientInfo *kekri;
+ CMS_PasswordRecipientInfo *pwri;
+ CMS_OtherRecipientInfo *ori;
+ } d;
+};
+
+typedef CMS_SignerIdentifier CMS_RecipientIdentifier;
+
+struct CMS_KeyTransRecipientInfo_st {
+ int32_t version;
+ CMS_RecipientIdentifier *rid;
+ X509_ALGOR *keyEncryptionAlgorithm;
+ ASN1_OCTET_STRING *encryptedKey;
+ /* Recipient Key and cert */
+ X509 *recip;
+ EVP_PKEY *pkey;
+ /* Public key context for this operation */
+ EVP_PKEY_CTX *pctx;
+};
+
+struct CMS_KeyAgreeRecipientInfo_st {
+ int32_t version;
+ CMS_OriginatorIdentifierOrKey *originator;
+ ASN1_OCTET_STRING *ukm;
+ X509_ALGOR *keyEncryptionAlgorithm;
+ STACK_OF(CMS_RecipientEncryptedKey) *recipientEncryptedKeys;
+ /* Public key context associated with current operation */
+ EVP_PKEY_CTX *pctx;
+ /* Cipher context for CEK wrapping */
+ EVP_CIPHER_CTX *ctx;
+};
+
+struct CMS_OriginatorIdentifierOrKey_st {
+ int type;
+ union {
+ CMS_IssuerAndSerialNumber *issuerAndSerialNumber;
+ ASN1_OCTET_STRING *subjectKeyIdentifier;
+ CMS_OriginatorPublicKey *originatorKey;
+ } d;
+};
+
+struct CMS_OriginatorPublicKey_st {
+ X509_ALGOR *algorithm;
+ ASN1_BIT_STRING *publicKey;
+};
+
+struct CMS_RecipientEncryptedKey_st {
+ CMS_KeyAgreeRecipientIdentifier *rid;
+ ASN1_OCTET_STRING *encryptedKey;
+ /* Public key associated with this recipient */
+ EVP_PKEY *pkey;
+};
+
+struct CMS_KeyAgreeRecipientIdentifier_st {
+ int type;
+ union {
+ CMS_IssuerAndSerialNumber *issuerAndSerialNumber;
+ CMS_RecipientKeyIdentifier *rKeyId;
+ } d;
+};
+
+struct CMS_RecipientKeyIdentifier_st {
+ ASN1_OCTET_STRING *subjectKeyIdentifier;
+ ASN1_GENERALIZEDTIME *date;
+ CMS_OtherKeyAttribute *other;
+};
+
+struct CMS_KEKRecipientInfo_st {
+ int32_t version;
+ CMS_KEKIdentifier *kekid;
+ X509_ALGOR *keyEncryptionAlgorithm;
+ ASN1_OCTET_STRING *encryptedKey;
+ /* Extra info: symmetric key to use */
+ unsigned char *key;
+ size_t keylen;
+};
+
+struct CMS_KEKIdentifier_st {
+ ASN1_OCTET_STRING *keyIdentifier;
+ ASN1_GENERALIZEDTIME *date;
+ CMS_OtherKeyAttribute *other;
+};
+
+struct CMS_PasswordRecipientInfo_st {
+ int32_t version;
+ X509_ALGOR *keyDerivationAlgorithm;
+ X509_ALGOR *keyEncryptionAlgorithm;
+ ASN1_OCTET_STRING *encryptedKey;
+ /* Extra info: password to use */
+ unsigned char *pass;
+ size_t passlen;
+};
+
+struct CMS_OtherRecipientInfo_st {
+ ASN1_OBJECT *oriType;
+ ASN1_TYPE *oriValue;
+};
+
+struct CMS_DigestedData_st {
+ int32_t version;
+ X509_ALGOR *digestAlgorithm;
+ CMS_EncapsulatedContentInfo *encapContentInfo;
+ ASN1_OCTET_STRING *digest;
+};
+
+struct CMS_EncryptedData_st {
+ int32_t version;
+ CMS_EncryptedContentInfo *encryptedContentInfo;
+ STACK_OF(X509_ATTRIBUTE) *unprotectedAttrs;
+};
+
+struct CMS_AuthenticatedData_st {
+ int32_t version;
+ CMS_OriginatorInfo *originatorInfo;
+ STACK_OF(CMS_RecipientInfo) *recipientInfos;
+ X509_ALGOR *macAlgorithm;
+ X509_ALGOR *digestAlgorithm;
+ CMS_EncapsulatedContentInfo *encapContentInfo;
+ STACK_OF(X509_ATTRIBUTE) *authAttrs;
+ ASN1_OCTET_STRING *mac;
+ STACK_OF(X509_ATTRIBUTE) *unauthAttrs;
+};
+
+struct CMS_CompressedData_st {
+ int32_t version;
+ X509_ALGOR *compressionAlgorithm;
+ STACK_OF(CMS_RecipientInfo) *recipientInfos;
+ CMS_EncapsulatedContentInfo *encapContentInfo;
+};
+
+struct CMS_RevocationInfoChoice_st {
+ int type;
+ union {
+ X509_CRL *crl;
+ CMS_OtherRevocationInfoFormat *other;
+ } d;
+};
+
+# define CMS_REVCHOICE_CRL 0
+# define CMS_REVCHOICE_OTHER 1
+
+struct CMS_OtherRevocationInfoFormat_st {
+ ASN1_OBJECT *otherRevInfoFormat;
+ ASN1_TYPE *otherRevInfo;
+};
+
+struct CMS_CertificateChoices {
+ int type;
+ union {
+ X509 *certificate;
+ ASN1_STRING *extendedCertificate; /* Obsolete */
+ ASN1_STRING *v1AttrCert; /* Left encoded for now */
+ ASN1_STRING *v2AttrCert; /* Left encoded for now */
+ CMS_OtherCertificateFormat *other;
+ } d;
+};
+
+# define CMS_CERTCHOICE_CERT 0
+# define CMS_CERTCHOICE_EXCERT 1
+# define CMS_CERTCHOICE_V1ACERT 2
+# define CMS_CERTCHOICE_V2ACERT 3
+# define CMS_CERTCHOICE_OTHER 4
+
+struct CMS_OtherCertificateFormat_st {
+ ASN1_OBJECT *otherCertFormat;
+ ASN1_TYPE *otherCert;
+};
+
+/*
+ * This is also defined in pkcs7.h but we duplicate it to allow the CMS code
+ * to be independent of PKCS#7
+ */
+
+struct CMS_IssuerAndSerialNumber_st {
+ X509_NAME *issuer;
+ ASN1_INTEGER *serialNumber;
+};
+
+struct CMS_OtherKeyAttribute_st {
+ ASN1_OBJECT *keyAttrId;
+ ASN1_TYPE *keyAttr;
+};
+
+/* ESS structures */
+
+struct CMS_ReceiptRequest_st {
+ ASN1_OCTET_STRING *signedContentIdentifier;
+ CMS_ReceiptsFrom *receiptsFrom;
+ STACK_OF(GENERAL_NAMES) *receiptsTo;
+};
+
+struct CMS_ReceiptsFrom_st {
+ int type;
+ union {
+ int32_t allOrFirstTier;
+ STACK_OF(GENERAL_NAMES) *receiptList;
+ } d;
+};
+
+struct CMS_Receipt_st {
+ int32_t version;
+ ASN1_OBJECT *contentType;
+ ASN1_OCTET_STRING *signedContentIdentifier;
+ ASN1_OCTET_STRING *originatorSignatureValue;
+};
+
+DECLARE_ASN1_FUNCTIONS(CMS_ContentInfo)
+DECLARE_ASN1_ITEM(CMS_SignerInfo)
+DECLARE_ASN1_ITEM(CMS_IssuerAndSerialNumber)
+DECLARE_ASN1_ITEM(CMS_Attributes_Sign)
+DECLARE_ASN1_ITEM(CMS_Attributes_Verify)
+DECLARE_ASN1_ITEM(CMS_RecipientInfo)
+DECLARE_ASN1_ITEM(CMS_PasswordRecipientInfo)
+DECLARE_ASN1_ALLOC_FUNCTIONS(CMS_IssuerAndSerialNumber)
+
+# define CMS_SIGNERINFO_ISSUER_SERIAL 0
+# define CMS_SIGNERINFO_KEYIDENTIFIER 1
+
+# define CMS_RECIPINFO_ISSUER_SERIAL 0
+# define CMS_RECIPINFO_KEYIDENTIFIER 1
+
+# define CMS_REK_ISSUER_SERIAL 0
+# define CMS_REK_KEYIDENTIFIER 1
+
+# define CMS_OIK_ISSUER_SERIAL 0
+# define CMS_OIK_KEYIDENTIFIER 1
+# define CMS_OIK_PUBKEY 2
+
+BIO *cms_content_bio(CMS_ContentInfo *cms);
+
+CMS_ContentInfo *cms_Data_create(void);
+
+CMS_ContentInfo *cms_DigestedData_create(const EVP_MD *md);
+BIO *cms_DigestedData_init_bio(const CMS_ContentInfo *cms);
+int cms_DigestedData_do_final(const CMS_ContentInfo *cms, BIO *chain, int verify);
+
+BIO *cms_SignedData_init_bio(CMS_ContentInfo *cms);
+int cms_SignedData_final(CMS_ContentInfo *cms, BIO *chain);
+int cms_set1_SignerIdentifier(CMS_SignerIdentifier *sid, X509 *cert,
+ int type);
+int cms_SignerIdentifier_get0_signer_id(CMS_SignerIdentifier *sid,
+ ASN1_OCTET_STRING **keyid,
+ X509_NAME **issuer,
+ ASN1_INTEGER **sno);
+int cms_SignerIdentifier_cert_cmp(CMS_SignerIdentifier *sid, X509 *cert);
+
+CMS_ContentInfo *cms_CompressedData_create(int comp_nid);
+BIO *cms_CompressedData_init_bio(const CMS_ContentInfo *cms);
+
+BIO *cms_DigestAlgorithm_init_bio(X509_ALGOR *digestAlgorithm);
+int cms_DigestAlgorithm_find_ctx(EVP_MD_CTX *mctx, BIO *chain,
+ X509_ALGOR *mdalg);
+
+int cms_ias_cert_cmp(CMS_IssuerAndSerialNumber *ias, X509 *cert);
+int cms_keyid_cert_cmp(ASN1_OCTET_STRING *keyid, X509 *cert);
+int cms_set1_ias(CMS_IssuerAndSerialNumber **pias, X509 *cert);
+int cms_set1_keyid(ASN1_OCTET_STRING **pkeyid, X509 *cert);
+
+BIO *cms_EncryptedContent_init_bio(CMS_EncryptedContentInfo *ec);
+BIO *cms_EncryptedData_init_bio(const CMS_ContentInfo *cms);
+int cms_EncryptedContent_init(CMS_EncryptedContentInfo *ec,
+ const EVP_CIPHER *cipher,
+ const unsigned char *key, size_t keylen);
+
+int cms_Receipt_verify(CMS_ContentInfo *cms, CMS_ContentInfo *req_cms);
+int cms_msgSigDigest_add1(CMS_SignerInfo *dest, CMS_SignerInfo *src);
+ASN1_OCTET_STRING *cms_encode_Receipt(CMS_SignerInfo *si);
+
+BIO *cms_EnvelopedData_init_bio(const CMS_ContentInfo *cms);
+CMS_EnvelopedData *cms_get0_enveloped(CMS_ContentInfo *cms);
+int cms_env_asn1_ctrl(CMS_RecipientInfo *ri, int cmd);
+int cms_pkey_get_ri_type(EVP_PKEY *pk);
+/* KARI routines */
+int cms_RecipientInfo_kari_init(CMS_RecipientInfo *ri, X509 *recip,
+ EVP_PKEY *pk, unsigned int flags);
+int cms_RecipientInfo_kari_encrypt(const CMS_ContentInfo *cms,
+ CMS_RecipientInfo *ri);
+
+/* PWRI routines */
+int cms_RecipientInfo_pwri_crypt(const CMS_ContentInfo *cms, CMS_RecipientInfo *ri,
+ int en_de);
+/* SignerInfo routines */
+int CMS_si_check_attributes(const CMS_SignerInfo *si);
+
+DECLARE_ASN1_ITEM(CMS_CertificateChoices)
+DECLARE_ASN1_ITEM(CMS_DigestedData)
+DECLARE_ASN1_ITEM(CMS_EncryptedData)
+DECLARE_ASN1_ITEM(CMS_EnvelopedData)
+DECLARE_ASN1_ITEM(CMS_KEKRecipientInfo)
+DECLARE_ASN1_ITEM(CMS_KeyAgreeRecipientInfo)
+DECLARE_ASN1_ITEM(CMS_KeyTransRecipientInfo)
+DECLARE_ASN1_ITEM(CMS_OriginatorPublicKey)
+DECLARE_ASN1_ITEM(CMS_OtherKeyAttribute)
+DECLARE_ASN1_ITEM(CMS_Receipt)
+DECLARE_ASN1_ITEM(CMS_ReceiptRequest)
+DECLARE_ASN1_ITEM(CMS_RecipientEncryptedKey)
+DECLARE_ASN1_ITEM(CMS_RecipientKeyIdentifier)
+DECLARE_ASN1_ITEM(CMS_RevocationInfoChoice)
+DECLARE_ASN1_ITEM(CMS_SignedData)
+DECLARE_ASN1_ITEM(CMS_CompressedData)
+
+#endif
#include <openssl/cms.h>
#include <openssl/rand.h>
#include <openssl/aes.h>
-#include "cms_lcl.h"
+#include "cms_local.h"
#include "crypto/asn1.h"
int CMS_RecipientInfo_set0_password(CMS_RecipientInfo *ri,
#include <openssl/err.h>
#include <openssl/cms.h>
#include <openssl/ess.h>
-#include "cms_lcl.h"
+#include "cms_local.h"
#include "crypto/asn1.h"
#include "crypto/evp.h"
#include "crypto/cms.h"
#include <openssl/x509v3.h>
#include <openssl/err.h>
#include <openssl/cms.h>
-#include "cms_lcl.h"
+#include "cms_local.h"
#include "crypto/asn1.h"
static BIO *cms_get_text_bio(BIO *out, unsigned int flags)
#include <openssl/err.h>
#include "crypto/cryptlib.h"
#include "internal/bio.h"
-#include "comp_lcl.h"
+#include "comp_local.h"
COMP_METHOD *COMP_zlib(void);
+++ /dev/null
-/*
- * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-struct comp_method_st {
- int type; /* NID for compression library */
- const char *name; /* A text string to identify the library */
- int (*init) (COMP_CTX *ctx);
- void (*finish) (COMP_CTX *ctx);
- int (*compress) (COMP_CTX *ctx,
- unsigned char *out, unsigned int olen,
- unsigned char *in, unsigned int ilen);
- int (*expand) (COMP_CTX *ctx,
- unsigned char *out, unsigned int olen,
- unsigned char *in, unsigned int ilen);
-};
-
-struct comp_ctx_st {
- struct comp_method_st *meth;
- unsigned long compress_in;
- unsigned long compress_out;
- unsigned long expand_in;
- unsigned long expand_out;
- void* data;
-};
#include <openssl/objects.h>
#include <openssl/comp.h>
#include <openssl/err.h>
-#include "comp_lcl.h"
+#include "comp_local.h"
COMP_CTX *COMP_CTX_new(COMP_METHOD *meth)
{
--- /dev/null
+/*
+ * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+struct comp_method_st {
+ int type; /* NID for compression library */
+ const char *name; /* A text string to identify the library */
+ int (*init) (COMP_CTX *ctx);
+ void (*finish) (COMP_CTX *ctx);
+ int (*compress) (COMP_CTX *ctx,
+ unsigned char *out, unsigned int olen,
+ unsigned char *in, unsigned int ilen);
+ int (*expand) (COMP_CTX *ctx,
+ unsigned char *out, unsigned int olen,
+ unsigned char *in, unsigned int ilen);
+};
+
+struct comp_ctx_st {
+ struct comp_method_st *meth;
+ unsigned long compress_in;
+ unsigned long compress_out;
+ unsigned long expand_in;
+ unsigned long expand_out;
+ void* data;
+};
+++ /dev/null
-/*
- * Copyright 2018 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-void conf_add_ssl_module(void);
-
--- /dev/null
+/*
+ * Copyright 2018 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+void conf_add_ssl_module(void);
+
#include <openssl/asn1.h>
#include <openssl/engine.h>
#include "internal/provider.h"
-#include "conf_lcl.h"
+#include "conf_local.h"
/* Load all OpenSSL builtin modules */
#include <openssl/conf.h>
#include <openssl/err.h>
#include "internal/sslconf.h"
-#include "conf_lcl.h"
+#include "conf_local.h"
/*
* SSL library configuration module placeholder. We load it here but defer
#include <openssl/asn1t.h>
-#include "crmf_int.h"
+#include "crmf_local.h"
/* explicit #includes not strictly needed since implied by the above: */
#include <openssl/crmf.h>
+++ /dev/null
-/*-
- * Copyright 2007-2019 The OpenSSL Project Authors. All Rights Reserved.
- * Copyright Nokia 2007-2019
- * Copyright Siemens AG 2015-2019
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- *
- * CRMF implementation by Martin Peylo, Miikka Viljanen, and David von Oheimb.
- */
-
-#ifndef OSSL_HEADER_CRMF_INT_H
-# define OSSL_HEADER_CRMF_INT_H
-
-# include <openssl/crmf.h>
-# include <openssl/err.h>
-
-/* explicit #includes not strictly needed since implied by the above: */
-# include <openssl/ossl_typ.h>
-# include <openssl/safestack.h>
-# include <openssl/x509.h>
-# include <openssl/x509v3.h>
-
-/*-
- * EncryptedValue ::= SEQUENCE {
- * intendedAlg [0] AlgorithmIdentifier OPTIONAL,
- * -- the intended algorithm for which the value will be used
- * symmAlg [1] AlgorithmIdentifier OPTIONAL,
- * -- the symmetric algorithm used to encrypt the value
- * encSymmKey [2] BIT STRING OPTIONAL,
- * -- the (encrypted) symmetric key used to encrypt the value
- * keyAlg [3] AlgorithmIdentifier OPTIONAL,
- * -- algorithm used to encrypt the symmetric key
- * valueHint [4] OCTET STRING OPTIONAL,
- * -- a brief description or identifier of the encValue content
- * -- (may be meaningful only to the sending entity, and
- * -- used only if EncryptedValue might be re-examined
- * -- by the sending entity in the future)
- * encValue BIT STRING
- * -- the encrypted value itself
- * }
- */
-struct ossl_crmf_encryptedvalue_st {
- X509_ALGOR *intendedAlg; /* 0 */
- X509_ALGOR *symmAlg; /* 1 */
- ASN1_BIT_STRING *encSymmKey; /* 2 */
- X509_ALGOR *keyAlg; /* 3 */
- ASN1_OCTET_STRING *valueHint; /* 4 */
- ASN1_BIT_STRING *encValue;
-} /* OSSL_CRMF_ENCRYPTEDVALUE */;
-
-/*-
- * Attributes ::= SET OF Attribute
- * => X509_ATTRIBUTE
- *
- * PrivateKeyInfo ::= SEQUENCE {
- * version INTEGER,
- * privateKeyAlgorithm AlgorithmIdentifier,
- * privateKey OCTET STRING,
- * attributes [0] IMPLICIT Attributes OPTIONAL
- * }
- */
-typedef struct ossl_crmf_privatekeyinfo_st {
- ASN1_INTEGER *version;
- X509_ALGOR *privateKeyAlgorithm;
- ASN1_OCTET_STRING *privateKey;
- STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */
-} OSSL_CRMF_PRIVATEKEYINFO;
-DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_PRIVATEKEYINFO)
-
-/*-
- * section 4.2.1 Private Key Info Content Type
- * id-ct-encKeyWithID OBJECT IDENTIFIER ::= {id-ct 21}
- *
- * EncKeyWithID ::= SEQUENCE {
- * privateKey PrivateKeyInfo,
- * identifier CHOICE {
- * string UTF8String,
- * generalName GeneralName
- * } OPTIONAL
- * }
- */
-typedef struct ossl_crmf_enckeywithid_identifier_st {
- int type;
- union {
- ASN1_UTF8STRING *string;
- GENERAL_NAME *generalName;
- } value;
-} OSSL_CRMF_ENCKEYWITHID_IDENTIFIER;
-DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_ENCKEYWITHID_IDENTIFIER)
-
-typedef struct ossl_crmf_enckeywithid_st {
- OSSL_CRMF_PRIVATEKEYINFO *privateKey;
- /* [0] */
- OSSL_CRMF_ENCKEYWITHID_IDENTIFIER *identifier;
-} OSSL_CRMF_ENCKEYWITHID;
-DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_ENCKEYWITHID)
-
-/*-
- * CertId ::= SEQUENCE {
- * issuer GeneralName,
- * serialNumber INTEGER
- * }
- */
-struct ossl_crmf_certid_st {
- GENERAL_NAME *issuer;
- ASN1_INTEGER *serialNumber;
-} /* OSSL_CRMF_CERTID */;
-DECLARE_ASN1_DUP_FUNCTION(OSSL_CRMF_CERTID)
-
-/*-
- * SinglePubInfo ::= SEQUENCE {
- * pubMethod INTEGER {
- * dontCare (0),
- * x500 (1),
- * web (2),
- * ldap (3) },
- * pubLocation GeneralName OPTIONAL
- * }
- */
-struct ossl_crmf_singlepubinfo_st {
- ASN1_INTEGER *pubMethod;
- GENERAL_NAME *pubLocation;
-} /* OSSL_CRMF_SINGLEPUBINFO */;
-DEFINE_STACK_OF(OSSL_CRMF_SINGLEPUBINFO)
-typedef STACK_OF(OSSL_CRMF_SINGLEPUBINFO) OSSL_CRMF_PUBINFOS;
-
-
-/*-
- * PKIPublicationInfo ::= SEQUENCE {
- * action INTEGER {
- * dontPublish (0),
- * pleasePublish (1) },
- * pubInfos SEQUENCE SIZE (1..MAX) OF SinglePubInfo OPTIONAL
- * -- pubInfos MUST NOT be present if action is "dontPublish"
- * -- (if action is "pleasePublish" and pubInfos is omitted,
- * -- "dontCare" is assumed)
- * }
- */
-struct ossl_crmf_pkipublicationinfo_st {
- ASN1_INTEGER *action;
- OSSL_CRMF_PUBINFOS *pubInfos;
-} /* OSSL_CRMF_PKIPUBLICATIONINFO */;
-DECLARE_ASN1_DUP_FUNCTION(OSSL_CRMF_PKIPUBLICATIONINFO)
-
-/*-
- * PKMACValue ::= SEQUENCE {
- * algId AlgorithmIdentifier,
- * -- algorithm value shall be PasswordBasedMac {1 2 840 113533 7 66 13}
- * -- parameter value is PBMParameter
- * value BIT STRING
- * }
- */
-typedef struct ossl_crmf_pkmacvalue_st {
- X509_ALGOR *algId;
- ASN1_BIT_STRING *value;
-} OSSL_CRMF_PKMACVALUE;
-DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_PKMACVALUE)
-
-/*-
- * SubsequentMessage ::= INTEGER {
- * encrCert (0),
- * -- requests that resulting certificate be encrypted for the
- * -- end entity (following which, POP will be proven in a
- * -- confirmation message)
- * challengeResp (1)
- * -- requests that CA engage in challenge-response exchange with
- * -- end entity in order to prove private key possession
- * }
- *
- * POPOPrivKey ::= CHOICE {
- * thisMessage [0] BIT STRING, -- Deprecated
- * -- possession is proven in this message (which contains the private
- * -- key itself (encrypted for the CA))
- * subsequentMessage [1] SubsequentMessage,
- * -- possession will be proven in a subsequent message
- * dhMAC [2] BIT STRING, -- Deprecated
- * agreeMAC [3] PKMACValue,
- * encryptedKey [4] EnvelopedData
- * }
- */
-
-typedef struct ossl_crmf_popoprivkey_st {
- int type;
- union {
- ASN1_BIT_STRING *thisMessage; /* 0 */ /* Deprecated */
- ASN1_INTEGER *subsequentMessage; /* 1 */
- ASN1_BIT_STRING *dhMAC; /* 2 */ /* Deprecated */
- OSSL_CRMF_PKMACVALUE *agreeMAC; /* 3 */
- /*
- * TODO: This is not ASN1_NULL but CMS_ENVELOPEDDATA which should be
- * somehow taken from crypto/cms which exists now
- * - this is not used anywhere so far
- */
- ASN1_NULL *encryptedKey; /* 4 */
- } value;
-} OSSL_CRMF_POPOPRIVKEY;
-DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_POPOPRIVKEY)
-
-/*-
- * PBMParameter ::= SEQUENCE {
- * salt OCTET STRING,
- * owf AlgorithmIdentifier,
- * -- AlgId for a One-Way Function (SHA-1 recommended)
- * iterationCount INTEGER,
- * -- number of times the OWF is applied
- * mac AlgorithmIdentifier
- * -- the MAC AlgId (e.g., DES-MAC, Triple-DES-MAC [PKCS11],
- * -- or HMAC [HMAC, RFC2202])
- * }
- */
-struct ossl_crmf_pbmparameter_st {
- ASN1_OCTET_STRING *salt;
- X509_ALGOR *owf;
- ASN1_INTEGER *iterationCount;
- X509_ALGOR *mac;
-} /* OSSL_CRMF_PBMPARAMETER */;
-#define OSSL_CRMF_PBM_MAX_ITERATION_COUNT 100000 /* if too large allows DoS */
-
-/*-
- * POPOSigningKeyInput ::= SEQUENCE {
- * authInfo CHOICE {
- * sender [0] GeneralName,
- * -- used only if an authenticated identity has been
- * -- established for the sender (e.g., a DN from a
- * -- previously-issued and currently-valid certificate)
- * publicKeyMAC PKMACValue },
- * -- used if no authenticated GeneralName currently exists for
- * -- the sender; publicKeyMAC contains a password-based MAC
- * -- on the DER-encoded value of publicKey
- * publicKey SubjectPublicKeyInfo -- from CertTemplate
- * }
-*/
-typedef struct ossl_crmf_poposigningkeyinput_authinfo_st {
- int type;
- union {
- /* 0 */ GENERAL_NAME *sender;
- /* 1 */ OSSL_CRMF_PKMACVALUE *publicKeyMAC;
- } value;
-} OSSL_CRMF_POPOSIGNINGKEYINPUT_AUTHINFO;
-DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_POPOSIGNINGKEYINPUT_AUTHINFO)
-
-typedef struct ossl_crmf_poposigningkeyinput_st {
- OSSL_CRMF_POPOSIGNINGKEYINPUT_AUTHINFO *authInfo;
- X509_PUBKEY *publicKey;
-} OSSL_CRMF_POPOSIGNINGKEYINPUT;
-DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_POPOSIGNINGKEYINPUT)
-
-/*-
- * POPOSigningKey ::= SEQUENCE {
- * poposkInput [0] POPOSigningKeyInput OPTIONAL,
- * algorithmIdentifier AlgorithmIdentifier,
- * signature BIT STRING
- * }
- */
-struct ossl_crmf_poposigningkey_st {
- OSSL_CRMF_POPOSIGNINGKEYINPUT *poposkInput;
- X509_ALGOR *algorithmIdentifier;
- ASN1_BIT_STRING *signature;
-} /* OSSL_CRMF_POPOSIGNINGKEY */;
-DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_POPOSIGNINGKEY)
-
-/*-
- * ProofOfPossession ::= CHOICE {
- * raVerified [0] NULL,
- * -- used if the RA has already verified that the requester is in
- * -- possession of the private key
- * signature [1] POPOSigningKey,
- * keyEncipherment [2] POPOPrivKey,
- * keyAgreement [3] POPOPrivKey
- * }
- */
-typedef struct ossl_crmf_popo_st {
- int type;
- union {
- ASN1_NULL *raVerified; /* 0 */
- OSSL_CRMF_POPOSIGNINGKEY *signature; /* 1 */
- OSSL_CRMF_POPOPRIVKEY *keyEncipherment; /* 2 */
- OSSL_CRMF_POPOPRIVKEY *keyAgreement; /* 3 */
- } value;
-} OSSL_CRMF_POPO;
-DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_POPO)
-
-/*-
- * OptionalValidity ::= SEQUENCE {
- * notBefore [0] Time OPTIONAL,
- * notAfter [1] Time OPTIONAL -- at least one MUST be present
- * }
- */
-struct ossl_crmf_optionalvalidity_st {
- /* 0 */ ASN1_TIME *notBefore;
- /* 1 */ ASN1_TIME *notAfter;
-} /* OSSL_CRMF_OPTIONALVALIDITY */;
-DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_OPTIONALVALIDITY)
-
-/*-
- * CertTemplate ::= SEQUENCE {
- * version [0] Version OPTIONAL,
- * serialNumber [1] INTEGER OPTIONAL,
- * signingAlg [2] AlgorithmIdentifier OPTIONAL,
- * issuer [3] Name OPTIONAL,
- * validity [4] OptionalValidity OPTIONAL,
- * subject [5] Name OPTIONAL,
- * publicKey [6] SubjectPublicKeyInfo OPTIONAL,
- * issuerUID [7] UniqueIdentifier OPTIONAL,
- * subjectUID [8] UniqueIdentifier OPTIONAL,
- * extensions [9] Extensions OPTIONAL
- * }
- */
-struct ossl_crmf_certtemplate_st {
- ASN1_INTEGER *version; /* 0 */
- ASN1_INTEGER *serialNumber; /* 1 */ /* serialNumber MUST be omitted */
- /* This field is assigned by the CA during certificate creation */
- X509_ALGOR *signingAlg; /* 2 */ /* signingAlg MUST be omitted */
- /* This field is assigned by the CA during certificate creation */
- X509_NAME *issuer; /* 3 */
- OSSL_CRMF_OPTIONALVALIDITY *validity; /* 4 */
- X509_NAME *subject; /* 5 */
- X509_PUBKEY *publicKey; /* 6 */
- ASN1_BIT_STRING *issuerUID; /* 7 */ /* deprecated in version 2 */
- /* According to rfc 3280: UniqueIdentifier ::= BIT STRING */
- ASN1_BIT_STRING *subjectUID; /* 8 */ /* deprecated in version 2 */
- /* Could be X509_EXTENSION*S*, but that's only cosmetic */
- STACK_OF(X509_EXTENSION) *extensions; /* 9 */
-} /* OSSL_CRMF_CERTTEMPLATE */;
-
-/*-
- * CertRequest ::= SEQUENCE {
- * certReqId INTEGER, -- ID for matching request and reply
- * certTemplate CertTemplate, -- Selected fields of cert to be issued
- * controls Controls OPTIONAL -- Attributes affecting issuance
- * }
- */
-struct ossl_crmf_certrequest_st {
- ASN1_INTEGER *certReqId;
- OSSL_CRMF_CERTTEMPLATE *certTemplate;
- /* TODO: make OSSL_CRMF_CONTROLS out of that - but only cosmetical */
- STACK_OF(OSSL_CRMF_ATTRIBUTETYPEANDVALUE) *controls;
-} /* OSSL_CRMF_CERTREQUEST */;
-DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_CERTREQUEST)
-DECLARE_ASN1_DUP_FUNCTION(OSSL_CRMF_CERTREQUEST)
-
-/* TODO: isn't there a better way to have this for ANY type? */
-struct ossl_crmf_attributetypeandvalue_st {
- ASN1_OBJECT *type;
- union {
- /* NID_id_regCtrl_regToken */
- ASN1_UTF8STRING *regToken;
-
- /* NID_id_regCtrl_authenticator */
- ASN1_UTF8STRING *authenticator;
-
- /* NID_id_regCtrl_pkiPublicationInfo */
- OSSL_CRMF_PKIPUBLICATIONINFO *pkiPublicationInfo;
-
- /* NID_id_regCtrl_oldCertID */
- OSSL_CRMF_CERTID *oldCertID;
-
- /* NID_id_regCtrl_protocolEncrKey */
- X509_PUBKEY *protocolEncrKey;
-
- /* NID_id_regInfo_utf8Pairs */
- ASN1_UTF8STRING *utf8Pairs;
-
- /* NID_id_regInfo_certReq */
- OSSL_CRMF_CERTREQUEST *certReq;
-
- ASN1_TYPE *other;
- } value;
-} /* OSSL_CRMF_ATTRIBUTETYPEANDVALUE */;
-DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_ATTRIBUTETYPEANDVALUE)
-DEFINE_STACK_OF(OSSL_CRMF_ATTRIBUTETYPEANDVALUE)
-DECLARE_ASN1_DUP_FUNCTION(OSSL_CRMF_ATTRIBUTETYPEANDVALUE)
-
-/*-
- * CertReqMessages ::= SEQUENCE SIZE (1..MAX) OF CertReqMsg
- * CertReqMsg ::= SEQUENCE {
- * certReq CertRequest,
- * popo ProofOfPossession OPTIONAL,
- * -- content depends upon key type
- * regInfo SEQUENCE SIZE(1..MAX) OF AttributeTypeAndValue OPTIONAL
- * }
- */
-struct ossl_crmf_msg_st {
- OSSL_CRMF_CERTREQUEST *certReq;
- /* 0 */
- OSSL_CRMF_POPO *popo;
- /* 1 */
- STACK_OF(OSSL_CRMF_ATTRIBUTETYPEANDVALUE) *regInfo;
-} /* OSSL_CRMF_MSG */;
-/* DEFINE_STACK_OF(OSSL_CRMF_MSG) */
-#endif
#include <openssl/asn1t.h>
-#include "crmf_int.h"
-#include "internal/constant_time_locl.h"
+#include "crmf_local.h"
+#include "internal/constant_time.h"
/* explicit #includes not strictly needed since implied by the above: */
#include <openssl/crmf.h>
--- /dev/null
+/*-
+ * Copyright 2007-2019 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright Nokia 2007-2019
+ * Copyright Siemens AG 2015-2019
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ *
+ * CRMF implementation by Martin Peylo, Miikka Viljanen, and David von Oheimb.
+ */
+
+#ifndef OSSL_HEADER_CRMF_INT_H
+# define OSSL_HEADER_CRMF_INT_H
+
+# include <openssl/crmf.h>
+# include <openssl/err.h>
+
+/* explicit #includes not strictly needed since implied by the above: */
+# include <openssl/ossl_typ.h>
+# include <openssl/safestack.h>
+# include <openssl/x509.h>
+# include <openssl/x509v3.h>
+
+/*-
+ * EncryptedValue ::= SEQUENCE {
+ * intendedAlg [0] AlgorithmIdentifier OPTIONAL,
+ * -- the intended algorithm for which the value will be used
+ * symmAlg [1] AlgorithmIdentifier OPTIONAL,
+ * -- the symmetric algorithm used to encrypt the value
+ * encSymmKey [2] BIT STRING OPTIONAL,
+ * -- the (encrypted) symmetric key used to encrypt the value
+ * keyAlg [3] AlgorithmIdentifier OPTIONAL,
+ * -- algorithm used to encrypt the symmetric key
+ * valueHint [4] OCTET STRING OPTIONAL,
+ * -- a brief description or identifier of the encValue content
+ * -- (may be meaningful only to the sending entity, and
+ * -- used only if EncryptedValue might be re-examined
+ * -- by the sending entity in the future)
+ * encValue BIT STRING
+ * -- the encrypted value itself
+ * }
+ */
+struct ossl_crmf_encryptedvalue_st {
+ X509_ALGOR *intendedAlg; /* 0 */
+ X509_ALGOR *symmAlg; /* 1 */
+ ASN1_BIT_STRING *encSymmKey; /* 2 */
+ X509_ALGOR *keyAlg; /* 3 */
+ ASN1_OCTET_STRING *valueHint; /* 4 */
+ ASN1_BIT_STRING *encValue;
+} /* OSSL_CRMF_ENCRYPTEDVALUE */;
+
+/*-
+ * Attributes ::= SET OF Attribute
+ * => X509_ATTRIBUTE
+ *
+ * PrivateKeyInfo ::= SEQUENCE {
+ * version INTEGER,
+ * privateKeyAlgorithm AlgorithmIdentifier,
+ * privateKey OCTET STRING,
+ * attributes [0] IMPLICIT Attributes OPTIONAL
+ * }
+ */
+typedef struct ossl_crmf_privatekeyinfo_st {
+ ASN1_INTEGER *version;
+ X509_ALGOR *privateKeyAlgorithm;
+ ASN1_OCTET_STRING *privateKey;
+ STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */
+} OSSL_CRMF_PRIVATEKEYINFO;
+DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_PRIVATEKEYINFO)
+
+/*-
+ * section 4.2.1 Private Key Info Content Type
+ * id-ct-encKeyWithID OBJECT IDENTIFIER ::= {id-ct 21}
+ *
+ * EncKeyWithID ::= SEQUENCE {
+ * privateKey PrivateKeyInfo,
+ * identifier CHOICE {
+ * string UTF8String,
+ * generalName GeneralName
+ * } OPTIONAL
+ * }
+ */
+typedef struct ossl_crmf_enckeywithid_identifier_st {
+ int type;
+ union {
+ ASN1_UTF8STRING *string;
+ GENERAL_NAME *generalName;
+ } value;
+} OSSL_CRMF_ENCKEYWITHID_IDENTIFIER;
+DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_ENCKEYWITHID_IDENTIFIER)
+
+typedef struct ossl_crmf_enckeywithid_st {
+ OSSL_CRMF_PRIVATEKEYINFO *privateKey;
+ /* [0] */
+ OSSL_CRMF_ENCKEYWITHID_IDENTIFIER *identifier;
+} OSSL_CRMF_ENCKEYWITHID;
+DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_ENCKEYWITHID)
+
+/*-
+ * CertId ::= SEQUENCE {
+ * issuer GeneralName,
+ * serialNumber INTEGER
+ * }
+ */
+struct ossl_crmf_certid_st {
+ GENERAL_NAME *issuer;
+ ASN1_INTEGER *serialNumber;
+} /* OSSL_CRMF_CERTID */;
+DECLARE_ASN1_DUP_FUNCTION(OSSL_CRMF_CERTID)
+
+/*-
+ * SinglePubInfo ::= SEQUENCE {
+ * pubMethod INTEGER {
+ * dontCare (0),
+ * x500 (1),
+ * web (2),
+ * ldap (3) },
+ * pubLocation GeneralName OPTIONAL
+ * }
+ */
+struct ossl_crmf_singlepubinfo_st {
+ ASN1_INTEGER *pubMethod;
+ GENERAL_NAME *pubLocation;
+} /* OSSL_CRMF_SINGLEPUBINFO */;
+DEFINE_STACK_OF(OSSL_CRMF_SINGLEPUBINFO)
+typedef STACK_OF(OSSL_CRMF_SINGLEPUBINFO) OSSL_CRMF_PUBINFOS;
+
+
+/*-
+ * PKIPublicationInfo ::= SEQUENCE {
+ * action INTEGER {
+ * dontPublish (0),
+ * pleasePublish (1) },
+ * pubInfos SEQUENCE SIZE (1..MAX) OF SinglePubInfo OPTIONAL
+ * -- pubInfos MUST NOT be present if action is "dontPublish"
+ * -- (if action is "pleasePublish" and pubInfos is omitted,
+ * -- "dontCare" is assumed)
+ * }
+ */
+struct ossl_crmf_pkipublicationinfo_st {
+ ASN1_INTEGER *action;
+ OSSL_CRMF_PUBINFOS *pubInfos;
+} /* OSSL_CRMF_PKIPUBLICATIONINFO */;
+DECLARE_ASN1_DUP_FUNCTION(OSSL_CRMF_PKIPUBLICATIONINFO)
+
+/*-
+ * PKMACValue ::= SEQUENCE {
+ * algId AlgorithmIdentifier,
+ * -- algorithm value shall be PasswordBasedMac {1 2 840 113533 7 66 13}
+ * -- parameter value is PBMParameter
+ * value BIT STRING
+ * }
+ */
+typedef struct ossl_crmf_pkmacvalue_st {
+ X509_ALGOR *algId;
+ ASN1_BIT_STRING *value;
+} OSSL_CRMF_PKMACVALUE;
+DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_PKMACVALUE)
+
+/*-
+ * SubsequentMessage ::= INTEGER {
+ * encrCert (0),
+ * -- requests that resulting certificate be encrypted for the
+ * -- end entity (following which, POP will be proven in a
+ * -- confirmation message)
+ * challengeResp (1)
+ * -- requests that CA engage in challenge-response exchange with
+ * -- end entity in order to prove private key possession
+ * }
+ *
+ * POPOPrivKey ::= CHOICE {
+ * thisMessage [0] BIT STRING, -- Deprecated
+ * -- possession is proven in this message (which contains the private
+ * -- key itself (encrypted for the CA))
+ * subsequentMessage [1] SubsequentMessage,
+ * -- possession will be proven in a subsequent message
+ * dhMAC [2] BIT STRING, -- Deprecated
+ * agreeMAC [3] PKMACValue,
+ * encryptedKey [4] EnvelopedData
+ * }
+ */
+
+typedef struct ossl_crmf_popoprivkey_st {
+ int type;
+ union {
+ ASN1_BIT_STRING *thisMessage; /* 0 */ /* Deprecated */
+ ASN1_INTEGER *subsequentMessage; /* 1 */
+ ASN1_BIT_STRING *dhMAC; /* 2 */ /* Deprecated */
+ OSSL_CRMF_PKMACVALUE *agreeMAC; /* 3 */
+ /*
+ * TODO: This is not ASN1_NULL but CMS_ENVELOPEDDATA which should be
+ * somehow taken from crypto/cms which exists now
+ * - this is not used anywhere so far
+ */
+ ASN1_NULL *encryptedKey; /* 4 */
+ } value;
+} OSSL_CRMF_POPOPRIVKEY;
+DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_POPOPRIVKEY)
+
+/*-
+ * PBMParameter ::= SEQUENCE {
+ * salt OCTET STRING,
+ * owf AlgorithmIdentifier,
+ * -- AlgId for a One-Way Function (SHA-1 recommended)
+ * iterationCount INTEGER,
+ * -- number of times the OWF is applied
+ * mac AlgorithmIdentifier
+ * -- the MAC AlgId (e.g., DES-MAC, Triple-DES-MAC [PKCS11],
+ * -- or HMAC [HMAC, RFC2202])
+ * }
+ */
+struct ossl_crmf_pbmparameter_st {
+ ASN1_OCTET_STRING *salt;
+ X509_ALGOR *owf;
+ ASN1_INTEGER *iterationCount;
+ X509_ALGOR *mac;
+} /* OSSL_CRMF_PBMPARAMETER */;
+#define OSSL_CRMF_PBM_MAX_ITERATION_COUNT 100000 /* if too large allows DoS */
+
+/*-
+ * POPOSigningKeyInput ::= SEQUENCE {
+ * authInfo CHOICE {
+ * sender [0] GeneralName,
+ * -- used only if an authenticated identity has been
+ * -- established for the sender (e.g., a DN from a
+ * -- previously-issued and currently-valid certificate)
+ * publicKeyMAC PKMACValue },
+ * -- used if no authenticated GeneralName currently exists for
+ * -- the sender; publicKeyMAC contains a password-based MAC
+ * -- on the DER-encoded value of publicKey
+ * publicKey SubjectPublicKeyInfo -- from CertTemplate
+ * }
+*/
+typedef struct ossl_crmf_poposigningkeyinput_authinfo_st {
+ int type;
+ union {
+ /* 0 */ GENERAL_NAME *sender;
+ /* 1 */ OSSL_CRMF_PKMACVALUE *publicKeyMAC;
+ } value;
+} OSSL_CRMF_POPOSIGNINGKEYINPUT_AUTHINFO;
+DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_POPOSIGNINGKEYINPUT_AUTHINFO)
+
+typedef struct ossl_crmf_poposigningkeyinput_st {
+ OSSL_CRMF_POPOSIGNINGKEYINPUT_AUTHINFO *authInfo;
+ X509_PUBKEY *publicKey;
+} OSSL_CRMF_POPOSIGNINGKEYINPUT;
+DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_POPOSIGNINGKEYINPUT)
+
+/*-
+ * POPOSigningKey ::= SEQUENCE {
+ * poposkInput [0] POPOSigningKeyInput OPTIONAL,
+ * algorithmIdentifier AlgorithmIdentifier,
+ * signature BIT STRING
+ * }
+ */
+struct ossl_crmf_poposigningkey_st {
+ OSSL_CRMF_POPOSIGNINGKEYINPUT *poposkInput;
+ X509_ALGOR *algorithmIdentifier;
+ ASN1_BIT_STRING *signature;
+} /* OSSL_CRMF_POPOSIGNINGKEY */;
+DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_POPOSIGNINGKEY)
+
+/*-
+ * ProofOfPossession ::= CHOICE {
+ * raVerified [0] NULL,
+ * -- used if the RA has already verified that the requester is in
+ * -- possession of the private key
+ * signature [1] POPOSigningKey,
+ * keyEncipherment [2] POPOPrivKey,
+ * keyAgreement [3] POPOPrivKey
+ * }
+ */
+typedef struct ossl_crmf_popo_st {
+ int type;
+ union {
+ ASN1_NULL *raVerified; /* 0 */
+ OSSL_CRMF_POPOSIGNINGKEY *signature; /* 1 */
+ OSSL_CRMF_POPOPRIVKEY *keyEncipherment; /* 2 */
+ OSSL_CRMF_POPOPRIVKEY *keyAgreement; /* 3 */
+ } value;
+} OSSL_CRMF_POPO;
+DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_POPO)
+
+/*-
+ * OptionalValidity ::= SEQUENCE {
+ * notBefore [0] Time OPTIONAL,
+ * notAfter [1] Time OPTIONAL -- at least one MUST be present
+ * }
+ */
+struct ossl_crmf_optionalvalidity_st {
+ /* 0 */ ASN1_TIME *notBefore;
+ /* 1 */ ASN1_TIME *notAfter;
+} /* OSSL_CRMF_OPTIONALVALIDITY */;
+DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_OPTIONALVALIDITY)
+
+/*-
+ * CertTemplate ::= SEQUENCE {
+ * version [0] Version OPTIONAL,
+ * serialNumber [1] INTEGER OPTIONAL,
+ * signingAlg [2] AlgorithmIdentifier OPTIONAL,
+ * issuer [3] Name OPTIONAL,
+ * validity [4] OptionalValidity OPTIONAL,
+ * subject [5] Name OPTIONAL,
+ * publicKey [6] SubjectPublicKeyInfo OPTIONAL,
+ * issuerUID [7] UniqueIdentifier OPTIONAL,
+ * subjectUID [8] UniqueIdentifier OPTIONAL,
+ * extensions [9] Extensions OPTIONAL
+ * }
+ */
+struct ossl_crmf_certtemplate_st {
+ ASN1_INTEGER *version; /* 0 */
+ ASN1_INTEGER *serialNumber; /* 1 */ /* serialNumber MUST be omitted */
+ /* This field is assigned by the CA during certificate creation */
+ X509_ALGOR *signingAlg; /* 2 */ /* signingAlg MUST be omitted */
+ /* This field is assigned by the CA during certificate creation */
+ X509_NAME *issuer; /* 3 */
+ OSSL_CRMF_OPTIONALVALIDITY *validity; /* 4 */
+ X509_NAME *subject; /* 5 */
+ X509_PUBKEY *publicKey; /* 6 */
+ ASN1_BIT_STRING *issuerUID; /* 7 */ /* deprecated in version 2 */
+ /* According to rfc 3280: UniqueIdentifier ::= BIT STRING */
+ ASN1_BIT_STRING *subjectUID; /* 8 */ /* deprecated in version 2 */
+ /* Could be X509_EXTENSION*S*, but that's only cosmetic */
+ STACK_OF(X509_EXTENSION) *extensions; /* 9 */
+} /* OSSL_CRMF_CERTTEMPLATE */;
+
+/*-
+ * CertRequest ::= SEQUENCE {
+ * certReqId INTEGER, -- ID for matching request and reply
+ * certTemplate CertTemplate, -- Selected fields of cert to be issued
+ * controls Controls OPTIONAL -- Attributes affecting issuance
+ * }
+ */
+struct ossl_crmf_certrequest_st {
+ ASN1_INTEGER *certReqId;
+ OSSL_CRMF_CERTTEMPLATE *certTemplate;
+ /* TODO: make OSSL_CRMF_CONTROLS out of that - but only cosmetical */
+ STACK_OF(OSSL_CRMF_ATTRIBUTETYPEANDVALUE) *controls;
+} /* OSSL_CRMF_CERTREQUEST */;
+DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_CERTREQUEST)
+DECLARE_ASN1_DUP_FUNCTION(OSSL_CRMF_CERTREQUEST)
+
+/* TODO: isn't there a better way to have this for ANY type? */
+struct ossl_crmf_attributetypeandvalue_st {
+ ASN1_OBJECT *type;
+ union {
+ /* NID_id_regCtrl_regToken */
+ ASN1_UTF8STRING *regToken;
+
+ /* NID_id_regCtrl_authenticator */
+ ASN1_UTF8STRING *authenticator;
+
+ /* NID_id_regCtrl_pkiPublicationInfo */
+ OSSL_CRMF_PKIPUBLICATIONINFO *pkiPublicationInfo;
+
+ /* NID_id_regCtrl_oldCertID */
+ OSSL_CRMF_CERTID *oldCertID;
+
+ /* NID_id_regCtrl_protocolEncrKey */
+ X509_PUBKEY *protocolEncrKey;
+
+ /* NID_id_regInfo_utf8Pairs */
+ ASN1_UTF8STRING *utf8Pairs;
+
+ /* NID_id_regInfo_certReq */
+ OSSL_CRMF_CERTREQUEST *certReq;
+
+ ASN1_TYPE *other;
+ } value;
+} /* OSSL_CRMF_ATTRIBUTETYPEANDVALUE */;
+DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_ATTRIBUTETYPEANDVALUE)
+DEFINE_STACK_OF(OSSL_CRMF_ATTRIBUTETYPEANDVALUE)
+DECLARE_ASN1_DUP_FUNCTION(OSSL_CRMF_ATTRIBUTETYPEANDVALUE)
+
+/*-
+ * CertReqMessages ::= SEQUENCE SIZE (1..MAX) OF CertReqMsg
+ * CertReqMsg ::= SEQUENCE {
+ * certReq CertRequest,
+ * popo ProofOfPossession OPTIONAL,
+ * -- content depends upon key type
+ * regInfo SEQUENCE SIZE(1..MAX) OF AttributeTypeAndValue OPTIONAL
+ * }
+ */
+struct ossl_crmf_msg_st {
+ OSSL_CRMF_CERTREQUEST *certReq;
+ /* 0 */
+ OSSL_CRMF_POPO *popo;
+ /* 1 */
+ STACK_OF(OSSL_CRMF_ATTRIBUTETYPEANDVALUE) *regInfo;
+} /* OSSL_CRMF_MSG */;
+/* DEFINE_STACK_OF(OSSL_CRMF_MSG) */
+#endif
#include <openssl/rand.h>
#include <openssl/evp.h>
-#include "crmf_int.h"
+#include "crmf_local.h"
/* explicit #includes not strictly needed since implied by the above: */
#include <openssl/asn1t.h>
#include <openssl/err.h>
#include <openssl/evp.h>
-#include "ct_locl.h"
+#include "ct_local.h"
/*
* Decodes the base64 string |in| into |out|.
--- /dev/null
+/*
+ * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+#include <stddef.h>
+#include <openssl/ct.h>
+#include <openssl/evp.h>
+#include <openssl/x509.h>
+#include <openssl/x509v3.h>
+#include <openssl/safestack.h>
+
+/*
+ * From RFC6962: opaque SerializedSCT<1..2^16-1>; struct { SerializedSCT
+ * sct_list <1..2^16-1>; } SignedCertificateTimestampList;
+ */
+# define MAX_SCT_SIZE 65535
+# define MAX_SCT_LIST_SIZE MAX_SCT_SIZE
+
+/*
+ * Macros to read and write integers in network-byte order.
+ */
+
+#define n2s(c,s) ((s=(((unsigned int)((c)[0]))<< 8)| \
+ (((unsigned int)((c)[1])) )),c+=2)
+
+#define s2n(s,c) ((c[0]=(unsigned char)(((s)>> 8)&0xff), \
+ c[1]=(unsigned char)(((s) )&0xff)),c+=2)
+
+#define l2n3(l,c) ((c[0]=(unsigned char)(((l)>>16)&0xff), \
+ c[1]=(unsigned char)(((l)>> 8)&0xff), \
+ c[2]=(unsigned char)(((l) )&0xff)),c+=3)
+
+#define n2l8(c,l) (l =((uint64_t)(*((c)++)))<<56, \
+ l|=((uint64_t)(*((c)++)))<<48, \
+ l|=((uint64_t)(*((c)++)))<<40, \
+ l|=((uint64_t)(*((c)++)))<<32, \
+ l|=((uint64_t)(*((c)++)))<<24, \
+ l|=((uint64_t)(*((c)++)))<<16, \
+ l|=((uint64_t)(*((c)++)))<< 8, \
+ l|=((uint64_t)(*((c)++))))
+
+#define l2n8(l,c) (*((c)++)=(unsigned char)(((l)>>56)&0xff), \
+ *((c)++)=(unsigned char)(((l)>>48)&0xff), \
+ *((c)++)=(unsigned char)(((l)>>40)&0xff), \
+ *((c)++)=(unsigned char)(((l)>>32)&0xff), \
+ *((c)++)=(unsigned char)(((l)>>24)&0xff), \
+ *((c)++)=(unsigned char)(((l)>>16)&0xff), \
+ *((c)++)=(unsigned char)(((l)>> 8)&0xff), \
+ *((c)++)=(unsigned char)(((l) )&0xff))
+
+/* Signed Certificate Timestamp */
+struct sct_st {
+ sct_version_t version;
+ /* If version is not SCT_VERSION_V1, this contains the encoded SCT */
+ unsigned char *sct;
+ size_t sct_len;
+ /* If version is SCT_VERSION_V1, fields below contain components of the SCT */
+ unsigned char *log_id;
+ size_t log_id_len;
+ /*
+ * Note, we cannot distinguish between an unset timestamp, and one
+ * that is set to 0. However since CT didn't exist in 1970, no real
+ * SCT should ever be set as such.
+ */
+ uint64_t timestamp;
+ unsigned char *ext;
+ size_t ext_len;
+ unsigned char hash_alg;
+ unsigned char sig_alg;
+ unsigned char *sig;
+ size_t sig_len;
+ /* Log entry type */
+ ct_log_entry_type_t entry_type;
+ /* Where this SCT was found, e.g. certificate, OCSP response, etc. */
+ sct_source_t source;
+ /* The result of the last attempt to validate this SCT. */
+ sct_validation_status_t validation_status;
+};
+
+/* Miscellaneous data that is useful when verifying an SCT */
+struct sct_ctx_st {
+ /* Public key */
+ EVP_PKEY *pkey;
+ /* Hash of public key */
+ unsigned char *pkeyhash;
+ size_t pkeyhashlen;
+ /* For pre-certificate: issuer public key hash */
+ unsigned char *ihash;
+ size_t ihashlen;
+ /* certificate encoding */
+ unsigned char *certder;
+ size_t certderlen;
+ /* pre-certificate encoding */
+ unsigned char *preder;
+ size_t prederlen;
+ /* milliseconds since epoch (to check that the SCT isn't from the future) */
+ uint64_t epoch_time_in_ms;
+};
+
+/* Context when evaluating whether a Certificate Transparency policy is met */
+struct ct_policy_eval_ctx_st {
+ X509 *cert;
+ X509 *issuer;
+ CTLOG_STORE *log_store;
+ /* milliseconds since epoch (to check that SCTs aren't from the future) */
+ uint64_t epoch_time_in_ms;
+};
+
+/*
+ * Creates a new context for verifying an SCT.
+ */
+SCT_CTX *SCT_CTX_new(void);
+/*
+ * Deletes an SCT verification context.
+ */
+void SCT_CTX_free(SCT_CTX *sctx);
+
+/*
+ * Sets the certificate that the SCT was created for.
+ * If *cert does not have a poison extension, presigner must be NULL.
+ * If *cert does not have a poison extension, it may have a single SCT
+ * (NID_ct_precert_scts) extension.
+ * If either *cert or *presigner have an AKID (NID_authority_key_identifier)
+ * extension, both must have one.
+ * Returns 1 on success, 0 on failure.
+ */
+__owur int SCT_CTX_set1_cert(SCT_CTX *sctx, X509 *cert, X509 *presigner);
+
+/*
+ * Sets the issuer of the certificate that the SCT was created for.
+ * This is just a convenience method to save extracting the public key and
+ * calling SCT_CTX_set1_issuer_pubkey().
+ * Issuer must not be NULL.
+ * Returns 1 on success, 0 on failure.
+ */
+__owur int SCT_CTX_set1_issuer(SCT_CTX *sctx, const X509 *issuer);
+
+/*
+ * Sets the public key of the issuer of the certificate that the SCT was created
+ * for.
+ * The public key must not be NULL.
+ * Returns 1 on success, 0 on failure.
+ */
+__owur int SCT_CTX_set1_issuer_pubkey(SCT_CTX *sctx, X509_PUBKEY *pubkey);
+
+/*
+ * Sets the public key of the CT log that the SCT is from.
+ * Returns 1 on success, 0 on failure.
+ */
+__owur int SCT_CTX_set1_pubkey(SCT_CTX *sctx, X509_PUBKEY *pubkey);
+
+/*
+ * Sets the time to evaluate the SCT against, in milliseconds since the Unix
+ * epoch. If the SCT's timestamp is after this time, it will be interpreted as
+ * having been issued in the future. RFC6962 states that "TLS clients MUST
+ * reject SCTs whose timestamp is in the future", so an SCT will not validate
+ * in this case.
+ */
+void SCT_CTX_set_time(SCT_CTX *sctx, uint64_t time_in_ms);
+
+/*
+ * Verifies an SCT with the given context.
+ * Returns 1 if the SCT verifies successfully; any other value indicates
+ * failure. See EVP_DigestVerifyFinal() for the meaning of those values.
+ */
+__owur int SCT_CTX_verify(const SCT_CTX *sctx, const SCT *sct);
+
+/*
+ * Does this SCT have the minimum fields populated to be usable?
+ * Returns 1 if so, 0 otherwise.
+ */
+__owur int SCT_is_complete(const SCT *sct);
+
+/*
+ * Does this SCT have the signature-related fields populated?
+ * Returns 1 if so, 0 otherwise.
+ * This checks that the signature and hash algorithms are set to supported
+ * values and that the signature field is set.
+ */
+__owur int SCT_signature_is_complete(const SCT *sct);
+
+/*
+ * TODO(RJPercival): Create an SCT_signature struct and make i2o_SCT_signature
+ * and o2i_SCT_signature conform to the i2d/d2i conventions.
+ */
+
+/*
+* Serialize (to TLS format) an |sct| signature and write it to |out|.
+* If |out| is null, no signature will be output but the length will be returned.
+* If |out| points to a null pointer, a string will be allocated to hold the
+* TLS-format signature. It is the responsibility of the caller to free it.
+* If |out| points to an allocated string, the signature will be written to it.
+* The length of the signature in TLS format will be returned.
+*/
+__owur int i2o_SCT_signature(const SCT *sct, unsigned char **out);
+
+/*
+* Parses an SCT signature in TLS format and populates the |sct| with it.
+* |in| should be a pointer to a string containing the TLS-format signature.
+* |in| will be advanced to the end of the signature if parsing succeeds.
+* |len| should be the length of the signature in |in|.
+* Returns the number of bytes parsed, or a negative integer if an error occurs.
+* If an error occurs, the SCT's signature NID may be updated whilst the
+* signature field itself remains unset.
+*/
+__owur int o2i_SCT_signature(SCT *sct, const unsigned char **in, size_t len);
+
+/*
+ * Handlers for Certificate Transparency X509v3/OCSP extensions
+ */
+extern const X509V3_EXT_METHOD v3_ct_scts[3];
+++ /dev/null
-/*
- * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-#include <stddef.h>
-#include <openssl/ct.h>
-#include <openssl/evp.h>
-#include <openssl/x509.h>
-#include <openssl/x509v3.h>
-#include <openssl/safestack.h>
-
-/*
- * From RFC6962: opaque SerializedSCT<1..2^16-1>; struct { SerializedSCT
- * sct_list <1..2^16-1>; } SignedCertificateTimestampList;
- */
-# define MAX_SCT_SIZE 65535
-# define MAX_SCT_LIST_SIZE MAX_SCT_SIZE
-
-/*
- * Macros to read and write integers in network-byte order.
- */
-
-#define n2s(c,s) ((s=(((unsigned int)((c)[0]))<< 8)| \
- (((unsigned int)((c)[1])) )),c+=2)
-
-#define s2n(s,c) ((c[0]=(unsigned char)(((s)>> 8)&0xff), \
- c[1]=(unsigned char)(((s) )&0xff)),c+=2)
-
-#define l2n3(l,c) ((c[0]=(unsigned char)(((l)>>16)&0xff), \
- c[1]=(unsigned char)(((l)>> 8)&0xff), \
- c[2]=(unsigned char)(((l) )&0xff)),c+=3)
-
-#define n2l8(c,l) (l =((uint64_t)(*((c)++)))<<56, \
- l|=((uint64_t)(*((c)++)))<<48, \
- l|=((uint64_t)(*((c)++)))<<40, \
- l|=((uint64_t)(*((c)++)))<<32, \
- l|=((uint64_t)(*((c)++)))<<24, \
- l|=((uint64_t)(*((c)++)))<<16, \
- l|=((uint64_t)(*((c)++)))<< 8, \
- l|=((uint64_t)(*((c)++))))
-
-#define l2n8(l,c) (*((c)++)=(unsigned char)(((l)>>56)&0xff), \
- *((c)++)=(unsigned char)(((l)>>48)&0xff), \
- *((c)++)=(unsigned char)(((l)>>40)&0xff), \
- *((c)++)=(unsigned char)(((l)>>32)&0xff), \
- *((c)++)=(unsigned char)(((l)>>24)&0xff), \
- *((c)++)=(unsigned char)(((l)>>16)&0xff), \
- *((c)++)=(unsigned char)(((l)>> 8)&0xff), \
- *((c)++)=(unsigned char)(((l) )&0xff))
-
-/* Signed Certificate Timestamp */
-struct sct_st {
- sct_version_t version;
- /* If version is not SCT_VERSION_V1, this contains the encoded SCT */
- unsigned char *sct;
- size_t sct_len;
- /* If version is SCT_VERSION_V1, fields below contain components of the SCT */
- unsigned char *log_id;
- size_t log_id_len;
- /*
- * Note, we cannot distinguish between an unset timestamp, and one
- * that is set to 0. However since CT didn't exist in 1970, no real
- * SCT should ever be set as such.
- */
- uint64_t timestamp;
- unsigned char *ext;
- size_t ext_len;
- unsigned char hash_alg;
- unsigned char sig_alg;
- unsigned char *sig;
- size_t sig_len;
- /* Log entry type */
- ct_log_entry_type_t entry_type;
- /* Where this SCT was found, e.g. certificate, OCSP response, etc. */
- sct_source_t source;
- /* The result of the last attempt to validate this SCT. */
- sct_validation_status_t validation_status;
-};
-
-/* Miscellaneous data that is useful when verifying an SCT */
-struct sct_ctx_st {
- /* Public key */
- EVP_PKEY *pkey;
- /* Hash of public key */
- unsigned char *pkeyhash;
- size_t pkeyhashlen;
- /* For pre-certificate: issuer public key hash */
- unsigned char *ihash;
- size_t ihashlen;
- /* certificate encoding */
- unsigned char *certder;
- size_t certderlen;
- /* pre-certificate encoding */
- unsigned char *preder;
- size_t prederlen;
- /* milliseconds since epoch (to check that the SCT isn't from the future) */
- uint64_t epoch_time_in_ms;
-};
-
-/* Context when evaluating whether a Certificate Transparency policy is met */
-struct ct_policy_eval_ctx_st {
- X509 *cert;
- X509 *issuer;
- CTLOG_STORE *log_store;
- /* milliseconds since epoch (to check that SCTs aren't from the future) */
- uint64_t epoch_time_in_ms;
-};
-
-/*
- * Creates a new context for verifying an SCT.
- */
-SCT_CTX *SCT_CTX_new(void);
-/*
- * Deletes an SCT verification context.
- */
-void SCT_CTX_free(SCT_CTX *sctx);
-
-/*
- * Sets the certificate that the SCT was created for.
- * If *cert does not have a poison extension, presigner must be NULL.
- * If *cert does not have a poison extension, it may have a single SCT
- * (NID_ct_precert_scts) extension.
- * If either *cert or *presigner have an AKID (NID_authority_key_identifier)
- * extension, both must have one.
- * Returns 1 on success, 0 on failure.
- */
-__owur int SCT_CTX_set1_cert(SCT_CTX *sctx, X509 *cert, X509 *presigner);
-
-/*
- * Sets the issuer of the certificate that the SCT was created for.
- * This is just a convenience method to save extracting the public key and
- * calling SCT_CTX_set1_issuer_pubkey().
- * Issuer must not be NULL.
- * Returns 1 on success, 0 on failure.
- */
-__owur int SCT_CTX_set1_issuer(SCT_CTX *sctx, const X509 *issuer);
-
-/*
- * Sets the public key of the issuer of the certificate that the SCT was created
- * for.
- * The public key must not be NULL.
- * Returns 1 on success, 0 on failure.
- */
-__owur int SCT_CTX_set1_issuer_pubkey(SCT_CTX *sctx, X509_PUBKEY *pubkey);
-
-/*
- * Sets the public key of the CT log that the SCT is from.
- * Returns 1 on success, 0 on failure.
- */
-__owur int SCT_CTX_set1_pubkey(SCT_CTX *sctx, X509_PUBKEY *pubkey);
-
-/*
- * Sets the time to evaluate the SCT against, in milliseconds since the Unix
- * epoch. If the SCT's timestamp is after this time, it will be interpreted as
- * having been issued in the future. RFC6962 states that "TLS clients MUST
- * reject SCTs whose timestamp is in the future", so an SCT will not validate
- * in this case.
- */
-void SCT_CTX_set_time(SCT_CTX *sctx, uint64_t time_in_ms);
-
-/*
- * Verifies an SCT with the given context.
- * Returns 1 if the SCT verifies successfully; any other value indicates
- * failure. See EVP_DigestVerifyFinal() for the meaning of those values.
- */
-__owur int SCT_CTX_verify(const SCT_CTX *sctx, const SCT *sct);
-
-/*
- * Does this SCT have the minimum fields populated to be usable?
- * Returns 1 if so, 0 otherwise.
- */
-__owur int SCT_is_complete(const SCT *sct);
-
-/*
- * Does this SCT have the signature-related fields populated?
- * Returns 1 if so, 0 otherwise.
- * This checks that the signature and hash algorithms are set to supported
- * values and that the signature field is set.
- */
-__owur int SCT_signature_is_complete(const SCT *sct);
-
-/*
- * TODO(RJPercival): Create an SCT_signature struct and make i2o_SCT_signature
- * and o2i_SCT_signature conform to the i2d/d2i conventions.
- */
-
-/*
-* Serialize (to TLS format) an |sct| signature and write it to |out|.
-* If |out| is null, no signature will be output but the length will be returned.
-* If |out| points to a null pointer, a string will be allocated to hold the
-* TLS-format signature. It is the responsibility of the caller to free it.
-* If |out| points to an allocated string, the signature will be written to it.
-* The length of the signature in TLS format will be returned.
-*/
-__owur int i2o_SCT_signature(const SCT *sct, unsigned char **out);
-
-/*
-* Parses an SCT signature in TLS format and populates the |sct| with it.
-* |in| should be a pointer to a string containing the TLS-format signature.
-* |in| will be advanced to the end of the signature if parsing succeeds.
-* |len| should be the length of the signature in |in|.
-* Returns the number of bytes parsed, or a negative integer if an error occurs.
-* If an error occurs, the SCT's signature NID may be updated whilst the
-* signature field itself remains unset.
-*/
-__owur int o2i_SCT_signature(SCT *sct, const unsigned char **in, size_t len);
-
-/*
- * Handlers for Certificate Transparency X509v3/OCSP extensions
- */
-extern const X509V3_EXT_METHOD v3_ct_scts[3];
#include <openssl/ct.h>
#include <openssl/err.h>
-#include "ct_locl.h"
+#include "ct_local.h"
int o2i_SCT_signature(SCT *sct, const unsigned char **in, size_t len)
{
#include <openssl/err.h>
#include <time.h>
-#include "ct_locl.h"
+#include "ct_local.h"
/*
* Number of seconds in the future that an SCT timestamp can be, by default,
#include <openssl/asn1.h>
#include <openssl/bio.h>
-#include "ct_locl.h"
+#include "ct_local.h"
static void SCT_signature_algorithms_print(const SCT *sct, BIO *out)
{
#include <openssl/tls1.h>
#include <openssl/x509.h>
-#include "ct_locl.h"
+#include "ct_local.h"
SCT *SCT_new(void)
{
#include <openssl/obj_mac.h>
#include <openssl/x509.h>
-#include "ct_locl.h"
+#include "ct_local.h"
SCT_CTX *SCT_CTX_new(void)
{
#include <openssl/evp.h>
#include <openssl/x509.h>
-#include "ct_locl.h"
+#include "ct_local.h"
typedef enum sct_signature_type_t {
SIGNATURE_TYPE_NOT_SET = -1,
# error "CT is disabled"
#endif
-#include "ct_locl.h"
+#include "ct_local.h"
static char *i2s_poison(const X509V3_EXT_METHOD *method, void *val)
{
* https://www.openssl.org/source/license.html
*/
-#include "des_locl.h"
+#include "des_local.h"
DES_LONG DES_cbc_cksum(const unsigned char *in, DES_cblock *output,
long length, DES_key_schedule *schedule,
* https://www.openssl.org/source/license.html
*/
-#include "des_locl.h"
+#include "des_local.h"
/*
* The input and output encrypted as though 64bit cfb mode is being used.
* https://www.openssl.org/source/license.html
*/
-#include "des_locl.h"
+#include "des_local.h"
/*
* The input and output encrypted as though 64bit cfb mode is being used.
*/
#include "e_os.h"
-#include "des_locl.h"
+#include "des_local.h"
#include <assert.h>
/*
*/
#include <openssl/crypto.h>
-#include "des_locl.h"
+#include "des_local.h"
#include "spr.h"
void DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc)
--- /dev/null
+/*
+ * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+#ifndef HEADER_DES_LOCL_H
+# define HEADER_DES_LOCL_H
+
+# include <openssl/e_os2.h>
+
+# include <stdio.h>
+# include <stdlib.h>
+# include <string.h>
+
+# include <openssl/des.h>
+
+# ifdef OPENSSL_BUILD_SHLIBCRYPTO
+# undef OPENSSL_EXTERN
+# define OPENSSL_EXTERN OPENSSL_EXPORT
+# endif
+
+# define ITERATIONS 16
+# define HALF_ITERATIONS 8
+
+# define c2l(c,l) (l =((DES_LONG)(*((c)++))) , \
+ l|=((DES_LONG)(*((c)++)))<< 8L, \
+ l|=((DES_LONG)(*((c)++)))<<16L, \
+ l|=((DES_LONG)(*((c)++)))<<24L)
+
+/* NOTE - c is not incremented as per c2l */
+# define c2ln(c,l1,l2,n) { \
+ c+=n; \
+ l1=l2=0; \
+ switch (n) { \
+ case 8: l2 =((DES_LONG)(*(--(c))))<<24L; \
+ /* fall thru */ \
+ case 7: l2|=((DES_LONG)(*(--(c))))<<16L; \
+ /* fall thru */ \
+ case 6: l2|=((DES_LONG)(*(--(c))))<< 8L; \
+ /* fall thru */ \
+ case 5: l2|=((DES_LONG)(*(--(c)))); \
+ /* fall thru */ \
+ case 4: l1 =((DES_LONG)(*(--(c))))<<24L; \
+ /* fall thru */ \
+ case 3: l1|=((DES_LONG)(*(--(c))))<<16L; \
+ /* fall thru */ \
+ case 2: l1|=((DES_LONG)(*(--(c))))<< 8L; \
+ /* fall thru */ \
+ case 1: l1|=((DES_LONG)(*(--(c)))); \
+ } \
+ }
+
+# define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \
+ *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
+ *((c)++)=(unsigned char)(((l)>>16L)&0xff), \
+ *((c)++)=(unsigned char)(((l)>>24L)&0xff))
+
+/*
+ * replacements for htonl and ntohl since I have no idea what to do when
+ * faced with machines with 8 byte longs.
+ */
+
+# define n2l(c,l) (l =((DES_LONG)(*((c)++)))<<24L, \
+ l|=((DES_LONG)(*((c)++)))<<16L, \
+ l|=((DES_LONG)(*((c)++)))<< 8L, \
+ l|=((DES_LONG)(*((c)++))))
+
+# define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \
+ *((c)++)=(unsigned char)(((l)>>16L)&0xff), \
+ *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
+ *((c)++)=(unsigned char)(((l) )&0xff))
+
+/* NOTE - c is not incremented as per l2c */
+# define l2cn(l1,l2,c,n) { \
+ c+=n; \
+ switch (n) { \
+ case 8: *(--(c))=(unsigned char)(((l2)>>24L)&0xff); \
+ /* fall thru */ \
+ case 7: *(--(c))=(unsigned char)(((l2)>>16L)&0xff); \
+ /* fall thru */ \
+ case 6: *(--(c))=(unsigned char)(((l2)>> 8L)&0xff); \
+ /* fall thru */ \
+ case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \
+ /* fall thru */ \
+ case 4: *(--(c))=(unsigned char)(((l1)>>24L)&0xff); \
+ /* fall thru */ \
+ case 3: *(--(c))=(unsigned char)(((l1)>>16L)&0xff); \
+ /* fall thru */ \
+ case 2: *(--(c))=(unsigned char)(((l1)>> 8L)&0xff); \
+ /* fall thru */ \
+ case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \
+ } \
+ }
+
+# if defined(_MSC_VER)
+# define ROTATE(a,n) (_lrotr(a,n))
+# elif defined(__ICC)
+# define ROTATE(a,n) (_rotr(a,n))
+# elif defined(__GNUC__) && __GNUC__>=2 && !defined(__STRICT_ANSI__) && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) && !defined(PEDANTIC)
+# if defined(__i386) || defined(__i386__) || defined(__x86_64) || defined(__x86_64__)
+# define ROTATE(a,n) ({ register unsigned int ret; \
+ asm ("rorl %1,%0" \
+ : "=r"(ret) \
+ : "I"(n),"0"(a) \
+ : "cc"); \
+ ret; \
+ })
+# endif
+# endif
+# ifndef ROTATE
+# define ROTATE(a,n) (((a)>>(n))+((a)<<(32-(n))))
+# endif
+
+/*
+ * Don't worry about the LOAD_DATA() stuff, that is used by fcrypt() to add
+ * it's little bit to the front
+ */
+
+# ifdef DES_FCRYPT
+
+# define LOAD_DATA_tmp(R,S,u,t,E0,E1) \
+ { DES_LONG tmp; LOAD_DATA(R,S,u,t,E0,E1,tmp); }
+
+# define LOAD_DATA(R,S,u,t,E0,E1,tmp) \
+ t=R^(R>>16L); \
+ u=t&E0; t&=E1; \
+ tmp=(u<<16); u^=R^s[S ]; u^=tmp; \
+ tmp=(t<<16); t^=R^s[S+1]; t^=tmp
+# else
+# define LOAD_DATA_tmp(a,b,c,d,e,f) LOAD_DATA(a,b,c,d,e,f,g)
+# define LOAD_DATA(R,S,u,t,E0,E1,tmp) \
+ u=R^s[S ]; \
+ t=R^s[S+1]
+# endif
+
+/*
+ * It recently occurred to me that 0^0^0^0^0^0^0 == 0, so there is no reason
+ * to not xor all the sub items together. This potentially saves a register
+ * since things can be xored directly into L
+ */
+
+# define D_ENCRYPT(LL,R,S) { \
+ LOAD_DATA_tmp(R,S,u,t,E0,E1); \
+ t=ROTATE(t,4); \
+ LL^= \
+ DES_SPtrans[0][(u>> 2L)&0x3f]^ \
+ DES_SPtrans[2][(u>>10L)&0x3f]^ \
+ DES_SPtrans[4][(u>>18L)&0x3f]^ \
+ DES_SPtrans[6][(u>>26L)&0x3f]^ \
+ DES_SPtrans[1][(t>> 2L)&0x3f]^ \
+ DES_SPtrans[3][(t>>10L)&0x3f]^ \
+ DES_SPtrans[5][(t>>18L)&0x3f]^ \
+ DES_SPtrans[7][(t>>26L)&0x3f]; }
+
+ /*-
+ * IP and FP
+ * The problem is more of a geometric problem that random bit fiddling.
+ 0 1 2 3 4 5 6 7 62 54 46 38 30 22 14 6
+ 8 9 10 11 12 13 14 15 60 52 44 36 28 20 12 4
+ 16 17 18 19 20 21 22 23 58 50 42 34 26 18 10 2
+ 24 25 26 27 28 29 30 31 to 56 48 40 32 24 16 8 0
+
+ 32 33 34 35 36 37 38 39 63 55 47 39 31 23 15 7
+ 40 41 42 43 44 45 46 47 61 53 45 37 29 21 13 5
+ 48 49 50 51 52 53 54 55 59 51 43 35 27 19 11 3
+ 56 57 58 59 60 61 62 63 57 49 41 33 25 17 9 1
+
+ The output has been subject to swaps of the form
+ 0 1 -> 3 1 but the odd and even bits have been put into
+ 2 3 2 0
+ different words. The main trick is to remember that
+ t=((l>>size)^r)&(mask);
+ r^=t;
+ l^=(t<<size);
+ can be used to swap and move bits between words.
+
+ So l = 0 1 2 3 r = 16 17 18 19
+ 4 5 6 7 20 21 22 23
+ 8 9 10 11 24 25 26 27
+ 12 13 14 15 28 29 30 31
+ becomes (for size == 2 and mask == 0x3333)
+ t = 2^16 3^17 -- -- l = 0 1 16 17 r = 2 3 18 19
+ 6^20 7^21 -- -- 4 5 20 21 6 7 22 23
+ 10^24 11^25 -- -- 8 9 24 25 10 11 24 25
+ 14^28 15^29 -- -- 12 13 28 29 14 15 28 29
+
+ Thanks for hints from Richard Outerbridge - he told me IP&FP
+ could be done in 15 xor, 10 shifts and 5 ands.
+ When I finally started to think of the problem in 2D
+ I first got ~42 operations without xors. When I remembered
+ how to use xors :-) I got it to its final state.
+ */
+# define PERM_OP(a,b,t,n,m) ((t)=((((a)>>(n))^(b))&(m)),\
+ (b)^=(t),\
+ (a)^=((t)<<(n)))
+
+# define IP(l,r) \
+ { \
+ register DES_LONG tt; \
+ PERM_OP(r,l,tt, 4,0x0f0f0f0fL); \
+ PERM_OP(l,r,tt,16,0x0000ffffL); \
+ PERM_OP(r,l,tt, 2,0x33333333L); \
+ PERM_OP(l,r,tt, 8,0x00ff00ffL); \
+ PERM_OP(r,l,tt, 1,0x55555555L); \
+ }
+
+# define FP(l,r) \
+ { \
+ register DES_LONG tt; \
+ PERM_OP(l,r,tt, 1,0x55555555L); \
+ PERM_OP(r,l,tt, 8,0x00ff00ffL); \
+ PERM_OP(l,r,tt, 2,0x33333333L); \
+ PERM_OP(r,l,tt,16,0x0000ffffL); \
+ PERM_OP(l,r,tt, 4,0x0f0f0f0fL); \
+ }
+
+extern const DES_LONG DES_SPtrans[8][64];
+
+void fcrypt_body(DES_LONG *out, DES_key_schedule *ks,
+ DES_LONG Eswap0, DES_LONG Eswap1);
+
+#endif
+++ /dev/null
-/*
- * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-#ifndef HEADER_DES_LOCL_H
-# define HEADER_DES_LOCL_H
-
-# include <openssl/e_os2.h>
-
-# include <stdio.h>
-# include <stdlib.h>
-# include <string.h>
-
-# include <openssl/des.h>
-
-# ifdef OPENSSL_BUILD_SHLIBCRYPTO
-# undef OPENSSL_EXTERN
-# define OPENSSL_EXTERN OPENSSL_EXPORT
-# endif
-
-# define ITERATIONS 16
-# define HALF_ITERATIONS 8
-
-# define c2l(c,l) (l =((DES_LONG)(*((c)++))) , \
- l|=((DES_LONG)(*((c)++)))<< 8L, \
- l|=((DES_LONG)(*((c)++)))<<16L, \
- l|=((DES_LONG)(*((c)++)))<<24L)
-
-/* NOTE - c is not incremented as per c2l */
-# define c2ln(c,l1,l2,n) { \
- c+=n; \
- l1=l2=0; \
- switch (n) { \
- case 8: l2 =((DES_LONG)(*(--(c))))<<24L; \
- /* fall thru */ \
- case 7: l2|=((DES_LONG)(*(--(c))))<<16L; \
- /* fall thru */ \
- case 6: l2|=((DES_LONG)(*(--(c))))<< 8L; \
- /* fall thru */ \
- case 5: l2|=((DES_LONG)(*(--(c)))); \
- /* fall thru */ \
- case 4: l1 =((DES_LONG)(*(--(c))))<<24L; \
- /* fall thru */ \
- case 3: l1|=((DES_LONG)(*(--(c))))<<16L; \
- /* fall thru */ \
- case 2: l1|=((DES_LONG)(*(--(c))))<< 8L; \
- /* fall thru */ \
- case 1: l1|=((DES_LONG)(*(--(c)))); \
- } \
- }
-
-# define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \
- *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
- *((c)++)=(unsigned char)(((l)>>16L)&0xff), \
- *((c)++)=(unsigned char)(((l)>>24L)&0xff))
-
-/*
- * replacements for htonl and ntohl since I have no idea what to do when
- * faced with machines with 8 byte longs.
- */
-
-# define n2l(c,l) (l =((DES_LONG)(*((c)++)))<<24L, \
- l|=((DES_LONG)(*((c)++)))<<16L, \
- l|=((DES_LONG)(*((c)++)))<< 8L, \
- l|=((DES_LONG)(*((c)++))))
-
-# define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \
- *((c)++)=(unsigned char)(((l)>>16L)&0xff), \
- *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
- *((c)++)=(unsigned char)(((l) )&0xff))
-
-/* NOTE - c is not incremented as per l2c */
-# define l2cn(l1,l2,c,n) { \
- c+=n; \
- switch (n) { \
- case 8: *(--(c))=(unsigned char)(((l2)>>24L)&0xff); \
- /* fall thru */ \
- case 7: *(--(c))=(unsigned char)(((l2)>>16L)&0xff); \
- /* fall thru */ \
- case 6: *(--(c))=(unsigned char)(((l2)>> 8L)&0xff); \
- /* fall thru */ \
- case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \
- /* fall thru */ \
- case 4: *(--(c))=(unsigned char)(((l1)>>24L)&0xff); \
- /* fall thru */ \
- case 3: *(--(c))=(unsigned char)(((l1)>>16L)&0xff); \
- /* fall thru */ \
- case 2: *(--(c))=(unsigned char)(((l1)>> 8L)&0xff); \
- /* fall thru */ \
- case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \
- } \
- }
-
-# if defined(_MSC_VER)
-# define ROTATE(a,n) (_lrotr(a,n))
-# elif defined(__ICC)
-# define ROTATE(a,n) (_rotr(a,n))
-# elif defined(__GNUC__) && __GNUC__>=2 && !defined(__STRICT_ANSI__) && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) && !defined(PEDANTIC)
-# if defined(__i386) || defined(__i386__) || defined(__x86_64) || defined(__x86_64__)
-# define ROTATE(a,n) ({ register unsigned int ret; \
- asm ("rorl %1,%0" \
- : "=r"(ret) \
- : "I"(n),"0"(a) \
- : "cc"); \
- ret; \
- })
-# endif
-# endif
-# ifndef ROTATE
-# define ROTATE(a,n) (((a)>>(n))+((a)<<(32-(n))))
-# endif
-
-/*
- * Don't worry about the LOAD_DATA() stuff, that is used by fcrypt() to add
- * it's little bit to the front
- */
-
-# ifdef DES_FCRYPT
-
-# define LOAD_DATA_tmp(R,S,u,t,E0,E1) \
- { DES_LONG tmp; LOAD_DATA(R,S,u,t,E0,E1,tmp); }
-
-# define LOAD_DATA(R,S,u,t,E0,E1,tmp) \
- t=R^(R>>16L); \
- u=t&E0; t&=E1; \
- tmp=(u<<16); u^=R^s[S ]; u^=tmp; \
- tmp=(t<<16); t^=R^s[S+1]; t^=tmp
-# else
-# define LOAD_DATA_tmp(a,b,c,d,e,f) LOAD_DATA(a,b,c,d,e,f,g)
-# define LOAD_DATA(R,S,u,t,E0,E1,tmp) \
- u=R^s[S ]; \
- t=R^s[S+1]
-# endif
-
-/*
- * It recently occurred to me that 0^0^0^0^0^0^0 == 0, so there is no reason
- * to not xor all the sub items together. This potentially saves a register
- * since things can be xored directly into L
- */
-
-# define D_ENCRYPT(LL,R,S) { \
- LOAD_DATA_tmp(R,S,u,t,E0,E1); \
- t=ROTATE(t,4); \
- LL^= \
- DES_SPtrans[0][(u>> 2L)&0x3f]^ \
- DES_SPtrans[2][(u>>10L)&0x3f]^ \
- DES_SPtrans[4][(u>>18L)&0x3f]^ \
- DES_SPtrans[6][(u>>26L)&0x3f]^ \
- DES_SPtrans[1][(t>> 2L)&0x3f]^ \
- DES_SPtrans[3][(t>>10L)&0x3f]^ \
- DES_SPtrans[5][(t>>18L)&0x3f]^ \
- DES_SPtrans[7][(t>>26L)&0x3f]; }
-
- /*-
- * IP and FP
- * The problem is more of a geometric problem that random bit fiddling.
- 0 1 2 3 4 5 6 7 62 54 46 38 30 22 14 6
- 8 9 10 11 12 13 14 15 60 52 44 36 28 20 12 4
- 16 17 18 19 20 21 22 23 58 50 42 34 26 18 10 2
- 24 25 26 27 28 29 30 31 to 56 48 40 32 24 16 8 0
-
- 32 33 34 35 36 37 38 39 63 55 47 39 31 23 15 7
- 40 41 42 43 44 45 46 47 61 53 45 37 29 21 13 5
- 48 49 50 51 52 53 54 55 59 51 43 35 27 19 11 3
- 56 57 58 59 60 61 62 63 57 49 41 33 25 17 9 1
-
- The output has been subject to swaps of the form
- 0 1 -> 3 1 but the odd and even bits have been put into
- 2 3 2 0
- different words. The main trick is to remember that
- t=((l>>size)^r)&(mask);
- r^=t;
- l^=(t<<size);
- can be used to swap and move bits between words.
-
- So l = 0 1 2 3 r = 16 17 18 19
- 4 5 6 7 20 21 22 23
- 8 9 10 11 24 25 26 27
- 12 13 14 15 28 29 30 31
- becomes (for size == 2 and mask == 0x3333)
- t = 2^16 3^17 -- -- l = 0 1 16 17 r = 2 3 18 19
- 6^20 7^21 -- -- 4 5 20 21 6 7 22 23
- 10^24 11^25 -- -- 8 9 24 25 10 11 24 25
- 14^28 15^29 -- -- 12 13 28 29 14 15 28 29
-
- Thanks for hints from Richard Outerbridge - he told me IP&FP
- could be done in 15 xor, 10 shifts and 5 ands.
- When I finally started to think of the problem in 2D
- I first got ~42 operations without xors. When I remembered
- how to use xors :-) I got it to its final state.
- */
-# define PERM_OP(a,b,t,n,m) ((t)=((((a)>>(n))^(b))&(m)),\
- (b)^=(t),\
- (a)^=((t)<<(n)))
-
-# define IP(l,r) \
- { \
- register DES_LONG tt; \
- PERM_OP(r,l,tt, 4,0x0f0f0f0fL); \
- PERM_OP(l,r,tt,16,0x0000ffffL); \
- PERM_OP(r,l,tt, 2,0x33333333L); \
- PERM_OP(l,r,tt, 8,0x00ff00ffL); \
- PERM_OP(r,l,tt, 1,0x55555555L); \
- }
-
-# define FP(l,r) \
- { \
- register DES_LONG tt; \
- PERM_OP(l,r,tt, 1,0x55555555L); \
- PERM_OP(r,l,tt, 8,0x00ff00ffL); \
- PERM_OP(l,r,tt, 2,0x33333333L); \
- PERM_OP(r,l,tt,16,0x0000ffffL); \
- PERM_OP(l,r,tt, 4,0x0f0f0f0fL); \
- }
-
-extern const DES_LONG DES_SPtrans[8][64];
-
-void fcrypt_body(DES_LONG *out, DES_key_schedule *ks,
- DES_LONG Eswap0, DES_LONG Eswap1);
-
-#endif
* https://www.openssl.org/source/license.html
*/
-#include "des_locl.h"
+#include "des_local.h"
void DES_ecb3_encrypt(const_DES_cblock *input, DES_cblock *output,
DES_key_schedule *ks1, DES_key_schedule *ks2,
* https://www.openssl.org/source/license.html
*/
-#include "des_locl.h"
+#include "des_local.h"
#include <openssl/opensslv.h>
#include <openssl/bio.h>
#endif
#include <openssl/crypto.h>
-#include "des_locl.h"
+#include "des_local.h"
/*
* Added more values to handle illegal salt values the way normal crypt()
#include <stdio.h>
#define DES_FCRYPT
-#include "des_locl.h"
+#include "des_local.h"
#undef DES_FCRYPT
#undef PERM_OP
* des_enc.c (DES_ncbc_encrypt)
*/
-#include "des_locl.h"
+#include "des_local.h"
#ifdef CBC_ENC_C__DONT_UPDATE_IV
void DES_cbc_encrypt(const unsigned char *in, unsigned char *out, long length,
* https://www.openssl.org/source/license.html
*/
-#include "des_locl.h"
+#include "des_local.h"
/*
* The input and output encrypted as though 64bit ofb mode is being used.
* https://www.openssl.org/source/license.html
*/
-#include "des_locl.h"
+#include "des_local.h"
/*
* The input and output encrypted as though 64bit ofb mode is being used.
* https://www.openssl.org/source/license.html
*/
-#include "des_locl.h"
+#include "des_local.h"
/*
* The input and output are loaded in multiples of 8 bits. What this means is
* https://www.openssl.org/source/license.html
*/
-#include "des_locl.h"
+#include "des_local.h"
void DES_pcbc_encrypt(const unsigned char *input, unsigned char *output,
long length, DES_key_schedule *schedule,
* only based on the code in this paper and is almost definitely not the same
* as the MIT implementation.
*/
-#include "des_locl.h"
+#include "des_local.h"
#define Q_B0(a) (((DES_LONG)(a)))
#define Q_B1(a) (((DES_LONG)(a))<<8)
* 1.0 First working version
*/
#include <openssl/crypto.h>
-#include "des_locl.h"
+#include "des_local.h"
static const unsigned char odd_parity[256] = {
1, 1, 2, 2, 4, 4, 7, 7, 8, 8, 11, 11, 13, 13, 14, 14,
*/
#include <openssl/crypto.h>
-#include "des_locl.h"
+#include "des_local.h"
void DES_string_to_key(const char *str, DES_cblock *key)
{
* https://www.openssl.org/source/license.html
*/
-#include "des_locl.h"
+#include "des_local.h"
/* RSA's DESX */
#include "internal/cryptlib.h"
#include <openssl/x509.h>
#include <openssl/asn1.h>
-#include "dh_locl.h"
+#include "dh_local.h"
#include <openssl/bn.h>
#include "crypto/asn1.h"
#include "crypto/evp.h"
#include <stdio.h>
#include "internal/cryptlib.h"
#include <openssl/bn.h>
-#include "dh_locl.h"
+#include "dh_local.h"
#include <openssl/objects.h>
#include <openssl/asn1t.h>
#include <stdio.h>
#include "internal/cryptlib.h"
#include <openssl/bn.h>
-#include "dh_locl.h"
+#include "dh_local.h"
# define DH_NUMBER_ITERATIONS_FOR_PRIME 64
#include <stdio.h>
#include "internal/cryptlib.h"
#include <openssl/bn.h>
-#include "dh_locl.h"
+#include "dh_local.h"
static int dh_builtin_genparams(DH *ret, int prime_len, int generator,
BN_GENCB *cb);
#include <stdio.h>
#include "internal/cryptlib.h"
-#include "dh_locl.h"
+#include "dh_local.h"
#include "crypto/bn.h"
static int generate_key(DH *dh);
#include "internal/cryptlib.h"
#include "internal/refcount.h"
#include <openssl/bn.h>
-#include "dh_locl.h"
+#include "dh_local.h"
#include <openssl/engine.h>
int DH_set_method(DH *dh, const DH_METHOD *meth)
--- /dev/null
+/*
+ * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+#include <openssl/dh.h>
+#include "internal/refcount.h"
+
+#define DH_MIN_MODULUS_BITS 512
+
+struct dh_st {
+ /*
+ * This first argument is used to pick up errors when a DH is passed
+ * instead of a EVP_PKEY
+ */
+ int pad;
+ int version;
+ BIGNUM *p;
+ BIGNUM *g;
+ int32_t length; /* optional */
+ BIGNUM *pub_key; /* g^x % p */
+ BIGNUM *priv_key; /* x */
+ int flags;
+ BN_MONT_CTX *method_mont_p;
+ /* Place holders if we want to do X9.42 DH */
+ BIGNUM *q;
+ BIGNUM *j;
+ unsigned char *seed;
+ int seedlen;
+ BIGNUM *counter;
+ CRYPTO_REF_COUNT references;
+ CRYPTO_EX_DATA ex_data;
+ const DH_METHOD *meth;
+ ENGINE *engine;
+ CRYPTO_RWLOCK *lock;
+
+ /* Provider data */
+ size_t dirty_cnt; /* If any key material changes, increment this */
+};
+
+struct dh_method {
+ char *name;
+ /* Methods here */
+ int (*generate_key) (DH *dh);
+ int (*compute_key) (unsigned char *key, const BIGNUM *pub_key, DH *dh);
+
+ /* Can be null */
+ int (*bn_mod_exp) (const DH *dh, BIGNUM *r, const BIGNUM *a,
+ const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
+ BN_MONT_CTX *m_ctx);
+ int (*init) (DH *dh);
+ int (*finish) (DH *dh);
+ int flags;
+ char *app_data;
+ /* If this is non-NULL, it will be used to generate parameters */
+ int (*generate_params) (DH *dh, int prime_len, int generator,
+ BN_GENCB *cb);
+};
+
+int dh_buf2key(DH *key, const unsigned char *buf, size_t len);
+size_t dh_key2buf(const DH *dh, unsigned char **pbuf);
+++ /dev/null
-/*
- * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-#include <openssl/dh.h>
-#include "internal/refcount.h"
-
-#define DH_MIN_MODULUS_BITS 512
-
-struct dh_st {
- /*
- * This first argument is used to pick up errors when a DH is passed
- * instead of a EVP_PKEY
- */
- int pad;
- int version;
- BIGNUM *p;
- BIGNUM *g;
- int32_t length; /* optional */
- BIGNUM *pub_key; /* g^x % p */
- BIGNUM *priv_key; /* x */
- int flags;
- BN_MONT_CTX *method_mont_p;
- /* Place holders if we want to do X9.42 DH */
- BIGNUM *q;
- BIGNUM *j;
- unsigned char *seed;
- int seedlen;
- BIGNUM *counter;
- CRYPTO_REF_COUNT references;
- CRYPTO_EX_DATA ex_data;
- const DH_METHOD *meth;
- ENGINE *engine;
- CRYPTO_RWLOCK *lock;
-
- /* Provider data */
- size_t dirty_cnt; /* If any key material changes, increment this */
-};
-
-struct dh_method {
- char *name;
- /* Methods here */
- int (*generate_key) (DH *dh);
- int (*compute_key) (unsigned char *key, const BIGNUM *pub_key, DH *dh);
-
- /* Can be null */
- int (*bn_mod_exp) (const DH *dh, BIGNUM *r, const BIGNUM *a,
- const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
- BN_MONT_CTX *m_ctx);
- int (*init) (DH *dh);
- int (*finish) (DH *dh);
- int flags;
- char *app_data;
- /* If this is non-NULL, it will be used to generate parameters */
- int (*generate_params) (DH *dh, int prime_len, int generator,
- BN_GENCB *cb);
-};
-
-int dh_buf2key(DH *key, const unsigned char *buf, size_t len);
-size_t dh_key2buf(const DH *dh, unsigned char **pbuf);
* https://www.openssl.org/source/license.html
*/
-#include "dh_locl.h"
+#include "dh_local.h"
#include <string.h>
#include <openssl/err.h>
#include <openssl/asn1t.h>
#include <openssl/x509.h>
#include <openssl/evp.h>
-#include "dh_locl.h"
+#include "dh_local.h"
#include <openssl/bn.h>
#include <openssl/dsa.h>
#include <openssl/objects.h>
#include <stdio.h>
#include "internal/cryptlib.h"
-#include "dh_locl.h"
+#include "dh_local.h"
#include <openssl/bn.h>
#include "crypto/bn_dh.h"
#include <stdio.h>
#include "internal/cryptlib.h"
-#include "dh_locl.h"
+#include "dh_local.h"
#include <openssl/bn.h>
#include <openssl/objects.h>
#include "crypto/bn_dh.h"
#include "crypto/asn1.h"
#include "crypto/evp.h"
#include "internal/param_build.h"
-#include "dsa_locl.h"
+#include "dsa_local.h"
static int dsa_pub_decode(EVP_PKEY *pkey, X509_PUBKEY *pubkey)
{
#include <stdio.h>
#include "internal/cryptlib.h"
-#include "dsa_locl.h"
+#include "dsa_local.h"
#include <openssl/asn1.h>
#include <openssl/asn1t.h>
#include <openssl/rand.h>
#include <openssl/bn.h>
#include <openssl/rand.h>
#include <openssl/sha.h>
-#include "dsa_locl.h"
+#include "dsa_local.h"
int DSA_generate_parameters_ex(DSA *ret, int bits,
const unsigned char *seed_in, int seed_len,
#include <time.h>
#include "internal/cryptlib.h"
#include <openssl/bn.h>
-#include "dsa_locl.h"
+#include "dsa_local.h"
static int dsa_builtin_keygen(DSA *dsa);
#include "internal/cryptlib.h"
#include "internal/refcount.h"
#include <openssl/bn.h>
-#include "dsa_locl.h"
+#include "dsa_local.h"
#include <openssl/asn1.h>
#include <openssl/engine.h>
#include <openssl/dh.h>
--- /dev/null
+/*
+ * Copyright 2007-2016 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+#include <openssl/dsa.h>
+#include "internal/refcount.h"
+
+struct dsa_st {
+ /*
+ * This first variable is used to pick up errors where a DSA is passed
+ * instead of of a EVP_PKEY
+ */
+ int pad;
+ int32_t version;
+ BIGNUM *p;
+ BIGNUM *q; /* == 20 */
+ BIGNUM *g;
+ BIGNUM *pub_key; /* y public key */
+ BIGNUM *priv_key; /* x private key */
+ int flags;
+ /* Normally used to cache montgomery values */
+ BN_MONT_CTX *method_mont_p;
+ CRYPTO_REF_COUNT references;
+ CRYPTO_EX_DATA ex_data;
+ const DSA_METHOD *meth;
+ /* functional reference if 'meth' is ENGINE-provided */
+ ENGINE *engine;
+ CRYPTO_RWLOCK *lock;
+
+ /* Provider data */
+ size_t dirty_cnt; /* If any key material changes, increment this */
+};
+
+struct DSA_SIG_st {
+ BIGNUM *r;
+ BIGNUM *s;
+};
+
+struct dsa_method {
+ char *name;
+ DSA_SIG *(*dsa_do_sign) (const unsigned char *dgst, int dlen, DSA *dsa);
+ int (*dsa_sign_setup) (DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp,
+ BIGNUM **rp);
+ int (*dsa_do_verify) (const unsigned char *dgst, int dgst_len,
+ DSA_SIG *sig, DSA *dsa);
+ int (*dsa_mod_exp) (DSA *dsa, BIGNUM *rr, const BIGNUM *a1,
+ const BIGNUM *p1, const BIGNUM *a2, const BIGNUM *p2,
+ const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont);
+ /* Can be null */
+ int (*bn_mod_exp) (DSA *dsa, BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
+ const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
+ int (*init) (DSA *dsa);
+ int (*finish) (DSA *dsa);
+ int flags;
+ void *app_data;
+ /* If this is non-NULL, it is used to generate DSA parameters */
+ int (*dsa_paramgen) (DSA *dsa, int bits,
+ const unsigned char *seed, int seed_len,
+ int *counter_ret, unsigned long *h_ret,
+ BN_GENCB *cb);
+ /* If this is non-NULL, it is used to generate DSA keys */
+ int (*dsa_keygen) (DSA *dsa);
+};
+
+int dsa_builtin_paramgen(DSA *ret, size_t bits, size_t qbits,
+ const EVP_MD *evpmd, const unsigned char *seed_in,
+ size_t seed_len, unsigned char *seed_out,
+ int *counter_ret, unsigned long *h_ret,
+ BN_GENCB *cb);
+
+int dsa_builtin_paramgen2(DSA *ret, size_t L, size_t N,
+ const EVP_MD *evpmd, const unsigned char *seed_in,
+ size_t seed_len, int idx, unsigned char *seed_out,
+ int *counter_ret, unsigned long *h_ret,
+ BN_GENCB *cb);
+++ /dev/null
-/*
- * Copyright 2007-2016 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-#include <openssl/dsa.h>
-#include "internal/refcount.h"
-
-struct dsa_st {
- /*
- * This first variable is used to pick up errors where a DSA is passed
- * instead of of a EVP_PKEY
- */
- int pad;
- int32_t version;
- BIGNUM *p;
- BIGNUM *q; /* == 20 */
- BIGNUM *g;
- BIGNUM *pub_key; /* y public key */
- BIGNUM *priv_key; /* x private key */
- int flags;
- /* Normally used to cache montgomery values */
- BN_MONT_CTX *method_mont_p;
- CRYPTO_REF_COUNT references;
- CRYPTO_EX_DATA ex_data;
- const DSA_METHOD *meth;
- /* functional reference if 'meth' is ENGINE-provided */
- ENGINE *engine;
- CRYPTO_RWLOCK *lock;
-
- /* Provider data */
- size_t dirty_cnt; /* If any key material changes, increment this */
-};
-
-struct DSA_SIG_st {
- BIGNUM *r;
- BIGNUM *s;
-};
-
-struct dsa_method {
- char *name;
- DSA_SIG *(*dsa_do_sign) (const unsigned char *dgst, int dlen, DSA *dsa);
- int (*dsa_sign_setup) (DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp,
- BIGNUM **rp);
- int (*dsa_do_verify) (const unsigned char *dgst, int dgst_len,
- DSA_SIG *sig, DSA *dsa);
- int (*dsa_mod_exp) (DSA *dsa, BIGNUM *rr, const BIGNUM *a1,
- const BIGNUM *p1, const BIGNUM *a2, const BIGNUM *p2,
- const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont);
- /* Can be null */
- int (*bn_mod_exp) (DSA *dsa, BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
- const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
- int (*init) (DSA *dsa);
- int (*finish) (DSA *dsa);
- int flags;
- void *app_data;
- /* If this is non-NULL, it is used to generate DSA parameters */
- int (*dsa_paramgen) (DSA *dsa, int bits,
- const unsigned char *seed, int seed_len,
- int *counter_ret, unsigned long *h_ret,
- BN_GENCB *cb);
- /* If this is non-NULL, it is used to generate DSA keys */
- int (*dsa_keygen) (DSA *dsa);
-};
-
-int dsa_builtin_paramgen(DSA *ret, size_t bits, size_t qbits,
- const EVP_MD *evpmd, const unsigned char *seed_in,
- size_t seed_len, unsigned char *seed_out,
- int *counter_ret, unsigned long *h_ret,
- BN_GENCB *cb);
-
-int dsa_builtin_paramgen2(DSA *ret, size_t L, size_t N,
- const EVP_MD *evpmd, const unsigned char *seed_in,
- size_t seed_len, int idx, unsigned char *seed_out,
- int *counter_ret, unsigned long *h_ret,
- BN_GENCB *cb);
* or in the file LICENSE in the source distribution.
*/
-#include "dsa_locl.h"
+#include "dsa_local.h"
#include <string.h>
#include <openssl/err.h>
#include "crypto/bn.h"
#include <openssl/bn.h>
#include <openssl/sha.h>
-#include "dsa_locl.h"
+#include "dsa_local.h"
#include <openssl/asn1.h>
static DSA_SIG *dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa);
#include <openssl/evp.h>
#include <openssl/bn.h>
#include "crypto/evp.h"
-#include "dsa_locl.h"
+#include "dsa_local.h"
/* DSA pkey context structure */
*/
#include "internal/cryptlib.h"
-#include "dsa_locl.h"
+#include "dsa_local.h"
#include <openssl/bn.h>
DSA_SIG *DSA_do_sign(const unsigned char *dgst, int dlen, DSA *dsa)
*/
#include "internal/cryptlib.h"
-#include "dsa_locl.h"
+#include "dsa_local.h"
int DSA_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig,
DSA *dsa)
* https://www.openssl.org/source/license.html
*/
-#include "dso_locl.h"
+#include "dso_local.h"
#ifdef DSO_DL
# define _GNU_SOURCE /* make sure dladdr is declared */
#endif
-#include "dso_locl.h"
+#include "dso_local.h"
#include "e_os.h"
#ifdef DSO_DLFCN
* https://www.openssl.org/source/license.html
*/
-#include "dso_locl.h"
+#include "dso_local.h"
#include "internal/refcount.h"
static DSO_METHOD *default_DSO_meth = NULL;
--- /dev/null
+/*
+ * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+#include <stdio.h>
+#include "internal/cryptlib.h"
+#include "internal/dso.h"
+#include "crypto/dso_conf.h"
+#include "internal/refcount.h"
+
+/**********************************************************************/
+/* The low-level handle type used to refer to a loaded shared library */
+
+struct dso_st {
+ DSO_METHOD *meth;
+ /*
+ * Standard dlopen uses a (void *). Win32 uses a HANDLE. VMS doesn't use
+ * anything but will need to cache the filename for use in the dso_bind
+ * handler. All in all, let each method control its own destiny.
+ * "Handles" and such go in a STACK.
+ */
+ STACK_OF(void) *meth_data;
+ CRYPTO_REF_COUNT references;
+ int flags;
+ /*
+ * For use by applications etc ... use this for your bits'n'pieces, don't
+ * touch meth_data!
+ */
+ CRYPTO_EX_DATA ex_data;
+ /*
+ * If this callback function pointer is set to non-NULL, then it will be
+ * used in DSO_load() in place of meth->dso_name_converter. NB: This
+ * should normally set using DSO_set_name_converter().
+ */
+ DSO_NAME_CONVERTER_FUNC name_converter;
+ /*
+ * If this callback function pointer is set to non-NULL, then it will be
+ * used in DSO_load() in place of meth->dso_merger. NB: This should
+ * normally set using DSO_set_merger().
+ */
+ DSO_MERGER_FUNC merger;
+ /*
+ * This is populated with (a copy of) the platform-independent filename
+ * used for this DSO.
+ */
+ char *filename;
+ /*
+ * This is populated with (a copy of) the translated filename by which
+ * the DSO was actually loaded. It is NULL iff the DSO is not currently
+ * loaded. NB: This is here because the filename translation process may
+ * involve a callback being invoked more than once not only to convert to
+ * a platform-specific form, but also to try different filenames in the
+ * process of trying to perform a load. As such, this variable can be
+ * used to indicate (a) whether this DSO structure corresponds to a
+ * loaded library or not, and (b) the filename with which it was actually
+ * loaded.
+ */
+ char *loaded_filename;
+ CRYPTO_RWLOCK *lock;
+};
+
+struct dso_meth_st {
+ const char *name;
+ /*
+ * Loads a shared library, NB: new DSO_METHODs must ensure that a
+ * successful load populates the loaded_filename field, and likewise a
+ * successful unload OPENSSL_frees and NULLs it out.
+ */
+ int (*dso_load) (DSO *dso);
+ /* Unloads a shared library */
+ int (*dso_unload) (DSO *dso);
+ /*
+ * Binds a function - assumes a return type of DSO_FUNC_TYPE. This should
+ * be cast to the real function prototype by the caller. Platforms that
+ * don't have compatible representations for different prototypes (this
+ * is possible within ANSI C) are highly unlikely to have shared
+ * libraries at all, let alone a DSO_METHOD implemented for them.
+ */
+ DSO_FUNC_TYPE (*dso_bind_func) (DSO *dso, const char *symname);
+ /*
+ * The generic (yuck) "ctrl()" function. NB: Negative return values
+ * (rather than zero) indicate errors.
+ */
+ long (*dso_ctrl) (DSO *dso, int cmd, long larg, void *parg);
+ /*
+ * The default DSO_METHOD-specific function for converting filenames to a
+ * canonical native form.
+ */
+ DSO_NAME_CONVERTER_FUNC dso_name_converter;
+ /*
+ * The default DSO_METHOD-specific function for converting filenames to a
+ * canonical native form.
+ */
+ DSO_MERGER_FUNC dso_merger;
+ /* [De]Initialisation handlers. */
+ int (*init) (DSO *dso);
+ int (*finish) (DSO *dso);
+ /* Return pathname of the module containing location */
+ int (*pathbyaddr) (void *addr, char *path, int sz);
+ /* Perform global symbol lookup, i.e. among *all* modules */
+ void *(*globallookup) (const char *symname);
+};
+++ /dev/null
-/*
- * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-#include <stdio.h>
-#include "internal/cryptlib.h"
-#include "internal/dso.h"
-#include "crypto/dso_conf.h"
-#include "internal/refcount.h"
-
-/**********************************************************************/
-/* The low-level handle type used to refer to a loaded shared library */
-
-struct dso_st {
- DSO_METHOD *meth;
- /*
- * Standard dlopen uses a (void *). Win32 uses a HANDLE. VMS doesn't use
- * anything but will need to cache the filename for use in the dso_bind
- * handler. All in all, let each method control its own destiny.
- * "Handles" and such go in a STACK.
- */
- STACK_OF(void) *meth_data;
- CRYPTO_REF_COUNT references;
- int flags;
- /*
- * For use by applications etc ... use this for your bits'n'pieces, don't
- * touch meth_data!
- */
- CRYPTO_EX_DATA ex_data;
- /*
- * If this callback function pointer is set to non-NULL, then it will be
- * used in DSO_load() in place of meth->dso_name_converter. NB: This
- * should normally set using DSO_set_name_converter().
- */
- DSO_NAME_CONVERTER_FUNC name_converter;
- /*
- * If this callback function pointer is set to non-NULL, then it will be
- * used in DSO_load() in place of meth->dso_merger. NB: This should
- * normally set using DSO_set_merger().
- */
- DSO_MERGER_FUNC merger;
- /*
- * This is populated with (a copy of) the platform-independent filename
- * used for this DSO.
- */
- char *filename;
- /*
- * This is populated with (a copy of) the translated filename by which
- * the DSO was actually loaded. It is NULL iff the DSO is not currently
- * loaded. NB: This is here because the filename translation process may
- * involve a callback being invoked more than once not only to convert to
- * a platform-specific form, but also to try different filenames in the
- * process of trying to perform a load. As such, this variable can be
- * used to indicate (a) whether this DSO structure corresponds to a
- * loaded library or not, and (b) the filename with which it was actually
- * loaded.
- */
- char *loaded_filename;
- CRYPTO_RWLOCK *lock;
-};
-
-struct dso_meth_st {
- const char *name;
- /*
- * Loads a shared library, NB: new DSO_METHODs must ensure that a
- * successful load populates the loaded_filename field, and likewise a
- * successful unload OPENSSL_frees and NULLs it out.
- */
- int (*dso_load) (DSO *dso);
- /* Unloads a shared library */
- int (*dso_unload) (DSO *dso);
- /*
- * Binds a function - assumes a return type of DSO_FUNC_TYPE. This should
- * be cast to the real function prototype by the caller. Platforms that
- * don't have compatible representations for different prototypes (this
- * is possible within ANSI C) are highly unlikely to have shared
- * libraries at all, let alone a DSO_METHOD implemented for them.
- */
- DSO_FUNC_TYPE (*dso_bind_func) (DSO *dso, const char *symname);
- /*
- * The generic (yuck) "ctrl()" function. NB: Negative return values
- * (rather than zero) indicate errors.
- */
- long (*dso_ctrl) (DSO *dso, int cmd, long larg, void *parg);
- /*
- * The default DSO_METHOD-specific function for converting filenames to a
- * canonical native form.
- */
- DSO_NAME_CONVERTER_FUNC dso_name_converter;
- /*
- * The default DSO_METHOD-specific function for converting filenames to a
- * canonical native form.
- */
- DSO_MERGER_FUNC dso_merger;
- /* [De]Initialisation handlers. */
- int (*init) (DSO *dso);
- int (*finish) (DSO *dso);
- /* Return pathname of the module containing location */
- int (*pathbyaddr) (void *addr, char *path, int sz);
- /* Perform global symbol lookup, i.e. among *all* modules */
- void *(*globallookup) (const char *symname);
-};
* https://www.openssl.org/source/license.html
*/
-#include "dso_locl.h"
+#include "dso_local.h"
#ifdef DSO_NONE
* https://www.openssl.org/source/license.html
*/
-#include "dso_locl.h"
+#include "dso_local.h"
#ifdef OPENSSL_SYS_VMS
*/
#include "e_os.h"
-#include "dso_locl.h"
+#include "dso_local.h"
#if defined(DSO_WIN32)
*/
#include <string.h>
-#include "ec_lcl.h"
+#include "ec_local.h"
#include <openssl/sha.h>
#if defined(X25519_ASM) && (defined(__x86_64) || defined(__x86_64__) || \
#ifndef HEADER_ARCH_32_ARCH_INTRINSICS_H
# define HEADER_ARCH_32_ARCH_INTRINSICS_H
-#include "internal/constant_time_locl.h"
+#include "internal/constant_time.h"
# define ARCH_WORD_BITS 32
#include "point_448.h"
#include "ed448.h"
-#include "curve448_lcl.h"
+#include "curve448_local.h"
#define COFACTOR 4
+++ /dev/null
-/*
- * Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-#ifndef HEADER_CURVE448_LCL_H
-# define HEADER_CURVE448_LCL_H
-# include "curve448utils.h"
-
-int X448(uint8_t out_shared_key[56], const uint8_t private_key[56],
- const uint8_t peer_public_value[56]);
-
-void X448_public_from_private(uint8_t out_public_value[56],
- const uint8_t private_key[56]);
-
-int ED448_sign(OPENSSL_CTX *ctx, uint8_t *out_sig, const uint8_t *message,
- size_t message_len, const uint8_t public_key[57],
- const uint8_t private_key[57], const uint8_t *context,
- size_t context_len);
-
-int ED448_verify(OPENSSL_CTX *ctx, const uint8_t *message, size_t message_len,
- const uint8_t signature[114], const uint8_t public_key[57],
- const uint8_t *context, size_t context_len);
-
-int ED448ph_sign(OPENSSL_CTX *ctx, uint8_t *out_sig, const uint8_t hash[64],
- const uint8_t public_key[57], const uint8_t private_key[57],
- const uint8_t *context, size_t context_len);
-
-int ED448ph_verify(OPENSSL_CTX *ctx, const uint8_t hash[64],
- const uint8_t signature[114], const uint8_t public_key[57],
- const uint8_t *context, size_t context_len);
-
-int ED448_public_from_private(OPENSSL_CTX *ctx, uint8_t out_public_key[57],
- const uint8_t private_key[57]);
-
-#endif /* HEADER_CURVE448_LCL_H */
--- /dev/null
+/*
+ * Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+#ifndef HEADER_CURVE448_LCL_H
+# define HEADER_CURVE448_LCL_H
+# include "curve448utils.h"
+
+int X448(uint8_t out_shared_key[56], const uint8_t private_key[56],
+ const uint8_t peer_public_value[56]);
+
+void X448_public_from_private(uint8_t out_public_value[56],
+ const uint8_t private_key[56]);
+
+int ED448_sign(OPENSSL_CTX *ctx, uint8_t *out_sig, const uint8_t *message,
+ size_t message_len, const uint8_t public_key[57],
+ const uint8_t private_key[57], const uint8_t *context,
+ size_t context_len);
+
+int ED448_verify(OPENSSL_CTX *ctx, const uint8_t *message, size_t message_len,
+ const uint8_t signature[114], const uint8_t public_key[57],
+ const uint8_t *context, size_t context_len);
+
+int ED448ph_sign(OPENSSL_CTX *ctx, uint8_t *out_sig, const uint8_t hash[64],
+ const uint8_t public_key[57], const uint8_t private_key[57],
+ const uint8_t *context, size_t context_len);
+
+int ED448ph_verify(OPENSSL_CTX *ctx, const uint8_t hash[64],
+ const uint8_t signature[114], const uint8_t public_key[57],
+ const uint8_t *context, size_t context_len);
+
+int ED448_public_from_private(OPENSSL_CTX *ctx, uint8_t out_public_key[57],
+ const uint8_t private_key[57]);
+
+#endif /* HEADER_CURVE448_LCL_H */
#include <string.h>
#include <openssl/crypto.h>
#include <openssl/evp.h>
-#include "curve448_lcl.h"
+#include "curve448_local.h"
#include "word.h"
#include "ed448.h"
#include "internal/numbers.h"
#ifndef HEADER_FIELD_H
# define HEADER_FIELD_H
-# include "internal/constant_time_locl.h"
+# include "internal/constant_time.h"
# include <string.h>
# include <assert.h>
# include "word.h"
#include <openssl/err.h>
-#include "ec_lcl.h"
+#include "ec_local.h"
#ifndef OPENSSL_NO_EC2M
#include <openssl/err.h>
#include "crypto/bn.h"
-#include "ec_lcl.h"
+#include "ec_local.h"
#ifndef OPENSSL_NO_EC2M
#include <openssl/asn1t.h>
#include "crypto/asn1.h"
#include "crypto/evp.h"
-#include "ec_lcl.h"
+#include "ec_local.h"
#ifndef OPENSSL_NO_CMS
static int ecdh_cms_decrypt(CMS_RecipientInfo *ri);
*/
#include <string.h>
-#include "ec_lcl.h"
+#include "ec_local.h"
#include <openssl/err.h>
#include <openssl/asn1t.h>
#include <openssl/objects.h>
* https://www.openssl.org/source/license.html
*/
-#include "ec_lcl.h"
+#include "ec_local.h"
#include <openssl/err.h>
int EC_GROUP_check_named_curve(const EC_GROUP *group, int nist_only,
*/
#include <string.h>
-#include "ec_lcl.h"
+#include "ec_local.h"
#include <openssl/err.h>
#include <openssl/obj_mac.h>
#include <openssl/opensslconf.h>
#include <openssl/err.h>
#include "crypto/bn.h"
-#include "ec_lcl.h"
+#include "ec_local.h"
EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a,
const BIGNUM *b, BN_CTX *ctx)
#include "internal/cryptlib.h"
#include <string.h>
-#include "ec_lcl.h"
+#include "ec_local.h"
#include "internal/refcount.h"
#include <openssl/err.h>
#include <openssl/engine.h>
#include <openssl/ec.h>
#include <openssl/engine.h>
#include <openssl/err.h>
-#include "ec_lcl.h"
+#include "ec_local.h"
static const EC_KEY_METHOD openssl_ec_key_method = {
+++ /dev/null
-/*
- * Copyright 2001-2018 The OpenSSL Project Authors. All Rights Reserved.
- * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-#include <stdlib.h>
-
-#include <openssl/obj_mac.h>
-#include <openssl/ec.h>
-#include <openssl/bn.h>
-#include "internal/refcount.h"
-#include "crypto/ec.h"
-
-#if defined(__SUNPRO_C)
-# if __SUNPRO_C >= 0x520
-# pragma error_messages (off,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE)
-# endif
-#endif
-
-/* Use default functions for poin2oct, oct2point and compressed coordinates */
-#define EC_FLAGS_DEFAULT_OCT 0x1
-
-/* Use custom formats for EC_GROUP, EC_POINT and EC_KEY */
-#define EC_FLAGS_CUSTOM_CURVE 0x2
-
-/* Curve does not support signing operations */
-#define EC_FLAGS_NO_SIGN 0x4
-
-/*
- * Structure details are not part of the exported interface, so all this may
- * change in future versions.
- */
-
-struct ec_method_st {
- /* Various method flags */
- int flags;
- /* used by EC_METHOD_get_field_type: */
- int field_type; /* a NID */
- /*
- * used by EC_GROUP_new, EC_GROUP_free, EC_GROUP_clear_free,
- * EC_GROUP_copy:
- */
- int (*group_init) (EC_GROUP *);
- void (*group_finish) (EC_GROUP *);
- void (*group_clear_finish) (EC_GROUP *);
- int (*group_copy) (EC_GROUP *, const EC_GROUP *);
- /* used by EC_GROUP_set_curve, EC_GROUP_get_curve: */
- int (*group_set_curve) (EC_GROUP *, const BIGNUM *p, const BIGNUM *a,
- const BIGNUM *b, BN_CTX *);
- int (*group_get_curve) (const EC_GROUP *, BIGNUM *p, BIGNUM *a, BIGNUM *b,
- BN_CTX *);
- /* used by EC_GROUP_get_degree: */
- int (*group_get_degree) (const EC_GROUP *);
- int (*group_order_bits) (const EC_GROUP *);
- /* used by EC_GROUP_check: */
- int (*group_check_discriminant) (const EC_GROUP *, BN_CTX *);
- /*
- * used by EC_POINT_new, EC_POINT_free, EC_POINT_clear_free,
- * EC_POINT_copy:
- */
- int (*point_init) (EC_POINT *);
- void (*point_finish) (EC_POINT *);
- void (*point_clear_finish) (EC_POINT *);
- int (*point_copy) (EC_POINT *, const EC_POINT *);
- /*-
- * used by EC_POINT_set_to_infinity,
- * EC_POINT_set_Jprojective_coordinates_GFp,
- * EC_POINT_get_Jprojective_coordinates_GFp,
- * EC_POINT_set_affine_coordinates,
- * EC_POINT_get_affine_coordinates,
- * EC_POINT_set_compressed_coordinates:
- */
- int (*point_set_to_infinity) (const EC_GROUP *, EC_POINT *);
- int (*point_set_Jprojective_coordinates_GFp) (const EC_GROUP *,
- EC_POINT *, const BIGNUM *x,
- const BIGNUM *y,
- const BIGNUM *z, BN_CTX *);
- int (*point_get_Jprojective_coordinates_GFp) (const EC_GROUP *,
- const EC_POINT *, BIGNUM *x,
- BIGNUM *y, BIGNUM *z,
- BN_CTX *);
- int (*point_set_affine_coordinates) (const EC_GROUP *, EC_POINT *,
- const BIGNUM *x, const BIGNUM *y,
- BN_CTX *);
- int (*point_get_affine_coordinates) (const EC_GROUP *, const EC_POINT *,
- BIGNUM *x, BIGNUM *y, BN_CTX *);
- int (*point_set_compressed_coordinates) (const EC_GROUP *, EC_POINT *,
- const BIGNUM *x, int y_bit,
- BN_CTX *);
- /* used by EC_POINT_point2oct, EC_POINT_oct2point: */
- size_t (*point2oct) (const EC_GROUP *, const EC_POINT *,
- point_conversion_form_t form, unsigned char *buf,
- size_t len, BN_CTX *);
- int (*oct2point) (const EC_GROUP *, EC_POINT *, const unsigned char *buf,
- size_t len, BN_CTX *);
- /* used by EC_POINT_add, EC_POINT_dbl, ECP_POINT_invert: */
- int (*add) (const EC_GROUP *, EC_POINT *r, const EC_POINT *a,
- const EC_POINT *b, BN_CTX *);
- int (*dbl) (const EC_GROUP *, EC_POINT *r, const EC_POINT *a, BN_CTX *);
- int (*invert) (const EC_GROUP *, EC_POINT *, BN_CTX *);
- /*
- * used by EC_POINT_is_at_infinity, EC_POINT_is_on_curve, EC_POINT_cmp:
- */
- int (*is_at_infinity) (const EC_GROUP *, const EC_POINT *);
- int (*is_on_curve) (const EC_GROUP *, const EC_POINT *, BN_CTX *);
- int (*point_cmp) (const EC_GROUP *, const EC_POINT *a, const EC_POINT *b,
- BN_CTX *);
- /* used by EC_POINT_make_affine, EC_POINTs_make_affine: */
- int (*make_affine) (const EC_GROUP *, EC_POINT *, BN_CTX *);
- int (*points_make_affine) (const EC_GROUP *, size_t num, EC_POINT *[],
- BN_CTX *);
- /*
- * used by EC_POINTs_mul, EC_POINT_mul, EC_POINT_precompute_mult,
- * EC_POINT_have_precompute_mult (default implementations are used if the
- * 'mul' pointer is 0):
- */
- /*-
- * mul() calculates the value
- *
- * r := generator * scalar
- * + points[0] * scalars[0]
- * + ...
- * + points[num-1] * scalars[num-1].
- *
- * For a fixed point multiplication (scalar != NULL, num == 0)
- * or a variable point multiplication (scalar == NULL, num == 1),
- * mul() must use a constant time algorithm: in both cases callers
- * should provide an input scalar (either scalar or scalars[0])
- * in the range [0, ec_group_order); for robustness, implementers
- * should handle the case when the scalar has not been reduced, but
- * may treat it as an unusual input, without any constant-timeness
- * guarantee.
- */
- int (*mul) (const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar,
- size_t num, const EC_POINT *points[], const BIGNUM *scalars[],
- BN_CTX *);
- int (*precompute_mult) (EC_GROUP *group, BN_CTX *);
- int (*have_precompute_mult) (const EC_GROUP *group);
- /* internal functions */
- /*
- * 'field_mul', 'field_sqr', and 'field_div' can be used by 'add' and
- * 'dbl' so that the same implementations of point operations can be used
- * with different optimized implementations of expensive field
- * operations:
- */
- int (*field_mul) (const EC_GROUP *, BIGNUM *r, const BIGNUM *a,
- const BIGNUM *b, BN_CTX *);
- int (*field_sqr) (const EC_GROUP *, BIGNUM *r, const BIGNUM *a, BN_CTX *);
- int (*field_div) (const EC_GROUP *, BIGNUM *r, const BIGNUM *a,
- const BIGNUM *b, BN_CTX *);
- /*-
- * 'field_inv' computes the multiplicative inverse of a in the field,
- * storing the result in r.
- *
- * If 'a' is zero (or equivalent), you'll get an EC_R_CANNOT_INVERT error.
- */
- int (*field_inv) (const EC_GROUP *, BIGNUM *r, const BIGNUM *a, BN_CTX *);
- /* e.g. to Montgomery */
- int (*field_encode) (const EC_GROUP *, BIGNUM *r, const BIGNUM *a,
- BN_CTX *);
- /* e.g. from Montgomery */
- int (*field_decode) (const EC_GROUP *, BIGNUM *r, const BIGNUM *a,
- BN_CTX *);
- int (*field_set_to_one) (const EC_GROUP *, BIGNUM *r, BN_CTX *);
- /* private key operations */
- size_t (*priv2oct)(const EC_KEY *eckey, unsigned char *buf, size_t len);
- int (*oct2priv)(EC_KEY *eckey, const unsigned char *buf, size_t len);
- int (*set_private)(EC_KEY *eckey, const BIGNUM *priv_key);
- int (*keygen)(EC_KEY *eckey);
- int (*keycheck)(const EC_KEY *eckey);
- int (*keygenpub)(EC_KEY *eckey);
- int (*keycopy)(EC_KEY *dst, const EC_KEY *src);
- void (*keyfinish)(EC_KEY *eckey);
- /* custom ECDH operation */
- int (*ecdh_compute_key)(unsigned char **pout, size_t *poutlen,
- const EC_POINT *pub_key, const EC_KEY *ecdh);
- /* custom ECDSA */
- int (*ecdsa_sign_setup)(EC_KEY *eckey, BN_CTX *ctx, BIGNUM **kinvp,
- BIGNUM **rp);
- ECDSA_SIG *(*ecdsa_sign_sig)(const unsigned char *dgst, int dgstlen,
- const BIGNUM *kinv, const BIGNUM *r,
- EC_KEY *eckey);
- int (*ecdsa_verify_sig)(const unsigned char *dgst, int dgstlen,
- const ECDSA_SIG *sig, EC_KEY *eckey);
- /* Inverse modulo order */
- int (*field_inverse_mod_ord)(const EC_GROUP *, BIGNUM *r,
- const BIGNUM *x, BN_CTX *);
- int (*blind_coordinates)(const EC_GROUP *group, EC_POINT *p, BN_CTX *ctx);
- int (*ladder_pre)(const EC_GROUP *group,
- EC_POINT *r, EC_POINT *s,
- EC_POINT *p, BN_CTX *ctx);
- int (*ladder_step)(const EC_GROUP *group,
- EC_POINT *r, EC_POINT *s,
- EC_POINT *p, BN_CTX *ctx);
- int (*ladder_post)(const EC_GROUP *group,
- EC_POINT *r, EC_POINT *s,
- EC_POINT *p, BN_CTX *ctx);
-};
-
-/*
- * Types and functions to manipulate pre-computed values.
- */
-typedef struct nistp224_pre_comp_st NISTP224_PRE_COMP;
-typedef struct nistp256_pre_comp_st NISTP256_PRE_COMP;
-typedef struct nistp521_pre_comp_st NISTP521_PRE_COMP;
-typedef struct nistz256_pre_comp_st NISTZ256_PRE_COMP;
-typedef struct ec_pre_comp_st EC_PRE_COMP;
-
-struct ec_group_st {
- const EC_METHOD *meth;
- EC_POINT *generator; /* optional */
- BIGNUM *order, *cofactor;
- int curve_name; /* optional NID for named curve */
- int asn1_flag; /* flag to control the asn1 encoding */
- point_conversion_form_t asn1_form;
- unsigned char *seed; /* optional seed for parameters (appears in
- * ASN1) */
- size_t seed_len;
- /*
- * The following members are handled by the method functions, even if
- * they appear generic
- */
- /*
- * Field specification. For curves over GF(p), this is the modulus; for
- * curves over GF(2^m), this is the irreducible polynomial defining the
- * field.
- */
- BIGNUM *field;
- /*
- * Field specification for curves over GF(2^m). The irreducible f(t) is
- * then of the form: t^poly[0] + t^poly[1] + ... + t^poly[k] where m =
- * poly[0] > poly[1] > ... > poly[k] = 0. The array is terminated with
- * poly[k+1]=-1. All elliptic curve irreducibles have at most 5 non-zero
- * terms.
- */
- int poly[6];
- /*
- * Curve coefficients. (Here the assumption is that BIGNUMs can be used
- * or abused for all kinds of fields, not just GF(p).) For characteristic
- * > 3, the curve is defined by a Weierstrass equation of the form y^2 =
- * x^3 + a*x + b. For characteristic 2, the curve is defined by an
- * equation of the form y^2 + x*y = x^3 + a*x^2 + b.
- */
- BIGNUM *a, *b;
- /* enable optimized point arithmetics for special case */
- int a_is_minus3;
- /* method-specific (e.g., Montgomery structure) */
- void *field_data1;
- /* method-specific */
- void *field_data2;
- /* method-specific */
- int (*field_mod_func) (BIGNUM *, const BIGNUM *, const BIGNUM *,
- BN_CTX *);
- /* data for ECDSA inverse */
- BN_MONT_CTX *mont_data;
-
- /*
- * Precomputed values for speed. The PCT_xxx names match the
- * pre_comp.xxx union names; see the SETPRECOMP and HAVEPRECOMP
- * macros, below.
- */
- enum {
- PCT_none,
- PCT_nistp224, PCT_nistp256, PCT_nistp521, PCT_nistz256,
- PCT_ec
- } pre_comp_type;
- union {
- NISTP224_PRE_COMP *nistp224;
- NISTP256_PRE_COMP *nistp256;
- NISTP521_PRE_COMP *nistp521;
- NISTZ256_PRE_COMP *nistz256;
- EC_PRE_COMP *ec;
- } pre_comp;
-
- OPENSSL_CTX *libctx;
-};
-
-#define SETPRECOMP(g, type, pre) \
- g->pre_comp_type = PCT_##type, g->pre_comp.type = pre
-#define HAVEPRECOMP(g, type) \
- g->pre_comp_type == PCT_##type && g->pre_comp.type != NULL
-
-struct ec_key_st {
- const EC_KEY_METHOD *meth;
- ENGINE *engine;
- int version;
- EC_GROUP *group;
- EC_POINT *pub_key;
- BIGNUM *priv_key;
- unsigned int enc_flag;
- point_conversion_form_t conv_form;
- CRYPTO_REF_COUNT references;
- int flags;
-#ifndef FIPS_MODE
- CRYPTO_EX_DATA ex_data;
-#endif
- CRYPTO_RWLOCK *lock;
- OPENSSL_CTX *libctx;
-};
-
-struct ec_point_st {
- const EC_METHOD *meth;
- /* NID for the curve if known */
- int curve_name;
- /*
- * All members except 'meth' are handled by the method functions, even if
- * they appear generic
- */
- BIGNUM *X;
- BIGNUM *Y;
- BIGNUM *Z; /* Jacobian projective coordinates: * (X, Y,
- * Z) represents (X/Z^2, Y/Z^3) if Z != 0 */
- int Z_is_one; /* enable optimized point arithmetics for
- * special case */
-};
-
-static ossl_inline int ec_point_is_compat(const EC_POINT *point,
- const EC_GROUP *group)
-{
- return group->meth == point->meth
- && (group->curve_name == 0
- || point->curve_name == 0
- || group->curve_name == point->curve_name);
-}
-
-NISTP224_PRE_COMP *EC_nistp224_pre_comp_dup(NISTP224_PRE_COMP *);
-NISTP256_PRE_COMP *EC_nistp256_pre_comp_dup(NISTP256_PRE_COMP *);
-NISTP521_PRE_COMP *EC_nistp521_pre_comp_dup(NISTP521_PRE_COMP *);
-NISTZ256_PRE_COMP *EC_nistz256_pre_comp_dup(NISTZ256_PRE_COMP *);
-NISTP256_PRE_COMP *EC_nistp256_pre_comp_dup(NISTP256_PRE_COMP *);
-EC_PRE_COMP *EC_ec_pre_comp_dup(EC_PRE_COMP *);
-
-void EC_pre_comp_free(EC_GROUP *group);
-void EC_nistp224_pre_comp_free(NISTP224_PRE_COMP *);
-void EC_nistp256_pre_comp_free(NISTP256_PRE_COMP *);
-void EC_nistp521_pre_comp_free(NISTP521_PRE_COMP *);
-void EC_nistz256_pre_comp_free(NISTZ256_PRE_COMP *);
-void EC_ec_pre_comp_free(EC_PRE_COMP *);
-
-/*
- * method functions in ec_mult.c (ec_lib.c uses these as defaults if
- * group->method->mul is 0)
- */
-int ec_wNAF_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar,
- size_t num, const EC_POINT *points[], const BIGNUM *scalars[],
- BN_CTX *);
-int ec_wNAF_precompute_mult(EC_GROUP *group, BN_CTX *);
-int ec_wNAF_have_precompute_mult(const EC_GROUP *group);
-
-/* method functions in ecp_smpl.c */
-int ec_GFp_simple_group_init(EC_GROUP *);
-void ec_GFp_simple_group_finish(EC_GROUP *);
-void ec_GFp_simple_group_clear_finish(EC_GROUP *);
-int ec_GFp_simple_group_copy(EC_GROUP *, const EC_GROUP *);
-int ec_GFp_simple_group_set_curve(EC_GROUP *, const BIGNUM *p,
- const BIGNUM *a, const BIGNUM *b, BN_CTX *);
-int ec_GFp_simple_group_get_curve(const EC_GROUP *, BIGNUM *p, BIGNUM *a,
- BIGNUM *b, BN_CTX *);
-int ec_GFp_simple_group_get_degree(const EC_GROUP *);
-int ec_GFp_simple_group_check_discriminant(const EC_GROUP *, BN_CTX *);
-int ec_GFp_simple_point_init(EC_POINT *);
-void ec_GFp_simple_point_finish(EC_POINT *);
-void ec_GFp_simple_point_clear_finish(EC_POINT *);
-int ec_GFp_simple_point_copy(EC_POINT *, const EC_POINT *);
-int ec_GFp_simple_point_set_to_infinity(const EC_GROUP *, EC_POINT *);
-int ec_GFp_simple_set_Jprojective_coordinates_GFp(const EC_GROUP *,
- EC_POINT *, const BIGNUM *x,
- const BIGNUM *y,
- const BIGNUM *z, BN_CTX *);
-int ec_GFp_simple_get_Jprojective_coordinates_GFp(const EC_GROUP *,
- const EC_POINT *, BIGNUM *x,
- BIGNUM *y, BIGNUM *z,
- BN_CTX *);
-int ec_GFp_simple_point_set_affine_coordinates(const EC_GROUP *, EC_POINT *,
- const BIGNUM *x,
- const BIGNUM *y, BN_CTX *);
-int ec_GFp_simple_point_get_affine_coordinates(const EC_GROUP *,
- const EC_POINT *, BIGNUM *x,
- BIGNUM *y, BN_CTX *);
-int ec_GFp_simple_set_compressed_coordinates(const EC_GROUP *, EC_POINT *,
- const BIGNUM *x, int y_bit,
- BN_CTX *);
-size_t ec_GFp_simple_point2oct(const EC_GROUP *, const EC_POINT *,
- point_conversion_form_t form,
- unsigned char *buf, size_t len, BN_CTX *);
-int ec_GFp_simple_oct2point(const EC_GROUP *, EC_POINT *,
- const unsigned char *buf, size_t len, BN_CTX *);
-int ec_GFp_simple_add(const EC_GROUP *, EC_POINT *r, const EC_POINT *a,
- const EC_POINT *b, BN_CTX *);
-int ec_GFp_simple_dbl(const EC_GROUP *, EC_POINT *r, const EC_POINT *a,
- BN_CTX *);
-int ec_GFp_simple_invert(const EC_GROUP *, EC_POINT *, BN_CTX *);
-int ec_GFp_simple_is_at_infinity(const EC_GROUP *, const EC_POINT *);
-int ec_GFp_simple_is_on_curve(const EC_GROUP *, const EC_POINT *, BN_CTX *);
-int ec_GFp_simple_cmp(const EC_GROUP *, const EC_POINT *a, const EC_POINT *b,
- BN_CTX *);
-int ec_GFp_simple_make_affine(const EC_GROUP *, EC_POINT *, BN_CTX *);
-int ec_GFp_simple_points_make_affine(const EC_GROUP *, size_t num,
- EC_POINT *[], BN_CTX *);
-int ec_GFp_simple_field_mul(const EC_GROUP *, BIGNUM *r, const BIGNUM *a,
- const BIGNUM *b, BN_CTX *);
-int ec_GFp_simple_field_sqr(const EC_GROUP *, BIGNUM *r, const BIGNUM *a,
- BN_CTX *);
-int ec_GFp_simple_field_inv(const EC_GROUP *, BIGNUM *r, const BIGNUM *a,
- BN_CTX *);
-int ec_GFp_simple_blind_coordinates(const EC_GROUP *group, EC_POINT *p,
- BN_CTX *ctx);
-int ec_GFp_simple_ladder_pre(const EC_GROUP *group,
- EC_POINT *r, EC_POINT *s,
- EC_POINT *p, BN_CTX *ctx);
-int ec_GFp_simple_ladder_step(const EC_GROUP *group,
- EC_POINT *r, EC_POINT *s,
- EC_POINT *p, BN_CTX *ctx);
-int ec_GFp_simple_ladder_post(const EC_GROUP *group,
- EC_POINT *r, EC_POINT *s,
- EC_POINT *p, BN_CTX *ctx);
-
-/* method functions in ecp_mont.c */
-int ec_GFp_mont_group_init(EC_GROUP *);
-int ec_GFp_mont_group_set_curve(EC_GROUP *, const BIGNUM *p, const BIGNUM *a,
- const BIGNUM *b, BN_CTX *);
-void ec_GFp_mont_group_finish(EC_GROUP *);
-void ec_GFp_mont_group_clear_finish(EC_GROUP *);
-int ec_GFp_mont_group_copy(EC_GROUP *, const EC_GROUP *);
-int ec_GFp_mont_field_mul(const EC_GROUP *, BIGNUM *r, const BIGNUM *a,
- const BIGNUM *b, BN_CTX *);
-int ec_GFp_mont_field_sqr(const EC_GROUP *, BIGNUM *r, const BIGNUM *a,
- BN_CTX *);
-int ec_GFp_mont_field_inv(const EC_GROUP *, BIGNUM *r, const BIGNUM *a,
- BN_CTX *);
-int ec_GFp_mont_field_encode(const EC_GROUP *, BIGNUM *r, const BIGNUM *a,
- BN_CTX *);
-int ec_GFp_mont_field_decode(const EC_GROUP *, BIGNUM *r, const BIGNUM *a,
- BN_CTX *);
-int ec_GFp_mont_field_set_to_one(const EC_GROUP *, BIGNUM *r, BN_CTX *);
-
-/* method functions in ecp_nist.c */
-int ec_GFp_nist_group_copy(EC_GROUP *dest, const EC_GROUP *src);
-int ec_GFp_nist_group_set_curve(EC_GROUP *, const BIGNUM *p, const BIGNUM *a,
- const BIGNUM *b, BN_CTX *);
-int ec_GFp_nist_field_mul(const EC_GROUP *, BIGNUM *r, const BIGNUM *a,
- const BIGNUM *b, BN_CTX *);
-int ec_GFp_nist_field_sqr(const EC_GROUP *, BIGNUM *r, const BIGNUM *a,
- BN_CTX *);
-
-/* method functions in ec2_smpl.c */
-int ec_GF2m_simple_group_init(EC_GROUP *);
-void ec_GF2m_simple_group_finish(EC_GROUP *);
-void ec_GF2m_simple_group_clear_finish(EC_GROUP *);
-int ec_GF2m_simple_group_copy(EC_GROUP *, const EC_GROUP *);
-int ec_GF2m_simple_group_set_curve(EC_GROUP *, const BIGNUM *p,
- const BIGNUM *a, const BIGNUM *b,
- BN_CTX *);
-int ec_GF2m_simple_group_get_curve(const EC_GROUP *, BIGNUM *p, BIGNUM *a,
- BIGNUM *b, BN_CTX *);
-int ec_GF2m_simple_group_get_degree(const EC_GROUP *);
-int ec_GF2m_simple_group_check_discriminant(const EC_GROUP *, BN_CTX *);
-int ec_GF2m_simple_point_init(EC_POINT *);
-void ec_GF2m_simple_point_finish(EC_POINT *);
-void ec_GF2m_simple_point_clear_finish(EC_POINT *);
-int ec_GF2m_simple_point_copy(EC_POINT *, const EC_POINT *);
-int ec_GF2m_simple_point_set_to_infinity(const EC_GROUP *, EC_POINT *);
-int ec_GF2m_simple_point_set_affine_coordinates(const EC_GROUP *, EC_POINT *,
- const BIGNUM *x,
- const BIGNUM *y, BN_CTX *);
-int ec_GF2m_simple_point_get_affine_coordinates(const EC_GROUP *,
- const EC_POINT *, BIGNUM *x,
- BIGNUM *y, BN_CTX *);
-int ec_GF2m_simple_set_compressed_coordinates(const EC_GROUP *, EC_POINT *,
- const BIGNUM *x, int y_bit,
- BN_CTX *);
-size_t ec_GF2m_simple_point2oct(const EC_GROUP *, const EC_POINT *,
- point_conversion_form_t form,
- unsigned char *buf, size_t len, BN_CTX *);
-int ec_GF2m_simple_oct2point(const EC_GROUP *, EC_POINT *,
- const unsigned char *buf, size_t len, BN_CTX *);
-int ec_GF2m_simple_add(const EC_GROUP *, EC_POINT *r, const EC_POINT *a,
- const EC_POINT *b, BN_CTX *);
-int ec_GF2m_simple_dbl(const EC_GROUP *, EC_POINT *r, const EC_POINT *a,
- BN_CTX *);
-int ec_GF2m_simple_invert(const EC_GROUP *, EC_POINT *, BN_CTX *);
-int ec_GF2m_simple_is_at_infinity(const EC_GROUP *, const EC_POINT *);
-int ec_GF2m_simple_is_on_curve(const EC_GROUP *, const EC_POINT *, BN_CTX *);
-int ec_GF2m_simple_cmp(const EC_GROUP *, const EC_POINT *a, const EC_POINT *b,
- BN_CTX *);
-int ec_GF2m_simple_make_affine(const EC_GROUP *, EC_POINT *, BN_CTX *);
-int ec_GF2m_simple_points_make_affine(const EC_GROUP *, size_t num,
- EC_POINT *[], BN_CTX *);
-int ec_GF2m_simple_field_mul(const EC_GROUP *, BIGNUM *r, const BIGNUM *a,
- const BIGNUM *b, BN_CTX *);
-int ec_GF2m_simple_field_sqr(const EC_GROUP *, BIGNUM *r, const BIGNUM *a,
- BN_CTX *);
-int ec_GF2m_simple_field_div(const EC_GROUP *, BIGNUM *r, const BIGNUM *a,
- const BIGNUM *b, BN_CTX *);
-
-#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128
-/* method functions in ecp_nistp224.c */
-int ec_GFp_nistp224_group_init(EC_GROUP *group);
-int ec_GFp_nistp224_group_set_curve(EC_GROUP *group, const BIGNUM *p,
- const BIGNUM *a, const BIGNUM *n,
- BN_CTX *);
-int ec_GFp_nistp224_point_get_affine_coordinates(const EC_GROUP *group,
- const EC_POINT *point,
- BIGNUM *x, BIGNUM *y,
- BN_CTX *ctx);
-int ec_GFp_nistp224_mul(const EC_GROUP *group, EC_POINT *r,
- const BIGNUM *scalar, size_t num,
- const EC_POINT *points[], const BIGNUM *scalars[],
- BN_CTX *);
-int ec_GFp_nistp224_points_mul(const EC_GROUP *group, EC_POINT *r,
- const BIGNUM *scalar, size_t num,
- const EC_POINT *points[],
- const BIGNUM *scalars[], BN_CTX *ctx);
-int ec_GFp_nistp224_precompute_mult(EC_GROUP *group, BN_CTX *ctx);
-int ec_GFp_nistp224_have_precompute_mult(const EC_GROUP *group);
-
-/* method functions in ecp_nistp256.c */
-int ec_GFp_nistp256_group_init(EC_GROUP *group);
-int ec_GFp_nistp256_group_set_curve(EC_GROUP *group, const BIGNUM *p,
- const BIGNUM *a, const BIGNUM *n,
- BN_CTX *);
-int ec_GFp_nistp256_point_get_affine_coordinates(const EC_GROUP *group,
- const EC_POINT *point,
- BIGNUM *x, BIGNUM *y,
- BN_CTX *ctx);
-int ec_GFp_nistp256_mul(const EC_GROUP *group, EC_POINT *r,
- const BIGNUM *scalar, size_t num,
- const EC_POINT *points[], const BIGNUM *scalars[],
- BN_CTX *);
-int ec_GFp_nistp256_points_mul(const EC_GROUP *group, EC_POINT *r,
- const BIGNUM *scalar, size_t num,
- const EC_POINT *points[],
- const BIGNUM *scalars[], BN_CTX *ctx);
-int ec_GFp_nistp256_precompute_mult(EC_GROUP *group, BN_CTX *ctx);
-int ec_GFp_nistp256_have_precompute_mult(const EC_GROUP *group);
-
-/* method functions in ecp_nistp521.c */
-int ec_GFp_nistp521_group_init(EC_GROUP *group);
-int ec_GFp_nistp521_group_set_curve(EC_GROUP *group, const BIGNUM *p,
- const BIGNUM *a, const BIGNUM *n,
- BN_CTX *);
-int ec_GFp_nistp521_point_get_affine_coordinates(const EC_GROUP *group,
- const EC_POINT *point,
- BIGNUM *x, BIGNUM *y,
- BN_CTX *ctx);
-int ec_GFp_nistp521_mul(const EC_GROUP *group, EC_POINT *r,
- const BIGNUM *scalar, size_t num,
- const EC_POINT *points[], const BIGNUM *scalars[],
- BN_CTX *);
-int ec_GFp_nistp521_points_mul(const EC_GROUP *group, EC_POINT *r,
- const BIGNUM *scalar, size_t num,
- const EC_POINT *points[],
- const BIGNUM *scalars[], BN_CTX *ctx);
-int ec_GFp_nistp521_precompute_mult(EC_GROUP *group, BN_CTX *ctx);
-int ec_GFp_nistp521_have_precompute_mult(const EC_GROUP *group);
-
-/* utility functions in ecp_nistputil.c */
-void ec_GFp_nistp_points_make_affine_internal(size_t num, void *point_array,
- size_t felem_size,
- void *tmp_felems,
- void (*felem_one) (void *out),
- int (*felem_is_zero) (const void
- *in),
- void (*felem_assign) (void *out,
- const void
- *in),
- void (*felem_square) (void *out,
- const void
- *in),
- void (*felem_mul) (void *out,
- const void
- *in1,
- const void
- *in2),
- void (*felem_inv) (void *out,
- const void
- *in),
- void (*felem_contract) (void
- *out,
- const
- void
- *in));
-void ec_GFp_nistp_recode_scalar_bits(unsigned char *sign,
- unsigned char *digit, unsigned char in);
-#endif
-int ec_group_simple_order_bits(const EC_GROUP *group);
-
-#ifdef ECP_NISTZ256_ASM
-/** Returns GFp methods using montgomery multiplication, with x86-64 optimized
- * P256. See http://eprint.iacr.org/2013/816.
- * \return EC_METHOD object
- */
-const EC_METHOD *EC_GFp_nistz256_method(void);
-#endif
-#ifdef S390X_EC_ASM
-const EC_METHOD *EC_GFp_s390x_nistp256_method(void);
-const EC_METHOD *EC_GFp_s390x_nistp384_method(void);
-const EC_METHOD *EC_GFp_s390x_nistp521_method(void);
-#endif
-
-size_t ec_key_simple_priv2oct(const EC_KEY *eckey,
- unsigned char *buf, size_t len);
-int ec_key_simple_oct2priv(EC_KEY *eckey, const unsigned char *buf, size_t len);
-int ec_key_simple_generate_key(EC_KEY *eckey);
-int ec_key_simple_generate_public_key(EC_KEY *eckey);
-int ec_key_simple_check_key(const EC_KEY *eckey);
-
-int ec_curve_nid_from_params(const EC_GROUP *group, BN_CTX *ctx);
-
-/* EC_METHOD definitions */
-
-struct ec_key_method_st {
- const char *name;
- int32_t flags;
- int (*init)(EC_KEY *key);
- void (*finish)(EC_KEY *key);
- int (*copy)(EC_KEY *dest, const EC_KEY *src);
- int (*set_group)(EC_KEY *key, const EC_GROUP *grp);
- int (*set_private)(EC_KEY *key, const BIGNUM *priv_key);
- int (*set_public)(EC_KEY *key, const EC_POINT *pub_key);
- int (*keygen)(EC_KEY *key);
- int (*compute_key)(unsigned char **pout, size_t *poutlen,
- const EC_POINT *pub_key, const EC_KEY *ecdh);
- int (*sign)(int type, const unsigned char *dgst, int dlen, unsigned char
- *sig, unsigned int *siglen, const BIGNUM *kinv,
- const BIGNUM *r, EC_KEY *eckey);
- int (*sign_setup)(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp,
- BIGNUM **rp);
- ECDSA_SIG *(*sign_sig)(const unsigned char *dgst, int dgst_len,
- const BIGNUM *in_kinv, const BIGNUM *in_r,
- EC_KEY *eckey);
-
- int (*verify)(int type, const unsigned char *dgst, int dgst_len,
- const unsigned char *sigbuf, int sig_len, EC_KEY *eckey);
- int (*verify_sig)(const unsigned char *dgst, int dgst_len,
- const ECDSA_SIG *sig, EC_KEY *eckey);
-};
-
-#define EC_KEY_METHOD_DYNAMIC 1
-
-EC_KEY *ec_key_new_method_int(OPENSSL_CTX *libctx, ENGINE *engine);
-
-int ossl_ec_key_gen(EC_KEY *eckey);
-int ossl_ecdh_compute_key(unsigned char **pout, size_t *poutlen,
- const EC_POINT *pub_key, const EC_KEY *ecdh);
-int ecdh_simple_compute_key(unsigned char **pout, size_t *poutlen,
- const EC_POINT *pub_key, const EC_KEY *ecdh);
-
-struct ECDSA_SIG_st {
- BIGNUM *r;
- BIGNUM *s;
-};
-
-int ossl_ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp,
- BIGNUM **rp);
-int ossl_ecdsa_sign(int type, const unsigned char *dgst, int dlen,
- unsigned char *sig, unsigned int *siglen,
- const BIGNUM *kinv, const BIGNUM *r, EC_KEY *eckey);
-ECDSA_SIG *ossl_ecdsa_sign_sig(const unsigned char *dgst, int dgst_len,
- const BIGNUM *in_kinv, const BIGNUM *in_r,
- EC_KEY *eckey);
-int ossl_ecdsa_verify(int type, const unsigned char *dgst, int dgst_len,
- const unsigned char *sigbuf, int sig_len, EC_KEY *eckey);
-int ossl_ecdsa_verify_sig(const unsigned char *dgst, int dgst_len,
- const ECDSA_SIG *sig, EC_KEY *eckey);
-int ecdsa_simple_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp,
- BIGNUM **rp);
-ECDSA_SIG *ecdsa_simple_sign_sig(const unsigned char *dgst, int dgst_len,
- const BIGNUM *in_kinv, const BIGNUM *in_r,
- EC_KEY *eckey);
-int ecdsa_simple_verify_sig(const unsigned char *dgst, int dgst_len,
- const ECDSA_SIG *sig, EC_KEY *eckey);
-
-int ED25519_sign(uint8_t *out_sig, const uint8_t *message, size_t message_len,
- const uint8_t public_key[32], const uint8_t private_key[32]);
-int ED25519_verify(const uint8_t *message, size_t message_len,
- const uint8_t signature[64], const uint8_t public_key[32]);
-void ED25519_public_from_private(uint8_t out_public_key[32],
- const uint8_t private_key[32]);
-
-int X25519(uint8_t out_shared_key[32], const uint8_t private_key[32],
- const uint8_t peer_public_value[32]);
-void X25519_public_from_private(uint8_t out_public_value[32],
- const uint8_t private_key[32]);
-
-/*-
- * This functions computes a single point multiplication over the EC group,
- * using, at a high level, a Montgomery ladder with conditional swaps, with
- * various timing attack defenses.
- *
- * It performs either a fixed point multiplication
- * (scalar * generator)
- * when point is NULL, or a variable point multiplication
- * (scalar * point)
- * when point is not NULL.
- *
- * `scalar` cannot be NULL and should be in the range [0,n) otherwise all
- * constant time bets are off (where n is the cardinality of the EC group).
- *
- * This function expects `group->order` and `group->cardinality` to be well
- * defined and non-zero: it fails with an error code otherwise.
- *
- * NB: This says nothing about the constant-timeness of the ladder step
- * implementation (i.e., the default implementation is based on EC_POINT_add and
- * EC_POINT_dbl, which of course are not constant time themselves) or the
- * underlying multiprecision arithmetic.
- *
- * The product is stored in `r`.
- *
- * This is an internal function: callers are in charge of ensuring that the
- * input parameters `group`, `r`, `scalar` and `ctx` are not NULL.
- *
- * Returns 1 on success, 0 otherwise.
- */
-int ec_scalar_mul_ladder(const EC_GROUP *group, EC_POINT *r,
- const BIGNUM *scalar, const EC_POINT *point,
- BN_CTX *ctx);
-
-int ec_point_blind_coordinates(const EC_GROUP *group, EC_POINT *p, BN_CTX *ctx);
-
-static ossl_inline int ec_point_ladder_pre(const EC_GROUP *group,
- EC_POINT *r, EC_POINT *s,
- EC_POINT *p, BN_CTX *ctx)
-{
- if (group->meth->ladder_pre != NULL)
- return group->meth->ladder_pre(group, r, s, p, ctx);
-
- if (!EC_POINT_copy(s, p)
- || !EC_POINT_dbl(group, r, s, ctx))
- return 0;
-
- return 1;
-}
-
-static ossl_inline int ec_point_ladder_step(const EC_GROUP *group,
- EC_POINT *r, EC_POINT *s,
- EC_POINT *p, BN_CTX *ctx)
-{
- if (group->meth->ladder_step != NULL)
- return group->meth->ladder_step(group, r, s, p, ctx);
-
- if (!EC_POINT_add(group, s, r, s, ctx)
- || !EC_POINT_dbl(group, r, r, ctx))
- return 0;
-
- return 1;
-
-}
-
-static ossl_inline int ec_point_ladder_post(const EC_GROUP *group,
- EC_POINT *r, EC_POINT *s,
- EC_POINT *p, BN_CTX *ctx)
-{
- if (group->meth->ladder_post != NULL)
- return group->meth->ladder_post(group, r, s, p, ctx);
-
- return 1;
-}
#include <openssl/err.h>
#include <openssl/opensslv.h>
-#include "ec_lcl.h"
+#include "ec_local.h"
/* functions for EC_GROUP objects */
--- /dev/null
+/*
+ * Copyright 2001-2018 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+#include <stdlib.h>
+
+#include <openssl/obj_mac.h>
+#include <openssl/ec.h>
+#include <openssl/bn.h>
+#include "internal/refcount.h"
+#include "crypto/ec.h"
+
+#if defined(__SUNPRO_C)
+# if __SUNPRO_C >= 0x520
+# pragma error_messages (off,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE)
+# endif
+#endif
+
+/* Use default functions for poin2oct, oct2point and compressed coordinates */
+#define EC_FLAGS_DEFAULT_OCT 0x1
+
+/* Use custom formats for EC_GROUP, EC_POINT and EC_KEY */
+#define EC_FLAGS_CUSTOM_CURVE 0x2
+
+/* Curve does not support signing operations */
+#define EC_FLAGS_NO_SIGN 0x4
+
+/*
+ * Structure details are not part of the exported interface, so all this may
+ * change in future versions.
+ */
+
+struct ec_method_st {
+ /* Various method flags */
+ int flags;
+ /* used by EC_METHOD_get_field_type: */
+ int field_type; /* a NID */
+ /*
+ * used by EC_GROUP_new, EC_GROUP_free, EC_GROUP_clear_free,
+ * EC_GROUP_copy:
+ */
+ int (*group_init) (EC_GROUP *);
+ void (*group_finish) (EC_GROUP *);
+ void (*group_clear_finish) (EC_GROUP *);
+ int (*group_copy) (EC_GROUP *, const EC_GROUP *);
+ /* used by EC_GROUP_set_curve, EC_GROUP_get_curve: */
+ int (*group_set_curve) (EC_GROUP *, const BIGNUM *p, const BIGNUM *a,
+ const BIGNUM *b, BN_CTX *);
+ int (*group_get_curve) (const EC_GROUP *, BIGNUM *p, BIGNUM *a, BIGNUM *b,
+ BN_CTX *);
+ /* used by EC_GROUP_get_degree: */
+ int (*group_get_degree) (const EC_GROUP *);
+ int (*group_order_bits) (const EC_GROUP *);
+ /* used by EC_GROUP_check: */
+ int (*group_check_discriminant) (const EC_GROUP *, BN_CTX *);
+ /*
+ * used by EC_POINT_new, EC_POINT_free, EC_POINT_clear_free,
+ * EC_POINT_copy:
+ */
+ int (*point_init) (EC_POINT *);
+ void (*point_finish) (EC_POINT *);
+ void (*point_clear_finish) (EC_POINT *);
+ int (*point_copy) (EC_POINT *, const EC_POINT *);
+ /*-
+ * used by EC_POINT_set_to_infinity,
+ * EC_POINT_set_Jprojective_coordinates_GFp,
+ * EC_POINT_get_Jprojective_coordinates_GFp,
+ * EC_POINT_set_affine_coordinates,
+ * EC_POINT_get_affine_coordinates,
+ * EC_POINT_set_compressed_coordinates:
+ */
+ int (*point_set_to_infinity) (const EC_GROUP *, EC_POINT *);
+ int (*point_set_Jprojective_coordinates_GFp) (const EC_GROUP *,
+ EC_POINT *, const BIGNUM *x,
+ const BIGNUM *y,
+ const BIGNUM *z, BN_CTX *);
+ int (*point_get_Jprojective_coordinates_GFp) (const EC_GROUP *,
+ const EC_POINT *, BIGNUM *x,
+ BIGNUM *y, BIGNUM *z,
+ BN_CTX *);
+ int (*point_set_affine_coordinates) (const EC_GROUP *, EC_POINT *,
+ const BIGNUM *x, const BIGNUM *y,
+ BN_CTX *);
+ int (*point_get_affine_coordinates) (const EC_GROUP *, const EC_POINT *,
+ BIGNUM *x, BIGNUM *y, BN_CTX *);
+ int (*point_set_compressed_coordinates) (const EC_GROUP *, EC_POINT *,
+ const BIGNUM *x, int y_bit,
+ BN_CTX *);
+ /* used by EC_POINT_point2oct, EC_POINT_oct2point: */
+ size_t (*point2oct) (const EC_GROUP *, const EC_POINT *,
+ point_conversion_form_t form, unsigned char *buf,
+ size_t len, BN_CTX *);
+ int (*oct2point) (const EC_GROUP *, EC_POINT *, const unsigned char *buf,
+ size_t len, BN_CTX *);
+ /* used by EC_POINT_add, EC_POINT_dbl, ECP_POINT_invert: */
+ int (*add) (const EC_GROUP *, EC_POINT *r, const EC_POINT *a,
+ const EC_POINT *b, BN_CTX *);
+ int (*dbl) (const EC_GROUP *, EC_POINT *r, const EC_POINT *a, BN_CTX *);
+ int (*invert) (const EC_GROUP *, EC_POINT *, BN_CTX *);
+ /*
+ * used by EC_POINT_is_at_infinity, EC_POINT_is_on_curve, EC_POINT_cmp:
+ */
+ int (*is_at_infinity) (const EC_GROUP *, const EC_POINT *);
+ int (*is_on_curve) (const EC_GROUP *, const EC_POINT *, BN_CTX *);
+ int (*point_cmp) (const EC_GROUP *, const EC_POINT *a, const EC_POINT *b,
+ BN_CTX *);
+ /* used by EC_POINT_make_affine, EC_POINTs_make_affine: */
+ int (*make_affine) (const EC_GROUP *, EC_POINT *, BN_CTX *);
+ int (*points_make_affine) (const EC_GROUP *, size_t num, EC_POINT *[],
+ BN_CTX *);
+ /*
+ * used by EC_POINTs_mul, EC_POINT_mul, EC_POINT_precompute_mult,
+ * EC_POINT_have_precompute_mult (default implementations are used if the
+ * 'mul' pointer is 0):
+ */
+ /*-
+ * mul() calculates the value
+ *
+ * r := generator * scalar
+ * + points[0] * scalars[0]
+ * + ...
+ * + points[num-1] * scalars[num-1].
+ *
+ * For a fixed point multiplication (scalar != NULL, num == 0)
+ * or a variable point multiplication (scalar == NULL, num == 1),
+ * mul() must use a constant time algorithm: in both cases callers
+ * should provide an input scalar (either scalar or scalars[0])
+ * in the range [0, ec_group_order); for robustness, implementers
+ * should handle the case when the scalar has not been reduced, but
+ * may treat it as an unusual input, without any constant-timeness
+ * guarantee.
+ */
+ int (*mul) (const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar,
+ size_t num, const EC_POINT *points[], const BIGNUM *scalars[],
+ BN_CTX *);
+ int (*precompute_mult) (EC_GROUP *group, BN_CTX *);
+ int (*have_precompute_mult) (const EC_GROUP *group);
+ /* internal functions */
+ /*
+ * 'field_mul', 'field_sqr', and 'field_div' can be used by 'add' and
+ * 'dbl' so that the same implementations of point operations can be used
+ * with different optimized implementations of expensive field
+ * operations:
+ */
+ int (*field_mul) (const EC_GROUP *, BIGNUM *r, const BIGNUM *a,
+ const BIGNUM *b, BN_CTX *);
+ int (*field_sqr) (const EC_GROUP *, BIGNUM *r, const BIGNUM *a, BN_CTX *);
+ int (*field_div) (const EC_GROUP *, BIGNUM *r, const BIGNUM *a,
+ const BIGNUM *b, BN_CTX *);
+ /*-
+ * 'field_inv' computes the multiplicative inverse of a in the field,
+ * storing the result in r.
+ *
+ * If 'a' is zero (or equivalent), you'll get an EC_R_CANNOT_INVERT error.
+ */
+ int (*field_inv) (const EC_GROUP *, BIGNUM *r, const BIGNUM *a, BN_CTX *);
+ /* e.g. to Montgomery */
+ int (*field_encode) (const EC_GROUP *, BIGNUM *r, const BIGNUM *a,
+ BN_CTX *);
+ /* e.g. from Montgomery */
+ int (*field_decode) (const EC_GROUP *, BIGNUM *r, const BIGNUM *a,
+ BN_CTX *);
+ int (*field_set_to_one) (const EC_GROUP *, BIGNUM *r, BN_CTX *);
+ /* private key operations */
+ size_t (*priv2oct)(const EC_KEY *eckey, unsigned char *buf, size_t len);
+ int (*oct2priv)(EC_KEY *eckey, const unsigned char *buf, size_t len);
+ int (*set_private)(EC_KEY *eckey, const BIGNUM *priv_key);
+ int (*keygen)(EC_KEY *eckey);
+ int (*keycheck)(const EC_KEY *eckey);
+ int (*keygenpub)(EC_KEY *eckey);
+ int (*keycopy)(EC_KEY *dst, const EC_KEY *src);
+ void (*keyfinish)(EC_KEY *eckey);
+ /* custom ECDH operation */
+ int (*ecdh_compute_key)(unsigned char **pout, size_t *poutlen,
+ const EC_POINT *pub_key, const EC_KEY *ecdh);
+ /* custom ECDSA */
+ int (*ecdsa_sign_setup)(EC_KEY *eckey, BN_CTX *ctx, BIGNUM **kinvp,
+ BIGNUM **rp);
+ ECDSA_SIG *(*ecdsa_sign_sig)(const unsigned char *dgst, int dgstlen,
+ const BIGNUM *kinv, const BIGNUM *r,
+ EC_KEY *eckey);
+ int (*ecdsa_verify_sig)(const unsigned char *dgst, int dgstlen,
+ const ECDSA_SIG *sig, EC_KEY *eckey);
+ /* Inverse modulo order */
+ int (*field_inverse_mod_ord)(const EC_GROUP *, BIGNUM *r,
+ const BIGNUM *x, BN_CTX *);
+ int (*blind_coordinates)(const EC_GROUP *group, EC_POINT *p, BN_CTX *ctx);
+ int (*ladder_pre)(const EC_GROUP *group,
+ EC_POINT *r, EC_POINT *s,
+ EC_POINT *p, BN_CTX *ctx);
+ int (*ladder_step)(const EC_GROUP *group,
+ EC_POINT *r, EC_POINT *s,
+ EC_POINT *p, BN_CTX *ctx);
+ int (*ladder_post)(const EC_GROUP *group,
+ EC_POINT *r, EC_POINT *s,
+ EC_POINT *p, BN_CTX *ctx);
+};
+
+/*
+ * Types and functions to manipulate pre-computed values.
+ */
+typedef struct nistp224_pre_comp_st NISTP224_PRE_COMP;
+typedef struct nistp256_pre_comp_st NISTP256_PRE_COMP;
+typedef struct nistp521_pre_comp_st NISTP521_PRE_COMP;
+typedef struct nistz256_pre_comp_st NISTZ256_PRE_COMP;
+typedef struct ec_pre_comp_st EC_PRE_COMP;
+
+struct ec_group_st {
+ const EC_METHOD *meth;
+ EC_POINT *generator; /* optional */
+ BIGNUM *order, *cofactor;
+ int curve_name; /* optional NID for named curve */
+ int asn1_flag; /* flag to control the asn1 encoding */
+ point_conversion_form_t asn1_form;
+ unsigned char *seed; /* optional seed for parameters (appears in
+ * ASN1) */
+ size_t seed_len;
+ /*
+ * The following members are handled by the method functions, even if
+ * they appear generic
+ */
+ /*
+ * Field specification. For curves over GF(p), this is the modulus; for
+ * curves over GF(2^m), this is the irreducible polynomial defining the
+ * field.
+ */
+ BIGNUM *field;
+ /*
+ * Field specification for curves over GF(2^m). The irreducible f(t) is
+ * then of the form: t^poly[0] + t^poly[1] + ... + t^poly[k] where m =
+ * poly[0] > poly[1] > ... > poly[k] = 0. The array is terminated with
+ * poly[k+1]=-1. All elliptic curve irreducibles have at most 5 non-zero
+ * terms.
+ */
+ int poly[6];
+ /*
+ * Curve coefficients. (Here the assumption is that BIGNUMs can be used
+ * or abused for all kinds of fields, not just GF(p).) For characteristic
+ * > 3, the curve is defined by a Weierstrass equation of the form y^2 =
+ * x^3 + a*x + b. For characteristic 2, the curve is defined by an
+ * equation of the form y^2 + x*y = x^3 + a*x^2 + b.
+ */
+ BIGNUM *a, *b;
+ /* enable optimized point arithmetics for special case */
+ int a_is_minus3;
+ /* method-specific (e.g., Montgomery structure) */
+ void *field_data1;
+ /* method-specific */
+ void *field_data2;
+ /* method-specific */
+ int (*field_mod_func) (BIGNUM *, const BIGNUM *, const BIGNUM *,
+ BN_CTX *);
+ /* data for ECDSA inverse */
+ BN_MONT_CTX *mont_data;
+
+ /*
+ * Precomputed values for speed. The PCT_xxx names match the
+ * pre_comp.xxx union names; see the SETPRECOMP and HAVEPRECOMP
+ * macros, below.
+ */
+ enum {
+ PCT_none,
+ PCT_nistp224, PCT_nistp256, PCT_nistp521, PCT_nistz256,
+ PCT_ec
+ } pre_comp_type;
+ union {
+ NISTP224_PRE_COMP *nistp224;
+ NISTP256_PRE_COMP *nistp256;
+ NISTP521_PRE_COMP *nistp521;
+ NISTZ256_PRE_COMP *nistz256;
+ EC_PRE_COMP *ec;
+ } pre_comp;
+
+ OPENSSL_CTX *libctx;
+};
+
+#define SETPRECOMP(g, type, pre) \
+ g->pre_comp_type = PCT_##type, g->pre_comp.type = pre
+#define HAVEPRECOMP(g, type) \
+ g->pre_comp_type == PCT_##type && g->pre_comp.type != NULL
+
+struct ec_key_st {
+ const EC_KEY_METHOD *meth;
+ ENGINE *engine;
+ int version;
+ EC_GROUP *group;
+ EC_POINT *pub_key;
+ BIGNUM *priv_key;
+ unsigned int enc_flag;
+ point_conversion_form_t conv_form;
+ CRYPTO_REF_COUNT references;
+ int flags;
+#ifndef FIPS_MODE
+ CRYPTO_EX_DATA ex_data;
+#endif
+ CRYPTO_RWLOCK *lock;
+ OPENSSL_CTX *libctx;
+};
+
+struct ec_point_st {
+ const EC_METHOD *meth;
+ /* NID for the curve if known */
+ int curve_name;
+ /*
+ * All members except 'meth' are handled by the method functions, even if
+ * they appear generic
+ */
+ BIGNUM *X;
+ BIGNUM *Y;
+ BIGNUM *Z; /* Jacobian projective coordinates: * (X, Y,
+ * Z) represents (X/Z^2, Y/Z^3) if Z != 0 */
+ int Z_is_one; /* enable optimized point arithmetics for
+ * special case */
+};
+
+static ossl_inline int ec_point_is_compat(const EC_POINT *point,
+ const EC_GROUP *group)
+{
+ return group->meth == point->meth
+ && (group->curve_name == 0
+ || point->curve_name == 0
+ || group->curve_name == point->curve_name);
+}
+
+NISTP224_PRE_COMP *EC_nistp224_pre_comp_dup(NISTP224_PRE_COMP *);
+NISTP256_PRE_COMP *EC_nistp256_pre_comp_dup(NISTP256_PRE_COMP *);
+NISTP521_PRE_COMP *EC_nistp521_pre_comp_dup(NISTP521_PRE_COMP *);
+NISTZ256_PRE_COMP *EC_nistz256_pre_comp_dup(NISTZ256_PRE_COMP *);
+NISTP256_PRE_COMP *EC_nistp256_pre_comp_dup(NISTP256_PRE_COMP *);
+EC_PRE_COMP *EC_ec_pre_comp_dup(EC_PRE_COMP *);
+
+void EC_pre_comp_free(EC_GROUP *group);
+void EC_nistp224_pre_comp_free(NISTP224_PRE_COMP *);
+void EC_nistp256_pre_comp_free(NISTP256_PRE_COMP *);
+void EC_nistp521_pre_comp_free(NISTP521_PRE_COMP *);
+void EC_nistz256_pre_comp_free(NISTZ256_PRE_COMP *);
+void EC_ec_pre_comp_free(EC_PRE_COMP *);
+
+/*
+ * method functions in ec_mult.c (ec_lib.c uses these as defaults if
+ * group->method->mul is 0)
+ */
+int ec_wNAF_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar,
+ size_t num, const EC_POINT *points[], const BIGNUM *scalars[],
+ BN_CTX *);
+int ec_wNAF_precompute_mult(EC_GROUP *group, BN_CTX *);
+int ec_wNAF_have_precompute_mult(const EC_GROUP *group);
+
+/* method functions in ecp_smpl.c */
+int ec_GFp_simple_group_init(EC_GROUP *);
+void ec_GFp_simple_group_finish(EC_GROUP *);
+void ec_GFp_simple_group_clear_finish(EC_GROUP *);
+int ec_GFp_simple_group_copy(EC_GROUP *, const EC_GROUP *);
+int ec_GFp_simple_group_set_curve(EC_GROUP *, const BIGNUM *p,
+ const BIGNUM *a, const BIGNUM *b, BN_CTX *);
+int ec_GFp_simple_group_get_curve(const EC_GROUP *, BIGNUM *p, BIGNUM *a,
+ BIGNUM *b, BN_CTX *);
+int ec_GFp_simple_group_get_degree(const EC_GROUP *);
+int ec_GFp_simple_group_check_discriminant(const EC_GROUP *, BN_CTX *);
+int ec_GFp_simple_point_init(EC_POINT *);
+void ec_GFp_simple_point_finish(EC_POINT *);
+void ec_GFp_simple_point_clear_finish(EC_POINT *);
+int ec_GFp_simple_point_copy(EC_POINT *, const EC_POINT *);
+int ec_GFp_simple_point_set_to_infinity(const EC_GROUP *, EC_POINT *);
+int ec_GFp_simple_set_Jprojective_coordinates_GFp(const EC_GROUP *,
+ EC_POINT *, const BIGNUM *x,
+ const BIGNUM *y,
+ const BIGNUM *z, BN_CTX *);
+int ec_GFp_simple_get_Jprojective_coordinates_GFp(const EC_GROUP *,
+ const EC_POINT *, BIGNUM *x,
+ BIGNUM *y, BIGNUM *z,
+ BN_CTX *);
+int ec_GFp_simple_point_set_affine_coordinates(const EC_GROUP *, EC_POINT *,
+ const BIGNUM *x,
+ const BIGNUM *y, BN_CTX *);
+int ec_GFp_simple_point_get_affine_coordinates(const EC_GROUP *,
+ const EC_POINT *, BIGNUM *x,
+ BIGNUM *y, BN_CTX *);
+int ec_GFp_simple_set_compressed_coordinates(const EC_GROUP *, EC_POINT *,
+ const BIGNUM *x, int y_bit,
+ BN_CTX *);
+size_t ec_GFp_simple_point2oct(const EC_GROUP *, const EC_POINT *,
+ point_conversion_form_t form,
+ unsigned char *buf, size_t len, BN_CTX *);
+int ec_GFp_simple_oct2point(const EC_GROUP *, EC_POINT *,
+ const unsigned char *buf, size_t len, BN_CTX *);
+int ec_GFp_simple_add(const EC_GROUP *, EC_POINT *r, const EC_POINT *a,
+ const EC_POINT *b, BN_CTX *);
+int ec_GFp_simple_dbl(const EC_GROUP *, EC_POINT *r, const EC_POINT *a,
+ BN_CTX *);
+int ec_GFp_simple_invert(const EC_GROUP *, EC_POINT *, BN_CTX *);
+int ec_GFp_simple_is_at_infinity(const EC_GROUP *, const EC_POINT *);
+int ec_GFp_simple_is_on_curve(const EC_GROUP *, const EC_POINT *, BN_CTX *);
+int ec_GFp_simple_cmp(const EC_GROUP *, const EC_POINT *a, const EC_POINT *b,
+ BN_CTX *);
+int ec_GFp_simple_make_affine(const EC_GROUP *, EC_POINT *, BN_CTX *);
+int ec_GFp_simple_points_make_affine(const EC_GROUP *, size_t num,
+ EC_POINT *[], BN_CTX *);
+int ec_GFp_simple_field_mul(const EC_GROUP *, BIGNUM *r, const BIGNUM *a,
+ const BIGNUM *b, BN_CTX *);
+int ec_GFp_simple_field_sqr(const EC_GROUP *, BIGNUM *r, const BIGNUM *a,
+ BN_CTX *);
+int ec_GFp_simple_field_inv(const EC_GROUP *, BIGNUM *r, const BIGNUM *a,
+ BN_CTX *);
+int ec_GFp_simple_blind_coordinates(const EC_GROUP *group, EC_POINT *p,
+ BN_CTX *ctx);
+int ec_GFp_simple_ladder_pre(const EC_GROUP *group,
+ EC_POINT *r, EC_POINT *s,
+ EC_POINT *p, BN_CTX *ctx);
+int ec_GFp_simple_ladder_step(const EC_GROUP *group,
+ EC_POINT *r, EC_POINT *s,
+ EC_POINT *p, BN_CTX *ctx);
+int ec_GFp_simple_ladder_post(const EC_GROUP *group,
+ EC_POINT *r, EC_POINT *s,
+ EC_POINT *p, BN_CTX *ctx);
+
+/* method functions in ecp_mont.c */
+int ec_GFp_mont_group_init(EC_GROUP *);
+int ec_GFp_mont_group_set_curve(EC_GROUP *, const BIGNUM *p, const BIGNUM *a,
+ const BIGNUM *b, BN_CTX *);
+void ec_GFp_mont_group_finish(EC_GROUP *);
+void ec_GFp_mont_group_clear_finish(EC_GROUP *);
+int ec_GFp_mont_group_copy(EC_GROUP *, const EC_GROUP *);
+int ec_GFp_mont_field_mul(const EC_GROUP *, BIGNUM *r, const BIGNUM *a,
+ const BIGNUM *b, BN_CTX *);
+int ec_GFp_mont_field_sqr(const EC_GROUP *, BIGNUM *r, const BIGNUM *a,
+ BN_CTX *);
+int ec_GFp_mont_field_inv(const EC_GROUP *, BIGNUM *r, const BIGNUM *a,
+ BN_CTX *);
+int ec_GFp_mont_field_encode(const EC_GROUP *, BIGNUM *r, const BIGNUM *a,
+ BN_CTX *);
+int ec_GFp_mont_field_decode(const EC_GROUP *, BIGNUM *r, const BIGNUM *a,
+ BN_CTX *);
+int ec_GFp_mont_field_set_to_one(const EC_GROUP *, BIGNUM *r, BN_CTX *);
+
+/* method functions in ecp_nist.c */
+int ec_GFp_nist_group_copy(EC_GROUP *dest, const EC_GROUP *src);
+int ec_GFp_nist_group_set_curve(EC_GROUP *, const BIGNUM *p, const BIGNUM *a,
+ const BIGNUM *b, BN_CTX *);
+int ec_GFp_nist_field_mul(const EC_GROUP *, BIGNUM *r, const BIGNUM *a,
+ const BIGNUM *b, BN_CTX *);
+int ec_GFp_nist_field_sqr(const EC_GROUP *, BIGNUM *r, const BIGNUM *a,
+ BN_CTX *);
+
+/* method functions in ec2_smpl.c */
+int ec_GF2m_simple_group_init(EC_GROUP *);
+void ec_GF2m_simple_group_finish(EC_GROUP *);
+void ec_GF2m_simple_group_clear_finish(EC_GROUP *);
+int ec_GF2m_simple_group_copy(EC_GROUP *, const EC_GROUP *);
+int ec_GF2m_simple_group_set_curve(EC_GROUP *, const BIGNUM *p,
+ const BIGNUM *a, const BIGNUM *b,
+ BN_CTX *);
+int ec_GF2m_simple_group_get_curve(const EC_GROUP *, BIGNUM *p, BIGNUM *a,
+ BIGNUM *b, BN_CTX *);
+int ec_GF2m_simple_group_get_degree(const EC_GROUP *);
+int ec_GF2m_simple_group_check_discriminant(const EC_GROUP *, BN_CTX *);
+int ec_GF2m_simple_point_init(EC_POINT *);
+void ec_GF2m_simple_point_finish(EC_POINT *);
+void ec_GF2m_simple_point_clear_finish(EC_POINT *);
+int ec_GF2m_simple_point_copy(EC_POINT *, const EC_POINT *);
+int ec_GF2m_simple_point_set_to_infinity(const EC_GROUP *, EC_POINT *);
+int ec_GF2m_simple_point_set_affine_coordinates(const EC_GROUP *, EC_POINT *,
+ const BIGNUM *x,
+ const BIGNUM *y, BN_CTX *);
+int ec_GF2m_simple_point_get_affine_coordinates(const EC_GROUP *,
+ const EC_POINT *, BIGNUM *x,
+ BIGNUM *y, BN_CTX *);
+int ec_GF2m_simple_set_compressed_coordinates(const EC_GROUP *, EC_POINT *,
+ const BIGNUM *x, int y_bit,
+ BN_CTX *);
+size_t ec_GF2m_simple_point2oct(const EC_GROUP *, const EC_POINT *,
+ point_conversion_form_t form,
+ unsigned char *buf, size_t len, BN_CTX *);
+int ec_GF2m_simple_oct2point(const EC_GROUP *, EC_POINT *,
+ const unsigned char *buf, size_t len, BN_CTX *);
+int ec_GF2m_simple_add(const EC_GROUP *, EC_POINT *r, const EC_POINT *a,
+ const EC_POINT *b, BN_CTX *);
+int ec_GF2m_simple_dbl(const EC_GROUP *, EC_POINT *r, const EC_POINT *a,
+ BN_CTX *);
+int ec_GF2m_simple_invert(const EC_GROUP *, EC_POINT *, BN_CTX *);
+int ec_GF2m_simple_is_at_infinity(const EC_GROUP *, const EC_POINT *);
+int ec_GF2m_simple_is_on_curve(const EC_GROUP *, const EC_POINT *, BN_CTX *);
+int ec_GF2m_simple_cmp(const EC_GROUP *, const EC_POINT *a, const EC_POINT *b,
+ BN_CTX *);
+int ec_GF2m_simple_make_affine(const EC_GROUP *, EC_POINT *, BN_CTX *);
+int ec_GF2m_simple_points_make_affine(const EC_GROUP *, size_t num,
+ EC_POINT *[], BN_CTX *);
+int ec_GF2m_simple_field_mul(const EC_GROUP *, BIGNUM *r, const BIGNUM *a,
+ const BIGNUM *b, BN_CTX *);
+int ec_GF2m_simple_field_sqr(const EC_GROUP *, BIGNUM *r, const BIGNUM *a,
+ BN_CTX *);
+int ec_GF2m_simple_field_div(const EC_GROUP *, BIGNUM *r, const BIGNUM *a,
+ const BIGNUM *b, BN_CTX *);
+
+#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128
+/* method functions in ecp_nistp224.c */
+int ec_GFp_nistp224_group_init(EC_GROUP *group);
+int ec_GFp_nistp224_group_set_curve(EC_GROUP *group, const BIGNUM *p,
+ const BIGNUM *a, const BIGNUM *n,
+ BN_CTX *);
+int ec_GFp_nistp224_point_get_affine_coordinates(const EC_GROUP *group,
+ const EC_POINT *point,
+ BIGNUM *x, BIGNUM *y,
+ BN_CTX *ctx);
+int ec_GFp_nistp224_mul(const EC_GROUP *group, EC_POINT *r,
+ const BIGNUM *scalar, size_t num,
+ const EC_POINT *points[], const BIGNUM *scalars[],
+ BN_CTX *);
+int ec_GFp_nistp224_points_mul(const EC_GROUP *group, EC_POINT *r,
+ const BIGNUM *scalar, size_t num,
+ const EC_POINT *points[],
+ const BIGNUM *scalars[], BN_CTX *ctx);
+int ec_GFp_nistp224_precompute_mult(EC_GROUP *group, BN_CTX *ctx);
+int ec_GFp_nistp224_have_precompute_mult(const EC_GROUP *group);
+
+/* method functions in ecp_nistp256.c */
+int ec_GFp_nistp256_group_init(EC_GROUP *group);
+int ec_GFp_nistp256_group_set_curve(EC_GROUP *group, const BIGNUM *p,
+ const BIGNUM *a, const BIGNUM *n,
+ BN_CTX *);
+int ec_GFp_nistp256_point_get_affine_coordinates(const EC_GROUP *group,
+ const EC_POINT *point,
+ BIGNUM *x, BIGNUM *y,
+ BN_CTX *ctx);
+int ec_GFp_nistp256_mul(const EC_GROUP *group, EC_POINT *r,
+ const BIGNUM *scalar, size_t num,
+ const EC_POINT *points[], const BIGNUM *scalars[],
+ BN_CTX *);
+int ec_GFp_nistp256_points_mul(const EC_GROUP *group, EC_POINT *r,
+ const BIGNUM *scalar, size_t num,
+ const EC_POINT *points[],
+ const BIGNUM *scalars[], BN_CTX *ctx);
+int ec_GFp_nistp256_precompute_mult(EC_GROUP *group, BN_CTX *ctx);
+int ec_GFp_nistp256_have_precompute_mult(const EC_GROUP *group);
+
+/* method functions in ecp_nistp521.c */
+int ec_GFp_nistp521_group_init(EC_GROUP *group);
+int ec_GFp_nistp521_group_set_curve(EC_GROUP *group, const BIGNUM *p,
+ const BIGNUM *a, const BIGNUM *n,
+ BN_CTX *);
+int ec_GFp_nistp521_point_get_affine_coordinates(const EC_GROUP *group,
+ const EC_POINT *point,
+ BIGNUM *x, BIGNUM *y,
+ BN_CTX *ctx);
+int ec_GFp_nistp521_mul(const EC_GROUP *group, EC_POINT *r,
+ const BIGNUM *scalar, size_t num,
+ const EC_POINT *points[], const BIGNUM *scalars[],
+ BN_CTX *);
+int ec_GFp_nistp521_points_mul(const EC_GROUP *group, EC_POINT *r,
+ const BIGNUM *scalar, size_t num,
+ const EC_POINT *points[],
+ const BIGNUM *scalars[], BN_CTX *ctx);
+int ec_GFp_nistp521_precompute_mult(EC_GROUP *group, BN_CTX *ctx);
+int ec_GFp_nistp521_have_precompute_mult(const EC_GROUP *group);
+
+/* utility functions in ecp_nistputil.c */
+void ec_GFp_nistp_points_make_affine_internal(size_t num, void *point_array,
+ size_t felem_size,
+ void *tmp_felems,
+ void (*felem_one) (void *out),
+ int (*felem_is_zero) (const void
+ *in),
+ void (*felem_assign) (void *out,
+ const void
+ *in),
+ void (*felem_square) (void *out,
+ const void
+ *in),
+ void (*felem_mul) (void *out,
+ const void
+ *in1,
+ const void
+ *in2),
+ void (*felem_inv) (void *out,
+ const void
+ *in),
+ void (*felem_contract) (void
+ *out,
+ const
+ void
+ *in));
+void ec_GFp_nistp_recode_scalar_bits(unsigned char *sign,
+ unsigned char *digit, unsigned char in);
+#endif
+int ec_group_simple_order_bits(const EC_GROUP *group);
+
+#ifdef ECP_NISTZ256_ASM
+/** Returns GFp methods using montgomery multiplication, with x86-64 optimized
+ * P256. See http://eprint.iacr.org/2013/816.
+ * \return EC_METHOD object
+ */
+const EC_METHOD *EC_GFp_nistz256_method(void);
+#endif
+#ifdef S390X_EC_ASM
+const EC_METHOD *EC_GFp_s390x_nistp256_method(void);
+const EC_METHOD *EC_GFp_s390x_nistp384_method(void);
+const EC_METHOD *EC_GFp_s390x_nistp521_method(void);
+#endif
+
+size_t ec_key_simple_priv2oct(const EC_KEY *eckey,
+ unsigned char *buf, size_t len);
+int ec_key_simple_oct2priv(EC_KEY *eckey, const unsigned char *buf, size_t len);
+int ec_key_simple_generate_key(EC_KEY *eckey);
+int ec_key_simple_generate_public_key(EC_KEY *eckey);
+int ec_key_simple_check_key(const EC_KEY *eckey);
+
+int ec_curve_nid_from_params(const EC_GROUP *group, BN_CTX *ctx);
+
+/* EC_METHOD definitions */
+
+struct ec_key_method_st {
+ const char *name;
+ int32_t flags;
+ int (*init)(EC_KEY *key);
+ void (*finish)(EC_KEY *key);
+ int (*copy)(EC_KEY *dest, const EC_KEY *src);
+ int (*set_group)(EC_KEY *key, const EC_GROUP *grp);
+ int (*set_private)(EC_KEY *key, const BIGNUM *priv_key);
+ int (*set_public)(EC_KEY *key, const EC_POINT *pub_key);
+ int (*keygen)(EC_KEY *key);
+ int (*compute_key)(unsigned char **pout, size_t *poutlen,
+ const EC_POINT *pub_key, const EC_KEY *ecdh);
+ int (*sign)(int type, const unsigned char *dgst, int dlen, unsigned char
+ *sig, unsigned int *siglen, const BIGNUM *kinv,
+ const BIGNUM *r, EC_KEY *eckey);
+ int (*sign_setup)(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp,
+ BIGNUM **rp);
+ ECDSA_SIG *(*sign_sig)(const unsigned char *dgst, int dgst_len,
+ const BIGNUM *in_kinv, const BIGNUM *in_r,
+ EC_KEY *eckey);
+
+ int (*verify)(int type, const unsigned char *dgst, int dgst_len,
+ const unsigned char *sigbuf, int sig_len, EC_KEY *eckey);
+ int (*verify_sig)(const unsigned char *dgst, int dgst_len,
+ const ECDSA_SIG *sig, EC_KEY *eckey);
+};
+
+#define EC_KEY_METHOD_DYNAMIC 1
+
+EC_KEY *ec_key_new_method_int(OPENSSL_CTX *libctx, ENGINE *engine);
+
+int ossl_ec_key_gen(EC_KEY *eckey);
+int ossl_ecdh_compute_key(unsigned char **pout, size_t *poutlen,
+ const EC_POINT *pub_key, const EC_KEY *ecdh);
+int ecdh_simple_compute_key(unsigned char **pout, size_t *poutlen,
+ const EC_POINT *pub_key, const EC_KEY *ecdh);
+
+struct ECDSA_SIG_st {
+ BIGNUM *r;
+ BIGNUM *s;
+};
+
+int ossl_ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp,
+ BIGNUM **rp);
+int ossl_ecdsa_sign(int type, const unsigned char *dgst, int dlen,
+ unsigned char *sig, unsigned int *siglen,
+ const BIGNUM *kinv, const BIGNUM *r, EC_KEY *eckey);
+ECDSA_SIG *ossl_ecdsa_sign_sig(const unsigned char *dgst, int dgst_len,
+ const BIGNUM *in_kinv, const BIGNUM *in_r,
+ EC_KEY *eckey);
+int ossl_ecdsa_verify(int type, const unsigned char *dgst, int dgst_len,
+ const unsigned char *sigbuf, int sig_len, EC_KEY *eckey);
+int ossl_ecdsa_verify_sig(const unsigned char *dgst, int dgst_len,
+ const ECDSA_SIG *sig, EC_KEY *eckey);
+int ecdsa_simple_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp,
+ BIGNUM **rp);
+ECDSA_SIG *ecdsa_simple_sign_sig(const unsigned char *dgst, int dgst_len,
+ const BIGNUM *in_kinv, const BIGNUM *in_r,
+ EC_KEY *eckey);
+int ecdsa_simple_verify_sig(const unsigned char *dgst, int dgst_len,
+ const ECDSA_SIG *sig, EC_KEY *eckey);
+
+int ED25519_sign(uint8_t *out_sig, const uint8_t *message, size_t message_len,
+ const uint8_t public_key[32], const uint8_t private_key[32]);
+int ED25519_verify(const uint8_t *message, size_t message_len,
+ const uint8_t signature[64], const uint8_t public_key[32]);
+void ED25519_public_from_private(uint8_t out_public_key[32],
+ const uint8_t private_key[32]);
+
+int X25519(uint8_t out_shared_key[32], const uint8_t private_key[32],
+ const uint8_t peer_public_value[32]);
+void X25519_public_from_private(uint8_t out_public_value[32],
+ const uint8_t private_key[32]);
+
+/*-
+ * This functions computes a single point multiplication over the EC group,
+ * using, at a high level, a Montgomery ladder with conditional swaps, with
+ * various timing attack defenses.
+ *
+ * It performs either a fixed point multiplication
+ * (scalar * generator)
+ * when point is NULL, or a variable point multiplication
+ * (scalar * point)
+ * when point is not NULL.
+ *
+ * `scalar` cannot be NULL and should be in the range [0,n) otherwise all
+ * constant time bets are off (where n is the cardinality of the EC group).
+ *
+ * This function expects `group->order` and `group->cardinality` to be well
+ * defined and non-zero: it fails with an error code otherwise.
+ *
+ * NB: This says nothing about the constant-timeness of the ladder step
+ * implementation (i.e., the default implementation is based on EC_POINT_add and
+ * EC_POINT_dbl, which of course are not constant time themselves) or the
+ * underlying multiprecision arithmetic.
+ *
+ * The product is stored in `r`.
+ *
+ * This is an internal function: callers are in charge of ensuring that the
+ * input parameters `group`, `r`, `scalar` and `ctx` are not NULL.
+ *
+ * Returns 1 on success, 0 otherwise.
+ */
+int ec_scalar_mul_ladder(const EC_GROUP *group, EC_POINT *r,
+ const BIGNUM *scalar, const EC_POINT *point,
+ BN_CTX *ctx);
+
+int ec_point_blind_coordinates(const EC_GROUP *group, EC_POINT *p, BN_CTX *ctx);
+
+static ossl_inline int ec_point_ladder_pre(const EC_GROUP *group,
+ EC_POINT *r, EC_POINT *s,
+ EC_POINT *p, BN_CTX *ctx)
+{
+ if (group->meth->ladder_pre != NULL)
+ return group->meth->ladder_pre(group, r, s, p, ctx);
+
+ if (!EC_POINT_copy(s, p)
+ || !EC_POINT_dbl(group, r, s, ctx))
+ return 0;
+
+ return 1;
+}
+
+static ossl_inline int ec_point_ladder_step(const EC_GROUP *group,
+ EC_POINT *r, EC_POINT *s,
+ EC_POINT *p, BN_CTX *ctx)
+{
+ if (group->meth->ladder_step != NULL)
+ return group->meth->ladder_step(group, r, s, p, ctx);
+
+ if (!EC_POINT_add(group, s, r, s, ctx)
+ || !EC_POINT_dbl(group, r, r, ctx))
+ return 0;
+
+ return 1;
+
+}
+
+static ossl_inline int ec_point_ladder_post(const EC_GROUP *group,
+ EC_POINT *r, EC_POINT *s,
+ EC_POINT *p, BN_CTX *ctx)
+{
+ if (group->meth->ladder_post != NULL)
+ return group->meth->ladder_post(group, r, s, p, ctx);
+
+ return 1;
+}
#include "internal/cryptlib.h"
#include "crypto/bn.h"
-#include "ec_lcl.h"
+#include "ec_local.h"
#include "internal/refcount.h"
/*
#include <openssl/err.h>
#include <openssl/opensslv.h>
-#include "ec_lcl.h"
+#include "ec_local.h"
int EC_POINT_set_compressed_coordinates(const EC_GROUP *group, EC_POINT *point,
const BIGNUM *x, int y_bit, BN_CTX *ctx)
#include <openssl/asn1t.h>
#include <openssl/x509.h>
#include <openssl/ec.h>
-#include "ec_lcl.h"
+#include "ec_local.h"
#include <openssl/evp.h>
#include "crypto/evp.h"
#include <openssl/crypto.h>
#include <openssl/err.h>
-#include "ec_lcl.h"
+#include "ec_local.h"
BIGNUM *EC_POINT_point2bn(const EC_GROUP *group,
const EC_POINT *point,
#include <openssl/ec.h>
#include <openssl/evp.h>
#include <openssl/kdf.h>
-#include "ec_lcl.h"
+#include "ec_local.h"
/* Key derivation function from X9.63/SECG */
int ecdh_KDF_X9_63(unsigned char *out, size_t outlen,
#include <openssl/bn.h>
#include <openssl/objects.h>
#include <openssl/ec.h>
-#include "ec_lcl.h"
+#include "ec_local.h"
int ossl_ecdh_compute_key(unsigned char **psec, size_t *pseclen,
const EC_POINT *pub_key, const EC_KEY *ecdh)
#include <openssl/obj_mac.h>
#include <openssl/rand.h>
#include "crypto/bn.h"
-#include "ec_lcl.h"
+#include "ec_local.h"
int ossl_ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp,
BIGNUM **rp)
*/
#include <openssl/ec.h>
-#include "ec_lcl.h"
+#include "ec_local.h"
#include <openssl/err.h>
ECDSA_SIG *ECDSA_do_sign(const unsigned char *dgst, int dlen, EC_KEY *eckey)
*/
#include <openssl/ec.h>
-#include "ec_lcl.h"
+#include "ec_local.h"
#include <openssl/err.h>
/*-
#include <openssl/err.h>
-#include "ec_lcl.h"
+#include "ec_local.h"
const EC_METHOD *EC_GFp_mont_method(void)
{
#include <openssl/err.h>
#include <openssl/obj_mac.h>
-#include "ec_lcl.h"
+#include "ec_local.h"
const EC_METHOD *EC_GFp_nist_method(void)
{
# include <stdint.h>
# include <string.h>
# include <openssl/err.h>
-# include "ec_lcl.h"
+# include "ec_local.h"
# if defined(__SIZEOF_INT128__) && __SIZEOF_INT128__==16
/* even with gcc, the typedef won't work for 32-bit platforms */
# include <stdint.h>
# include <string.h>
# include <openssl/err.h>
-# include "ec_lcl.h"
+# include "ec_local.h"
# if defined(__SIZEOF_INT128__) && __SIZEOF_INT128__==16
/* even with gcc, the typedef won't work for 32-bit platforms */
# include <string.h>
# include <openssl/err.h>
-# include "ec_lcl.h"
+# include "ec_local.h"
# if defined(__SIZEOF_INT128__) && __SIZEOF_INT128__==16
/* even with gcc, the typedef won't work for 32-bit platforms */
*/
# include <stddef.h>
-# include "ec_lcl.h"
+# include "ec_local.h"
/*
* Convert an array of points into affine coordinates. (If the point at
#include "internal/cryptlib.h"
#include "crypto/bn.h"
-#include "ec_lcl.h"
+#include "ec_local.h"
#include "internal/refcount.h"
#if BN_BITS2 != 64
#include <openssl/err.h>
#include <openssl/symhacks.h>
-#include "ec_lcl.h"
+#include "ec_local.h"
int ec_GFp_simple_set_compressed_coordinates(const EC_GROUP *group,
EC_POINT *point,
#include <string.h>
#include <openssl/err.h>
#include <openssl/rand.h>
-#include "ec_lcl.h"
+#include "ec_local.h"
#include "s390x_arch.h"
/* Size of parameter blocks */
#include <openssl/err.h>
#include <openssl/symhacks.h>
-#include "ec_lcl.h"
+#include "ec_local.h"
const EC_METHOD *EC_GFp_simple_method(void)
{
#include <openssl/rand.h>
#include "crypto/asn1.h"
#include "crypto/evp.h"
-#include "ec_lcl.h"
-#include "curve448/curve448_lcl.h"
+#include "ec_local.h"
+#include "curve448/curve448_local.h"
#define X25519_BITS 253
#define X25519_SECURITY_BITS 128
lynched for sticking all this in CHANGES or the commit mails :-).
ENGINE_TABLE underlies this restructuring, as described in the internal header
-"eng_int.h", implemented in eng_table.c, and used in each of the "class" files;
+"eng_local.h", implemented in eng_table.c, and used in each of the "class" files;
tb_rsa.c, tb_dsa.c, etc.
However, "EVP_CIPHER" underlies the motivation and design of ENGINE_TABLE so
*/
#include "internal/cryptlib.h"
-#include "eng_int.h"
+#include "eng_local.h"
void ENGINE_load_builtin_engines(void)
{
* https://www.openssl.org/source/license.html
*/
-#include "eng_int.h"
+#include "eng_local.h"
#include <openssl/conf.h>
#include <openssl/trace.h>
* https://www.openssl.org/source/license.html
*/
-#include "eng_int.h"
+#include "eng_local.h"
/*
* When querying a ENGINE-specific control command's 'description', this
* https://www.openssl.org/source/license.html
*/
-#include "eng_int.h"
+#include "eng_local.h"
#include "internal/dso.h"
#include <openssl/crypto.h>
* https://www.openssl.org/source/license.html
*/
-#include "eng_int.h"
+#include "eng_local.h"
#include <openssl/conf.h>
int ENGINE_set_default(ENGINE *e, unsigned int flags)
*/
#include "e_os.h"
-#include "eng_int.h"
+#include "eng_local.h"
/*
* Initialise a engine type for use (or up its functional reference count if
+++ /dev/null
-/*
- * Copyright 2001-2018 The OpenSSL Project Authors. All Rights Reserved.
- * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-#ifndef HEADER_ENGINE_INT_H
-# define HEADER_ENGINE_INT_H
-
-# include <openssl/trace.h>
-# include "internal/cryptlib.h"
-# include "crypto/engine.h"
-# include "internal/thread_once.h"
-# include "internal/refcount.h"
-
-extern CRYPTO_RWLOCK *global_engine_lock;
-
-/*
- * This prints the engine's pointer address (truncated to unsigned int),
- * "struct" or "funct" to indicate the reference type, the before and after
- * reference count, and the file:line-number pair. The "engine_ref_debug"
- * statements must come *after* the change.
- */
-# define engine_ref_debug(e, isfunct, diff) \
- OSSL_TRACE6(ENGINE_REF_COUNT, \
- "engine: %p %s from %d to %d (%s:%d)\n", \
- (void *)(e), (isfunct ? "funct" : "struct"), \
- ((isfunct) \
- ? ((e)->funct_ref - (diff)) \
- : ((e)->struct_ref - (diff))), \
- ((isfunct) ? (e)->funct_ref : (e)->struct_ref), \
- (OPENSSL_FILE), (OPENSSL_LINE))
-
-/*
- * Any code that will need cleanup operations should use these functions to
- * register callbacks. engine_cleanup_int() will call all registered
- * callbacks in order. NB: both the "add" functions assume the engine lock to
- * already be held (in "write" mode).
- */
-typedef void (ENGINE_CLEANUP_CB) (void);
-typedef struct st_engine_cleanup_item {
- ENGINE_CLEANUP_CB *cb;
-} ENGINE_CLEANUP_ITEM;
-DEFINE_STACK_OF(ENGINE_CLEANUP_ITEM)
-void engine_cleanup_add_first(ENGINE_CLEANUP_CB *cb);
-void engine_cleanup_add_last(ENGINE_CLEANUP_CB *cb);
-
-/* We need stacks of ENGINEs for use in eng_table.c */
-DEFINE_STACK_OF(ENGINE)
-
-/*
- * This represents an implementation table. Dependent code should instantiate
- * it as a (ENGINE_TABLE *) pointer value set initially to NULL.
- */
-typedef struct st_engine_table ENGINE_TABLE;
-int engine_table_register(ENGINE_TABLE **table, ENGINE_CLEANUP_CB *cleanup,
- ENGINE *e, const int *nids, int num_nids,
- int setdefault);
-void engine_table_unregister(ENGINE_TABLE **table, ENGINE *e);
-void engine_table_cleanup(ENGINE_TABLE **table);
-ENGINE *engine_table_select_int(ENGINE_TABLE **table, int nid, const char *f,
- int l);
-# define engine_table_select(t,n) \
- engine_table_select_int(t,n,OPENSSL_FILE,OPENSSL_LINE)
-typedef void (engine_table_doall_cb) (int nid, STACK_OF(ENGINE) *sk,
- ENGINE *def, void *arg);
-void engine_table_doall(ENGINE_TABLE *table, engine_table_doall_cb *cb,
- void *arg);
-
-/*
- * Internal versions of API functions that have control over locking. These
- * are used between C files when functionality needs to be shared but the
- * caller may already be controlling of the engine lock.
- */
-int engine_unlocked_init(ENGINE *e);
-int engine_unlocked_finish(ENGINE *e, int unlock_for_handlers);
-int engine_free_util(ENGINE *e, int not_locked);
-
-/*
- * This function will reset all "set"able values in an ENGINE to NULL. This
- * won't touch reference counts or ex_data, but is equivalent to calling all
- * the ENGINE_set_***() functions with a NULL value.
- */
-void engine_set_all_null(ENGINE *e);
-
-/*
- * NB: Bitwise OR-able values for the "flags" variable in ENGINE are now
- * exposed in engine.h.
- */
-
-/* Free up dynamically allocated public key methods associated with ENGINE */
-
-void engine_pkey_meths_free(ENGINE *e);
-void engine_pkey_asn1_meths_free(ENGINE *e);
-
-/* Once initialisation function */
-extern CRYPTO_ONCE engine_lock_init;
-DECLARE_RUN_ONCE(do_engine_lock_init)
-
-/*
- * This is a structure for storing implementations of various crypto
- * algorithms and functions.
- */
-struct engine_st {
- const char *id;
- const char *name;
- const RSA_METHOD *rsa_meth;
- const DSA_METHOD *dsa_meth;
- const DH_METHOD *dh_meth;
- const EC_KEY_METHOD *ec_meth;
- const RAND_METHOD *rand_meth;
- /* Cipher handling is via this callback */
- ENGINE_CIPHERS_PTR ciphers;
- /* Digest handling is via this callback */
- ENGINE_DIGESTS_PTR digests;
- /* Public key handling via this callback */
- ENGINE_PKEY_METHS_PTR pkey_meths;
- /* ASN1 public key handling via this callback */
- ENGINE_PKEY_ASN1_METHS_PTR pkey_asn1_meths;
- ENGINE_GEN_INT_FUNC_PTR destroy;
- ENGINE_GEN_INT_FUNC_PTR init;
- ENGINE_GEN_INT_FUNC_PTR finish;
- ENGINE_CTRL_FUNC_PTR ctrl;
- ENGINE_LOAD_KEY_PTR load_privkey;
- ENGINE_LOAD_KEY_PTR load_pubkey;
- ENGINE_SSL_CLIENT_CERT_PTR load_ssl_client_cert;
- const ENGINE_CMD_DEFN *cmd_defns;
- int flags;
- /* reference count on the structure itself */
- CRYPTO_REF_COUNT struct_ref;
- /*
- * reference count on usability of the engine type. NB: This controls the
- * loading and initialisation of any functionality required by this
- * engine, whereas the previous count is simply to cope with
- * (de)allocation of this structure. Hence, running_ref <= struct_ref at
- * all times.
- */
- int funct_ref;
- /* A place to store per-ENGINE data */
- CRYPTO_EX_DATA ex_data;
- /* Used to maintain the linked-list of engines. */
- struct engine_st *prev;
- struct engine_st *next;
-};
-
-typedef struct st_engine_pile ENGINE_PILE;
-
-DEFINE_LHASH_OF(ENGINE_PILE);
-
-#endif /* HEADER_ENGINE_INT_H */
*/
#include "e_os.h"
-#include "eng_int.h"
+#include "eng_local.h"
#include <openssl/rand.h>
#include "internal/refcount.h"
* https://www.openssl.org/source/license.html
*/
-#include "eng_int.h"
+#include "eng_local.h"
/*
* The linked-list of pointers to engine types. engine_list_head incorporates
--- /dev/null
+/*
+ * Copyright 2001-2018 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+#ifndef HEADER_ENGINE_INT_H
+# define HEADER_ENGINE_INT_H
+
+# include <openssl/trace.h>
+# include "internal/cryptlib.h"
+# include "crypto/engine.h"
+# include "internal/thread_once.h"
+# include "internal/refcount.h"
+
+extern CRYPTO_RWLOCK *global_engine_lock;
+
+/*
+ * This prints the engine's pointer address (truncated to unsigned int),
+ * "struct" or "funct" to indicate the reference type, the before and after
+ * reference count, and the file:line-number pair. The "engine_ref_debug"
+ * statements must come *after* the change.
+ */
+# define engine_ref_debug(e, isfunct, diff) \
+ OSSL_TRACE6(ENGINE_REF_COUNT, \
+ "engine: %p %s from %d to %d (%s:%d)\n", \
+ (void *)(e), (isfunct ? "funct" : "struct"), \
+ ((isfunct) \
+ ? ((e)->funct_ref - (diff)) \
+ : ((e)->struct_ref - (diff))), \
+ ((isfunct) ? (e)->funct_ref : (e)->struct_ref), \
+ (OPENSSL_FILE), (OPENSSL_LINE))
+
+/*
+ * Any code that will need cleanup operations should use these functions to
+ * register callbacks. engine_cleanup_int() will call all registered
+ * callbacks in order. NB: both the "add" functions assume the engine lock to
+ * already be held (in "write" mode).
+ */
+typedef void (ENGINE_CLEANUP_CB) (void);
+typedef struct st_engine_cleanup_item {
+ ENGINE_CLEANUP_CB *cb;
+} ENGINE_CLEANUP_ITEM;
+DEFINE_STACK_OF(ENGINE_CLEANUP_ITEM)
+void engine_cleanup_add_first(ENGINE_CLEANUP_CB *cb);
+void engine_cleanup_add_last(ENGINE_CLEANUP_CB *cb);
+
+/* We need stacks of ENGINEs for use in eng_table.c */
+DEFINE_STACK_OF(ENGINE)
+
+/*
+ * This represents an implementation table. Dependent code should instantiate
+ * it as a (ENGINE_TABLE *) pointer value set initially to NULL.
+ */
+typedef struct st_engine_table ENGINE_TABLE;
+int engine_table_register(ENGINE_TABLE **table, ENGINE_CLEANUP_CB *cleanup,
+ ENGINE *e, const int *nids, int num_nids,
+ int setdefault);
+void engine_table_unregister(ENGINE_TABLE **table, ENGINE *e);
+void engine_table_cleanup(ENGINE_TABLE **table);
+ENGINE *engine_table_select_int(ENGINE_TABLE **table, int nid, const char *f,
+ int l);
+# define engine_table_select(t,n) \
+ engine_table_select_int(t,n,OPENSSL_FILE,OPENSSL_LINE)
+typedef void (engine_table_doall_cb) (int nid, STACK_OF(ENGINE) *sk,
+ ENGINE *def, void *arg);
+void engine_table_doall(ENGINE_TABLE *table, engine_table_doall_cb *cb,
+ void *arg);
+
+/*
+ * Internal versions of API functions that have control over locking. These
+ * are used between C files when functionality needs to be shared but the
+ * caller may already be controlling of the engine lock.
+ */
+int engine_unlocked_init(ENGINE *e);
+int engine_unlocked_finish(ENGINE *e, int unlock_for_handlers);
+int engine_free_util(ENGINE *e, int not_locked);
+
+/*
+ * This function will reset all "set"able values in an ENGINE to NULL. This
+ * won't touch reference counts or ex_data, but is equivalent to calling all
+ * the ENGINE_set_***() functions with a NULL value.
+ */
+void engine_set_all_null(ENGINE *e);
+
+/*
+ * NB: Bitwise OR-able values for the "flags" variable in ENGINE are now
+ * exposed in engine.h.
+ */
+
+/* Free up dynamically allocated public key methods associated with ENGINE */
+
+void engine_pkey_meths_free(ENGINE *e);
+void engine_pkey_asn1_meths_free(ENGINE *e);
+
+/* Once initialisation function */
+extern CRYPTO_ONCE engine_lock_init;
+DECLARE_RUN_ONCE(do_engine_lock_init)
+
+/*
+ * This is a structure for storing implementations of various crypto
+ * algorithms and functions.
+ */
+struct engine_st {
+ const char *id;
+ const char *name;
+ const RSA_METHOD *rsa_meth;
+ const DSA_METHOD *dsa_meth;
+ const DH_METHOD *dh_meth;
+ const EC_KEY_METHOD *ec_meth;
+ const RAND_METHOD *rand_meth;
+ /* Cipher handling is via this callback */
+ ENGINE_CIPHERS_PTR ciphers;
+ /* Digest handling is via this callback */
+ ENGINE_DIGESTS_PTR digests;
+ /* Public key handling via this callback */
+ ENGINE_PKEY_METHS_PTR pkey_meths;
+ /* ASN1 public key handling via this callback */
+ ENGINE_PKEY_ASN1_METHS_PTR pkey_asn1_meths;
+ ENGINE_GEN_INT_FUNC_PTR destroy;
+ ENGINE_GEN_INT_FUNC_PTR init;
+ ENGINE_GEN_INT_FUNC_PTR finish;
+ ENGINE_CTRL_FUNC_PTR ctrl;
+ ENGINE_LOAD_KEY_PTR load_privkey;
+ ENGINE_LOAD_KEY_PTR load_pubkey;
+ ENGINE_SSL_CLIENT_CERT_PTR load_ssl_client_cert;
+ const ENGINE_CMD_DEFN *cmd_defns;
+ int flags;
+ /* reference count on the structure itself */
+ CRYPTO_REF_COUNT struct_ref;
+ /*
+ * reference count on usability of the engine type. NB: This controls the
+ * loading and initialisation of any functionality required by this
+ * engine, whereas the previous count is simply to cope with
+ * (de)allocation of this structure. Hence, running_ref <= struct_ref at
+ * all times.
+ */
+ int funct_ref;
+ /* A place to store per-ENGINE data */
+ CRYPTO_EX_DATA ex_data;
+ /* Used to maintain the linked-list of engines. */
+ struct engine_st *prev;
+ struct engine_st *next;
+};
+
+typedef struct st_engine_pile ENGINE_PILE;
+
+DEFINE_LHASH_OF(ENGINE_PILE);
+
+#endif /* HEADER_ENGINE_INT_H */
* https://www.openssl.org/source/license.html
*/
-#include "eng_int.h"
+#include "eng_local.h"
/* Basic get/set stuff */
#include <openssl/evp.h>
#include <openssl/lhash.h>
#include <openssl/trace.h>
-#include "eng_int.h"
+#include "eng_local.h"
/* The type of the items in the table */
struct st_engine_pile {
int uptodate;
};
-/* The type exposed in eng_int.h */
+/* The type exposed in eng_local.h */
struct st_engine_table {
LHASH_OF(ENGINE_PILE) piles;
}; /* ENGINE_TABLE */
}
/*
- * Privately exposed (via eng_int.h) functions for adding and/or removing
+ * Privately exposed (via eng_local.h) functions for adding and/or removing
* ENGINEs from the implementation table
*/
int engine_table_register(ENGINE_TABLE **table, ENGINE_CLEANUP_CB *cleanup,
*/
#include "e_os.h"
-#include "eng_int.h"
+#include "eng_local.h"
#include <openssl/evp.h>
#include "crypto/asn1.h"
* https://www.openssl.org/source/license.html
*/
-#include "eng_int.h"
+#include "eng_local.h"
static ENGINE_TABLE *cipher_table = NULL;
* https://www.openssl.org/source/license.html
*/
-#include "eng_int.h"
+#include "eng_local.h"
static ENGINE_TABLE *dh_table = NULL;
static const int dummy_nid = 1;
* https://www.openssl.org/source/license.html
*/
-#include "eng_int.h"
+#include "eng_local.h"
static ENGINE_TABLE *digest_table = NULL;
* https://www.openssl.org/source/license.html
*/
-#include "eng_int.h"
+#include "eng_local.h"
static ENGINE_TABLE *dsa_table = NULL;
static const int dummy_nid = 1;
* https://www.openssl.org/source/license.html
*/
-#include "eng_int.h"
+#include "eng_local.h"
static ENGINE_TABLE *dh_table = NULL;
static const int dummy_nid = 1;
* https://www.openssl.org/source/license.html
*/
-#include "eng_int.h"
+#include "eng_local.h"
#include <openssl/evp.h>
static ENGINE_TABLE *pkey_meth_table = NULL;
* https://www.openssl.org/source/license.html
*/
-#include "eng_int.h"
+#include "eng_local.h"
static ENGINE_TABLE *rand_table = NULL;
static const int dummy_nid = 1;
* https://www.openssl.org/source/license.html
*/
-#include "eng_int.h"
+#include "eng_local.h"
static ENGINE_TABLE *rsa_table = NULL;
static const int dummy_nid = 1;
#include <openssl/opensslconf.h>
#include "internal/thread_once.h"
#include "crypto/ctype.h"
-#include "internal/constant_time_locl.h"
+#include "internal/constant_time.h"
#include "e_os.h"
-#include "err_locl.h"
+#include "err_local.h"
/* Forward declaration in case it's not published because of configuration */
ERR_STATE *ERR_get_state(void);
#include <string.h>
#include <openssl/err.h>
-#include "err_locl.h"
+#include "err_local.h"
void ERR_new(void)
{
--- /dev/null
+/*
+ * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+#include <openssl/err.h>
+#include <openssl/e_os2.h>
+
+static ossl_inline void err_get_slot(ERR_STATE *es)
+{
+ es->top = (es->top + 1) % ERR_NUM_ERRORS;
+ if (es->top == es->bottom)
+ es->bottom = (es->bottom + 1) % ERR_NUM_ERRORS;
+}
+
+static ossl_inline void err_clear_data(ERR_STATE *es, size_t i, int deall)
+{
+ if (es->err_data_flags[i] & ERR_TXT_MALLOCED) {
+ if (deall) {
+ OPENSSL_free(es->err_data[i]);
+ es->err_data[i] = NULL;
+ es->err_data_size[i] = 0;
+ es->err_data_flags[i] = 0;
+ } else if (es->err_data[i] != NULL) {
+ es->err_data[i][0] = '\0';
+ }
+ } else {
+ es->err_data[i] = NULL;
+ es->err_data_size[i] = 0;
+ es->err_data_flags[i] = 0;
+ }
+}
+
+static ossl_inline void err_set_error(ERR_STATE *es, size_t i,
+ int lib, int reason)
+{
+ es->err_buffer[i] = ERR_PACK(lib, 0, reason);
+}
+
+static ossl_inline void err_set_debug(ERR_STATE *es, size_t i,
+ const char *file, int line,
+ const char *fn)
+{
+ es->err_file[i] = file;
+ es->err_line[i] = line;
+ es->err_func[i] = fn;
+}
+
+static ossl_inline void err_set_data(ERR_STATE *es, size_t i,
+ void *data, size_t datasz, int flags)
+{
+ es->err_data[i] = data;
+ es->err_data_size[i] = datasz;
+ es->err_data_flags[i] = flags;
+}
+
+static ossl_inline void err_clear(ERR_STATE *es, size_t i, int deall)
+{
+ err_clear_data(es, i, (deall));
+ es->err_flags[i] = 0;
+ es->err_buffer[i] = 0;
+ es->err_file[i] = NULL;
+ es->err_line[i] = -1;
+}
+
+ERR_STATE *err_get_state_int(void);
+++ /dev/null
-/*
- * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-#include <openssl/err.h>
-#include <openssl/e_os2.h>
-
-static ossl_inline void err_get_slot(ERR_STATE *es)
-{
- es->top = (es->top + 1) % ERR_NUM_ERRORS;
- if (es->top == es->bottom)
- es->bottom = (es->bottom + 1) % ERR_NUM_ERRORS;
-}
-
-static ossl_inline void err_clear_data(ERR_STATE *es, size_t i, int deall)
-{
- if (es->err_data_flags[i] & ERR_TXT_MALLOCED) {
- if (deall) {
- OPENSSL_free(es->err_data[i]);
- es->err_data[i] = NULL;
- es->err_data_size[i] = 0;
- es->err_data_flags[i] = 0;
- } else if (es->err_data[i] != NULL) {
- es->err_data[i][0] = '\0';
- }
- } else {
- es->err_data[i] = NULL;
- es->err_data_size[i] = 0;
- es->err_data_flags[i] = 0;
- }
-}
-
-static ossl_inline void err_set_error(ERR_STATE *es, size_t i,
- int lib, int reason)
-{
- es->err_buffer[i] = ERR_PACK(lib, 0, reason);
-}
-
-static ossl_inline void err_set_debug(ERR_STATE *es, size_t i,
- const char *file, int line,
- const char *fn)
-{
- es->err_file[i] = file;
- es->err_line[i] = line;
- es->err_func[i] = fn;
-}
-
-static ossl_inline void err_set_data(ERR_STATE *es, size_t i,
- void *data, size_t datasz, int flags)
-{
- es->err_data[i] = data;
- es->err_data_size[i] = datasz;
- es->err_data_flags[i] = flags;
-}
-
-static ossl_inline void err_clear(ERR_STATE *es, size_t i, int deall)
-{
- err_clear_data(es, i, (deall));
- es->err_flags[i] = 0;
- es->err_buffer[i] = 0;
- es->err_file[i] = NULL;
- es->err_line[i] = -1;
-}
-
-ERR_STATE *err_get_state_int(void);
#include <openssl/crypto.h>
#include <openssl/buffer.h>
#include <openssl/err.h>
-#include "err_locl.h"
+#include "err_local.h"
void ERR_print_errors_cb(int (*cb) (const char *str, size_t len, void *u),
void *u)
# additional header files to be scanned for function names
L NONE include/openssl/x509_vfy.h NONE
-L NONE crypto/ec/ec_lcl.h NONE
-L NONE crypto/cms/cms_lcl.h NONE
-L NONE crypto/ct/ct_locl.h NONE
-L NONE ssl/ssl_locl.h NONE
+L NONE crypto/ec/ec_local.h NONE
+L NONE crypto/cms/cms_local.h NONE
+L NONE crypto/ct/ct_local.h NONE
+L NONE ssl/ssl_local.h NONE
# SSL/TLS alerts
R SSL_R_SSLV3_ALERT_UNEXPECTED_MESSAGE 1010
#include <openssl/buffer.h>
#include <openssl/evp.h>
#include "crypto/evp.h"
-#include "evp_locl.h"
+#include "evp_local.h"
#include "internal/bio.h"
/*
#include <openssl/evp.h>
#include "crypto/evp.h"
#include "internal/provider.h"
-#include "evp_locl.h"
+#include "evp_local.h"
EVP_CIPHER *EVP_CIPHER_meth_new(int cipher_type, int block_size, int key_len)
{
#include "internal/cryptlib.h"
#include "crypto/evp.h"
#include "internal/provider.h"
-#include "evp_locl.h"
+#include "evp_local.h"
/* This call frees resources associated with the context */
int EVP_MD_CTX_reset(EVP_MD_CTX *ctx)
#include "crypto/modes.h"
#include "crypto/siv.h"
#include "crypto/ciphermode_platform.h"
-#include "evp_locl.h"
+#include "evp_local.h"
typedef struct {
union {
#include "internal/cryptlib.h"
#include "crypto/modes.h"
#include "crypto/evp.h"
-#include "internal/constant_time_locl.h"
+#include "internal/constant_time.h"
typedef struct {
AES_KEY ks;
#include <openssl/rand.h>
#include "internal/cryptlib.h"
#include "crypto/modes.h"
-#include "internal/constant_time_locl.h"
+#include "internal/constant_time.h"
#include "crypto/evp.h"
typedef struct {
# include "crypto/aria.h"
# include "crypto/evp.h"
# include "crypto/modes.h"
-# include "evp_locl.h"
+# include "evp_local.h"
/* ARIA subkey Structure */
typedef struct {
# include <openssl/evp.h>
# include <openssl/objects.h>
# include "crypto/evp.h"
-# include "evp_locl.h"
+# include "evp_local.h"
# include "crypto/chacha.h"
typedef struct {
# include "crypto/evp.h"
# include <openssl/des.h>
# include <openssl/rand.h>
-# include "evp_locl.h"
+# include "evp_local.h"
typedef struct {
union {
# include <openssl/evp.h>
# include "crypto/evp.h"
# include <openssl/objects.h>
-# include "evp_locl.h"
+# include "evp_local.h"
# include <openssl/rc5.h>
static int r_32_12_16_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
#include "internal/cryptlib.h"
#include <openssl/evp.h>
#include "crypto/evp.h"
-#include "evp_locl.h"
+#include "evp_local.h"
static unsigned char conv_ascii2bin(unsigned char a,
const unsigned char *table);
#include <openssl/core_names.h>
#include "crypto/evp.h"
#include "internal/provider.h"
-#include "evp_locl.h"
+#include "evp_local.h"
int EVP_CIPHER_CTX_reset(EVP_CIPHER_CTX *ctx)
{
#include "internal/core.h"
#include "internal/provider.h"
#include "internal/namemap.h"
-#include "crypto/evp.h" /* evp_locl.h needs it */
-#include "evp_locl.h"
+#include "crypto/evp.h" /* evp_local.h needs it */
+#include "evp_local.h"
static void default_method_store_free(void *vstore)
{
#include <openssl/dh.h>
#include "crypto/evp.h"
#include "internal/provider.h"
-#include "evp_locl.h"
+#include "evp_local.h"
#if !defined(FIPS_MODE)
int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type)
--- /dev/null
+/*
+ * Copyright 2000-2019 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+/* EVP_MD_CTX related stuff */
+
+#include <openssl/core_numbers.h>
+
+#define EVP_CTRL_RET_UNSUPPORTED -1
+
+
+struct evp_md_ctx_st {
+ const EVP_MD *reqdigest; /* The original requested digest */
+ const EVP_MD *digest;
+ ENGINE *engine; /* functional reference if 'digest' is
+ * ENGINE-provided */
+ unsigned long flags;
+ void *md_data;
+ /* Public key context for sign/verify */
+ EVP_PKEY_CTX *pctx;
+ /* Update function: usually copied from EVP_MD */
+ int (*update) (EVP_MD_CTX *ctx, const void *data, size_t count);
+
+ /* Provider ctx */
+ void *provctx;
+ EVP_MD *fetched_digest;
+} /* EVP_MD_CTX */ ;
+
+struct evp_cipher_ctx_st {
+ const EVP_CIPHER *cipher;
+ ENGINE *engine; /* functional reference if 'cipher' is
+ * ENGINE-provided */
+ int encrypt; /* encrypt or decrypt */
+ int buf_len; /* number we have left */
+ unsigned char oiv[EVP_MAX_IV_LENGTH]; /* original iv */
+ unsigned char iv[EVP_MAX_IV_LENGTH]; /* working iv */
+ unsigned char buf[EVP_MAX_BLOCK_LENGTH]; /* saved partial block */
+ int num; /* used by cfb/ofb/ctr mode */
+ /* FIXME: Should this even exist? It appears unused */
+ void *app_data; /* application stuff */
+ int key_len; /* May change for variable length cipher */
+ unsigned long flags; /* Various flags */
+ void *cipher_data; /* per EVP data */
+ int final_used;
+ int block_mask;
+ unsigned char final[EVP_MAX_BLOCK_LENGTH]; /* possible final block */
+
+ /* Provider ctx */
+ void *provctx;
+ EVP_CIPHER *fetched_cipher;
+} /* EVP_CIPHER_CTX */ ;
+
+struct evp_mac_ctx_st {
+ EVP_MAC *meth; /* Method structure */
+ void *data; /* Individual method data */
+} /* EVP_MAC_CTX */;
+
+struct evp_kdf_ctx_st {
+ EVP_KDF *meth; /* Method structure */
+ void *data; /* Algorithm-specific data */
+} /* EVP_KDF_CTX */ ;
+
+struct evp_keymgmt_st {
+ int id; /* libcrypto internal */
+
+ int name_id;
+ OSSL_PROVIDER *prov;
+ CRYPTO_REF_COUNT refcnt;
+ CRYPTO_RWLOCK *lock;
+
+ /* Domain parameter routines */
+ OSSL_OP_keymgmt_importdomparams_fn *importdomparams;
+ OSSL_OP_keymgmt_gendomparams_fn *gendomparams;
+ OSSL_OP_keymgmt_freedomparams_fn *freedomparams;
+ OSSL_OP_keymgmt_exportdomparams_fn *exportdomparams;
+ OSSL_OP_keymgmt_importdomparam_types_fn *importdomparam_types;
+ OSSL_OP_keymgmt_exportdomparam_types_fn *exportdomparam_types;
+
+ /* Key routines */
+ OSSL_OP_keymgmt_importkey_fn *importkey;
+ OSSL_OP_keymgmt_genkey_fn *genkey;
+ OSSL_OP_keymgmt_loadkey_fn *loadkey;
+ OSSL_OP_keymgmt_freekey_fn *freekey;
+ OSSL_OP_keymgmt_exportkey_fn *exportkey;
+ OSSL_OP_keymgmt_importkey_types_fn *importkey_types;
+ OSSL_OP_keymgmt_exportkey_types_fn *exportkey_types;
+} /* EVP_KEYMGMT */ ;
+
+struct keymgmt_data_st {
+ OPENSSL_CTX *ctx;
+ const char *properties;
+};
+
+struct evp_keyexch_st {
+ int name_id;
+ OSSL_PROVIDER *prov;
+ CRYPTO_REF_COUNT refcnt;
+ CRYPTO_RWLOCK *lock;
+
+ EVP_KEYMGMT *keymgmt;
+
+ OSSL_OP_keyexch_newctx_fn *newctx;
+ OSSL_OP_keyexch_init_fn *init;
+ OSSL_OP_keyexch_set_peer_fn *set_peer;
+ OSSL_OP_keyexch_derive_fn *derive;
+ OSSL_OP_keyexch_freectx_fn *freectx;
+ OSSL_OP_keyexch_dupctx_fn *dupctx;
+ OSSL_OP_keyexch_set_ctx_params_fn *set_ctx_params;
+ OSSL_OP_keyexch_settable_ctx_params_fn *settable_ctx_params;
+} /* EVP_KEYEXCH */;
+
+struct evp_signature_st {
+ int name_id;
+ OSSL_PROVIDER *prov;
+ CRYPTO_REF_COUNT refcnt;
+ CRYPTO_RWLOCK *lock;
+
+ EVP_KEYMGMT *keymgmt;
+
+ OSSL_OP_signature_newctx_fn *newctx;
+ OSSL_OP_signature_sign_init_fn *sign_init;
+ OSSL_OP_signature_sign_fn *sign;
+ OSSL_OP_signature_verify_init_fn *verify_init;
+ OSSL_OP_signature_verify_fn *verify;
+ OSSL_OP_signature_verify_recover_init_fn *verify_recover_init;
+ OSSL_OP_signature_verify_recover_fn *verify_recover;
+ OSSL_OP_signature_freectx_fn *freectx;
+ OSSL_OP_signature_dupctx_fn *dupctx;
+ OSSL_OP_signature_get_ctx_params_fn *get_ctx_params;
+ OSSL_OP_signature_gettable_ctx_params_fn *gettable_ctx_params;
+ OSSL_OP_signature_set_ctx_params_fn *set_ctx_params;
+ OSSL_OP_signature_settable_ctx_params_fn *settable_ctx_params;
+} /* EVP_SIGNATURE */;
+
+int PKCS5_v2_PBKDF2_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass,
+ int passlen, ASN1_TYPE *param,
+ const EVP_CIPHER *c, const EVP_MD *md,
+ int en_de);
+
+struct evp_Encode_Ctx_st {
+ /* number saved in a partial encode/decode */
+ int num;
+ /*
+ * The length is either the output line length (in input bytes) or the
+ * shortest input line length that is ok. Once decoding begins, the
+ * length is adjusted up each time a longer line is decoded
+ */
+ int length;
+ /* data to encode */
+ unsigned char enc_data[80];
+ /* number read on current line */
+ int line_num;
+ unsigned int flags;
+};
+
+typedef struct evp_pbe_st EVP_PBE_CTL;
+DEFINE_STACK_OF(EVP_PBE_CTL)
+
+int is_partially_overlapping(const void *ptr1, const void *ptr2, int len);
+
+#include <openssl/ossl_typ.h>
+#include <openssl/core.h>
+
+void *evp_generic_fetch(OPENSSL_CTX *ctx, int operation_id,
+ const char *name, const char *properties,
+ void *(*new_method)(int name_id,
+ const OSSL_DISPATCH *fns,
+ OSSL_PROVIDER *prov,
+ void *method_data),
+ void *method_data,
+ int (*up_ref_method)(void *),
+ void (*free_method)(void *));
+void *evp_generic_fetch_by_number(OPENSSL_CTX *ctx, int operation_id,
+ int name_id, const char *properties,
+ void *(*new_method)(int name_id,
+ const OSSL_DISPATCH *fns,
+ OSSL_PROVIDER *prov,
+ void *method_data),
+ void *method_data,
+ int (*up_ref_method)(void *),
+ void (*free_method)(void *));
+void evp_generic_do_all(OPENSSL_CTX *libctx, int operation_id,
+ void (*user_fn)(void *method, void *arg),
+ void *user_arg,
+ void *(*new_method)(int name_id,
+ const OSSL_DISPATCH *fns,
+ OSSL_PROVIDER *prov,
+ void *method_data),
+ void *method_data,
+ void (*free_method)(void *));
+
+/* Internal fetchers for method types that are to be combined with others */
+EVP_KEYMGMT *evp_keymgmt_fetch_by_number(OPENSSL_CTX *ctx, int name_id,
+ const char *properties);
+
+/* Internal structure constructors for fetched methods */
+EVP_MD *evp_md_new(void);
+EVP_CIPHER *evp_cipher_new(void);
+
+/* Helper functions to avoid duplicating code */
+
+/*
+ * These methods implement different ways to pass a params array to the
+ * provider. They will return one of these values:
+ *
+ * -2 if the method doesn't come from a provider
+ * (evp_do_param will return this to the called)
+ * -1 if the provider doesn't offer the desired function
+ * (evp_do_param will raise an error and return 0)
+ * or the return value from the desired function
+ * (evp_do_param will return it to the caller)
+ */
+int evp_do_ciph_getparams(const EVP_CIPHER *ciph, OSSL_PARAM params[]);
+int evp_do_ciph_ctx_getparams(const EVP_CIPHER *ciph, void *provctx,
+ OSSL_PARAM params[]);
+int evp_do_ciph_ctx_setparams(const EVP_CIPHER *ciph, void *provctx,
+ OSSL_PARAM params[]);
+int evp_do_md_getparams(const EVP_MD *md, OSSL_PARAM params[]);
+int evp_do_md_ctx_getparams(const EVP_MD *md, void *provctx,
+ OSSL_PARAM params[]);
+int evp_do_md_ctx_setparams(const EVP_MD *md, void *provctx,
+ OSSL_PARAM params[]);
+
+OSSL_PARAM *evp_pkey_to_param(EVP_PKEY *pkey, size_t *sz);
+
+#define M_check_autoarg(ctx, arg, arglen, err) \
+ if (ctx->pmeth->flags & EVP_PKEY_FLAG_AUTOARGLEN) { \
+ size_t pksize = (size_t)EVP_PKEY_size(ctx->pkey); \
+ \
+ if (pksize == 0) { \
+ ERR_raise(ERR_LIB_EVP, EVP_R_INVALID_KEY); /*ckerr_ignore*/ \
+ return 0; \
+ } \
+ if (arg == NULL) { \
+ *arglen = pksize; \
+ return 1; \
+ } \
+ if (*arglen < pksize) { \
+ ERR_raise(ERR_LIB_EVP, EVP_R_BUFFER_TOO_SMALL); /*ckerr_ignore*/ \
+ return 0; \
+ } \
+ }
+
+void evp_pkey_ctx_free_old_ops(EVP_PKEY_CTX *ctx);
+
+/* OSSL_PROVIDER * is only used to get the library context */
+const char *evp_first_name(OSSL_PROVIDER *prov, int name_id);
+int evp_is_a(OSSL_PROVIDER *prov, int number, const char *name);
+void evp_doall_names(OSSL_PROVIDER *prov, int number,
+ void (*fn)(const char *name, void *data),
+ void *data);
+++ /dev/null
-/*
- * Copyright 2000-2019 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-/* EVP_MD_CTX related stuff */
-
-#include <openssl/core_numbers.h>
-
-#define EVP_CTRL_RET_UNSUPPORTED -1
-
-
-struct evp_md_ctx_st {
- const EVP_MD *reqdigest; /* The original requested digest */
- const EVP_MD *digest;
- ENGINE *engine; /* functional reference if 'digest' is
- * ENGINE-provided */
- unsigned long flags;
- void *md_data;
- /* Public key context for sign/verify */
- EVP_PKEY_CTX *pctx;
- /* Update function: usually copied from EVP_MD */
- int (*update) (EVP_MD_CTX *ctx, const void *data, size_t count);
-
- /* Provider ctx */
- void *provctx;
- EVP_MD *fetched_digest;
-} /* EVP_MD_CTX */ ;
-
-struct evp_cipher_ctx_st {
- const EVP_CIPHER *cipher;
- ENGINE *engine; /* functional reference if 'cipher' is
- * ENGINE-provided */
- int encrypt; /* encrypt or decrypt */
- int buf_len; /* number we have left */
- unsigned char oiv[EVP_MAX_IV_LENGTH]; /* original iv */
- unsigned char iv[EVP_MAX_IV_LENGTH]; /* working iv */
- unsigned char buf[EVP_MAX_BLOCK_LENGTH]; /* saved partial block */
- int num; /* used by cfb/ofb/ctr mode */
- /* FIXME: Should this even exist? It appears unused */
- void *app_data; /* application stuff */
- int key_len; /* May change for variable length cipher */
- unsigned long flags; /* Various flags */
- void *cipher_data; /* per EVP data */
- int final_used;
- int block_mask;
- unsigned char final[EVP_MAX_BLOCK_LENGTH]; /* possible final block */
-
- /* Provider ctx */
- void *provctx;
- EVP_CIPHER *fetched_cipher;
-} /* EVP_CIPHER_CTX */ ;
-
-struct evp_mac_ctx_st {
- EVP_MAC *meth; /* Method structure */
- void *data; /* Individual method data */
-} /* EVP_MAC_CTX */;
-
-struct evp_kdf_ctx_st {
- EVP_KDF *meth; /* Method structure */
- void *data; /* Algorithm-specific data */
-} /* EVP_KDF_CTX */ ;
-
-struct evp_keymgmt_st {
- int id; /* libcrypto internal */
-
- int name_id;
- OSSL_PROVIDER *prov;
- CRYPTO_REF_COUNT refcnt;
- CRYPTO_RWLOCK *lock;
-
- /* Domain parameter routines */
- OSSL_OP_keymgmt_importdomparams_fn *importdomparams;
- OSSL_OP_keymgmt_gendomparams_fn *gendomparams;
- OSSL_OP_keymgmt_freedomparams_fn *freedomparams;
- OSSL_OP_keymgmt_exportdomparams_fn *exportdomparams;
- OSSL_OP_keymgmt_importdomparam_types_fn *importdomparam_types;
- OSSL_OP_keymgmt_exportdomparam_types_fn *exportdomparam_types;
-
- /* Key routines */
- OSSL_OP_keymgmt_importkey_fn *importkey;
- OSSL_OP_keymgmt_genkey_fn *genkey;
- OSSL_OP_keymgmt_loadkey_fn *loadkey;
- OSSL_OP_keymgmt_freekey_fn *freekey;
- OSSL_OP_keymgmt_exportkey_fn *exportkey;
- OSSL_OP_keymgmt_importkey_types_fn *importkey_types;
- OSSL_OP_keymgmt_exportkey_types_fn *exportkey_types;
-} /* EVP_KEYMGMT */ ;
-
-struct keymgmt_data_st {
- OPENSSL_CTX *ctx;
- const char *properties;
-};
-
-struct evp_keyexch_st {
- int name_id;
- OSSL_PROVIDER *prov;
- CRYPTO_REF_COUNT refcnt;
- CRYPTO_RWLOCK *lock;
-
- EVP_KEYMGMT *keymgmt;
-
- OSSL_OP_keyexch_newctx_fn *newctx;
- OSSL_OP_keyexch_init_fn *init;
- OSSL_OP_keyexch_set_peer_fn *set_peer;
- OSSL_OP_keyexch_derive_fn *derive;
- OSSL_OP_keyexch_freectx_fn *freectx;
- OSSL_OP_keyexch_dupctx_fn *dupctx;
- OSSL_OP_keyexch_set_ctx_params_fn *set_ctx_params;
- OSSL_OP_keyexch_settable_ctx_params_fn *settable_ctx_params;
-} /* EVP_KEYEXCH */;
-
-struct evp_signature_st {
- int name_id;
- OSSL_PROVIDER *prov;
- CRYPTO_REF_COUNT refcnt;
- CRYPTO_RWLOCK *lock;
-
- EVP_KEYMGMT *keymgmt;
-
- OSSL_OP_signature_newctx_fn *newctx;
- OSSL_OP_signature_sign_init_fn *sign_init;
- OSSL_OP_signature_sign_fn *sign;
- OSSL_OP_signature_verify_init_fn *verify_init;
- OSSL_OP_signature_verify_fn *verify;
- OSSL_OP_signature_verify_recover_init_fn *verify_recover_init;
- OSSL_OP_signature_verify_recover_fn *verify_recover;
- OSSL_OP_signature_freectx_fn *freectx;
- OSSL_OP_signature_dupctx_fn *dupctx;
- OSSL_OP_signature_get_ctx_params_fn *get_ctx_params;
- OSSL_OP_signature_gettable_ctx_params_fn *gettable_ctx_params;
- OSSL_OP_signature_set_ctx_params_fn *set_ctx_params;
- OSSL_OP_signature_settable_ctx_params_fn *settable_ctx_params;
-} /* EVP_SIGNATURE */;
-
-int PKCS5_v2_PBKDF2_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass,
- int passlen, ASN1_TYPE *param,
- const EVP_CIPHER *c, const EVP_MD *md,
- int en_de);
-
-struct evp_Encode_Ctx_st {
- /* number saved in a partial encode/decode */
- int num;
- /*
- * The length is either the output line length (in input bytes) or the
- * shortest input line length that is ok. Once decoding begins, the
- * length is adjusted up each time a longer line is decoded
- */
- int length;
- /* data to encode */
- unsigned char enc_data[80];
- /* number read on current line */
- int line_num;
- unsigned int flags;
-};
-
-typedef struct evp_pbe_st EVP_PBE_CTL;
-DEFINE_STACK_OF(EVP_PBE_CTL)
-
-int is_partially_overlapping(const void *ptr1, const void *ptr2, int len);
-
-#include <openssl/ossl_typ.h>
-#include <openssl/core.h>
-
-void *evp_generic_fetch(OPENSSL_CTX *ctx, int operation_id,
- const char *name, const char *properties,
- void *(*new_method)(int name_id,
- const OSSL_DISPATCH *fns,
- OSSL_PROVIDER *prov,
- void *method_data),
- void *method_data,
- int (*up_ref_method)(void *),
- void (*free_method)(void *));
-void *evp_generic_fetch_by_number(OPENSSL_CTX *ctx, int operation_id,
- int name_id, const char *properties,
- void *(*new_method)(int name_id,
- const OSSL_DISPATCH *fns,
- OSSL_PROVIDER *prov,
- void *method_data),
- void *method_data,
- int (*up_ref_method)(void *),
- void (*free_method)(void *));
-void evp_generic_do_all(OPENSSL_CTX *libctx, int operation_id,
- void (*user_fn)(void *method, void *arg),
- void *user_arg,
- void *(*new_method)(int name_id,
- const OSSL_DISPATCH *fns,
- OSSL_PROVIDER *prov,
- void *method_data),
- void *method_data,
- void (*free_method)(void *));
-
-/* Internal fetchers for method types that are to be combined with others */
-EVP_KEYMGMT *evp_keymgmt_fetch_by_number(OPENSSL_CTX *ctx, int name_id,
- const char *properties);
-
-/* Internal structure constructors for fetched methods */
-EVP_MD *evp_md_new(void);
-EVP_CIPHER *evp_cipher_new(void);
-
-/* Helper functions to avoid duplicating code */
-
-/*
- * These methods implement different ways to pass a params array to the
- * provider. They will return one of these values:
- *
- * -2 if the method doesn't come from a provider
- * (evp_do_param will return this to the called)
- * -1 if the provider doesn't offer the desired function
- * (evp_do_param will raise an error and return 0)
- * or the return value from the desired function
- * (evp_do_param will return it to the caller)
- */
-int evp_do_ciph_getparams(const EVP_CIPHER *ciph, OSSL_PARAM params[]);
-int evp_do_ciph_ctx_getparams(const EVP_CIPHER *ciph, void *provctx,
- OSSL_PARAM params[]);
-int evp_do_ciph_ctx_setparams(const EVP_CIPHER *ciph, void *provctx,
- OSSL_PARAM params[]);
-int evp_do_md_getparams(const EVP_MD *md, OSSL_PARAM params[]);
-int evp_do_md_ctx_getparams(const EVP_MD *md, void *provctx,
- OSSL_PARAM params[]);
-int evp_do_md_ctx_setparams(const EVP_MD *md, void *provctx,
- OSSL_PARAM params[]);
-
-OSSL_PARAM *evp_pkey_to_param(EVP_PKEY *pkey, size_t *sz);
-
-#define M_check_autoarg(ctx, arg, arglen, err) \
- if (ctx->pmeth->flags & EVP_PKEY_FLAG_AUTOARGLEN) { \
- size_t pksize = (size_t)EVP_PKEY_size(ctx->pkey); \
- \
- if (pksize == 0) { \
- ERR_raise(ERR_LIB_EVP, EVP_R_INVALID_KEY); /*ckerr_ignore*/ \
- return 0; \
- } \
- if (arg == NULL) { \
- *arglen = pksize; \
- return 1; \
- } \
- if (*arglen < pksize) { \
- ERR_raise(ERR_LIB_EVP, EVP_R_BUFFER_TOO_SMALL); /*ckerr_ignore*/ \
- return 0; \
- } \
- }
-
-void evp_pkey_ctx_free_old_ops(EVP_PKEY_CTX *ctx);
-
-/* OSSL_PROVIDER * is only used to get the library context */
-const char *evp_first_name(OSSL_PROVIDER *prov, int name_id);
-int evp_is_a(OSSL_PROVIDER *prov, int number, const char *name);
-void evp_doall_names(OSSL_PROVIDER *prov, int number,
- void (*fn)(const char *name, void *data),
- void *data);
#include <openssl/pkcs12.h>
#include <openssl/x509.h>
#include "crypto/evp.h"
-#include "evp_locl.h"
+#include "evp_local.h"
/* Password based encryption (PBE) functions */
#include <openssl/core.h>
#include <openssl/evp.h>
#include <openssl/err.h>
-#include <openssl/asn1.h> /* evp_locl.h needs it */
-#include <openssl/safestack.h> /* evp_locl.h needs it */
-#include "crypto/evp.h" /* evp_locl.h needs it */
-#include "evp_locl.h"
+#include <openssl/asn1.h> /* evp_local.h needs it */
+#include <openssl/safestack.h> /* evp_local.h needs it */
+#include "crypto/evp.h" /* evp_local.h needs it */
+#include "evp_local.h"
/*
* EVP_CTRL_RET_UNSUPPORTED = -1 is the returned value from any ctrl function
#include "crypto/evp.h"
#include "internal/provider.h"
#include "internal/numbers.h" /* includes SIZE_MAX */
-#include "evp_locl.h"
+#include "evp_local.h"
static EVP_KEYEXCH *evp_keyexch_new(OSSL_PROVIDER *prov)
{
#include "crypto/evp.h"
#include "internal/numbers.h"
#include "internal/provider.h"
-#include "evp_locl.h"
+#include "evp_local.h"
EVP_KDF_CTX *EVP_KDF_CTX_new(EVP_KDF *kdf)
{
#include <openssl/kdf.h>
#include "crypto/evp.h"
#include "internal/provider.h"
-#include "evp_locl.h"
+#include "evp_local.h"
static int evp_kdf_up_ref(void *vkdf)
{
#include "crypto/evp.h"
#include "crypto/asn1.h"
#include "internal/provider.h"
-#include "evp_locl.h"
+#include "evp_local.h"
static OSSL_PARAM *paramdefs_to_params(const OSSL_PARAM *paramdefs)
{
#include "internal/provider.h"
#include "internal/refcount.h"
#include "crypto/evp.h"
-#include "evp_locl.h"
+#include "evp_local.h"
static void *keymgmt_new(void)
#include <openssl/objects.h>
#include "crypto/evp.h"
#include "internal/sha3.h"
-#include "evp_locl.h"
+#include "evp_local.h"
static int init(EVP_MD_CTX *ctx)
{
#include <openssl/objects.h>
#include <openssl/x509.h>
#include "crypto/evp.h"
-#include "evp_locl.h"
+#include "evp_local.h"
static int update(EVP_MD_CTX *ctx, const void *data, size_t datalen)
{
#include "internal/nelem.h"
#include "crypto/evp.h"
#include "internal/provider.h"
-#include "evp_locl.h"
+#include "evp_local.h"
EVP_MAC_CTX *EVP_MAC_CTX_new(EVP_MAC *mac)
{
#include <openssl/core_numbers.h>
#include "crypto/evp.h"
#include "internal/provider.h"
-#include "evp_locl.h"
+#include "evp_local.h"
static int evp_mac_up_ref(void *vmac)
{
#include <openssl/trace.h>
#include <openssl/core_names.h>
#include "crypto/evp.h"
-#include "evp_locl.h"
+#include "evp_local.h"
int PKCS5_PBKDF2_HMAC(const char *pass, int passlen,
const unsigned char *salt, int saltlen, int iter,
#include <openssl/params.h>
#include <openssl/core_names.h>
#include "crypto/evp.h"
-#include "evp_locl.h"
+#include "evp_local.h"
/* MAC PKEY context structure */
#include "internal/cryptlib.h"
#include "crypto/evp.h"
#include "internal/provider.h"
-#include "evp_locl.h"
+#include "evp_local.h"
static EVP_SIGNATURE *evp_signature_new(OSSL_PROVIDER *prov)
{
#include "crypto/evp.h"
#include "internal/numbers.h"
#include "internal/provider.h"
-#include "evp_locl.h"
+#include "evp_local.h"
typedef const EVP_PKEY_METHOD *(*pmeth_fn)(void);
typedef int sk_cmp_fn_type(const char *const *a, const char *const *b);
#include "internal/cryptlib.h"
#include <openssl/hmac.h>
#include <openssl/opensslconf.h>
-#include "hmac_lcl.h"
+#include "hmac_local.h"
int HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len,
const EVP_MD *md, ENGINE *impl)
+++ /dev/null
-/*
- * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-#ifndef HEADER_HMAC_LCL_H
-# define HEADER_HMAC_LCL_H
-
-/* The current largest case is for SHA3-224 */
-#define HMAC_MAX_MD_CBLOCK_SIZE 144
-
-struct hmac_ctx_st {
- const EVP_MD *md;
- EVP_MD_CTX *md_ctx;
- EVP_MD_CTX *i_ctx;
- EVP_MD_CTX *o_ctx;
- unsigned int key_length;
- unsigned char key[HMAC_MAX_MD_CBLOCK_SIZE];
-};
-
-#endif
--- /dev/null
+/*
+ * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+#ifndef HEADER_HMAC_LCL_H
+# define HEADER_HMAC_LCL_H
+
+/* The current largest case is for SHA3-224 */
+#define HMAC_MAX_MD_CBLOCK_SIZE 144
+
+struct hmac_ctx_st {
+ const EVP_MD *md;
+ EVP_MD_CTX *md_ctx;
+ EVP_MD_CTX *i_ctx;
+ EVP_MD_CTX *o_ctx;
+ unsigned int key_length;
+ unsigned char key[HMAC_MAX_MD_CBLOCK_SIZE];
+};
+
+#endif
*/
#include <openssl/idea.h>
-#include "idea_lcl.h"
+#include "idea_local.h"
void IDEA_cbc_encrypt(const unsigned char *in, unsigned char *out,
long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv,
*/
#include <openssl/idea.h>
-#include "idea_lcl.h"
+#include "idea_local.h"
/*
* The input and output encrypted as though 64bit cfb mode is being used.
*/
#include <openssl/idea.h>
-#include "idea_lcl.h"
+#include "idea_local.h"
#include <openssl/opensslv.h>
const char *IDEA_options(void)
*/
#include <openssl/idea.h>
-#include "idea_lcl.h"
+#include "idea_local.h"
/*
* The input and output encrypted as though 64bit ofb mode is being used.
*/
#include <openssl/idea.h>
-#include "idea_lcl.h"
+#include "idea_local.h"
static IDEA_INT inverse(unsigned int xin);
void IDEA_set_encrypt_key(const unsigned char *key, IDEA_KEY_SCHEDULE *ks)
+++ /dev/null
-/*
- * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-#define idea_mul(r,a,b,ul) \
-ul=(unsigned long)a*b; \
-if (ul != 0) \
- { \
- r=(ul&0xffff)-(ul>>16); \
- r-=((r)>>16); \
- } \
-else \
- r=(-(int)a-b+1); /* assuming a or b is 0 and in range */
-
-/* NOTE - c is not incremented as per n2l */
-#define n2ln(c,l1,l2,n) { \
- c+=n; \
- l1=l2=0; \
- switch (n) { \
- case 8: l2 =((unsigned long)(*(--(c)))) ; \
- /* fall thru */ \
- case 7: l2|=((unsigned long)(*(--(c))))<< 8; \
- /* fall thru */ \
- case 6: l2|=((unsigned long)(*(--(c))))<<16; \
- /* fall thru */ \
- case 5: l2|=((unsigned long)(*(--(c))))<<24; \
- /* fall thru */ \
- case 4: l1 =((unsigned long)(*(--(c)))) ; \
- /* fall thru */ \
- case 3: l1|=((unsigned long)(*(--(c))))<< 8; \
- /* fall thru */ \
- case 2: l1|=((unsigned long)(*(--(c))))<<16; \
- /* fall thru */ \
- case 1: l1|=((unsigned long)(*(--(c))))<<24; \
- } \
- }
-
-/* NOTE - c is not incremented as per l2n */
-#define l2nn(l1,l2,c,n) { \
- c+=n; \
- switch (n) { \
- case 8: *(--(c))=(unsigned char)(((l2) )&0xff); \
- /* fall thru */ \
- case 7: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \
- /* fall thru */ \
- case 6: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \
- /* fall thru */ \
- case 5: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \
- /* fall thru */ \
- case 4: *(--(c))=(unsigned char)(((l1) )&0xff); \
- /* fall thru */ \
- case 3: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \
- /* fall thru */ \
- case 2: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \
- /* fall thru */ \
- case 1: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \
- } \
- }
-
-#undef n2l
-#define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24L, \
- l|=((unsigned long)(*((c)++)))<<16L, \
- l|=((unsigned long)(*((c)++)))<< 8L, \
- l|=((unsigned long)(*((c)++))))
-
-#undef l2n
-#define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \
- *((c)++)=(unsigned char)(((l)>>16L)&0xff), \
- *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
- *((c)++)=(unsigned char)(((l) )&0xff))
-
-#undef s2n
-#define s2n(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \
- *((c)++)=(unsigned char)(((l)>> 8L)&0xff))
-
-#undef n2s
-#define n2s(c,l) (l =((IDEA_INT)(*((c)++)))<< 8L, \
- l|=((IDEA_INT)(*((c)++))) )
-
-
-#define E_IDEA(num) \
- x1&=0xffff; \
- idea_mul(x1,x1,*p,ul); p++; \
- x2+= *(p++); \
- x3+= *(p++); \
- x4&=0xffff; \
- idea_mul(x4,x4,*p,ul); p++; \
- t0=(x1^x3)&0xffff; \
- idea_mul(t0,t0,*p,ul); p++; \
- t1=(t0+(x2^x4))&0xffff; \
- idea_mul(t1,t1,*p,ul); p++; \
- t0+=t1; \
- x1^=t1; \
- x4^=t0; \
- ul=x2^t0; /* do the swap to x3 */ \
- x2=x3^t1; \
- x3=ul;
--- /dev/null
+/*
+ * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+#define idea_mul(r,a,b,ul) \
+ul=(unsigned long)a*b; \
+if (ul != 0) \
+ { \
+ r=(ul&0xffff)-(ul>>16); \
+ r-=((r)>>16); \
+ } \
+else \
+ r=(-(int)a-b+1); /* assuming a or b is 0 and in range */
+
+/* NOTE - c is not incremented as per n2l */
+#define n2ln(c,l1,l2,n) { \
+ c+=n; \
+ l1=l2=0; \
+ switch (n) { \
+ case 8: l2 =((unsigned long)(*(--(c)))) ; \
+ /* fall thru */ \
+ case 7: l2|=((unsigned long)(*(--(c))))<< 8; \
+ /* fall thru */ \
+ case 6: l2|=((unsigned long)(*(--(c))))<<16; \
+ /* fall thru */ \
+ case 5: l2|=((unsigned long)(*(--(c))))<<24; \
+ /* fall thru */ \
+ case 4: l1 =((unsigned long)(*(--(c)))) ; \
+ /* fall thru */ \
+ case 3: l1|=((unsigned long)(*(--(c))))<< 8; \
+ /* fall thru */ \
+ case 2: l1|=((unsigned long)(*(--(c))))<<16; \
+ /* fall thru */ \
+ case 1: l1|=((unsigned long)(*(--(c))))<<24; \
+ } \
+ }
+
+/* NOTE - c is not incremented as per l2n */
+#define l2nn(l1,l2,c,n) { \
+ c+=n; \
+ switch (n) { \
+ case 8: *(--(c))=(unsigned char)(((l2) )&0xff); \
+ /* fall thru */ \
+ case 7: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \
+ /* fall thru */ \
+ case 6: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \
+ /* fall thru */ \
+ case 5: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \
+ /* fall thru */ \
+ case 4: *(--(c))=(unsigned char)(((l1) )&0xff); \
+ /* fall thru */ \
+ case 3: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \
+ /* fall thru */ \
+ case 2: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \
+ /* fall thru */ \
+ case 1: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \
+ } \
+ }
+
+#undef n2l
+#define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24L, \
+ l|=((unsigned long)(*((c)++)))<<16L, \
+ l|=((unsigned long)(*((c)++)))<< 8L, \
+ l|=((unsigned long)(*((c)++))))
+
+#undef l2n
+#define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \
+ *((c)++)=(unsigned char)(((l)>>16L)&0xff), \
+ *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
+ *((c)++)=(unsigned char)(((l) )&0xff))
+
+#undef s2n
+#define s2n(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \
+ *((c)++)=(unsigned char)(((l)>> 8L)&0xff))
+
+#undef n2s
+#define n2s(c,l) (l =((IDEA_INT)(*((c)++)))<< 8L, \
+ l|=((IDEA_INT)(*((c)++))) )
+
+
+#define E_IDEA(num) \
+ x1&=0xffff; \
+ idea_mul(x1,x1,*p,ul); p++; \
+ x2+= *(p++); \
+ x3+= *(p++); \
+ x4&=0xffff; \
+ idea_mul(x4,x4,*p,ul); p++; \
+ t0=(x1^x3)&0xffff; \
+ idea_mul(t0,t0,*p,ul); p++; \
+ t1=(t0+(x2^x4))&0xffff; \
+ idea_mul(t1,t1,*p,ul); p++; \
+ t0+=t1; \
+ x1^=t1; \
+ x4^=t0; \
+ ul=x2^t0; /* do the swap to x3 */ \
+ x2=x3^t1; \
+ x3=ul;
#include <openssl/bio.h>
#include <openssl/lhash.h>
-#include "lhash_lcl.h"
+#include "lhash_local.h"
# ifndef OPENSSL_NO_STDIO
void OPENSSL_LH_stats(const OPENSSL_LHASH *lh, FILE *fp)
#include <openssl/err.h>
#include "crypto/ctype.h"
#include "crypto/lhash.h"
-#include "lhash_lcl.h"
+#include "lhash_local.h"
/*
* A hashing implementation that appears to be based on the linear hashing
+++ /dev/null
-/*
- * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-#include <openssl/crypto.h>
-
-#include "internal/tsan_assist.h"
-
-struct lhash_node_st {
- void *data;
- struct lhash_node_st *next;
- unsigned long hash;
-};
-
-struct lhash_st {
- OPENSSL_LH_NODE **b;
- OPENSSL_LH_COMPFUNC comp;
- OPENSSL_LH_HASHFUNC hash;
- unsigned int num_nodes;
- unsigned int num_alloc_nodes;
- unsigned int p;
- unsigned int pmax;
- unsigned long up_load; /* load times 256 */
- unsigned long down_load; /* load times 256 */
- unsigned long num_items;
- unsigned long num_expands;
- unsigned long num_expand_reallocs;
- unsigned long num_contracts;
- unsigned long num_contract_reallocs;
- TSAN_QUALIFIER unsigned long num_hash_calls;
- TSAN_QUALIFIER unsigned long num_comp_calls;
- unsigned long num_insert;
- unsigned long num_replace;
- unsigned long num_delete;
- unsigned long num_no_delete;
- TSAN_QUALIFIER unsigned long num_retrieve;
- TSAN_QUALIFIER unsigned long num_retrieve_miss;
- TSAN_QUALIFIER unsigned long num_hash_comps;
- int error;
-};
--- /dev/null
+/*
+ * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+#include <openssl/crypto.h>
+
+#include "internal/tsan_assist.h"
+
+struct lhash_node_st {
+ void *data;
+ struct lhash_node_st *next;
+ unsigned long hash;
+};
+
+struct lhash_st {
+ OPENSSL_LH_NODE **b;
+ OPENSSL_LH_COMPFUNC comp;
+ OPENSSL_LH_HASHFUNC hash;
+ unsigned int num_nodes;
+ unsigned int num_alloc_nodes;
+ unsigned int p;
+ unsigned int pmax;
+ unsigned long up_load; /* load times 256 */
+ unsigned long down_load; /* load times 256 */
+ unsigned long num_items;
+ unsigned long num_expands;
+ unsigned long num_expand_reallocs;
+ unsigned long num_contracts;
+ unsigned long num_contract_reallocs;
+ TSAN_QUALIFIER unsigned long num_hash_calls;
+ TSAN_QUALIFIER unsigned long num_comp_calls;
+ unsigned long num_insert;
+ unsigned long num_replace;
+ unsigned long num_delete;
+ unsigned long num_no_delete;
+ TSAN_QUALIFIER unsigned long num_retrieve;
+ TSAN_QUALIFIER unsigned long num_retrieve_miss;
+ TSAN_QUALIFIER unsigned long num_hash_comps;
+ int error;
+};
#include <stdio.h>
#include <openssl/opensslv.h>
-#include "md4_locl.h"
+#include "md4_local.h"
/*
* Implemented from RFC1186 The MD4 Message-Digest Algorithm
const unsigned char *data = data_;
register unsigned MD32_REG_T A, B, C, D, l;
# ifndef MD32_XARRAY
- /* See comment in crypto/sha/sha_locl.h for details. */
+ /* See comment in crypto/sha/sha_local.h for details. */
unsigned MD32_REG_T XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7,
XX8, XX9, XX10, XX11, XX12, XX13, XX14, XX15;
# define X(i) XX##i
--- /dev/null
+/*
+ * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <openssl/opensslconf.h>
+#include <openssl/md4.h>
+
+void md4_block_data_order(MD4_CTX *c, const void *p, size_t num);
+
+#define DATA_ORDER_IS_LITTLE_ENDIAN
+
+#define HASH_LONG MD4_LONG
+#define HASH_CTX MD4_CTX
+#define HASH_CBLOCK MD4_CBLOCK
+#define HASH_UPDATE MD4_Update
+#define HASH_TRANSFORM MD4_Transform
+#define HASH_FINAL MD4_Final
+#define HASH_MAKE_STRING(c,s) do { \
+ unsigned long ll; \
+ ll=(c)->A; (void)HOST_l2c(ll,(s)); \
+ ll=(c)->B; (void)HOST_l2c(ll,(s)); \
+ ll=(c)->C; (void)HOST_l2c(ll,(s)); \
+ ll=(c)->D; (void)HOST_l2c(ll,(s)); \
+ } while (0)
+#define HASH_BLOCK_DATA_ORDER md4_block_data_order
+
+#include "crypto/md32_common.h"
+
+/*-
+#define F(x,y,z) (((x) & (y)) | ((~(x)) & (z)))
+#define G(x,y,z) (((x) & (y)) | ((x) & ((z))) | ((y) & ((z))))
+*/
+
+/*
+ * As pointed out by Wei Dai, the above can be simplified to the code
+ * below. Wei attributes these optimizations to Peter Gutmann's SHS code,
+ * and he attributes it to Rich Schroeppel.
+ */
+#define F(b,c,d) ((((c) ^ (d)) & (b)) ^ (d))
+#define G(b,c,d) (((b) & (c)) | ((b) & (d)) | ((c) & (d)))
+#define H(b,c,d) ((b) ^ (c) ^ (d))
+
+#define R0(a,b,c,d,k,s,t) { \
+ a+=((k)+(t)+F((b),(c),(d))); \
+ a=ROTATE(a,s); };
+
+#define R1(a,b,c,d,k,s,t) { \
+ a+=((k)+(t)+G((b),(c),(d))); \
+ a=ROTATE(a,s); };\
+
+#define R2(a,b,c,d,k,s,t) { \
+ a+=((k)+(t)+H((b),(c),(d))); \
+ a=ROTATE(a,s); };
+++ /dev/null
-/*
- * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include <openssl/opensslconf.h>
-#include <openssl/md4.h>
-
-void md4_block_data_order(MD4_CTX *c, const void *p, size_t num);
-
-#define DATA_ORDER_IS_LITTLE_ENDIAN
-
-#define HASH_LONG MD4_LONG
-#define HASH_CTX MD4_CTX
-#define HASH_CBLOCK MD4_CBLOCK
-#define HASH_UPDATE MD4_Update
-#define HASH_TRANSFORM MD4_Transform
-#define HASH_FINAL MD4_Final
-#define HASH_MAKE_STRING(c,s) do { \
- unsigned long ll; \
- ll=(c)->A; (void)HOST_l2c(ll,(s)); \
- ll=(c)->B; (void)HOST_l2c(ll,(s)); \
- ll=(c)->C; (void)HOST_l2c(ll,(s)); \
- ll=(c)->D; (void)HOST_l2c(ll,(s)); \
- } while (0)
-#define HASH_BLOCK_DATA_ORDER md4_block_data_order
-
-#include "crypto/md32_common.h"
-
-/*-
-#define F(x,y,z) (((x) & (y)) | ((~(x)) & (z)))
-#define G(x,y,z) (((x) & (y)) | ((x) & ((z))) | ((y) & ((z))))
-*/
-
-/*
- * As pointed out by Wei Dai, the above can be simplified to the code
- * below. Wei attributes these optimizations to Peter Gutmann's SHS code,
- * and he attributes it to Rich Schroeppel.
- */
-#define F(b,c,d) ((((c) ^ (d)) & (b)) ^ (d))
-#define G(b,c,d) (((b) & (c)) | ((b) & (d)) | ((c) & (d)))
-#define H(b,c,d) ((b) ^ (c) ^ (d))
-
-#define R0(a,b,c,d,k,s,t) { \
- a+=((k)+(t)+F((b),(c),(d))); \
- a=ROTATE(a,s); };
-
-#define R1(a,b,c,d,k,s,t) { \
- a+=((k)+(t)+G((b),(c),(d))); \
- a=ROTATE(a,s); };\
-
-#define R2(a,b,c,d,k,s,t) { \
- a+=((k)+(t)+H((b),(c),(d))); \
- a=ROTATE(a,s); };
*/
#include <stdio.h>
-#include "md5_locl.h"
+#include "md5_local.h"
#include <openssl/opensslv.h>
/*
const unsigned char *data = data_;
register unsigned MD32_REG_T A, B, C, D, l;
# ifndef MD32_XARRAY
- /* See comment in crypto/sha/sha_locl.h for details. */
+ /* See comment in crypto/sha/sha_local.h for details. */
unsigned MD32_REG_T XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7,
XX8, XX9, XX10, XX11, XX12, XX13, XX14, XX15;
# define X(i) XX##i
--- /dev/null
+/*
+ * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <openssl/e_os2.h>
+#include <openssl/md5.h>
+
+#ifdef MD5_ASM
+# if defined(__i386) || defined(__i386__) || defined(_M_IX86) || \
+ defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || defined(_M_X64)
+# define md5_block_data_order md5_block_asm_data_order
+# elif defined(__ia64) || defined(__ia64__) || defined(_M_IA64)
+# define md5_block_data_order md5_block_asm_data_order
+# elif defined(__sparc) || defined(__sparc__)
+# define md5_block_data_order md5_block_asm_data_order
+# endif
+#endif
+
+void md5_block_data_order(MD5_CTX *c, const void *p, size_t num);
+
+#define DATA_ORDER_IS_LITTLE_ENDIAN
+
+#define HASH_LONG MD5_LONG
+#define HASH_CTX MD5_CTX
+#define HASH_CBLOCK MD5_CBLOCK
+#define HASH_UPDATE MD5_Update
+#define HASH_TRANSFORM MD5_Transform
+#define HASH_FINAL MD5_Final
+#define HASH_MAKE_STRING(c,s) do { \
+ unsigned long ll; \
+ ll=(c)->A; (void)HOST_l2c(ll,(s)); \
+ ll=(c)->B; (void)HOST_l2c(ll,(s)); \
+ ll=(c)->C; (void)HOST_l2c(ll,(s)); \
+ ll=(c)->D; (void)HOST_l2c(ll,(s)); \
+ } while (0)
+#define HASH_BLOCK_DATA_ORDER md5_block_data_order
+
+#include "crypto/md32_common.h"
+
+/*-
+#define F(x,y,z) (((x) & (y)) | ((~(x)) & (z)))
+#define G(x,y,z) (((x) & (z)) | ((y) & (~(z))))
+*/
+
+/*
+ * As pointed out by Wei Dai, the above can be simplified to the code
+ * below. Wei attributes these optimizations to Peter Gutmann's
+ * SHS code, and he attributes it to Rich Schroeppel.
+ */
+#define F(b,c,d) ((((c) ^ (d)) & (b)) ^ (d))
+#define G(b,c,d) ((((b) ^ (c)) & (d)) ^ (c))
+#define H(b,c,d) ((b) ^ (c) ^ (d))
+#define I(b,c,d) (((~(d)) | (b)) ^ (c))
+
+#define R0(a,b,c,d,k,s,t) { \
+ a+=((k)+(t)+F((b),(c),(d))); \
+ a=ROTATE(a,s); \
+ a+=b; };\
+
+#define R1(a,b,c,d,k,s,t) { \
+ a+=((k)+(t)+G((b),(c),(d))); \
+ a=ROTATE(a,s); \
+ a+=b; };
+
+#define R2(a,b,c,d,k,s,t) { \
+ a+=((k)+(t)+H((b),(c),(d))); \
+ a=ROTATE(a,s); \
+ a+=b; };
+
+#define R3(a,b,c,d,k,s,t) { \
+ a+=((k)+(t)+I((b),(c),(d))); \
+ a=ROTATE(a,s); \
+ a+=b; };
+++ /dev/null
-/*
- * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include <openssl/e_os2.h>
-#include <openssl/md5.h>
-
-#ifdef MD5_ASM
-# if defined(__i386) || defined(__i386__) || defined(_M_IX86) || \
- defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || defined(_M_X64)
-# define md5_block_data_order md5_block_asm_data_order
-# elif defined(__ia64) || defined(__ia64__) || defined(_M_IA64)
-# define md5_block_data_order md5_block_asm_data_order
-# elif defined(__sparc) || defined(__sparc__)
-# define md5_block_data_order md5_block_asm_data_order
-# endif
-#endif
-
-void md5_block_data_order(MD5_CTX *c, const void *p, size_t num);
-
-#define DATA_ORDER_IS_LITTLE_ENDIAN
-
-#define HASH_LONG MD5_LONG
-#define HASH_CTX MD5_CTX
-#define HASH_CBLOCK MD5_CBLOCK
-#define HASH_UPDATE MD5_Update
-#define HASH_TRANSFORM MD5_Transform
-#define HASH_FINAL MD5_Final
-#define HASH_MAKE_STRING(c,s) do { \
- unsigned long ll; \
- ll=(c)->A; (void)HOST_l2c(ll,(s)); \
- ll=(c)->B; (void)HOST_l2c(ll,(s)); \
- ll=(c)->C; (void)HOST_l2c(ll,(s)); \
- ll=(c)->D; (void)HOST_l2c(ll,(s)); \
- } while (0)
-#define HASH_BLOCK_DATA_ORDER md5_block_data_order
-
-#include "crypto/md32_common.h"
-
-/*-
-#define F(x,y,z) (((x) & (y)) | ((~(x)) & (z)))
-#define G(x,y,z) (((x) & (z)) | ((y) & (~(z))))
-*/
-
-/*
- * As pointed out by Wei Dai, the above can be simplified to the code
- * below. Wei attributes these optimizations to Peter Gutmann's
- * SHS code, and he attributes it to Rich Schroeppel.
- */
-#define F(b,c,d) ((((c) ^ (d)) & (b)) ^ (d))
-#define G(b,c,d) ((((b) ^ (c)) & (d)) ^ (c))
-#define H(b,c,d) ((b) ^ (c) ^ (d))
-#define I(b,c,d) (((~(d)) | (b)) ^ (c))
-
-#define R0(a,b,c,d,k,s,t) { \
- a+=((k)+(t)+F((b),(c),(d))); \
- a=ROTATE(a,s); \
- a+=b; };\
-
-#define R1(a,b,c,d,k,s,t) { \
- a+=((k)+(t)+G((b),(c),(d))); \
- a=ROTATE(a,s); \
- a+=b; };
-
-#define R2(a,b,c,d,k,s,t) { \
- a+=((k)+(t)+H((b),(c),(d))); \
- a=ROTATE(a,s); \
- a+=b; };
-
-#define R3(a,b,c,d,k,s,t) { \
- a+=((k)+(t)+I((b),(c),(d))); \
- a=ROTATE(a,s); \
- a+=b; };
#include <openssl/e_os2.h>
#include "internal/thread_once.h"
#include "crypto/lhash.h"
-#include "obj_lcl.h"
+#include "obj_local.h"
#include "e_os.h"
/*
#include "crypto/objects.h"
#include <openssl/bn.h>
#include "crypto/asn1.h"
-#include "obj_lcl.h"
+#include "obj_local.h"
/* obj_dat.h is generated from objects.h by obj_dat.pl */
#include "obj_dat.h"
+++ /dev/null
-/*
- * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-typedef struct name_funcs_st NAME_FUNCS;
-DEFINE_STACK_OF(NAME_FUNCS)
-DEFINE_LHASH_OF(OBJ_NAME);
-typedef struct added_obj_st ADDED_OBJ;
-DEFINE_LHASH_OF(ADDED_OBJ);
--- /dev/null
+/*
+ * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+typedef struct name_funcs_st NAME_FUNCS;
+DEFINE_STACK_OF(NAME_FUNCS)
+DEFINE_LHASH_OF(OBJ_NAME);
+typedef struct added_obj_st ADDED_OBJ;
+DEFINE_LHASH_OF(ADDED_OBJ);
#include <openssl/asn1.h>
#include <openssl/asn1t.h>
#include <openssl/ocsp.h>
-#include "ocsp_lcl.h"
+#include "ocsp_local.h"
ASN1_SEQUENCE(OCSP_SIGNATURE) = {
ASN1_EMBED(OCSP_SIGNATURE, signatureAlgorithm, X509_ALGOR),
#include <openssl/pem.h>
#include <openssl/x509v3.h>
#include <openssl/ocsp.h>
-#include "ocsp_lcl.h"
+#include "ocsp_local.h"
/*
* Utility functions related to sending OCSP requests and extracting relevant
#include <openssl/objects.h>
#include <openssl/x509.h>
#include <openssl/ocsp.h>
-#include "ocsp_lcl.h"
+#include "ocsp_local.h"
#include <openssl/rand.h>
#include <openssl/x509v3.h>
+++ /dev/null
-/*
- * Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-/*- CertID ::= SEQUENCE {
- * hashAlgorithm AlgorithmIdentifier,
- * issuerNameHash OCTET STRING, -- Hash of Issuer's DN
- * issuerKeyHash OCTET STRING, -- Hash of Issuers public key (excluding the tag & length fields)
- * serialNumber CertificateSerialNumber }
- */
-struct ocsp_cert_id_st {
- X509_ALGOR hashAlgorithm;
- ASN1_OCTET_STRING issuerNameHash;
- ASN1_OCTET_STRING issuerKeyHash;
- ASN1_INTEGER serialNumber;
-};
-
-/*- Request ::= SEQUENCE {
- * reqCert CertID,
- * singleRequestExtensions [0] EXPLICIT Extensions OPTIONAL }
- */
-struct ocsp_one_request_st {
- OCSP_CERTID *reqCert;
- STACK_OF(X509_EXTENSION) *singleRequestExtensions;
-};
-
-/*- TBSRequest ::= SEQUENCE {
- * version [0] EXPLICIT Version DEFAULT v1,
- * requestorName [1] EXPLICIT GeneralName OPTIONAL,
- * requestList SEQUENCE OF Request,
- * requestExtensions [2] EXPLICIT Extensions OPTIONAL }
- */
-struct ocsp_req_info_st {
- ASN1_INTEGER *version;
- GENERAL_NAME *requestorName;
- STACK_OF(OCSP_ONEREQ) *requestList;
- STACK_OF(X509_EXTENSION) *requestExtensions;
-};
-
-/*- Signature ::= SEQUENCE {
- * signatureAlgorithm AlgorithmIdentifier,
- * signature BIT STRING,
- * certs [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL }
- */
-struct ocsp_signature_st {
- X509_ALGOR signatureAlgorithm;
- ASN1_BIT_STRING *signature;
- STACK_OF(X509) *certs;
-};
-
-/*- OCSPRequest ::= SEQUENCE {
- * tbsRequest TBSRequest,
- * optionalSignature [0] EXPLICIT Signature OPTIONAL }
- */
-struct ocsp_request_st {
- OCSP_REQINFO tbsRequest;
- OCSP_SIGNATURE *optionalSignature; /* OPTIONAL */
-};
-
-/*- OCSPResponseStatus ::= ENUMERATED {
- * successful (0), --Response has valid confirmations
- * malformedRequest (1), --Illegal confirmation request
- * internalError (2), --Internal error in issuer
- * tryLater (3), --Try again later
- * --(4) is not used
- * sigRequired (5), --Must sign the request
- * unauthorized (6) --Request unauthorized
- * }
- */
-
-/*- ResponseBytes ::= SEQUENCE {
- * responseType OBJECT IDENTIFIER,
- * response OCTET STRING }
- */
-struct ocsp_resp_bytes_st {
- ASN1_OBJECT *responseType;
- ASN1_OCTET_STRING *response;
-};
-
-/*- OCSPResponse ::= SEQUENCE {
- * responseStatus OCSPResponseStatus,
- * responseBytes [0] EXPLICIT ResponseBytes OPTIONAL }
- */
-struct ocsp_response_st {
- ASN1_ENUMERATED *responseStatus;
- OCSP_RESPBYTES *responseBytes;
-};
-
-/*- ResponderID ::= CHOICE {
- * byName [1] Name,
- * byKey [2] KeyHash }
- */
-struct ocsp_responder_id_st {
- int type;
- union {
- X509_NAME *byName;
- ASN1_OCTET_STRING *byKey;
- } value;
-};
-
-/*- KeyHash ::= OCTET STRING --SHA-1 hash of responder's public key
- * --(excluding the tag and length fields)
- */
-
-/*- RevokedInfo ::= SEQUENCE {
- * revocationTime GeneralizedTime,
- * revocationReason [0] EXPLICIT CRLReason OPTIONAL }
- */
-struct ocsp_revoked_info_st {
- ASN1_GENERALIZEDTIME *revocationTime;
- ASN1_ENUMERATED *revocationReason;
-};
-
-/*- CertStatus ::= CHOICE {
- * good [0] IMPLICIT NULL,
- * revoked [1] IMPLICIT RevokedInfo,
- * unknown [2] IMPLICIT UnknownInfo }
- */
-struct ocsp_cert_status_st {
- int type;
- union {
- ASN1_NULL *good;
- OCSP_REVOKEDINFO *revoked;
- ASN1_NULL *unknown;
- } value;
-};
-
-/*- SingleResponse ::= SEQUENCE {
- * certID CertID,
- * certStatus CertStatus,
- * thisUpdate GeneralizedTime,
- * nextUpdate [0] EXPLICIT GeneralizedTime OPTIONAL,
- * singleExtensions [1] EXPLICIT Extensions OPTIONAL }
- */
-struct ocsp_single_response_st {
- OCSP_CERTID *certId;
- OCSP_CERTSTATUS *certStatus;
- ASN1_GENERALIZEDTIME *thisUpdate;
- ASN1_GENERALIZEDTIME *nextUpdate;
- STACK_OF(X509_EXTENSION) *singleExtensions;
-};
-
-/*- ResponseData ::= SEQUENCE {
- * version [0] EXPLICIT Version DEFAULT v1,
- * responderID ResponderID,
- * producedAt GeneralizedTime,
- * responses SEQUENCE OF SingleResponse,
- * responseExtensions [1] EXPLICIT Extensions OPTIONAL }
- */
-struct ocsp_response_data_st {
- ASN1_INTEGER *version;
- OCSP_RESPID responderId;
- ASN1_GENERALIZEDTIME *producedAt;
- STACK_OF(OCSP_SINGLERESP) *responses;
- STACK_OF(X509_EXTENSION) *responseExtensions;
-};
-
-/*- BasicOCSPResponse ::= SEQUENCE {
- * tbsResponseData ResponseData,
- * signatureAlgorithm AlgorithmIdentifier,
- * signature BIT STRING,
- * certs [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL }
- */
- /*
- * Note 1: The value for "signature" is specified in the OCSP rfc2560 as
- * follows: "The value for the signature SHALL be computed on the hash of
- * the DER encoding ResponseData." This means that you must hash the
- * DER-encoded tbsResponseData, and then run it through a crypto-signing
- * function, which will (at least w/RSA) do a hash-'n'-private-encrypt
- * operation. This seems a bit odd, but that's the spec. Also note that
- * the data structures do not leave anywhere to independently specify the
- * algorithm used for the initial hash. So, we look at the
- * signature-specification algorithm, and try to do something intelligent.
- * -- Kathy Weinhold, CertCo
- */
- /*
- * Note 2: It seems that the mentioned passage from RFC 2560 (section
- * 4.2.1) is open for interpretation. I've done tests against another
- * responder, and found that it doesn't do the double hashing that the RFC
- * seems to say one should. Therefore, all relevant functions take a flag
- * saying which variant should be used. -- Richard Levitte, OpenSSL team
- * and CeloCom
- */
-struct ocsp_basic_response_st {
- OCSP_RESPDATA tbsResponseData;
- X509_ALGOR signatureAlgorithm;
- ASN1_BIT_STRING *signature;
- STACK_OF(X509) *certs;
-};
-
-/*-
- * CrlID ::= SEQUENCE {
- * crlUrl [0] EXPLICIT IA5String OPTIONAL,
- * crlNum [1] EXPLICIT INTEGER OPTIONAL,
- * crlTime [2] EXPLICIT GeneralizedTime OPTIONAL }
- */
-struct ocsp_crl_id_st {
- ASN1_IA5STRING *crlUrl;
- ASN1_INTEGER *crlNum;
- ASN1_GENERALIZEDTIME *crlTime;
-};
-
-/*-
- * ServiceLocator ::= SEQUENCE {
- * issuer Name,
- * locator AuthorityInfoAccessSyntax OPTIONAL }
- */
-struct ocsp_service_locator_st {
- X509_NAME *issuer;
- STACK_OF(ACCESS_DESCRIPTION) *locator;
-};
-
-# define OCSP_REQUEST_sign(o,pkey,md) \
- ASN1_item_sign(ASN1_ITEM_rptr(OCSP_REQINFO),\
- &(o)->optionalSignature->signatureAlgorithm,NULL,\
- (o)->optionalSignature->signature,&(o)->tbsRequest,pkey,md)
-
-# define OCSP_BASICRESP_sign(o,pkey,md,d) \
- ASN1_item_sign(ASN1_ITEM_rptr(OCSP_RESPDATA),&(o)->signatureAlgorithm,\
- NULL,(o)->signature,&(o)->tbsResponseData,pkey,md)
-
-# define OCSP_BASICRESP_sign_ctx(o,ctx,d) \
- ASN1_item_sign_ctx(ASN1_ITEM_rptr(OCSP_RESPDATA),&(o)->signatureAlgorithm,\
- NULL,(o)->signature,&(o)->tbsResponseData,ctx)
-
-# define OCSP_REQUEST_verify(a,r) ASN1_item_verify(ASN1_ITEM_rptr(OCSP_REQINFO),\
- &(a)->optionalSignature->signatureAlgorithm,\
- (a)->optionalSignature->signature,&(a)->tbsRequest,r)
-
-# define OCSP_BASICRESP_verify(a,r,d) ASN1_item_verify(ASN1_ITEM_rptr(OCSP_RESPDATA),\
- &(a)->signatureAlgorithm,(a)->signature,&(a)->tbsResponseData,r)
#include <openssl/pem.h>
#include <openssl/x509v3.h>
#include <openssl/ocsp.h>
-#include "ocsp_lcl.h"
+#include "ocsp_local.h"
#include <openssl/asn1t.h>
/* Convert a certificate and its issuer to an OCSP_CERTID */
--- /dev/null
+/*
+ * Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+/*- CertID ::= SEQUENCE {
+ * hashAlgorithm AlgorithmIdentifier,
+ * issuerNameHash OCTET STRING, -- Hash of Issuer's DN
+ * issuerKeyHash OCTET STRING, -- Hash of Issuers public key (excluding the tag & length fields)
+ * serialNumber CertificateSerialNumber }
+ */
+struct ocsp_cert_id_st {
+ X509_ALGOR hashAlgorithm;
+ ASN1_OCTET_STRING issuerNameHash;
+ ASN1_OCTET_STRING issuerKeyHash;
+ ASN1_INTEGER serialNumber;
+};
+
+/*- Request ::= SEQUENCE {
+ * reqCert CertID,
+ * singleRequestExtensions [0] EXPLICIT Extensions OPTIONAL }
+ */
+struct ocsp_one_request_st {
+ OCSP_CERTID *reqCert;
+ STACK_OF(X509_EXTENSION) *singleRequestExtensions;
+};
+
+/*- TBSRequest ::= SEQUENCE {
+ * version [0] EXPLICIT Version DEFAULT v1,
+ * requestorName [1] EXPLICIT GeneralName OPTIONAL,
+ * requestList SEQUENCE OF Request,
+ * requestExtensions [2] EXPLICIT Extensions OPTIONAL }
+ */
+struct ocsp_req_info_st {
+ ASN1_INTEGER *version;
+ GENERAL_NAME *requestorName;
+ STACK_OF(OCSP_ONEREQ) *requestList;
+ STACK_OF(X509_EXTENSION) *requestExtensions;
+};
+
+/*- Signature ::= SEQUENCE {
+ * signatureAlgorithm AlgorithmIdentifier,
+ * signature BIT STRING,
+ * certs [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL }
+ */
+struct ocsp_signature_st {
+ X509_ALGOR signatureAlgorithm;
+ ASN1_BIT_STRING *signature;
+ STACK_OF(X509) *certs;
+};
+
+/*- OCSPRequest ::= SEQUENCE {
+ * tbsRequest TBSRequest,
+ * optionalSignature [0] EXPLICIT Signature OPTIONAL }
+ */
+struct ocsp_request_st {
+ OCSP_REQINFO tbsRequest;
+ OCSP_SIGNATURE *optionalSignature; /* OPTIONAL */
+};
+
+/*- OCSPResponseStatus ::= ENUMERATED {
+ * successful (0), --Response has valid confirmations
+ * malformedRequest (1), --Illegal confirmation request
+ * internalError (2), --Internal error in issuer
+ * tryLater (3), --Try again later
+ * --(4) is not used
+ * sigRequired (5), --Must sign the request
+ * unauthorized (6) --Request unauthorized
+ * }
+ */
+
+/*- ResponseBytes ::= SEQUENCE {
+ * responseType OBJECT IDENTIFIER,
+ * response OCTET STRING }
+ */
+struct ocsp_resp_bytes_st {
+ ASN1_OBJECT *responseType;
+ ASN1_OCTET_STRING *response;
+};
+
+/*- OCSPResponse ::= SEQUENCE {
+ * responseStatus OCSPResponseStatus,
+ * responseBytes [0] EXPLICIT ResponseBytes OPTIONAL }
+ */
+struct ocsp_response_st {
+ ASN1_ENUMERATED *responseStatus;
+ OCSP_RESPBYTES *responseBytes;
+};
+
+/*- ResponderID ::= CHOICE {
+ * byName [1] Name,
+ * byKey [2] KeyHash }
+ */
+struct ocsp_responder_id_st {
+ int type;
+ union {
+ X509_NAME *byName;
+ ASN1_OCTET_STRING *byKey;
+ } value;
+};
+
+/*- KeyHash ::= OCTET STRING --SHA-1 hash of responder's public key
+ * --(excluding the tag and length fields)
+ */
+
+/*- RevokedInfo ::= SEQUENCE {
+ * revocationTime GeneralizedTime,
+ * revocationReason [0] EXPLICIT CRLReason OPTIONAL }
+ */
+struct ocsp_revoked_info_st {
+ ASN1_GENERALIZEDTIME *revocationTime;
+ ASN1_ENUMERATED *revocationReason;
+};
+
+/*- CertStatus ::= CHOICE {
+ * good [0] IMPLICIT NULL,
+ * revoked [1] IMPLICIT RevokedInfo,
+ * unknown [2] IMPLICIT UnknownInfo }
+ */
+struct ocsp_cert_status_st {
+ int type;
+ union {
+ ASN1_NULL *good;
+ OCSP_REVOKEDINFO *revoked;
+ ASN1_NULL *unknown;
+ } value;
+};
+
+/*- SingleResponse ::= SEQUENCE {
+ * certID CertID,
+ * certStatus CertStatus,
+ * thisUpdate GeneralizedTime,
+ * nextUpdate [0] EXPLICIT GeneralizedTime OPTIONAL,
+ * singleExtensions [1] EXPLICIT Extensions OPTIONAL }
+ */
+struct ocsp_single_response_st {
+ OCSP_CERTID *certId;
+ OCSP_CERTSTATUS *certStatus;
+ ASN1_GENERALIZEDTIME *thisUpdate;
+ ASN1_GENERALIZEDTIME *nextUpdate;
+ STACK_OF(X509_EXTENSION) *singleExtensions;
+};
+
+/*- ResponseData ::= SEQUENCE {
+ * version [0] EXPLICIT Version DEFAULT v1,
+ * responderID ResponderID,
+ * producedAt GeneralizedTime,
+ * responses SEQUENCE OF SingleResponse,
+ * responseExtensions [1] EXPLICIT Extensions OPTIONAL }
+ */
+struct ocsp_response_data_st {
+ ASN1_INTEGER *version;
+ OCSP_RESPID responderId;
+ ASN1_GENERALIZEDTIME *producedAt;
+ STACK_OF(OCSP_SINGLERESP) *responses;
+ STACK_OF(X509_EXTENSION) *responseExtensions;
+};
+
+/*- BasicOCSPResponse ::= SEQUENCE {
+ * tbsResponseData ResponseData,
+ * signatureAlgorithm AlgorithmIdentifier,
+ * signature BIT STRING,
+ * certs [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL }
+ */
+ /*
+ * Note 1: The value for "signature" is specified in the OCSP rfc2560 as
+ * follows: "The value for the signature SHALL be computed on the hash of
+ * the DER encoding ResponseData." This means that you must hash the
+ * DER-encoded tbsResponseData, and then run it through a crypto-signing
+ * function, which will (at least w/RSA) do a hash-'n'-private-encrypt
+ * operation. This seems a bit odd, but that's the spec. Also note that
+ * the data structures do not leave anywhere to independently specify the
+ * algorithm used for the initial hash. So, we look at the
+ * signature-specification algorithm, and try to do something intelligent.
+ * -- Kathy Weinhold, CertCo
+ */
+ /*
+ * Note 2: It seems that the mentioned passage from RFC 2560 (section
+ * 4.2.1) is open for interpretation. I've done tests against another
+ * responder, and found that it doesn't do the double hashing that the RFC
+ * seems to say one should. Therefore, all relevant functions take a flag
+ * saying which variant should be used. -- Richard Levitte, OpenSSL team
+ * and CeloCom
+ */
+struct ocsp_basic_response_st {
+ OCSP_RESPDATA tbsResponseData;
+ X509_ALGOR signatureAlgorithm;
+ ASN1_BIT_STRING *signature;
+ STACK_OF(X509) *certs;
+};
+
+/*-
+ * CrlID ::= SEQUENCE {
+ * crlUrl [0] EXPLICIT IA5String OPTIONAL,
+ * crlNum [1] EXPLICIT INTEGER OPTIONAL,
+ * crlTime [2] EXPLICIT GeneralizedTime OPTIONAL }
+ */
+struct ocsp_crl_id_st {
+ ASN1_IA5STRING *crlUrl;
+ ASN1_INTEGER *crlNum;
+ ASN1_GENERALIZEDTIME *crlTime;
+};
+
+/*-
+ * ServiceLocator ::= SEQUENCE {
+ * issuer Name,
+ * locator AuthorityInfoAccessSyntax OPTIONAL }
+ */
+struct ocsp_service_locator_st {
+ X509_NAME *issuer;
+ STACK_OF(ACCESS_DESCRIPTION) *locator;
+};
+
+# define OCSP_REQUEST_sign(o,pkey,md) \
+ ASN1_item_sign(ASN1_ITEM_rptr(OCSP_REQINFO),\
+ &(o)->optionalSignature->signatureAlgorithm,NULL,\
+ (o)->optionalSignature->signature,&(o)->tbsRequest,pkey,md)
+
+# define OCSP_BASICRESP_sign(o,pkey,md,d) \
+ ASN1_item_sign(ASN1_ITEM_rptr(OCSP_RESPDATA),&(o)->signatureAlgorithm,\
+ NULL,(o)->signature,&(o)->tbsResponseData,pkey,md)
+
+# define OCSP_BASICRESP_sign_ctx(o,ctx,d) \
+ ASN1_item_sign_ctx(ASN1_ITEM_rptr(OCSP_RESPDATA),&(o)->signatureAlgorithm,\
+ NULL,(o)->signature,&(o)->tbsResponseData,ctx)
+
+# define OCSP_REQUEST_verify(a,r) ASN1_item_verify(ASN1_ITEM_rptr(OCSP_REQINFO),\
+ &(a)->optionalSignature->signatureAlgorithm,\
+ (a)->optionalSignature->signature,&(a)->tbsRequest,r)
+
+# define OCSP_BASICRESP_verify(a,r,d) ASN1_item_verify(ASN1_ITEM_rptr(OCSP_RESPDATA),\
+ &(a)->signatureAlgorithm,(a)->signature,&(a)->tbsResponseData,r)
#include <openssl/bio.h>
#include <openssl/err.h>
#include <openssl/ocsp.h>
-#include "ocsp_lcl.h"
+#include "ocsp_local.h"
#include "internal/cryptlib.h"
#include <openssl/pem.h>
#include <openssl/pem.h>
#include <openssl/x509v3.h>
#include <openssl/ocsp.h>
-#include "ocsp_lcl.h"
+#include "ocsp_local.h"
/*
* Utility functions related to sending OCSP responses and extracting
*/
#include <openssl/ocsp.h>
-#include "ocsp_lcl.h"
+#include "ocsp_local.h"
#include <openssl/err.h>
#include <string.h>
# include <openssl/conf.h>
# include <openssl/asn1.h>
# include <openssl/ocsp.h>
-# include "ocsp_lcl.h"
+# include "ocsp_local.h"
# include <openssl/x509v3.h>
# include "../x509/ext_dat.h"
#include <stdio.h>
#include "internal/cryptlib.h"
#include <openssl/pkcs12.h>
-#include "p12_lcl.h"
+#include "p12_local.h"
/* Pack an object into an OCTET STRING and turn into a safebag */
#include "internal/cryptlib.h"
#include <openssl/asn1t.h>
#include <openssl/pkcs12.h>
-#include "p12_lcl.h"
+#include "p12_local.h"
/* PKCS#12 ASN1 module */
#include <stdio.h>
#include "internal/cryptlib.h"
#include <openssl/pkcs12.h>
-#include "p12_lcl.h"
+#include "p12_local.h"
/* Add a local keyid to a safebag */
#include <stdio.h>
#include "internal/cryptlib.h"
#include <openssl/pkcs12.h>
-#include "p12_lcl.h"
+#include "p12_local.h"
static int pkcs12_add_bag(STACK_OF(PKCS12_SAFEBAG) **pbags,
PKCS12_SAFEBAG *bag);
#include <stdio.h>
#include "internal/cryptlib.h"
#include <openssl/pkcs12.h>
-#include "p12_lcl.h"
+#include "p12_local.h"
/* Initialise a PKCS12 structure to take data */
+++ /dev/null
-/*
- * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-struct PKCS12_MAC_DATA_st {
- X509_SIG *dinfo;
- ASN1_OCTET_STRING *salt;
- ASN1_INTEGER *iter; /* defaults to 1 */
-};
-
-struct PKCS12_st {
- ASN1_INTEGER *version;
- PKCS12_MAC_DATA *mac;
- PKCS7 *authsafes;
-};
-
-struct PKCS12_SAFEBAG_st {
- ASN1_OBJECT *type;
- union {
- struct pkcs12_bag_st *bag; /* secret, crl and certbag */
- struct pkcs8_priv_key_info_st *keybag; /* keybag */
- X509_SIG *shkeybag; /* shrouded key bag */
- STACK_OF(PKCS12_SAFEBAG) *safes;
- ASN1_TYPE *other;
- } value;
- STACK_OF(X509_ATTRIBUTE) *attrib;
-};
-
-struct pkcs12_bag_st {
- ASN1_OBJECT *type;
- union {
- ASN1_OCTET_STRING *x509cert;
- ASN1_OCTET_STRING *x509crl;
- ASN1_OCTET_STRING *octet;
- ASN1_IA5STRING *sdsicert;
- ASN1_TYPE *other; /* Secret or other bag */
- } value;
-};
--- /dev/null
+/*
+ * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+struct PKCS12_MAC_DATA_st {
+ X509_SIG *dinfo;
+ ASN1_OCTET_STRING *salt;
+ ASN1_INTEGER *iter; /* defaults to 1 */
+};
+
+struct PKCS12_st {
+ ASN1_INTEGER *version;
+ PKCS12_MAC_DATA *mac;
+ PKCS7 *authsafes;
+};
+
+struct PKCS12_SAFEBAG_st {
+ ASN1_OBJECT *type;
+ union {
+ struct pkcs12_bag_st *bag; /* secret, crl and certbag */
+ struct pkcs8_priv_key_info_st *keybag; /* keybag */
+ X509_SIG *shkeybag; /* shrouded key bag */
+ STACK_OF(PKCS12_SAFEBAG) *safes;
+ ASN1_TYPE *other;
+ } value;
+ STACK_OF(X509_ATTRIBUTE) *attrib;
+};
+
+struct pkcs12_bag_st {
+ ASN1_OBJECT *type;
+ union {
+ ASN1_OCTET_STRING *x509cert;
+ ASN1_OCTET_STRING *x509crl;
+ ASN1_OCTET_STRING *octet;
+ ASN1_IA5STRING *sdsicert;
+ ASN1_TYPE *other; /* Secret or other bag */
+ } value;
+};
#include <openssl/hmac.h>
#include <openssl/rand.h>
#include <openssl/pkcs12.h>
-#include "p12_lcl.h"
+#include "p12_local.h"
int PKCS12_mac_present(const PKCS12 *p12)
{
#include <openssl/pem.h>
#include <openssl/err.h>
#include <openssl/pkcs12.h>
-#include "p12_lcl.h"
+#include "p12_local.h"
/* PKCS#12 password change routine */
#include <stdio.h>
#include "internal/cryptlib.h"
#include <openssl/pkcs12.h>
-#include "p12_lcl.h"
+#include "p12_local.h"
#if !OPENSSL_API_1_1_0
ASN1_TYPE *PKCS12_get_attr(const PKCS12_SAFEBAG *bag, int attr_nid)
poly1305_blocks(void *ctx, const unsigned char *inp, size_t len, u32 padbit);
/*
- * Type-agnostic "rip-off" from constant_time_locl.h
+ * Type-agnostic "rip-off" from constant_time.h
*/
# define CONSTANT_TIME_CARRY(a,b) ( \
(a ^ ((a ^ b) | ((a - b) ^ b))) >> (sizeof(a) * 8 - 1) \
#include <openssl/bn.h>
#include <internal/cryptlib.h>
#include <crypto/chacha.h>
-#include "bn/bn_lcl.h"
+#include "bn/bn_local.h"
#include "ppc_arch.h"
#include <openssl/lhash.h>
#include "internal/propertyerr.h"
#include "internal/property.h"
-#include "property_lcl.h"
+#include "property_local.h"
/*
* Implement a property definition cache.
#include "internal/thread_once.h"
#include "crypto/lhash.h"
#include "crypto/sparse_array.h"
-#include "property_lcl.h"
+#include "property_local.h"
/* The number of elements in the query cache before we initiate a flush */
#define IMPL_CACHE_FLUSH_THRESHOLD 500
+++ /dev/null
-/*
- * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
- * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-#include <openssl/crypto.h>
-#include "internal/property.h"
-
-typedef struct ossl_property_list_st OSSL_PROPERTY_LIST;
-typedef int OSSL_PROPERTY_IDX;
-
-/* Property string functions */
-OSSL_PROPERTY_IDX ossl_property_name(OPENSSL_CTX *ctx, const char *s,
- int create);
-OSSL_PROPERTY_IDX ossl_property_value(OPENSSL_CTX *ctx, const char *s,
- int create);
-
-/* Property list functions */
-void ossl_property_free(OSSL_PROPERTY_LIST *p);
-int ossl_property_has_optional(const OSSL_PROPERTY_LIST *query);
-int ossl_property_match_count(const OSSL_PROPERTY_LIST *query,
- const OSSL_PROPERTY_LIST *defn);
-OSSL_PROPERTY_LIST *ossl_property_merge(const OSSL_PROPERTY_LIST *a,
- const OSSL_PROPERTY_LIST *b);
-
-/* Property definition functions */
-OSSL_PROPERTY_LIST *ossl_parse_property(OPENSSL_CTX *ctx, const char *s);
-
-/* Property query functions */
-OSSL_PROPERTY_LIST *ossl_parse_query(OPENSSL_CTX *ctx, const char *s);
-
-/* Property definition cache functions */
-OSSL_PROPERTY_LIST *ossl_prop_defn_get(OPENSSL_CTX *ctx, const char *prop);
-int ossl_prop_defn_set(OPENSSL_CTX *ctx, const char *prop,
- OSSL_PROPERTY_LIST *pl);
-
-/* Property cache lock / unlock */
-int ossl_property_write_lock(OSSL_METHOD_STORE *);
-int ossl_property_read_lock(OSSL_METHOD_STORE *);
-int ossl_property_unlock(OSSL_METHOD_STORE *);
-
--- /dev/null
+/*
+ * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+#include <openssl/crypto.h>
+#include "internal/property.h"
+
+typedef struct ossl_property_list_st OSSL_PROPERTY_LIST;
+typedef int OSSL_PROPERTY_IDX;
+
+/* Property string functions */
+OSSL_PROPERTY_IDX ossl_property_name(OPENSSL_CTX *ctx, const char *s,
+ int create);
+OSSL_PROPERTY_IDX ossl_property_value(OPENSSL_CTX *ctx, const char *s,
+ int create);
+
+/* Property list functions */
+void ossl_property_free(OSSL_PROPERTY_LIST *p);
+int ossl_property_has_optional(const OSSL_PROPERTY_LIST *query);
+int ossl_property_match_count(const OSSL_PROPERTY_LIST *query,
+ const OSSL_PROPERTY_LIST *defn);
+OSSL_PROPERTY_LIST *ossl_property_merge(const OSSL_PROPERTY_LIST *a,
+ const OSSL_PROPERTY_LIST *b);
+
+/* Property definition functions */
+OSSL_PROPERTY_LIST *ossl_parse_property(OPENSSL_CTX *ctx, const char *s);
+
+/* Property query functions */
+OSSL_PROPERTY_LIST *ossl_parse_query(OPENSSL_CTX *ctx, const char *s);
+
+/* Property definition cache functions */
+OSSL_PROPERTY_LIST *ossl_prop_defn_get(OPENSSL_CTX *ctx, const char *prop);
+int ossl_prop_defn_set(OPENSSL_CTX *ctx, const char *prop,
+ OSSL_PROPERTY_LIST *pl);
+
+/* Property cache lock / unlock */
+int ossl_property_write_lock(OSSL_METHOD_STORE *);
+int ossl_property_read_lock(OSSL_METHOD_STORE *);
+int ossl_property_unlock(OSSL_METHOD_STORE *);
+
#include "internal/property.h"
#include "crypto/ctype.h"
#include "internal/nelem.h"
-#include "property_lcl.h"
+#include "property_local.h"
#include "e_os.h"
typedef enum {
#include <openssl/crypto.h>
#include <openssl/lhash.h>
#include "crypto/lhash.h"
-#include "property_lcl.h"
+#include "property_local.h"
/*
* Property strings are a consolidation of all strings seen by the property
#include <openssl/err.h>
#include <openssl/rand.h>
#include "internal/thread_once.h"
-#include "rand_lcl.h"
+#include "rand_local.h"
/*
* Implementation of NIST SP 800-90A CTR DRBG.
#include <openssl/rand.h>
#include "internal/thread_once.h"
#include "internal/providercommon.h"
-#include "rand_lcl.h"
+#include "rand_local.h"
/* 440 bits from SP800-90Ar1 10.1 table 2 */
#define HASH_PRNG_SMALL_SEEDLEN (440/8)
#include <openssl/rand.h>
#include "internal/thread_once.h"
#include "internal/providercommon.h"
-#include "rand_lcl.h"
+#include "rand_local.h"
/*
* Called twice by SP800-90Ar1 10.1.2.2 HMAC_DRBG_Update_Process.
#include <openssl/crypto.h>
#include <openssl/err.h>
#include <openssl/rand.h>
-#include "rand_lcl.h"
+#include "rand_local.h"
#include "internal/thread_once.h"
#include "crypto/rand.h"
#include "crypto/cryptlib.h"
#include "crypto/rand.h"
#include "internal/thread_once.h"
#include "internal/cryptlib.h"
-#include "rand_lcl.h"
+#include "rand_local.h"
typedef struct crng_test_global_st {
unsigned char crngt_prev[EVP_MAX_MD_SIZE];
+++ /dev/null
-/*
- * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-#ifndef HEADER_RAND_LCL_H
-# define HEADER_RAND_LCL_H
-
-# include <openssl/aes.h>
-# include <openssl/evp.h>
-# include <openssl/sha.h>
-# include <openssl/hmac.h>
-# include <openssl/ec.h>
-# include <openssl/rand_drbg.h>
-# include "internal/tsan_assist.h"
-# include "crypto/rand.h"
-
-# include "internal/numbers.h"
-
-/* How many times to read the TSC as a randomness source. */
-# define TSC_READ_COUNT 4
-
-/* Maximum reseed intervals */
-# define MAX_RESEED_INTERVAL (1 << 24)
-# define MAX_RESEED_TIME_INTERVAL (1 << 20) /* approx. 12 days */
-
-/* Default reseed intervals */
-# define MASTER_RESEED_INTERVAL (1 << 8)
-# define SLAVE_RESEED_INTERVAL (1 << 16)
-# define MASTER_RESEED_TIME_INTERVAL (60*60) /* 1 hour */
-# define SLAVE_RESEED_TIME_INTERVAL (7*60) /* 7 minutes */
-
-/*
- * The number of bytes that constitutes an atomic lump of entropy with respect
- * to the FIPS 140-2 section 4.9.2 Conditional Tests. The size is somewhat
- * arbitrary, the smaller the value, the less entropy is consumed on first
- * read but the higher the probability of the test failing by accident.
- *
- * The value is in bytes.
- */
-#define CRNGT_BUFSIZ 16
-
-/*
- * Maximum input size for the DRBG (entropy, nonce, personalization string)
- *
- * NIST SP800 90Ar1 allows a maximum of (1 << 35) bits i.e., (1 << 32) bytes.
- *
- * We lower it to 'only' INT32_MAX bytes, which is equivalent to 2 gigabytes.
- */
-# define DRBG_MAX_LENGTH INT32_MAX
-
-/* The default nonce */
-#ifdef CHARSET_EBCDIC
-# define DRBG_DEFAULT_PERS_STRING { 0x4f, 0x70, 0x65, 0x6e, 0x53, 0x53, \
- 0x4c, 0x20, 0x4e, 0x49, 0x53, 0x54, 0x20, 0x53, 0x50, 0x20, 0x38, 0x30, \
- 0x30, 0x2d, 0x39, 0x30, 0x41, 0x20, 0x44, 0x52, 0x42, 0x47, 0x00};
-#else
-# define DRBG_DEFAULT_PERS_STRING "OpenSSL NIST SP 800-90A DRBG"
-#endif
-
-/*
- * Maximum allocation size for RANDOM_POOL buffers
- *
- * The max_len value for the buffer provided to the rand_drbg_get_entropy()
- * callback is currently 2^31 bytes (2 gigabytes), if a derivation function
- * is used. Since this is much too large to be allocated, the rand_pool_new()
- * function chooses more modest values as default pool length, bounded
- * by RAND_POOL_MIN_LENGTH and RAND_POOL_MAX_LENGTH
- *
- * The choice of the RAND_POOL_FACTOR is large enough such that the
- * RAND_POOL can store a random input which has a lousy entropy rate of
- * 8/256 (= 0.03125) bits per byte. This input will be sent through the
- * derivation function which 'compresses' the low quality input into a
- * high quality output.
- *
- * The factor 1.5 below is the pessimistic estimate for the extra amount
- * of entropy required when no get_nonce() callback is defined.
- */
-# define RAND_POOL_FACTOR 256
-# define RAND_POOL_MAX_LENGTH (RAND_POOL_FACTOR * \
- 3 * (RAND_DRBG_STRENGTH / 16))
-/*
- * = (RAND_POOL_FACTOR * \
- * 1.5 * (RAND_DRBG_STRENGTH / 8))
- */
-
-/*
- * Initial allocation minimum.
- *
- * There is a distinction between the secure and normal allocation minimums.
- * Ideally, the secure allocation size should be a power of two. The normal
- * allocation size doesn't have any such restriction.
- *
- * The secure value is based on 128 bits of secure material, which is 16 bytes.
- * Typically, the DRBGs will set a minimum larger than this so optimal
- * allocation ought to take place (for full quality seed material).
- *
- * The normal value has been chosed by noticing that the rand_drbg_get_nonce
- * function is usually the largest of the built in allocation (twenty four
- * bytes and then appending another sixteen bytes). This means the buffer ends
- * with 40 bytes. The value of forty eight is comfortably above this which
- * allows some slack in the platform specific values used.
- */
-# define RAND_POOL_MIN_ALLOCATION(secure) ((secure) ? 16 : 48)
-
-/* DRBG status values */
-typedef enum drbg_status_e {
- DRBG_UNINITIALISED,
- DRBG_READY,
- DRBG_ERROR
-} DRBG_STATUS;
-
-
-/* instantiate */
-typedef int (*RAND_DRBG_instantiate_fn)(RAND_DRBG *ctx,
- const unsigned char *ent,
- size_t entlen,
- const unsigned char *nonce,
- size_t noncelen,
- const unsigned char *pers,
- size_t perslen);
-/* reseed */
-typedef int (*RAND_DRBG_reseed_fn)(RAND_DRBG *ctx,
- const unsigned char *ent,
- size_t entlen,
- const unsigned char *adin,
- size_t adinlen);
-/* generate output */
-typedef int (*RAND_DRBG_generate_fn)(RAND_DRBG *ctx,
- unsigned char *out,
- size_t outlen,
- const unsigned char *adin,
- size_t adinlen);
-/* uninstantiate */
-typedef int (*RAND_DRBG_uninstantiate_fn)(RAND_DRBG *ctx);
-
-
-/*
- * The DRBG methods
- */
-
-typedef struct rand_drbg_method_st {
- RAND_DRBG_instantiate_fn instantiate;
- RAND_DRBG_reseed_fn reseed;
- RAND_DRBG_generate_fn generate;
- RAND_DRBG_uninstantiate_fn uninstantiate;
-} RAND_DRBG_METHOD;
-
-/* 888 bits from SP800-90Ar1 10.1 table 2 */
-#define HASH_PRNG_MAX_SEEDLEN (888/8)
-
-typedef struct rand_drbg_hash_st {
- EVP_MD *md;
- EVP_MD_CTX *ctx;
- size_t blocklen;
- unsigned char V[HASH_PRNG_MAX_SEEDLEN];
- unsigned char C[HASH_PRNG_MAX_SEEDLEN];
- /* Temporary value storage: should always exceed max digest length */
- unsigned char vtmp[HASH_PRNG_MAX_SEEDLEN];
-} RAND_DRBG_HASH;
-
-typedef struct rand_drbg_hmac_st {
- EVP_MD *md;
- HMAC_CTX *ctx;
- size_t blocklen;
- unsigned char K[EVP_MAX_MD_SIZE];
- unsigned char V[EVP_MAX_MD_SIZE];
-} RAND_DRBG_HMAC;
-
-/*
- * The state of a DRBG AES-CTR.
- */
-typedef struct rand_drbg_ctr_st {
- EVP_CIPHER_CTX *ctx;
- EVP_CIPHER_CTX *ctx_df;
- EVP_CIPHER *cipher;
- size_t keylen;
- unsigned char K[32];
- unsigned char V[16];
- /* Temporary block storage used by ctr_df */
- unsigned char bltmp[16];
- size_t bltmp_pos;
- unsigned char KX[48];
-} RAND_DRBG_CTR;
-
-
-/*
- * The 'random pool' acts as a dumb container for collecting random
- * input from various entropy sources. The pool has no knowledge about
- * whether its randomness is fed into a legacy RAND_METHOD via RAND_add()
- * or into a new style RAND_DRBG. It is the callers duty to 1) initialize the
- * random pool, 2) pass it to the polling callbacks, 3) seed the RNG, and
- * 4) cleanup the random pool again.
- *
- * The random pool contains no locking mechanism because its scope and
- * lifetime is intended to be restricted to a single stack frame.
- */
-struct rand_pool_st {
- unsigned char *buffer; /* points to the beginning of the random pool */
- size_t len; /* current number of random bytes contained in the pool */
-
- int attached; /* true pool was attached to existing buffer */
- int secure; /* 1: allocated on the secure heap, 0: otherwise */
-
- size_t min_len; /* minimum number of random bytes requested */
- size_t max_len; /* maximum number of random bytes (allocated buffer size) */
- size_t alloc_len; /* current number of bytes allocated */
- size_t entropy; /* current entropy count in bits */
- size_t entropy_requested; /* requested entropy count in bits */
-};
-
-/*
- * The state of all types of DRBGs, even though we only have CTR mode
- * right now.
- */
-struct rand_drbg_st {
- CRYPTO_RWLOCK *lock;
- /* The library context this DRBG is associated with, if any */
- OPENSSL_CTX *libctx;
- RAND_DRBG *parent;
- int secure; /* 1: allocated on the secure heap, 0: otherwise */
- int type; /* the nid of the underlying algorithm */
- /*
- * Stores the return value of openssl_get_fork_id() as of when we last
- * reseeded. The DRBG reseeds automatically whenever drbg->fork_id !=
- * openssl_get_fork_id(). Used to provide fork-safety and reseed this
- * DRBG in the child process.
- */
- int fork_id;
- unsigned short flags; /* various external flags */
-
- /*
- * The random_data is used by RAND_add()/drbg_add() to attach random
- * data to the global drbg, such that the rand_drbg_get_entropy() callback
- * can pull it during instantiation and reseeding. This is necessary to
- * reconcile the different philosophies of the RAND and the RAND_DRBG
- * with respect to how randomness is added to the RNG during reseeding
- * (see PR #4328).
- */
- struct rand_pool_st *seed_pool;
-
- /*
- * Auxiliary pool for additional data.
- */
- struct rand_pool_st *adin_pool;
-
- /*
- * The following parameters are setup by the per-type "init" function.
- *
- * The supported types and their init functions are:
- * (1) CTR_DRBG: drbg_ctr_init().
- * (2) HMAC_DRBG: drbg_hmac_init().
- * (3) HASH_DRBG: drbg_hash_init().
- *
- * The parameters are closely related to the ones described in
- * section '10.2.1 CTR_DRBG' of [NIST SP 800-90Ar1], with one
- * crucial difference: In the NIST standard, all counts are given
- * in bits, whereas in OpenSSL entropy counts are given in bits
- * and buffer lengths are given in bytes.
- *
- * Since this difference has lead to some confusion in the past,
- * (see [GitHub Issue #2443], formerly [rt.openssl.org #4055])
- * the 'len' suffix has been added to all buffer sizes for
- * clarification.
- */
-
- int strength;
- size_t max_request;
- size_t min_entropylen, max_entropylen;
- size_t min_noncelen, max_noncelen;
- size_t max_perslen, max_adinlen;
-
- /*
- * Counts the number of generate requests since the last reseed
- * (Starts at 1). This value is the reseed_counter as defined in
- * NIST SP 800-90Ar1
- */
- unsigned int reseed_gen_counter;
- /*
- * Maximum number of generate requests until a reseed is required.
- * This value is ignored if it is zero.
- */
- unsigned int reseed_interval;
- /* Stores the time when the last reseeding occurred */
- time_t reseed_time;
- /*
- * Specifies the maximum time interval (in seconds) between reseeds.
- * This value is ignored if it is zero.
- */
- time_t reseed_time_interval;
- /*
- * Counts the number of reseeds since instantiation.
- * This value is ignored if it is zero.
- *
- * This counter is used only for seed propagation from the <master> DRBG
- * to its two children, the <public> and <private> DRBG. This feature is
- * very special and its sole purpose is to ensure that any randomness which
- * is added by RAND_add() or RAND_seed() will have an immediate effect on
- * the output of RAND_bytes() resp. RAND_priv_bytes().
- */
- TSAN_QUALIFIER unsigned int reseed_prop_counter;
- unsigned int reseed_next_counter;
-
- size_t seedlen;
- DRBG_STATUS state;
-
- /* Application data, mainly used in the KATs. */
- CRYPTO_EX_DATA ex_data;
-
- /* Implementation specific data */
- union {
- RAND_DRBG_CTR ctr;
- RAND_DRBG_HASH hash;
- RAND_DRBG_HMAC hmac;
- } data;
-
- /* Implementation specific methods */
- RAND_DRBG_METHOD *meth;
-
- /* Callback functions. See comments in rand_lib.c */
- RAND_DRBG_get_entropy_fn get_entropy;
- RAND_DRBG_cleanup_entropy_fn cleanup_entropy;
- RAND_DRBG_get_nonce_fn get_nonce;
- RAND_DRBG_cleanup_nonce_fn cleanup_nonce;
-};
-
-/* The global RAND method, and the global buffer and DRBG instance. */
-extern RAND_METHOD rand_meth;
-
-/* DRBG helpers */
-int rand_drbg_restart(RAND_DRBG *drbg,
- const unsigned char *buffer, size_t len, size_t entropy);
-size_t rand_drbg_seedlen(RAND_DRBG *drbg);
-/* locking api */
-int rand_drbg_lock(RAND_DRBG *drbg);
-int rand_drbg_unlock(RAND_DRBG *drbg);
-int rand_drbg_enable_locking(RAND_DRBG *drbg);
-
-
-/* initializes the DRBG implementation */
-int drbg_ctr_init(RAND_DRBG *drbg);
-int drbg_hash_init(RAND_DRBG *drbg);
-int drbg_hmac_init(RAND_DRBG *drbg);
-
-/*
- * Entropy call back for the FIPS 140-2 section 4.9.2 Conditional Tests.
- * These need to be exposed for the unit tests.
- */
-int rand_crngt_get_entropy_cb(OPENSSL_CTX *ctx, RAND_POOL *pool,
- unsigned char *buf, unsigned char *md,
- unsigned int *md_size);
-extern int (*crngt_get_entropy)(OPENSSL_CTX *ctx, RAND_POOL *pool,
- unsigned char *buf, unsigned char *md,
- unsigned int *md_size);
-
-#endif
#include "crypto/rand.h"
#include <openssl/engine.h>
#include "internal/thread_once.h"
-#include "rand_lcl.h"
+#include "rand_local.h"
#include "e_os.h"
#ifndef FIPS_MODE
--- /dev/null
+/*
+ * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+#ifndef HEADER_RAND_LCL_H
+# define HEADER_RAND_LCL_H
+
+# include <openssl/aes.h>
+# include <openssl/evp.h>
+# include <openssl/sha.h>
+# include <openssl/hmac.h>
+# include <openssl/ec.h>
+# include <openssl/rand_drbg.h>
+# include "internal/tsan_assist.h"
+# include "crypto/rand.h"
+
+# include "internal/numbers.h"
+
+/* How many times to read the TSC as a randomness source. */
+# define TSC_READ_COUNT 4
+
+/* Maximum reseed intervals */
+# define MAX_RESEED_INTERVAL (1 << 24)
+# define MAX_RESEED_TIME_INTERVAL (1 << 20) /* approx. 12 days */
+
+/* Default reseed intervals */
+# define MASTER_RESEED_INTERVAL (1 << 8)
+# define SLAVE_RESEED_INTERVAL (1 << 16)
+# define MASTER_RESEED_TIME_INTERVAL (60*60) /* 1 hour */
+# define SLAVE_RESEED_TIME_INTERVAL (7*60) /* 7 minutes */
+
+/*
+ * The number of bytes that constitutes an atomic lump of entropy with respect
+ * to the FIPS 140-2 section 4.9.2 Conditional Tests. The size is somewhat
+ * arbitrary, the smaller the value, the less entropy is consumed on first
+ * read but the higher the probability of the test failing by accident.
+ *
+ * The value is in bytes.
+ */
+#define CRNGT_BUFSIZ 16
+
+/*
+ * Maximum input size for the DRBG (entropy, nonce, personalization string)
+ *
+ * NIST SP800 90Ar1 allows a maximum of (1 << 35) bits i.e., (1 << 32) bytes.
+ *
+ * We lower it to 'only' INT32_MAX bytes, which is equivalent to 2 gigabytes.
+ */
+# define DRBG_MAX_LENGTH INT32_MAX
+
+/* The default nonce */
+#ifdef CHARSET_EBCDIC
+# define DRBG_DEFAULT_PERS_STRING { 0x4f, 0x70, 0x65, 0x6e, 0x53, 0x53, \
+ 0x4c, 0x20, 0x4e, 0x49, 0x53, 0x54, 0x20, 0x53, 0x50, 0x20, 0x38, 0x30, \
+ 0x30, 0x2d, 0x39, 0x30, 0x41, 0x20, 0x44, 0x52, 0x42, 0x47, 0x00};
+#else
+# define DRBG_DEFAULT_PERS_STRING "OpenSSL NIST SP 800-90A DRBG"
+#endif
+
+/*
+ * Maximum allocation size for RANDOM_POOL buffers
+ *
+ * The max_len value for the buffer provided to the rand_drbg_get_entropy()
+ * callback is currently 2^31 bytes (2 gigabytes), if a derivation function
+ * is used. Since this is much too large to be allocated, the rand_pool_new()
+ * function chooses more modest values as default pool length, bounded
+ * by RAND_POOL_MIN_LENGTH and RAND_POOL_MAX_LENGTH
+ *
+ * The choice of the RAND_POOL_FACTOR is large enough such that the
+ * RAND_POOL can store a random input which has a lousy entropy rate of
+ * 8/256 (= 0.03125) bits per byte. This input will be sent through the
+ * derivation function which 'compresses' the low quality input into a
+ * high quality output.
+ *
+ * The factor 1.5 below is the pessimistic estimate for the extra amount
+ * of entropy required when no get_nonce() callback is defined.
+ */
+# define RAND_POOL_FACTOR 256
+# define RAND_POOL_MAX_LENGTH (RAND_POOL_FACTOR * \
+ 3 * (RAND_DRBG_STRENGTH / 16))
+/*
+ * = (RAND_POOL_FACTOR * \
+ * 1.5 * (RAND_DRBG_STRENGTH / 8))
+ */
+
+/*
+ * Initial allocation minimum.
+ *
+ * There is a distinction between the secure and normal allocation minimums.
+ * Ideally, the secure allocation size should be a power of two. The normal
+ * allocation size doesn't have any such restriction.
+ *
+ * The secure value is based on 128 bits of secure material, which is 16 bytes.
+ * Typically, the DRBGs will set a minimum larger than this so optimal
+ * allocation ought to take place (for full quality seed material).
+ *
+ * The normal value has been chosed by noticing that the rand_drbg_get_nonce
+ * function is usually the largest of the built in allocation (twenty four
+ * bytes and then appending another sixteen bytes). This means the buffer ends
+ * with 40 bytes. The value of forty eight is comfortably above this which
+ * allows some slack in the platform specific values used.
+ */
+# define RAND_POOL_MIN_ALLOCATION(secure) ((secure) ? 16 : 48)
+
+/* DRBG status values */
+typedef enum drbg_status_e {
+ DRBG_UNINITIALISED,
+ DRBG_READY,
+ DRBG_ERROR
+} DRBG_STATUS;
+
+
+/* instantiate */
+typedef int (*RAND_DRBG_instantiate_fn)(RAND_DRBG *ctx,
+ const unsigned char *ent,
+ size_t entlen,
+ const unsigned char *nonce,
+ size_t noncelen,
+ const unsigned char *pers,
+ size_t perslen);
+/* reseed */
+typedef int (*RAND_DRBG_reseed_fn)(RAND_DRBG *ctx,
+ const unsigned char *ent,
+ size_t entlen,
+ const unsigned char *adin,
+ size_t adinlen);
+/* generate output */
+typedef int (*RAND_DRBG_generate_fn)(RAND_DRBG *ctx,
+ unsigned char *out,
+ size_t outlen,
+ const unsigned char *adin,
+ size_t adinlen);
+/* uninstantiate */
+typedef int (*RAND_DRBG_uninstantiate_fn)(RAND_DRBG *ctx);
+
+
+/*
+ * The DRBG methods
+ */
+
+typedef struct rand_drbg_method_st {
+ RAND_DRBG_instantiate_fn instantiate;
+ RAND_DRBG_reseed_fn reseed;
+ RAND_DRBG_generate_fn generate;
+ RAND_DRBG_uninstantiate_fn uninstantiate;
+} RAND_DRBG_METHOD;
+
+/* 888 bits from SP800-90Ar1 10.1 table 2 */
+#define HASH_PRNG_MAX_SEEDLEN (888/8)
+
+typedef struct rand_drbg_hash_st {
+ EVP_MD *md;
+ EVP_MD_CTX *ctx;
+ size_t blocklen;
+ unsigned char V[HASH_PRNG_MAX_SEEDLEN];
+ unsigned char C[HASH_PRNG_MAX_SEEDLEN];
+ /* Temporary value storage: should always exceed max digest length */
+ unsigned char vtmp[HASH_PRNG_MAX_SEEDLEN];
+} RAND_DRBG_HASH;
+
+typedef struct rand_drbg_hmac_st {
+ EVP_MD *md;
+ HMAC_CTX *ctx;
+ size_t blocklen;
+ unsigned char K[EVP_MAX_MD_SIZE];
+ unsigned char V[EVP_MAX_MD_SIZE];
+} RAND_DRBG_HMAC;
+
+/*
+ * The state of a DRBG AES-CTR.
+ */
+typedef struct rand_drbg_ctr_st {
+ EVP_CIPHER_CTX *ctx;
+ EVP_CIPHER_CTX *ctx_df;
+ EVP_CIPHER *cipher;
+ size_t keylen;
+ unsigned char K[32];
+ unsigned char V[16];
+ /* Temporary block storage used by ctr_df */
+ unsigned char bltmp[16];
+ size_t bltmp_pos;
+ unsigned char KX[48];
+} RAND_DRBG_CTR;
+
+
+/*
+ * The 'random pool' acts as a dumb container for collecting random
+ * input from various entropy sources. The pool has no knowledge about
+ * whether its randomness is fed into a legacy RAND_METHOD via RAND_add()
+ * or into a new style RAND_DRBG. It is the callers duty to 1) initialize the
+ * random pool, 2) pass it to the polling callbacks, 3) seed the RNG, and
+ * 4) cleanup the random pool again.
+ *
+ * The random pool contains no locking mechanism because its scope and
+ * lifetime is intended to be restricted to a single stack frame.
+ */
+struct rand_pool_st {
+ unsigned char *buffer; /* points to the beginning of the random pool */
+ size_t len; /* current number of random bytes contained in the pool */
+
+ int attached; /* true pool was attached to existing buffer */
+ int secure; /* 1: allocated on the secure heap, 0: otherwise */
+
+ size_t min_len; /* minimum number of random bytes requested */
+ size_t max_len; /* maximum number of random bytes (allocated buffer size) */
+ size_t alloc_len; /* current number of bytes allocated */
+ size_t entropy; /* current entropy count in bits */
+ size_t entropy_requested; /* requested entropy count in bits */
+};
+
+/*
+ * The state of all types of DRBGs, even though we only have CTR mode
+ * right now.
+ */
+struct rand_drbg_st {
+ CRYPTO_RWLOCK *lock;
+ /* The library context this DRBG is associated with, if any */
+ OPENSSL_CTX *libctx;
+ RAND_DRBG *parent;
+ int secure; /* 1: allocated on the secure heap, 0: otherwise */
+ int type; /* the nid of the underlying algorithm */
+ /*
+ * Stores the return value of openssl_get_fork_id() as of when we last
+ * reseeded. The DRBG reseeds automatically whenever drbg->fork_id !=
+ * openssl_get_fork_id(). Used to provide fork-safety and reseed this
+ * DRBG in the child process.
+ */
+ int fork_id;
+ unsigned short flags; /* various external flags */
+
+ /*
+ * The random_data is used by RAND_add()/drbg_add() to attach random
+ * data to the global drbg, such that the rand_drbg_get_entropy() callback
+ * can pull it during instantiation and reseeding. This is necessary to
+ * reconcile the different philosophies of the RAND and the RAND_DRBG
+ * with respect to how randomness is added to the RNG during reseeding
+ * (see PR #4328).
+ */
+ struct rand_pool_st *seed_pool;
+
+ /*
+ * Auxiliary pool for additional data.
+ */
+ struct rand_pool_st *adin_pool;
+
+ /*
+ * The following parameters are setup by the per-type "init" function.
+ *
+ * The supported types and their init functions are:
+ * (1) CTR_DRBG: drbg_ctr_init().
+ * (2) HMAC_DRBG: drbg_hmac_init().
+ * (3) HASH_DRBG: drbg_hash_init().
+ *
+ * The parameters are closely related to the ones described in
+ * section '10.2.1 CTR_DRBG' of [NIST SP 800-90Ar1], with one
+ * crucial difference: In the NIST standard, all counts are given
+ * in bits, whereas in OpenSSL entropy counts are given in bits
+ * and buffer lengths are given in bytes.
+ *
+ * Since this difference has lead to some confusion in the past,
+ * (see [GitHub Issue #2443], formerly [rt.openssl.org #4055])
+ * the 'len' suffix has been added to all buffer sizes for
+ * clarification.
+ */
+
+ int strength;
+ size_t max_request;
+ size_t min_entropylen, max_entropylen;
+ size_t min_noncelen, max_noncelen;
+ size_t max_perslen, max_adinlen;
+
+ /*
+ * Counts the number of generate requests since the last reseed
+ * (Starts at 1). This value is the reseed_counter as defined in
+ * NIST SP 800-90Ar1
+ */
+ unsigned int reseed_gen_counter;
+ /*
+ * Maximum number of generate requests until a reseed is required.
+ * This value is ignored if it is zero.
+ */
+ unsigned int reseed_interval;
+ /* Stores the time when the last reseeding occurred */
+ time_t reseed_time;
+ /*
+ * Specifies the maximum time interval (in seconds) between reseeds.
+ * This value is ignored if it is zero.
+ */
+ time_t reseed_time_interval;
+ /*
+ * Counts the number of reseeds since instantiation.
+ * This value is ignored if it is zero.
+ *
+ * This counter is used only for seed propagation from the <master> DRBG
+ * to its two children, the <public> and <private> DRBG. This feature is
+ * very special and its sole purpose is to ensure that any randomness which
+ * is added by RAND_add() or RAND_seed() will have an immediate effect on
+ * the output of RAND_bytes() resp. RAND_priv_bytes().
+ */
+ TSAN_QUALIFIER unsigned int reseed_prop_counter;
+ unsigned int reseed_next_counter;
+
+ size_t seedlen;
+ DRBG_STATUS state;
+
+ /* Application data, mainly used in the KATs. */
+ CRYPTO_EX_DATA ex_data;
+
+ /* Implementation specific data */
+ union {
+ RAND_DRBG_CTR ctr;
+ RAND_DRBG_HASH hash;
+ RAND_DRBG_HMAC hmac;
+ } data;
+
+ /* Implementation specific methods */
+ RAND_DRBG_METHOD *meth;
+
+ /* Callback functions. See comments in rand_lib.c */
+ RAND_DRBG_get_entropy_fn get_entropy;
+ RAND_DRBG_cleanup_entropy_fn cleanup_entropy;
+ RAND_DRBG_get_nonce_fn get_nonce;
+ RAND_DRBG_cleanup_nonce_fn cleanup_nonce;
+};
+
+/* The global RAND method, and the global buffer and DRBG instance. */
+extern RAND_METHOD rand_meth;
+
+/* DRBG helpers */
+int rand_drbg_restart(RAND_DRBG *drbg,
+ const unsigned char *buffer, size_t len, size_t entropy);
+size_t rand_drbg_seedlen(RAND_DRBG *drbg);
+/* locking api */
+int rand_drbg_lock(RAND_DRBG *drbg);
+int rand_drbg_unlock(RAND_DRBG *drbg);
+int rand_drbg_enable_locking(RAND_DRBG *drbg);
+
+
+/* initializes the DRBG implementation */
+int drbg_ctr_init(RAND_DRBG *drbg);
+int drbg_hash_init(RAND_DRBG *drbg);
+int drbg_hmac_init(RAND_DRBG *drbg);
+
+/*
+ * Entropy call back for the FIPS 140-2 section 4.9.2 Conditional Tests.
+ * These need to be exposed for the unit tests.
+ */
+int rand_crngt_get_entropy_cb(OPENSSL_CTX *ctx, RAND_POOL *pool,
+ unsigned char *buf, unsigned char *md,
+ unsigned int *md_size);
+extern int (*crngt_get_entropy)(OPENSSL_CTX *ctx, RAND_POOL *pool,
+ unsigned char *buf, unsigned char *md,
+ unsigned int *md_size);
+
+#endif
#include "internal/cryptlib.h"
#include <openssl/rand.h>
#include <openssl/crypto.h>
-#include "rand_lcl.h"
+#include "rand_local.h"
#include "crypto/rand.h"
#include <stdio.h>
#include "internal/dso.h"
# include "internal/cryptlib.h"
# include <openssl/rand.h>
# include "crypto/rand.h"
-# include "rand_lcl.h"
+# include "rand_local.h"
# include <descrip.h>
# include <dvidef.h>
# include <jpidef.h>
NON_EMPTY_TRANSLATION_UNIT
#else
# include <openssl/rand.h>
-# include "rand_lcl.h"
+# include "rand_local.h"
# include "crypto/rand.h"
# include "internal/cryptlib.h"
# include <version.h>
#include "internal/cryptlib.h"
#include <openssl/rand.h>
-#include "rand_lcl.h"
+#include "rand_local.h"
#include "crypto/rand.h"
#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32)
*/
#include <openssl/rc2.h>
-#include "rc2_locl.h"
+#include "rc2_local.h"
void RC2_cbc_encrypt(const unsigned char *in, unsigned char *out, long length,
RC2_KEY *ks, unsigned char *iv, int encrypt)
*/
#include <openssl/rc2.h>
-#include "rc2_locl.h"
+#include "rc2_local.h"
#include <openssl/opensslv.h>
/*-
--- /dev/null
+/*
+ * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+#undef c2l
+#define c2l(c,l) (l =((unsigned long)(*((c)++))) , \
+ l|=((unsigned long)(*((c)++)))<< 8L, \
+ l|=((unsigned long)(*((c)++)))<<16L, \
+ l|=((unsigned long)(*((c)++)))<<24L)
+
+/* NOTE - c is not incremented as per c2l */
+#undef c2ln
+#define c2ln(c,l1,l2,n) { \
+ c+=n; \
+ l1=l2=0; \
+ switch (n) { \
+ case 8: l2 =((unsigned long)(*(--(c))))<<24L; \
+ /* fall thru */ \
+ case 7: l2|=((unsigned long)(*(--(c))))<<16L; \
+ /* fall thru */ \
+ case 6: l2|=((unsigned long)(*(--(c))))<< 8L; \
+ /* fall thru */ \
+ case 5: l2|=((unsigned long)(*(--(c)))); \
+ /* fall thru */ \
+ case 4: l1 =((unsigned long)(*(--(c))))<<24L; \
+ /* fall thru */ \
+ case 3: l1|=((unsigned long)(*(--(c))))<<16L; \
+ /* fall thru */ \
+ case 2: l1|=((unsigned long)(*(--(c))))<< 8L; \
+ /* fall thru */ \
+ case 1: l1|=((unsigned long)(*(--(c)))); \
+ } \
+ }
+
+#undef l2c
+#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \
+ *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
+ *((c)++)=(unsigned char)(((l)>>16L)&0xff), \
+ *((c)++)=(unsigned char)(((l)>>24L)&0xff))
+
+/* NOTE - c is not incremented as per l2c */
+#undef l2cn
+#define l2cn(l1,l2,c,n) { \
+ c+=n; \
+ switch (n) { \
+ case 8: *(--(c))=(unsigned char)(((l2)>>24L)&0xff); \
+ /* fall thru */ \
+ case 7: *(--(c))=(unsigned char)(((l2)>>16L)&0xff); \
+ /* fall thru */ \
+ case 6: *(--(c))=(unsigned char)(((l2)>> 8L)&0xff); \
+ /* fall thru */ \
+ case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \
+ /* fall thru */ \
+ case 4: *(--(c))=(unsigned char)(((l1)>>24L)&0xff); \
+ /* fall thru */ \
+ case 3: *(--(c))=(unsigned char)(((l1)>>16L)&0xff); \
+ /* fall thru */ \
+ case 2: *(--(c))=(unsigned char)(((l1)>> 8L)&0xff); \
+ /* fall thru */ \
+ case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \
+ } \
+ }
+
+/* NOTE - c is not incremented as per n2l */
+#define n2ln(c,l1,l2,n) { \
+ c+=n; \
+ l1=l2=0; \
+ switch (n) { \
+ case 8: l2 =((unsigned long)(*(--(c)))) ; \
+ /* fall thru */ \
+ case 7: l2|=((unsigned long)(*(--(c))))<< 8; \
+ /* fall thru */ \
+ case 6: l2|=((unsigned long)(*(--(c))))<<16; \
+ /* fall thru */ \
+ case 5: l2|=((unsigned long)(*(--(c))))<<24; \
+ /* fall thru */ \
+ case 4: l1 =((unsigned long)(*(--(c)))) ; \
+ /* fall thru */ \
+ case 3: l1|=((unsigned long)(*(--(c))))<< 8; \
+ /* fall thru */ \
+ case 2: l1|=((unsigned long)(*(--(c))))<<16; \
+ /* fall thru */ \
+ case 1: l1|=((unsigned long)(*(--(c))))<<24; \
+ } \
+ }
+
+/* NOTE - c is not incremented as per l2n */
+#define l2nn(l1,l2,c,n) { \
+ c+=n; \
+ switch (n) { \
+ case 8: *(--(c))=(unsigned char)(((l2) )&0xff); \
+ /* fall thru */ \
+ case 7: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \
+ /* fall thru */ \
+ case 6: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \
+ /* fall thru */ \
+ case 5: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \
+ /* fall thru */ \
+ case 4: *(--(c))=(unsigned char)(((l1) )&0xff); \
+ /* fall thru */ \
+ case 3: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \
+ /* fall thru */ \
+ case 2: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \
+ /* fall thru */ \
+ case 1: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \
+ } \
+ }
+
+#undef n2l
+#define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24L, \
+ l|=((unsigned long)(*((c)++)))<<16L, \
+ l|=((unsigned long)(*((c)++)))<< 8L, \
+ l|=((unsigned long)(*((c)++))))
+
+#undef l2n
+#define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \
+ *((c)++)=(unsigned char)(((l)>>16L)&0xff), \
+ *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
+ *((c)++)=(unsigned char)(((l) )&0xff))
+
+#define C_RC2(n) \
+ t=(x0+(x1& ~x3)+(x2&x3)+ *(p0++))&0xffff; \
+ x0=(t<<1)|(t>>15); \
+ t=(x1+(x2& ~x0)+(x3&x0)+ *(p0++))&0xffff; \
+ x1=(t<<2)|(t>>14); \
+ t=(x2+(x3& ~x1)+(x0&x1)+ *(p0++))&0xffff; \
+ x2=(t<<3)|(t>>13); \
+ t=(x3+(x0& ~x2)+(x1&x2)+ *(p0++))&0xffff; \
+ x3=(t<<5)|(t>>11);
+++ /dev/null
-/*
- * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-#undef c2l
-#define c2l(c,l) (l =((unsigned long)(*((c)++))) , \
- l|=((unsigned long)(*((c)++)))<< 8L, \
- l|=((unsigned long)(*((c)++)))<<16L, \
- l|=((unsigned long)(*((c)++)))<<24L)
-
-/* NOTE - c is not incremented as per c2l */
-#undef c2ln
-#define c2ln(c,l1,l2,n) { \
- c+=n; \
- l1=l2=0; \
- switch (n) { \
- case 8: l2 =((unsigned long)(*(--(c))))<<24L; \
- /* fall thru */ \
- case 7: l2|=((unsigned long)(*(--(c))))<<16L; \
- /* fall thru */ \
- case 6: l2|=((unsigned long)(*(--(c))))<< 8L; \
- /* fall thru */ \
- case 5: l2|=((unsigned long)(*(--(c)))); \
- /* fall thru */ \
- case 4: l1 =((unsigned long)(*(--(c))))<<24L; \
- /* fall thru */ \
- case 3: l1|=((unsigned long)(*(--(c))))<<16L; \
- /* fall thru */ \
- case 2: l1|=((unsigned long)(*(--(c))))<< 8L; \
- /* fall thru */ \
- case 1: l1|=((unsigned long)(*(--(c)))); \
- } \
- }
-
-#undef l2c
-#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \
- *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
- *((c)++)=(unsigned char)(((l)>>16L)&0xff), \
- *((c)++)=(unsigned char)(((l)>>24L)&0xff))
-
-/* NOTE - c is not incremented as per l2c */
-#undef l2cn
-#define l2cn(l1,l2,c,n) { \
- c+=n; \
- switch (n) { \
- case 8: *(--(c))=(unsigned char)(((l2)>>24L)&0xff); \
- /* fall thru */ \
- case 7: *(--(c))=(unsigned char)(((l2)>>16L)&0xff); \
- /* fall thru */ \
- case 6: *(--(c))=(unsigned char)(((l2)>> 8L)&0xff); \
- /* fall thru */ \
- case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \
- /* fall thru */ \
- case 4: *(--(c))=(unsigned char)(((l1)>>24L)&0xff); \
- /* fall thru */ \
- case 3: *(--(c))=(unsigned char)(((l1)>>16L)&0xff); \
- /* fall thru */ \
- case 2: *(--(c))=(unsigned char)(((l1)>> 8L)&0xff); \
- /* fall thru */ \
- case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \
- } \
- }
-
-/* NOTE - c is not incremented as per n2l */
-#define n2ln(c,l1,l2,n) { \
- c+=n; \
- l1=l2=0; \
- switch (n) { \
- case 8: l2 =((unsigned long)(*(--(c)))) ; \
- /* fall thru */ \
- case 7: l2|=((unsigned long)(*(--(c))))<< 8; \
- /* fall thru */ \
- case 6: l2|=((unsigned long)(*(--(c))))<<16; \
- /* fall thru */ \
- case 5: l2|=((unsigned long)(*(--(c))))<<24; \
- /* fall thru */ \
- case 4: l1 =((unsigned long)(*(--(c)))) ; \
- /* fall thru */ \
- case 3: l1|=((unsigned long)(*(--(c))))<< 8; \
- /* fall thru */ \
- case 2: l1|=((unsigned long)(*(--(c))))<<16; \
- /* fall thru */ \
- case 1: l1|=((unsigned long)(*(--(c))))<<24; \
- } \
- }
-
-/* NOTE - c is not incremented as per l2n */
-#define l2nn(l1,l2,c,n) { \
- c+=n; \
- switch (n) { \
- case 8: *(--(c))=(unsigned char)(((l2) )&0xff); \
- /* fall thru */ \
- case 7: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \
- /* fall thru */ \
- case 6: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \
- /* fall thru */ \
- case 5: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \
- /* fall thru */ \
- case 4: *(--(c))=(unsigned char)(((l1) )&0xff); \
- /* fall thru */ \
- case 3: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \
- /* fall thru */ \
- case 2: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \
- /* fall thru */ \
- case 1: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \
- } \
- }
-
-#undef n2l
-#define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24L, \
- l|=((unsigned long)(*((c)++)))<<16L, \
- l|=((unsigned long)(*((c)++)))<< 8L, \
- l|=((unsigned long)(*((c)++))))
-
-#undef l2n
-#define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \
- *((c)++)=(unsigned char)(((l)>>16L)&0xff), \
- *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
- *((c)++)=(unsigned char)(((l) )&0xff))
-
-#define C_RC2(n) \
- t=(x0+(x1& ~x3)+(x2&x3)+ *(p0++))&0xffff; \
- x0=(t<<1)|(t>>15); \
- t=(x1+(x2& ~x0)+(x3&x0)+ *(p0++))&0xffff; \
- x1=(t<<2)|(t>>14); \
- t=(x2+(x3& ~x1)+(x0&x1)+ *(p0++))&0xffff; \
- x2=(t<<3)|(t>>13); \
- t=(x3+(x0& ~x2)+(x1&x2)+ *(p0++))&0xffff; \
- x3=(t<<5)|(t>>11);
*/
#include <openssl/rc2.h>
-#include "rc2_locl.h"
+#include "rc2_local.h"
static const unsigned char key_table[256] = {
0xd9, 0x78, 0xf9, 0xc4, 0x19, 0xdd, 0xb5, 0xed, 0x28, 0xe9, 0xfd, 0x79,
*/
#include <openssl/rc2.h>
-#include "rc2_locl.h"
+#include "rc2_local.h"
/*
* The input and output encrypted as though 64bit cfb mode is being used.
*/
#include <openssl/rc2.h>
-#include "rc2_locl.h"
+#include "rc2_local.h"
/*
* The input and output encrypted as though 64bit ofb mode is being used.
*/
#include <openssl/rc4.h>
-#include "rc4_locl.h"
+#include "rc4_local.h"
/*-
* RC4 as implemented from a posting from
--- /dev/null
+/*
+ * Copyright 1998-2016 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+#ifndef HEADER_RC4_LOCL_H
+# define HEADER_RC4_LOCL_H
+
+# include <openssl/opensslconf.h>
+# include "internal/cryptlib.h"
+
+#endif
+++ /dev/null
-/*
- * Copyright 1998-2016 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-#ifndef HEADER_RC4_LOCL_H
-# define HEADER_RC4_LOCL_H
-
-# include <openssl/opensslconf.h>
-# include "internal/cryptlib.h"
-
-#endif
*/
#include <openssl/rc4.h>
-#include "rc4_locl.h"
+#include "rc4_local.h"
#include <openssl/opensslv.h>
const char *RC4_options(void)
*/
#include <openssl/rc5.h>
-#include "rc5_locl.h"
+#include "rc5_local.h"
#include <openssl/opensslv.h>
void RC5_32_ecb_encrypt(const unsigned char *in, unsigned char *out,
#include <stdio.h>
#include <openssl/rc5.h>
-#include "rc5_locl.h"
+#include "rc5_local.h"
void RC5_32_cbc_encrypt(const unsigned char *in, unsigned char *out,
long length, RC5_32_KEY *ks, unsigned char *iv,
--- /dev/null
+/*
+ * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+#include <stdlib.h>
+
+#undef c2l
+#define c2l(c,l) (l =((unsigned long)(*((c)++))) , \
+ l|=((unsigned long)(*((c)++)))<< 8L, \
+ l|=((unsigned long)(*((c)++)))<<16L, \
+ l|=((unsigned long)(*((c)++)))<<24L)
+
+/* NOTE - c is not incremented as per c2l */
+#undef c2ln
+#define c2ln(c,l1,l2,n) { \
+ c+=n; \
+ l1=l2=0; \
+ switch (n) { \
+ case 8: l2 =((unsigned long)(*(--(c))))<<24L; \
+ /* fall thru */ \
+ case 7: l2|=((unsigned long)(*(--(c))))<<16L; \
+ /* fall thru */ \
+ case 6: l2|=((unsigned long)(*(--(c))))<< 8L; \
+ /* fall thru */ \
+ case 5: l2|=((unsigned long)(*(--(c)))); \
+ /* fall thru */ \
+ case 4: l1 =((unsigned long)(*(--(c))))<<24L; \
+ /* fall thru */ \
+ case 3: l1|=((unsigned long)(*(--(c))))<<16L; \
+ /* fall thru */ \
+ case 2: l1|=((unsigned long)(*(--(c))))<< 8L; \
+ /* fall thru */ \
+ case 1: l1|=((unsigned long)(*(--(c)))); \
+ } \
+ }
+
+#undef l2c
+#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \
+ *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
+ *((c)++)=(unsigned char)(((l)>>16L)&0xff), \
+ *((c)++)=(unsigned char)(((l)>>24L)&0xff))
+
+/* NOTE - c is not incremented as per l2c */
+#undef l2cn
+#define l2cn(l1,l2,c,n) { \
+ c+=n; \
+ switch (n) { \
+ case 8: *(--(c))=(unsigned char)(((l2)>>24L)&0xff); \
+ /* fall thru */ \
+ case 7: *(--(c))=(unsigned char)(((l2)>>16L)&0xff); \
+ /* fall thru */ \
+ case 6: *(--(c))=(unsigned char)(((l2)>> 8L)&0xff); \
+ /* fall thru */ \
+ case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \
+ /* fall thru */ \
+ case 4: *(--(c))=(unsigned char)(((l1)>>24L)&0xff); \
+ /* fall thru */ \
+ case 3: *(--(c))=(unsigned char)(((l1)>>16L)&0xff); \
+ /* fall thru */ \
+ case 2: *(--(c))=(unsigned char)(((l1)>> 8L)&0xff); \
+ /* fall thru */ \
+ case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \
+ } \
+ }
+
+/* NOTE - c is not incremented as per n2l */
+#define n2ln(c,l1,l2,n) { \
+ c+=n; \
+ l1=l2=0; \
+ switch (n) { \
+ case 8: l2 =((unsigned long)(*(--(c)))) ; \
+ /* fall thru */ \
+ case 7: l2|=((unsigned long)(*(--(c))))<< 8; \
+ /* fall thru */ \
+ case 6: l2|=((unsigned long)(*(--(c))))<<16; \
+ /* fall thru */ \
+ case 5: l2|=((unsigned long)(*(--(c))))<<24; \
+ /* fall thru */ \
+ case 4: l1 =((unsigned long)(*(--(c)))) ; \
+ /* fall thru */ \
+ case 3: l1|=((unsigned long)(*(--(c))))<< 8; \
+ /* fall thru */ \
+ case 2: l1|=((unsigned long)(*(--(c))))<<16; \
+ /* fall thru */ \
+ case 1: l1|=((unsigned long)(*(--(c))))<<24; \
+ } \
+ }
+
+/* NOTE - c is not incremented as per l2n */
+#define l2nn(l1,l2,c,n) { \
+ c+=n; \
+ switch (n) { \
+ case 8: *(--(c))=(unsigned char)(((l2) )&0xff); \
+ /* fall thru */ \
+ case 7: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \
+ /* fall thru */ \
+ case 6: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \
+ /* fall thru */ \
+ case 5: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \
+ /* fall thru */ \
+ case 4: *(--(c))=(unsigned char)(((l1) )&0xff); \
+ /* fall thru */ \
+ case 3: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \
+ /* fall thru */ \
+ case 2: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \
+ /* fall thru */ \
+ case 1: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \
+ } \
+ }
+
+#undef n2l
+#define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24L, \
+ l|=((unsigned long)(*((c)++)))<<16L, \
+ l|=((unsigned long)(*((c)++)))<< 8L, \
+ l|=((unsigned long)(*((c)++))))
+
+#undef l2n
+#define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \
+ *((c)++)=(unsigned char)(((l)>>16L)&0xff), \
+ *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
+ *((c)++)=(unsigned char)(((l) )&0xff))
+
+#if (defined(OPENSSL_SYS_WIN32) && defined(_MSC_VER))
+# define ROTATE_l32(a,n) _lrotl(a,n)
+# define ROTATE_r32(a,n) _lrotr(a,n)
+#elif defined(__ICC)
+# define ROTATE_l32(a,n) _rotl(a,n)
+# define ROTATE_r32(a,n) _rotr(a,n)
+#elif defined(__GNUC__) && __GNUC__>=2 && !defined(__STRICT_ANSI__) && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) && !defined(PEDANTIC)
+# if defined(__i386) || defined(__i386__) || defined(__x86_64) || defined(__x86_64__)
+# define ROTATE_l32(a,n) ({ register unsigned int ret; \
+ asm ("roll %%cl,%0" \
+ : "=r"(ret) \
+ : "c"(n),"0"((unsigned int)(a)) \
+ : "cc"); \
+ ret; \
+ })
+# define ROTATE_r32(a,n) ({ register unsigned int ret; \
+ asm ("rorl %%cl,%0" \
+ : "=r"(ret) \
+ : "c"(n),"0"((unsigned int)(a)) \
+ : "cc"); \
+ ret; \
+ })
+# endif
+#endif
+#ifndef ROTATE_l32
+# define ROTATE_l32(a,n) (((a)<<(n&0x1f))|(((a)&0xffffffff)>>((32-n)&0x1f)))
+#endif
+#ifndef ROTATE_r32
+# define ROTATE_r32(a,n) (((a)<<((32-n)&0x1f))|(((a)&0xffffffff)>>(n&0x1f)))
+#endif
+
+#define RC5_32_MASK 0xffffffffL
+
+#define RC5_16_P 0xB7E1
+#define RC5_16_Q 0x9E37
+#define RC5_32_P 0xB7E15163L
+#define RC5_32_Q 0x9E3779B9L
+#define RC5_64_P 0xB7E151628AED2A6BLL
+#define RC5_64_Q 0x9E3779B97F4A7C15LL
+
+#define E_RC5_32(a,b,s,n) \
+ a^=b; \
+ a=ROTATE_l32(a,b); \
+ a+=s[n]; \
+ a&=RC5_32_MASK; \
+ b^=a; \
+ b=ROTATE_l32(b,a); \
+ b+=s[n+1]; \
+ b&=RC5_32_MASK;
+
+#define D_RC5_32(a,b,s,n) \
+ b-=s[n+1]; \
+ b&=RC5_32_MASK; \
+ b=ROTATE_r32(b,a); \
+ b^=a; \
+ a-=s[n]; \
+ a&=RC5_32_MASK; \
+ a=ROTATE_r32(a,b); \
+ a^=b;
+++ /dev/null
-/*
- * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-#include <stdlib.h>
-
-#undef c2l
-#define c2l(c,l) (l =((unsigned long)(*((c)++))) , \
- l|=((unsigned long)(*((c)++)))<< 8L, \
- l|=((unsigned long)(*((c)++)))<<16L, \
- l|=((unsigned long)(*((c)++)))<<24L)
-
-/* NOTE - c is not incremented as per c2l */
-#undef c2ln
-#define c2ln(c,l1,l2,n) { \
- c+=n; \
- l1=l2=0; \
- switch (n) { \
- case 8: l2 =((unsigned long)(*(--(c))))<<24L; \
- /* fall thru */ \
- case 7: l2|=((unsigned long)(*(--(c))))<<16L; \
- /* fall thru */ \
- case 6: l2|=((unsigned long)(*(--(c))))<< 8L; \
- /* fall thru */ \
- case 5: l2|=((unsigned long)(*(--(c)))); \
- /* fall thru */ \
- case 4: l1 =((unsigned long)(*(--(c))))<<24L; \
- /* fall thru */ \
- case 3: l1|=((unsigned long)(*(--(c))))<<16L; \
- /* fall thru */ \
- case 2: l1|=((unsigned long)(*(--(c))))<< 8L; \
- /* fall thru */ \
- case 1: l1|=((unsigned long)(*(--(c)))); \
- } \
- }
-
-#undef l2c
-#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \
- *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
- *((c)++)=(unsigned char)(((l)>>16L)&0xff), \
- *((c)++)=(unsigned char)(((l)>>24L)&0xff))
-
-/* NOTE - c is not incremented as per l2c */
-#undef l2cn
-#define l2cn(l1,l2,c,n) { \
- c+=n; \
- switch (n) { \
- case 8: *(--(c))=(unsigned char)(((l2)>>24L)&0xff); \
- /* fall thru */ \
- case 7: *(--(c))=(unsigned char)(((l2)>>16L)&0xff); \
- /* fall thru */ \
- case 6: *(--(c))=(unsigned char)(((l2)>> 8L)&0xff); \
- /* fall thru */ \
- case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \
- /* fall thru */ \
- case 4: *(--(c))=(unsigned char)(((l1)>>24L)&0xff); \
- /* fall thru */ \
- case 3: *(--(c))=(unsigned char)(((l1)>>16L)&0xff); \
- /* fall thru */ \
- case 2: *(--(c))=(unsigned char)(((l1)>> 8L)&0xff); \
- /* fall thru */ \
- case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \
- } \
- }
-
-/* NOTE - c is not incremented as per n2l */
-#define n2ln(c,l1,l2,n) { \
- c+=n; \
- l1=l2=0; \
- switch (n) { \
- case 8: l2 =((unsigned long)(*(--(c)))) ; \
- /* fall thru */ \
- case 7: l2|=((unsigned long)(*(--(c))))<< 8; \
- /* fall thru */ \
- case 6: l2|=((unsigned long)(*(--(c))))<<16; \
- /* fall thru */ \
- case 5: l2|=((unsigned long)(*(--(c))))<<24; \
- /* fall thru */ \
- case 4: l1 =((unsigned long)(*(--(c)))) ; \
- /* fall thru */ \
- case 3: l1|=((unsigned long)(*(--(c))))<< 8; \
- /* fall thru */ \
- case 2: l1|=((unsigned long)(*(--(c))))<<16; \
- /* fall thru */ \
- case 1: l1|=((unsigned long)(*(--(c))))<<24; \
- } \
- }
-
-/* NOTE - c is not incremented as per l2n */
-#define l2nn(l1,l2,c,n) { \
- c+=n; \
- switch (n) { \
- case 8: *(--(c))=(unsigned char)(((l2) )&0xff); \
- /* fall thru */ \
- case 7: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \
- /* fall thru */ \
- case 6: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \
- /* fall thru */ \
- case 5: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \
- /* fall thru */ \
- case 4: *(--(c))=(unsigned char)(((l1) )&0xff); \
- /* fall thru */ \
- case 3: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \
- /* fall thru */ \
- case 2: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \
- /* fall thru */ \
- case 1: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \
- } \
- }
-
-#undef n2l
-#define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24L, \
- l|=((unsigned long)(*((c)++)))<<16L, \
- l|=((unsigned long)(*((c)++)))<< 8L, \
- l|=((unsigned long)(*((c)++))))
-
-#undef l2n
-#define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \
- *((c)++)=(unsigned char)(((l)>>16L)&0xff), \
- *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
- *((c)++)=(unsigned char)(((l) )&0xff))
-
-#if (defined(OPENSSL_SYS_WIN32) && defined(_MSC_VER))
-# define ROTATE_l32(a,n) _lrotl(a,n)
-# define ROTATE_r32(a,n) _lrotr(a,n)
-#elif defined(__ICC)
-# define ROTATE_l32(a,n) _rotl(a,n)
-# define ROTATE_r32(a,n) _rotr(a,n)
-#elif defined(__GNUC__) && __GNUC__>=2 && !defined(__STRICT_ANSI__) && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) && !defined(PEDANTIC)
-# if defined(__i386) || defined(__i386__) || defined(__x86_64) || defined(__x86_64__)
-# define ROTATE_l32(a,n) ({ register unsigned int ret; \
- asm ("roll %%cl,%0" \
- : "=r"(ret) \
- : "c"(n),"0"((unsigned int)(a)) \
- : "cc"); \
- ret; \
- })
-# define ROTATE_r32(a,n) ({ register unsigned int ret; \
- asm ("rorl %%cl,%0" \
- : "=r"(ret) \
- : "c"(n),"0"((unsigned int)(a)) \
- : "cc"); \
- ret; \
- })
-# endif
-#endif
-#ifndef ROTATE_l32
-# define ROTATE_l32(a,n) (((a)<<(n&0x1f))|(((a)&0xffffffff)>>((32-n)&0x1f)))
-#endif
-#ifndef ROTATE_r32
-# define ROTATE_r32(a,n) (((a)<<((32-n)&0x1f))|(((a)&0xffffffff)>>(n&0x1f)))
-#endif
-
-#define RC5_32_MASK 0xffffffffL
-
-#define RC5_16_P 0xB7E1
-#define RC5_16_Q 0x9E37
-#define RC5_32_P 0xB7E15163L
-#define RC5_32_Q 0x9E3779B9L
-#define RC5_64_P 0xB7E151628AED2A6BLL
-#define RC5_64_Q 0x9E3779B97F4A7C15LL
-
-#define E_RC5_32(a,b,s,n) \
- a^=b; \
- a=ROTATE_l32(a,b); \
- a+=s[n]; \
- a&=RC5_32_MASK; \
- b^=a; \
- b=ROTATE_l32(b,a); \
- b+=s[n+1]; \
- b&=RC5_32_MASK;
-
-#define D_RC5_32(a,b,s,n) \
- b-=s[n+1]; \
- b&=RC5_32_MASK; \
- b=ROTATE_r32(b,a); \
- b^=a; \
- a-=s[n]; \
- a&=RC5_32_MASK; \
- a=ROTATE_r32(a,b); \
- a^=b;
*/
#include <openssl/rc5.h>
-#include "rc5_locl.h"
+#include "rc5_local.h"
int RC5_32_set_key(RC5_32_KEY *key, int len, const unsigned char *data,
int rounds)
*/
#include <openssl/rc5.h>
-#include "rc5_locl.h"
+#include "rc5_local.h"
/*
* The input and output encrypted as though 64bit cfb mode is being used.
*/
#include <openssl/rc5.h>
-#include "rc5_locl.h"
+#include "rc5_local.h"
/*
* The input and output encrypted as though 64bit ofb mode is being used.
*/
#include <stdio.h>
-#include "rmd_locl.h"
+#include "rmd_local.h"
#include <openssl/opensslv.h>
#ifdef RMD160_ASM
register unsigned MD32_REG_T A, B, C, D, E;
unsigned MD32_REG_T a, b, c, d, e, l;
# ifndef MD32_XARRAY
- /* See comment in crypto/sha/sha_locl.h for details. */
+ /* See comment in crypto/sha/sha_local.h for details. */
unsigned MD32_REG_T XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7,
XX8, XX9, XX10, XX11, XX12, XX13, XX14, XX15;
# define X(i) XX##i
--- /dev/null
+/*
+ * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <openssl/opensslconf.h>
+#include <openssl/ripemd.h>
+
+/*
+ * DO EXAMINE COMMENTS IN crypto/md5/md5_local.h & crypto/md5/md5_dgst.c
+ * FOR EXPLANATIONS ON FOLLOWING "CODE."
+ */
+#ifdef RMD160_ASM
+# if defined(__i386) || defined(__i386__) || defined(_M_IX86)
+# define ripemd160_block_data_order ripemd160_block_asm_data_order
+# endif
+#endif
+
+void ripemd160_block_data_order(RIPEMD160_CTX *c, const void *p, size_t num);
+
+#define DATA_ORDER_IS_LITTLE_ENDIAN
+
+#define HASH_LONG RIPEMD160_LONG
+#define HASH_CTX RIPEMD160_CTX
+#define HASH_CBLOCK RIPEMD160_CBLOCK
+#define HASH_UPDATE RIPEMD160_Update
+#define HASH_TRANSFORM RIPEMD160_Transform
+#define HASH_FINAL RIPEMD160_Final
+#define HASH_MAKE_STRING(c,s) do { \
+ unsigned long ll; \
+ ll=(c)->A; (void)HOST_l2c(ll,(s)); \
+ ll=(c)->B; (void)HOST_l2c(ll,(s)); \
+ ll=(c)->C; (void)HOST_l2c(ll,(s)); \
+ ll=(c)->D; (void)HOST_l2c(ll,(s)); \
+ ll=(c)->E; (void)HOST_l2c(ll,(s)); \
+ } while (0)
+#define HASH_BLOCK_DATA_ORDER ripemd160_block_data_order
+
+#include "crypto/md32_common.h"
+
+/*
+ * Transformed F2 and F4 are courtesy of Wei Dai
+ */
+#define F1(x,y,z) ((x) ^ (y) ^ (z))
+#define F2(x,y,z) ((((y) ^ (z)) & (x)) ^ (z))
+#define F3(x,y,z) (((~(y)) | (x)) ^ (z))
+#define F4(x,y,z) ((((x) ^ (y)) & (z)) ^ (y))
+#define F5(x,y,z) (((~(z)) | (y)) ^ (x))
+
+#define RIPEMD160_A 0x67452301L
+#define RIPEMD160_B 0xEFCDAB89L
+#define RIPEMD160_C 0x98BADCFEL
+#define RIPEMD160_D 0x10325476L
+#define RIPEMD160_E 0xC3D2E1F0L
+
+#include "rmdconst.h"
+
+#define RIP1(a,b,c,d,e,w,s) { \
+ a+=F1(b,c,d)+X(w); \
+ a=ROTATE(a,s)+e; \
+ c=ROTATE(c,10); }
+
+#define RIP2(a,b,c,d,e,w,s,K) { \
+ a+=F2(b,c,d)+X(w)+K; \
+ a=ROTATE(a,s)+e; \
+ c=ROTATE(c,10); }
+
+#define RIP3(a,b,c,d,e,w,s,K) { \
+ a+=F3(b,c,d)+X(w)+K; \
+ a=ROTATE(a,s)+e; \
+ c=ROTATE(c,10); }
+
+#define RIP4(a,b,c,d,e,w,s,K) { \
+ a+=F4(b,c,d)+X(w)+K; \
+ a=ROTATE(a,s)+e; \
+ c=ROTATE(c,10); }
+
+#define RIP5(a,b,c,d,e,w,s,K) { \
+ a+=F5(b,c,d)+X(w)+K; \
+ a=ROTATE(a,s)+e; \
+ c=ROTATE(c,10); }
+++ /dev/null
-/*
- * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include <openssl/opensslconf.h>
-#include <openssl/ripemd.h>
-
-/*
- * DO EXAMINE COMMENTS IN crypto/md5/md5_locl.h & crypto/md5/md5_dgst.c
- * FOR EXPLANATIONS ON FOLLOWING "CODE."
- */
-#ifdef RMD160_ASM
-# if defined(__i386) || defined(__i386__) || defined(_M_IX86)
-# define ripemd160_block_data_order ripemd160_block_asm_data_order
-# endif
-#endif
-
-void ripemd160_block_data_order(RIPEMD160_CTX *c, const void *p, size_t num);
-
-#define DATA_ORDER_IS_LITTLE_ENDIAN
-
-#define HASH_LONG RIPEMD160_LONG
-#define HASH_CTX RIPEMD160_CTX
-#define HASH_CBLOCK RIPEMD160_CBLOCK
-#define HASH_UPDATE RIPEMD160_Update
-#define HASH_TRANSFORM RIPEMD160_Transform
-#define HASH_FINAL RIPEMD160_Final
-#define HASH_MAKE_STRING(c,s) do { \
- unsigned long ll; \
- ll=(c)->A; (void)HOST_l2c(ll,(s)); \
- ll=(c)->B; (void)HOST_l2c(ll,(s)); \
- ll=(c)->C; (void)HOST_l2c(ll,(s)); \
- ll=(c)->D; (void)HOST_l2c(ll,(s)); \
- ll=(c)->E; (void)HOST_l2c(ll,(s)); \
- } while (0)
-#define HASH_BLOCK_DATA_ORDER ripemd160_block_data_order
-
-#include "crypto/md32_common.h"
-
-/*
- * Transformed F2 and F4 are courtesy of Wei Dai
- */
-#define F1(x,y,z) ((x) ^ (y) ^ (z))
-#define F2(x,y,z) ((((y) ^ (z)) & (x)) ^ (z))
-#define F3(x,y,z) (((~(y)) | (x)) ^ (z))
-#define F4(x,y,z) ((((x) ^ (y)) & (z)) ^ (y))
-#define F5(x,y,z) (((~(z)) | (y)) ^ (x))
-
-#define RIPEMD160_A 0x67452301L
-#define RIPEMD160_B 0xEFCDAB89L
-#define RIPEMD160_C 0x98BADCFEL
-#define RIPEMD160_D 0x10325476L
-#define RIPEMD160_E 0xC3D2E1F0L
-
-#include "rmdconst.h"
-
-#define RIP1(a,b,c,d,e,w,s) { \
- a+=F1(b,c,d)+X(w); \
- a=ROTATE(a,s)+e; \
- c=ROTATE(c,10); }
-
-#define RIP2(a,b,c,d,e,w,s,K) { \
- a+=F2(b,c,d)+X(w)+K; \
- a=ROTATE(a,s)+e; \
- c=ROTATE(c,10); }
-
-#define RIP3(a,b,c,d,e,w,s,K) { \
- a+=F3(b,c,d)+X(w)+K; \
- a=ROTATE(a,s)+e; \
- c=ROTATE(c,10); }
-
-#define RIP4(a,b,c,d,e,w,s,K) { \
- a+=F4(b,c,d)+X(w)+K; \
- a=ROTATE(a,s)+e; \
- c=ROTATE(c,10); }
-
-#define RIP5(a,b,c,d,e,w,s,K) { \
- a+=F5(b,c,d)+X(w)+K; \
- a=ROTATE(a,s)+e; \
- c=ROTATE(c,10); }
#include <openssl/cms.h>
#include "crypto/asn1.h"
#include "crypto/evp.h"
-#include "rsa_locl.h"
+#include "rsa_local.h"
#ifndef OPENSSL_NO_CMS
static int rsa_cms_sign(CMS_SignerInfo *si);
#include <openssl/bn.h>
#include <openssl/x509.h>
#include <openssl/asn1t.h>
-#include "rsa_locl.h"
+#include "rsa_local.h"
/*
* Override the default free and new methods,
#include <openssl/bn.h>
#include <openssl/err.h>
-#include "rsa_locl.h"
+#include "rsa_local.h"
int RSA_check_key(const RSA *key)
{
#include "internal/cryptlib.h"
#include "crypto/bn.h"
#include <openssl/rand.h>
-#include "rsa_locl.h"
+#include "rsa_local.h"
int RSA_bits(const RSA *r)
{
#include <time.h>
#include "internal/cryptlib.h"
#include <openssl/bn.h>
-#include "rsa_locl.h"
+#include "rsa_local.h"
static int rsa_builtin_keygen(RSA *rsa, int bits, int primes, BIGNUM *e_value,
BN_GENCB *cb);
#include <openssl/engine.h>
#include <openssl/evp.h>
#include "crypto/evp.h"
-#include "rsa_locl.h"
+#include "rsa_local.h"
RSA *RSA_new(void)
{
--- /dev/null
+/*
+ * Copyright 2006-2017 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+#ifndef RSA_LOCAL_HEADER_H
+#define RSA_LOCAL_HEADER_H
+
+#include <openssl/rsa.h>
+#include "internal/refcount.h"
+
+#define RSA_MAX_PRIME_NUM 5
+#define RSA_MIN_MODULUS_BITS 512
+
+typedef struct rsa_prime_info_st {
+ BIGNUM *r;
+ BIGNUM *d;
+ BIGNUM *t;
+ /* save product of primes prior to this one */
+ BIGNUM *pp;
+ BN_MONT_CTX *m;
+} RSA_PRIME_INFO;
+
+DECLARE_ASN1_ITEM(RSA_PRIME_INFO)
+DEFINE_STACK_OF(RSA_PRIME_INFO)
+
+struct rsa_st {
+ /*
+ * The first parameter is used to pickup errors where this is passed
+ * instead of an EVP_PKEY, it is set to 0
+ */
+ int pad;
+ int32_t version;
+ const RSA_METHOD *meth;
+ /* functional reference if 'meth' is ENGINE-provided */
+ ENGINE *engine;
+ BIGNUM *n;
+ BIGNUM *e;
+ BIGNUM *d;
+ BIGNUM *p;
+ BIGNUM *q;
+ BIGNUM *dmp1;
+ BIGNUM *dmq1;
+ BIGNUM *iqmp;
+ /* for multi-prime RSA, defined in RFC 8017 */
+ STACK_OF(RSA_PRIME_INFO) *prime_infos;
+ /* If a PSS only key this contains the parameter restrictions */
+ RSA_PSS_PARAMS *pss;
+ /* be careful using this if the RSA structure is shared */
+ CRYPTO_EX_DATA ex_data;
+ CRYPTO_REF_COUNT references;
+ int flags;
+ /* Used to cache montgomery values */
+ BN_MONT_CTX *_method_mod_n;
+ BN_MONT_CTX *_method_mod_p;
+ BN_MONT_CTX *_method_mod_q;
+ /*
+ * all BIGNUM values are actually in the following data, if it is not
+ * NULL
+ */
+ char *bignum_data;
+ BN_BLINDING *blinding;
+ BN_BLINDING *mt_blinding;
+ CRYPTO_RWLOCK *lock;
+};
+
+struct rsa_meth_st {
+ char *name;
+ int (*rsa_pub_enc) (int flen, const unsigned char *from,
+ unsigned char *to, RSA *rsa, int padding);
+ int (*rsa_pub_dec) (int flen, const unsigned char *from,
+ unsigned char *to, RSA *rsa, int padding);
+ int (*rsa_priv_enc) (int flen, const unsigned char *from,
+ unsigned char *to, RSA *rsa, int padding);
+ int (*rsa_priv_dec) (int flen, const unsigned char *from,
+ unsigned char *to, RSA *rsa, int padding);
+ /* Can be null */
+ int (*rsa_mod_exp) (BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx);
+ /* Can be null */
+ int (*bn_mod_exp) (BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
+ const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
+ /* called at new */
+ int (*init) (RSA *rsa);
+ /* called at free */
+ int (*finish) (RSA *rsa);
+ /* RSA_METHOD_FLAG_* things */
+ int flags;
+ /* may be needed! */
+ char *app_data;
+ /*
+ * New sign and verify functions: some libraries don't allow arbitrary
+ * data to be signed/verified: this allows them to be used. Note: for
+ * this to work the RSA_public_decrypt() and RSA_private_encrypt() should
+ * *NOT* be used RSA_sign(), RSA_verify() should be used instead.
+ */
+ int (*rsa_sign) (int type,
+ const unsigned char *m, unsigned int m_length,
+ unsigned char *sigret, unsigned int *siglen,
+ const RSA *rsa);
+ int (*rsa_verify) (int dtype, const unsigned char *m,
+ unsigned int m_length, const unsigned char *sigbuf,
+ unsigned int siglen, const RSA *rsa);
+ /*
+ * If this callback is NULL, the builtin software RSA key-gen will be
+ * used. This is for behavioural compatibility whilst the code gets
+ * rewired, but one day it would be nice to assume there are no such
+ * things as "builtin software" implementations.
+ */
+ int (*rsa_keygen) (RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb);
+ int (*rsa_multi_prime_keygen) (RSA *rsa, int bits, int primes,
+ BIGNUM *e, BN_GENCB *cb);
+};
+
+extern int int_rsa_verify(int dtype, const unsigned char *m,
+ unsigned int m_len, unsigned char *rm,
+ size_t *prm_len, const unsigned char *sigbuf,
+ size_t siglen, RSA *rsa);
+/* Macros to test if a pkey or ctx is for a PSS key */
+#define pkey_is_pss(pkey) (pkey->ameth->pkey_id == EVP_PKEY_RSA_PSS)
+#define pkey_ctx_is_pss(ctx) (ctx->pmeth->pkey_id == EVP_PKEY_RSA_PSS)
+
+RSA_PSS_PARAMS *rsa_pss_params_create(const EVP_MD *sigmd,
+ const EVP_MD *mgf1md, int saltlen);
+int rsa_pss_get_param(const RSA_PSS_PARAMS *pss, const EVP_MD **pmd,
+ const EVP_MD **pmgf1md, int *psaltlen);
+/* internal function to clear and free multi-prime parameters */
+void rsa_multip_info_free_ex(RSA_PRIME_INFO *pinfo);
+void rsa_multip_info_free(RSA_PRIME_INFO *pinfo);
+RSA_PRIME_INFO *rsa_multip_info_new(void);
+int rsa_multip_calc_product(RSA *rsa);
+int rsa_multip_cap(int bits);
+
+uint16_t rsa_compute_security_bits(int n);
+
+int rsa_sp800_56b_validate_strength(int nbits, int strength);
+int rsa_check_pminusq_diff(BIGNUM *diff, const BIGNUM *p, const BIGNUM *q,
+ int nbits);
+int rsa_get_lcm(BN_CTX *ctx, const BIGNUM *p, const BIGNUM *q,
+ BIGNUM *lcm, BIGNUM *gcd, BIGNUM *p1, BIGNUM *q1,
+ BIGNUM *p1q1);
+
+int rsa_check_public_exponent(const BIGNUM *e);
+int rsa_check_private_exponent(const RSA *rsa, int nbits, BN_CTX *ctx);
+int rsa_check_prime_factor(BIGNUM *p, BIGNUM *e, int nbits, BN_CTX *ctx);
+int rsa_check_prime_factor_range(const BIGNUM *p, int nbits, BN_CTX *ctx);
+int rsa_check_crt_components(const RSA *rsa, BN_CTX *ctx);
+
+int rsa_sp800_56b_pairwise_test(RSA *rsa, BN_CTX *ctx);
+int rsa_sp800_56b_check_public(const RSA *rsa);
+int rsa_sp800_56b_check_private(const RSA *rsa);
+int rsa_sp800_56b_check_keypair(const RSA *rsa, const BIGNUM *efixed,
+ int strength, int nbits);
+int rsa_sp800_56b_generate_key(RSA *rsa, int nbits, const BIGNUM *efixed,
+ BN_GENCB *cb);
+
+int rsa_sp800_56b_derive_params_from_pq(RSA *rsa, int nbits,
+ const BIGNUM *e, BN_CTX *ctx);
+int rsa_fips186_4_gen_prob_primes(RSA *rsa, BIGNUM *p1, BIGNUM *p2,
+ BIGNUM *Xpout, const BIGNUM *Xp,
+ const BIGNUM *Xp1, const BIGNUM *Xp2,
+ BIGNUM *q1, BIGNUM *q2, BIGNUM *Xqout,
+ const BIGNUM *Xq, const BIGNUM *Xq1,
+ const BIGNUM *Xq2, int nbits,
+ const BIGNUM *e, BN_CTX *ctx, BN_GENCB *cb);
+
+#endif /* RSA_LOCAL_HEADER_H */
+++ /dev/null
-/*
- * Copyright 2006-2017 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-#ifndef RSA_LOCAL_HEADER_H
-#define RSA_LOCAL_HEADER_H
-
-#include <openssl/rsa.h>
-#include "internal/refcount.h"
-
-#define RSA_MAX_PRIME_NUM 5
-#define RSA_MIN_MODULUS_BITS 512
-
-typedef struct rsa_prime_info_st {
- BIGNUM *r;
- BIGNUM *d;
- BIGNUM *t;
- /* save product of primes prior to this one */
- BIGNUM *pp;
- BN_MONT_CTX *m;
-} RSA_PRIME_INFO;
-
-DECLARE_ASN1_ITEM(RSA_PRIME_INFO)
-DEFINE_STACK_OF(RSA_PRIME_INFO)
-
-struct rsa_st {
- /*
- * The first parameter is used to pickup errors where this is passed
- * instead of an EVP_PKEY, it is set to 0
- */
- int pad;
- int32_t version;
- const RSA_METHOD *meth;
- /* functional reference if 'meth' is ENGINE-provided */
- ENGINE *engine;
- BIGNUM *n;
- BIGNUM *e;
- BIGNUM *d;
- BIGNUM *p;
- BIGNUM *q;
- BIGNUM *dmp1;
- BIGNUM *dmq1;
- BIGNUM *iqmp;
- /* for multi-prime RSA, defined in RFC 8017 */
- STACK_OF(RSA_PRIME_INFO) *prime_infos;
- /* If a PSS only key this contains the parameter restrictions */
- RSA_PSS_PARAMS *pss;
- /* be careful using this if the RSA structure is shared */
- CRYPTO_EX_DATA ex_data;
- CRYPTO_REF_COUNT references;
- int flags;
- /* Used to cache montgomery values */
- BN_MONT_CTX *_method_mod_n;
- BN_MONT_CTX *_method_mod_p;
- BN_MONT_CTX *_method_mod_q;
- /*
- * all BIGNUM values are actually in the following data, if it is not
- * NULL
- */
- char *bignum_data;
- BN_BLINDING *blinding;
- BN_BLINDING *mt_blinding;
- CRYPTO_RWLOCK *lock;
-};
-
-struct rsa_meth_st {
- char *name;
- int (*rsa_pub_enc) (int flen, const unsigned char *from,
- unsigned char *to, RSA *rsa, int padding);
- int (*rsa_pub_dec) (int flen, const unsigned char *from,
- unsigned char *to, RSA *rsa, int padding);
- int (*rsa_priv_enc) (int flen, const unsigned char *from,
- unsigned char *to, RSA *rsa, int padding);
- int (*rsa_priv_dec) (int flen, const unsigned char *from,
- unsigned char *to, RSA *rsa, int padding);
- /* Can be null */
- int (*rsa_mod_exp) (BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx);
- /* Can be null */
- int (*bn_mod_exp) (BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
- const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
- /* called at new */
- int (*init) (RSA *rsa);
- /* called at free */
- int (*finish) (RSA *rsa);
- /* RSA_METHOD_FLAG_* things */
- int flags;
- /* may be needed! */
- char *app_data;
- /*
- * New sign and verify functions: some libraries don't allow arbitrary
- * data to be signed/verified: this allows them to be used. Note: for
- * this to work the RSA_public_decrypt() and RSA_private_encrypt() should
- * *NOT* be used RSA_sign(), RSA_verify() should be used instead.
- */
- int (*rsa_sign) (int type,
- const unsigned char *m, unsigned int m_length,
- unsigned char *sigret, unsigned int *siglen,
- const RSA *rsa);
- int (*rsa_verify) (int dtype, const unsigned char *m,
- unsigned int m_length, const unsigned char *sigbuf,
- unsigned int siglen, const RSA *rsa);
- /*
- * If this callback is NULL, the builtin software RSA key-gen will be
- * used. This is for behavioural compatibility whilst the code gets
- * rewired, but one day it would be nice to assume there are no such
- * things as "builtin software" implementations.
- */
- int (*rsa_keygen) (RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb);
- int (*rsa_multi_prime_keygen) (RSA *rsa, int bits, int primes,
- BIGNUM *e, BN_GENCB *cb);
-};
-
-extern int int_rsa_verify(int dtype, const unsigned char *m,
- unsigned int m_len, unsigned char *rm,
- size_t *prm_len, const unsigned char *sigbuf,
- size_t siglen, RSA *rsa);
-/* Macros to test if a pkey or ctx is for a PSS key */
-#define pkey_is_pss(pkey) (pkey->ameth->pkey_id == EVP_PKEY_RSA_PSS)
-#define pkey_ctx_is_pss(ctx) (ctx->pmeth->pkey_id == EVP_PKEY_RSA_PSS)
-
-RSA_PSS_PARAMS *rsa_pss_params_create(const EVP_MD *sigmd,
- const EVP_MD *mgf1md, int saltlen);
-int rsa_pss_get_param(const RSA_PSS_PARAMS *pss, const EVP_MD **pmd,
- const EVP_MD **pmgf1md, int *psaltlen);
-/* internal function to clear and free multi-prime parameters */
-void rsa_multip_info_free_ex(RSA_PRIME_INFO *pinfo);
-void rsa_multip_info_free(RSA_PRIME_INFO *pinfo);
-RSA_PRIME_INFO *rsa_multip_info_new(void);
-int rsa_multip_calc_product(RSA *rsa);
-int rsa_multip_cap(int bits);
-
-uint16_t rsa_compute_security_bits(int n);
-
-int rsa_sp800_56b_validate_strength(int nbits, int strength);
-int rsa_check_pminusq_diff(BIGNUM *diff, const BIGNUM *p, const BIGNUM *q,
- int nbits);
-int rsa_get_lcm(BN_CTX *ctx, const BIGNUM *p, const BIGNUM *q,
- BIGNUM *lcm, BIGNUM *gcd, BIGNUM *p1, BIGNUM *q1,
- BIGNUM *p1q1);
-
-int rsa_check_public_exponent(const BIGNUM *e);
-int rsa_check_private_exponent(const RSA *rsa, int nbits, BN_CTX *ctx);
-int rsa_check_prime_factor(BIGNUM *p, BIGNUM *e, int nbits, BN_CTX *ctx);
-int rsa_check_prime_factor_range(const BIGNUM *p, int nbits, BN_CTX *ctx);
-int rsa_check_crt_components(const RSA *rsa, BN_CTX *ctx);
-
-int rsa_sp800_56b_pairwise_test(RSA *rsa, BN_CTX *ctx);
-int rsa_sp800_56b_check_public(const RSA *rsa);
-int rsa_sp800_56b_check_private(const RSA *rsa);
-int rsa_sp800_56b_check_keypair(const RSA *rsa, const BIGNUM *efixed,
- int strength, int nbits);
-int rsa_sp800_56b_generate_key(RSA *rsa, int nbits, const BIGNUM *efixed,
- BN_GENCB *cb);
-
-int rsa_sp800_56b_derive_params_from_pq(RSA *rsa, int nbits,
- const BIGNUM *e, BN_CTX *ctx);
-int rsa_fips186_4_gen_prob_primes(RSA *rsa, BIGNUM *p1, BIGNUM *p2,
- BIGNUM *Xpout, const BIGNUM *Xp,
- const BIGNUM *Xp1, const BIGNUM *Xp2,
- BIGNUM *q1, BIGNUM *q2, BIGNUM *Xqout,
- const BIGNUM *Xq, const BIGNUM *Xq1,
- const BIGNUM *Xq2, int nbits,
- const BIGNUM *e, BN_CTX *ctx, BN_GENCB *cb);
-
-#endif /* RSA_LOCAL_HEADER_H */
*/
#include <string.h>
-#include "rsa_locl.h"
+#include "rsa_local.h"
#include <openssl/err.h>
RSA_METHOD *RSA_meth_new(const char *name, int flags)
#include <openssl/bn.h>
#include <openssl/err.h>
-#include "rsa_locl.h"
+#include "rsa_local.h"
void rsa_multip_info_free_ex(RSA_PRIME_INFO *pinfo)
{
* one-wayness. For the RSA function, this is an equivalent notion.
*/
-#include "internal/constant_time_locl.h"
+#include "internal/constant_time.h"
#include <stdio.h>
#include "internal/cryptlib.h"
#include <openssl/evp.h>
#include <openssl/rand.h>
#include <openssl/sha.h>
-#include "rsa_locl.h"
+#include "rsa_local.h"
int RSA_padding_add_PKCS1_OAEP(unsigned char *to, int tlen,
const unsigned char *from, int flen,
#include "internal/cryptlib.h"
#include "crypto/bn.h"
-#include "rsa_locl.h"
-#include "internal/constant_time_locl.h"
+#include "rsa_local.h"
+#include "internal/constant_time.h"
static int rsa_ossl_public_encrypt(int flen, const unsigned char *from,
unsigned char *to, RSA *rsa, int padding);
* https://www.openssl.org/source/license.html
*/
-#include "internal/constant_time_locl.h"
+#include "internal/constant_time.h"
#include <stdio.h>
#include "internal/cryptlib.h"
* https://www.openssl.org/source/license.html
*/
-#include "internal/constant_time_locl.h"
+#include "internal/constant_time.h"
#include <stdio.h>
#include "internal/cryptlib.h"
#include <openssl/x509v3.h>
#include <openssl/cms.h>
#include "crypto/evp.h"
-#include "rsa_locl.h"
+#include "rsa_local.h"
/* RSA pkey context structure */
#include <openssl/evp.h>
#include <openssl/rand.h>
#include <openssl/sha.h>
-#include "rsa_locl.h"
+#include "rsa_local.h"
static const unsigned char zeroes[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
#include <openssl/objects.h>
#include <openssl/x509.h>
#include "crypto/x509.h"
-#include "rsa_locl.h"
+#include "rsa_local.h"
/* Size of an SSL signature: MD5+SHA1 */
#define SSL_SIG_LENGTH 36
#include <openssl/err.h>
#include <openssl/bn.h>
#include "crypto/bn.h"
-#include "rsa_locl.h"
+#include "rsa_local.h"
/*
* Part of the RSA keypair test.
#include <openssl/err.h>
#include <openssl/bn.h>
#include "crypto/bn.h"
-#include "rsa_locl.h"
+#include "rsa_local.h"
#define RSA_FIPS1864_MIN_KEYGEN_KEYSIZE 2048
#define RSA_FIPS1864_MIN_KEYGEN_STRENGTH 112
#include <openssl/bn.h>
#include <openssl/rsa.h>
#include <openssl/rand.h>
-#include "internal/constant_time_locl.h"
+#include "internal/constant_time.h"
int RSA_padding_add_SSLv23(unsigned char *to, int tlen,
const unsigned char *from, int flen)
#include <time.h>
#include <openssl/err.h>
#include <openssl/bn.h>
-#include "rsa_locl.h"
+#include "rsa_local.h"
/* X9.31 RSA key derivation and generation */
# endif
# include <openssl/seed.h>
-# include "seed_locl.h"
+# include "seed_local.h"
# ifdef SS /* can get defined on Solaris by inclusion of
* <stdlib.h> */
--- /dev/null
+/*
+ * Copyright 2007-2018 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+/*
+ * Copyright (c) 2007 KISA(Korea Information Security Agency). All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Neither the name of author nor the names of its contributors may
+ * be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * 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.
+ *
+ */
+#ifndef HEADER_SEED_LOCL_H
+# define HEADER_SEED_LOCL_H
+
+# include "openssl/e_os2.h"
+# include <openssl/seed.h>
+
+# ifdef SEED_LONG /* need 32-bit type */
+typedef unsigned long seed_word;
+# else
+typedef unsigned int seed_word;
+# endif
+
+
+# define char2word(c, i) \
+ (i) = ((((seed_word)(c)[0]) << 24) | (((seed_word)(c)[1]) << 16) | (((seed_word)(c)[2]) << 8) | ((seed_word)(c)[3]))
+
+# define word2char(l, c) \
+ *((c)+0) = (unsigned char)((l)>>24) & 0xff; \
+ *((c)+1) = (unsigned char)((l)>>16) & 0xff; \
+ *((c)+2) = (unsigned char)((l)>> 8) & 0xff; \
+ *((c)+3) = (unsigned char)((l)) & 0xff
+
+# define KEYSCHEDULE_UPDATE0(T0, T1, X1, X2, X3, X4, KC) \
+ (T0) = (X3); \
+ (X3) = (((X3)<<8) ^ ((X4)>>24)) & 0xffffffff; \
+ (X4) = (((X4)<<8) ^ ((T0)>>24)) & 0xffffffff; \
+ (T0) = ((X1) + (X3) - (KC)) & 0xffffffff; \
+ (T1) = ((X2) + (KC) - (X4)) & 0xffffffff
+
+# define KEYSCHEDULE_UPDATE1(T0, T1, X1, X2, X3, X4, KC) \
+ (T0) = (X1); \
+ (X1) = (((X1)>>8) ^ ((X2)<<24)) & 0xffffffff; \
+ (X2) = (((X2)>>8) ^ ((T0)<<24)) & 0xffffffff; \
+ (T0) = ((X1) + (X3) - (KC)) & 0xffffffff; \
+ (T1) = ((X2) + (KC) - (X4)) & 0xffffffff
+
+# define KEYUPDATE_TEMP(T0, T1, K) \
+ (K)[0] = G_FUNC((T0)); \
+ (K)[1] = G_FUNC((T1))
+
+# define XOR_SEEDBLOCK(DST, SRC) \
+ ((DST))[0] ^= ((SRC))[0]; \
+ ((DST))[1] ^= ((SRC))[1]; \
+ ((DST))[2] ^= ((SRC))[2]; \
+ ((DST))[3] ^= ((SRC))[3]
+
+# define MOV_SEEDBLOCK(DST, SRC) \
+ ((DST))[0] = ((SRC))[0]; \
+ ((DST))[1] = ((SRC))[1]; \
+ ((DST))[2] = ((SRC))[2]; \
+ ((DST))[3] = ((SRC))[3]
+
+# define CHAR2WORD(C, I) \
+ char2word((C), (I)[0]); \
+ char2word((C+4), (I)[1]); \
+ char2word((C+8), (I)[2]); \
+ char2word((C+12), (I)[3])
+
+# define WORD2CHAR(I, C) \
+ word2char((I)[0], (C)); \
+ word2char((I)[1], (C+4)); \
+ word2char((I)[2], (C+8)); \
+ word2char((I)[3], (C+12))
+
+# define E_SEED(T0, T1, X1, X2, X3, X4, rbase) \
+ (T0) = (X3) ^ (ks->data)[(rbase)]; \
+ (T1) = (X4) ^ (ks->data)[(rbase)+1]; \
+ (T1) ^= (T0); \
+ (T1) = G_FUNC((T1)); \
+ (T0) = ((T0) + (T1)) & 0xffffffff; \
+ (T0) = G_FUNC((T0)); \
+ (T1) = ((T1) + (T0)) & 0xffffffff; \
+ (T1) = G_FUNC((T1)); \
+ (T0) = ((T0) + (T1)) & 0xffffffff; \
+ (X1) ^= (T0); \
+ (X2) ^= (T1)
+
+#endif /* HEADER_SEED_LOCL_H */
+++ /dev/null
-/*
- * Copyright 2007-2018 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-/*
- * Copyright (c) 2007 KISA(Korea Information Security Agency). All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Neither the name of author nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * 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.
- *
- */
-#ifndef HEADER_SEED_LOCL_H
-# define HEADER_SEED_LOCL_H
-
-# include "openssl/e_os2.h"
-# include <openssl/seed.h>
-
-# ifdef SEED_LONG /* need 32-bit type */
-typedef unsigned long seed_word;
-# else
-typedef unsigned int seed_word;
-# endif
-
-
-# define char2word(c, i) \
- (i) = ((((seed_word)(c)[0]) << 24) | (((seed_word)(c)[1]) << 16) | (((seed_word)(c)[2]) << 8) | ((seed_word)(c)[3]))
-
-# define word2char(l, c) \
- *((c)+0) = (unsigned char)((l)>>24) & 0xff; \
- *((c)+1) = (unsigned char)((l)>>16) & 0xff; \
- *((c)+2) = (unsigned char)((l)>> 8) & 0xff; \
- *((c)+3) = (unsigned char)((l)) & 0xff
-
-# define KEYSCHEDULE_UPDATE0(T0, T1, X1, X2, X3, X4, KC) \
- (T0) = (X3); \
- (X3) = (((X3)<<8) ^ ((X4)>>24)) & 0xffffffff; \
- (X4) = (((X4)<<8) ^ ((T0)>>24)) & 0xffffffff; \
- (T0) = ((X1) + (X3) - (KC)) & 0xffffffff; \
- (T1) = ((X2) + (KC) - (X4)) & 0xffffffff
-
-# define KEYSCHEDULE_UPDATE1(T0, T1, X1, X2, X3, X4, KC) \
- (T0) = (X1); \
- (X1) = (((X1)>>8) ^ ((X2)<<24)) & 0xffffffff; \
- (X2) = (((X2)>>8) ^ ((T0)<<24)) & 0xffffffff; \
- (T0) = ((X1) + (X3) - (KC)) & 0xffffffff; \
- (T1) = ((X2) + (KC) - (X4)) & 0xffffffff
-
-# define KEYUPDATE_TEMP(T0, T1, K) \
- (K)[0] = G_FUNC((T0)); \
- (K)[1] = G_FUNC((T1))
-
-# define XOR_SEEDBLOCK(DST, SRC) \
- ((DST))[0] ^= ((SRC))[0]; \
- ((DST))[1] ^= ((SRC))[1]; \
- ((DST))[2] ^= ((SRC))[2]; \
- ((DST))[3] ^= ((SRC))[3]
-
-# define MOV_SEEDBLOCK(DST, SRC) \
- ((DST))[0] = ((SRC))[0]; \
- ((DST))[1] = ((SRC))[1]; \
- ((DST))[2] = ((SRC))[2]; \
- ((DST))[3] = ((SRC))[3]
-
-# define CHAR2WORD(C, I) \
- char2word((C), (I)[0]); \
- char2word((C+4), (I)[1]); \
- char2word((C+8), (I)[2]); \
- char2word((C+12), (I)[3])
-
-# define WORD2CHAR(I, C) \
- word2char((I)[0], (C)); \
- word2char((I)[1], (C+4)); \
- word2char((I)[2], (C+8)); \
- word2char((I)[3], (C+12))
-
-# define E_SEED(T0, T1, X1, X2, X3, X4, rbase) \
- (T0) = (X3) ^ (ks->data)[(rbase)]; \
- (T1) = (X4) ^ (ks->data)[(rbase)+1]; \
- (T1) ^= (T0); \
- (T1) = G_FUNC((T1)); \
- (T0) = ((T0) + (T1)) & 0xffffffff; \
- (T0) = G_FUNC((T0)); \
- (T1) = ((T1) + (T0)) & 0xffffffff; \
- (T1) = G_FUNC((T1)); \
- (T0) = ((T0) + (T1)) & 0xffffffff; \
- (X1) ^= (T0); \
- (X2) ^= (T1)
-
-#endif /* HEADER_SEED_LOCL_H */
/* The implementation is in ../md32_common.h */
-#include "sha_locl.h"
+#include "sha_local.h"
#include "crypto/sha.h"
int sha1_ctrl(SHA_CTX *sha1, int cmd, int mslen, void *ms)
--- /dev/null
+/*
+ * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <openssl/opensslconf.h>
+#include <openssl/sha.h>
+
+#define DATA_ORDER_IS_BIG_ENDIAN
+
+#define HASH_LONG SHA_LONG
+#define HASH_CTX SHA_CTX
+#define HASH_CBLOCK SHA_CBLOCK
+#define HASH_MAKE_STRING(c,s) do { \
+ unsigned long ll; \
+ ll=(c)->h0; (void)HOST_l2c(ll,(s)); \
+ ll=(c)->h1; (void)HOST_l2c(ll,(s)); \
+ ll=(c)->h2; (void)HOST_l2c(ll,(s)); \
+ ll=(c)->h3; (void)HOST_l2c(ll,(s)); \
+ ll=(c)->h4; (void)HOST_l2c(ll,(s)); \
+ } while (0)
+
+#define HASH_UPDATE SHA1_Update
+#define HASH_TRANSFORM SHA1_Transform
+#define HASH_FINAL SHA1_Final
+#define HASH_INIT SHA1_Init
+#define HASH_BLOCK_DATA_ORDER sha1_block_data_order
+#define Xupdate(a,ix,ia,ib,ic,id) ( (a)=(ia^ib^ic^id), \
+ ix=(a)=ROTATE((a),1) \
+ )
+
+#ifndef SHA1_ASM
+static void sha1_block_data_order(SHA_CTX *c, const void *p, size_t num);
+#else
+void sha1_block_data_order(SHA_CTX *c, const void *p, size_t num);
+#endif
+
+#include "crypto/md32_common.h"
+
+#define INIT_DATA_h0 0x67452301UL
+#define INIT_DATA_h1 0xefcdab89UL
+#define INIT_DATA_h2 0x98badcfeUL
+#define INIT_DATA_h3 0x10325476UL
+#define INIT_DATA_h4 0xc3d2e1f0UL
+
+int HASH_INIT(SHA_CTX *c)
+{
+ memset(c, 0, sizeof(*c));
+ c->h0 = INIT_DATA_h0;
+ c->h1 = INIT_DATA_h1;
+ c->h2 = INIT_DATA_h2;
+ c->h3 = INIT_DATA_h3;
+ c->h4 = INIT_DATA_h4;
+ return 1;
+}
+
+#define K_00_19 0x5a827999UL
+#define K_20_39 0x6ed9eba1UL
+#define K_40_59 0x8f1bbcdcUL
+#define K_60_79 0xca62c1d6UL
+
+/*
+ * As pointed out by Wei Dai, F() below can be simplified to the code in
+ * F_00_19. Wei attributes these optimizations to Peter Gutmann's SHS code,
+ * and he attributes it to Rich Schroeppel.
+ * #define F(x,y,z) (((x) & (y)) | ((~(x)) & (z)))
+ * I've just become aware of another tweak to be made, again from Wei Dai,
+ * in F_40_59, (x&a)|(y&a) -> (x|y)&a
+ */
+#define F_00_19(b,c,d) ((((c) ^ (d)) & (b)) ^ (d))
+#define F_20_39(b,c,d) ((b) ^ (c) ^ (d))
+#define F_40_59(b,c,d) (((b) & (c)) | (((b)|(c)) & (d)))
+#define F_60_79(b,c,d) F_20_39(b,c,d)
+
+#ifndef OPENSSL_SMALL_FOOTPRINT
+
+# define BODY_00_15(i,a,b,c,d,e,f,xi) \
+ (f)=xi+(e)+K_00_19+ROTATE((a),5)+F_00_19((b),(c),(d)); \
+ (b)=ROTATE((b),30);
+
+# define BODY_16_19(i,a,b,c,d,e,f,xi,xa,xb,xc,xd) \
+ Xupdate(f,xi,xa,xb,xc,xd); \
+ (f)+=(e)+K_00_19+ROTATE((a),5)+F_00_19((b),(c),(d)); \
+ (b)=ROTATE((b),30);
+
+# define BODY_20_31(i,a,b,c,d,e,f,xi,xa,xb,xc,xd) \
+ Xupdate(f,xi,xa,xb,xc,xd); \
+ (f)+=(e)+K_20_39+ROTATE((a),5)+F_20_39((b),(c),(d)); \
+ (b)=ROTATE((b),30);
+
+# define BODY_32_39(i,a,b,c,d,e,f,xa,xb,xc,xd) \
+ Xupdate(f,xa,xa,xb,xc,xd); \
+ (f)+=(e)+K_20_39+ROTATE((a),5)+F_20_39((b),(c),(d)); \
+ (b)=ROTATE((b),30);
+
+# define BODY_40_59(i,a,b,c,d,e,f,xa,xb,xc,xd) \
+ Xupdate(f,xa,xa,xb,xc,xd); \
+ (f)+=(e)+K_40_59+ROTATE((a),5)+F_40_59((b),(c),(d)); \
+ (b)=ROTATE((b),30);
+
+# define BODY_60_79(i,a,b,c,d,e,f,xa,xb,xc,xd) \
+ Xupdate(f,xa,xa,xb,xc,xd); \
+ (f)=xa+(e)+K_60_79+ROTATE((a),5)+F_60_79((b),(c),(d)); \
+ (b)=ROTATE((b),30);
+
+# ifdef X
+# undef X
+# endif
+# ifndef MD32_XARRAY
+ /*
+ * Originally X was an array. As it's automatic it's natural
+ * to expect RISC compiler to accommodate at least part of it in
+ * the register bank, isn't it? Unfortunately not all compilers
+ * "find" this expectation reasonable:-( On order to make such
+ * compilers generate better code I replace X[] with a bunch of
+ * X0, X1, etc. See the function body below...
+ */
+# define X(i) XX##i
+# else
+ /*
+ * However! Some compilers (most notably HP C) get overwhelmed by
+ * that many local variables so that we have to have the way to
+ * fall down to the original behavior.
+ */
+# define X(i) XX[i]
+# endif
+
+# if !defined(SHA1_ASM)
+static void HASH_BLOCK_DATA_ORDER(SHA_CTX *c, const void *p, size_t num)
+{
+ const unsigned char *data = p;
+ register unsigned MD32_REG_T A, B, C, D, E, T, l;
+# ifndef MD32_XARRAY
+ unsigned MD32_REG_T XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7,
+ XX8, XX9, XX10, XX11, XX12, XX13, XX14, XX15;
+# else
+ SHA_LONG XX[16];
+# endif
+
+ A = c->h0;
+ B = c->h1;
+ C = c->h2;
+ D = c->h3;
+ E = c->h4;
+
+ for (;;) {
+ const union {
+ long one;
+ char little;
+ } is_endian = {
+ 1
+ };
+
+ if (!is_endian.little && sizeof(SHA_LONG) == 4
+ && ((size_t)p % 4) == 0) {
+ const SHA_LONG *W = (const SHA_LONG *)data;
+
+ X(0) = W[0];
+ X(1) = W[1];
+ BODY_00_15(0, A, B, C, D, E, T, X(0));
+ X(2) = W[2];
+ BODY_00_15(1, T, A, B, C, D, E, X(1));
+ X(3) = W[3];
+ BODY_00_15(2, E, T, A, B, C, D, X(2));
+ X(4) = W[4];
+ BODY_00_15(3, D, E, T, A, B, C, X(3));
+ X(5) = W[5];
+ BODY_00_15(4, C, D, E, T, A, B, X(4));
+ X(6) = W[6];
+ BODY_00_15(5, B, C, D, E, T, A, X(5));
+ X(7) = W[7];
+ BODY_00_15(6, A, B, C, D, E, T, X(6));
+ X(8) = W[8];
+ BODY_00_15(7, T, A, B, C, D, E, X(7));
+ X(9) = W[9];
+ BODY_00_15(8, E, T, A, B, C, D, X(8));
+ X(10) = W[10];
+ BODY_00_15(9, D, E, T, A, B, C, X(9));
+ X(11) = W[11];
+ BODY_00_15(10, C, D, E, T, A, B, X(10));
+ X(12) = W[12];
+ BODY_00_15(11, B, C, D, E, T, A, X(11));
+ X(13) = W[13];
+ BODY_00_15(12, A, B, C, D, E, T, X(12));
+ X(14) = W[14];
+ BODY_00_15(13, T, A, B, C, D, E, X(13));
+ X(15) = W[15];
+ BODY_00_15(14, E, T, A, B, C, D, X(14));
+ BODY_00_15(15, D, E, T, A, B, C, X(15));
+
+ data += SHA_CBLOCK;
+ } else {
+ (void)HOST_c2l(data, l);
+ X(0) = l;
+ (void)HOST_c2l(data, l);
+ X(1) = l;
+ BODY_00_15(0, A, B, C, D, E, T, X(0));
+ (void)HOST_c2l(data, l);
+ X(2) = l;
+ BODY_00_15(1, T, A, B, C, D, E, X(1));
+ (void)HOST_c2l(data, l);
+ X(3) = l;
+ BODY_00_15(2, E, T, A, B, C, D, X(2));
+ (void)HOST_c2l(data, l);
+ X(4) = l;
+ BODY_00_15(3, D, E, T, A, B, C, X(3));
+ (void)HOST_c2l(data, l);
+ X(5) = l;
+ BODY_00_15(4, C, D, E, T, A, B, X(4));
+ (void)HOST_c2l(data, l);
+ X(6) = l;
+ BODY_00_15(5, B, C, D, E, T, A, X(5));
+ (void)HOST_c2l(data, l);
+ X(7) = l;
+ BODY_00_15(6, A, B, C, D, E, T, X(6));
+ (void)HOST_c2l(data, l);
+ X(8) = l;
+ BODY_00_15(7, T, A, B, C, D, E, X(7));
+ (void)HOST_c2l(data, l);
+ X(9) = l;
+ BODY_00_15(8, E, T, A, B, C, D, X(8));
+ (void)HOST_c2l(data, l);
+ X(10) = l;
+ BODY_00_15(9, D, E, T, A, B, C, X(9));
+ (void)HOST_c2l(data, l);
+ X(11) = l;
+ BODY_00_15(10, C, D, E, T, A, B, X(10));
+ (void)HOST_c2l(data, l);
+ X(12) = l;
+ BODY_00_15(11, B, C, D, E, T, A, X(11));
+ (void)HOST_c2l(data, l);
+ X(13) = l;
+ BODY_00_15(12, A, B, C, D, E, T, X(12));
+ (void)HOST_c2l(data, l);
+ X(14) = l;
+ BODY_00_15(13, T, A, B, C, D, E, X(13));
+ (void)HOST_c2l(data, l);
+ X(15) = l;
+ BODY_00_15(14, E, T, A, B, C, D, X(14));
+ BODY_00_15(15, D, E, T, A, B, C, X(15));
+ }
+
+ BODY_16_19(16, C, D, E, T, A, B, X(0), X(0), X(2), X(8), X(13));
+ BODY_16_19(17, B, C, D, E, T, A, X(1), X(1), X(3), X(9), X(14));
+ BODY_16_19(18, A, B, C, D, E, T, X(2), X(2), X(4), X(10), X(15));
+ BODY_16_19(19, T, A, B, C, D, E, X(3), X(3), X(5), X(11), X(0));
+
+ BODY_20_31(20, E, T, A, B, C, D, X(4), X(4), X(6), X(12), X(1));
+ BODY_20_31(21, D, E, T, A, B, C, X(5), X(5), X(7), X(13), X(2));
+ BODY_20_31(22, C, D, E, T, A, B, X(6), X(6), X(8), X(14), X(3));
+ BODY_20_31(23, B, C, D, E, T, A, X(7), X(7), X(9), X(15), X(4));
+ BODY_20_31(24, A, B, C, D, E, T, X(8), X(8), X(10), X(0), X(5));
+ BODY_20_31(25, T, A, B, C, D, E, X(9), X(9), X(11), X(1), X(6));
+ BODY_20_31(26, E, T, A, B, C, D, X(10), X(10), X(12), X(2), X(7));
+ BODY_20_31(27, D, E, T, A, B, C, X(11), X(11), X(13), X(3), X(8));
+ BODY_20_31(28, C, D, E, T, A, B, X(12), X(12), X(14), X(4), X(9));
+ BODY_20_31(29, B, C, D, E, T, A, X(13), X(13), X(15), X(5), X(10));
+ BODY_20_31(30, A, B, C, D, E, T, X(14), X(14), X(0), X(6), X(11));
+ BODY_20_31(31, T, A, B, C, D, E, X(15), X(15), X(1), X(7), X(12));
+
+ BODY_32_39(32, E, T, A, B, C, D, X(0), X(2), X(8), X(13));
+ BODY_32_39(33, D, E, T, A, B, C, X(1), X(3), X(9), X(14));
+ BODY_32_39(34, C, D, E, T, A, B, X(2), X(4), X(10), X(15));
+ BODY_32_39(35, B, C, D, E, T, A, X(3), X(5), X(11), X(0));
+ BODY_32_39(36, A, B, C, D, E, T, X(4), X(6), X(12), X(1));
+ BODY_32_39(37, T, A, B, C, D, E, X(5), X(7), X(13), X(2));
+ BODY_32_39(38, E, T, A, B, C, D, X(6), X(8), X(14), X(3));
+ BODY_32_39(39, D, E, T, A, B, C, X(7), X(9), X(15), X(4));
+
+ BODY_40_59(40, C, D, E, T, A, B, X(8), X(10), X(0), X(5));
+ BODY_40_59(41, B, C, D, E, T, A, X(9), X(11), X(1), X(6));
+ BODY_40_59(42, A, B, C, D, E, T, X(10), X(12), X(2), X(7));
+ BODY_40_59(43, T, A, B, C, D, E, X(11), X(13), X(3), X(8));
+ BODY_40_59(44, E, T, A, B, C, D, X(12), X(14), X(4), X(9));
+ BODY_40_59(45, D, E, T, A, B, C, X(13), X(15), X(5), X(10));
+ BODY_40_59(46, C, D, E, T, A, B, X(14), X(0), X(6), X(11));
+ BODY_40_59(47, B, C, D, E, T, A, X(15), X(1), X(7), X(12));
+ BODY_40_59(48, A, B, C, D, E, T, X(0), X(2), X(8), X(13));
+ BODY_40_59(49, T, A, B, C, D, E, X(1), X(3), X(9), X(14));
+ BODY_40_59(50, E, T, A, B, C, D, X(2), X(4), X(10), X(15));
+ BODY_40_59(51, D, E, T, A, B, C, X(3), X(5), X(11), X(0));
+ BODY_40_59(52, C, D, E, T, A, B, X(4), X(6), X(12), X(1));
+ BODY_40_59(53, B, C, D, E, T, A, X(5), X(7), X(13), X(2));
+ BODY_40_59(54, A, B, C, D, E, T, X(6), X(8), X(14), X(3));
+ BODY_40_59(55, T, A, B, C, D, E, X(7), X(9), X(15), X(4));
+ BODY_40_59(56, E, T, A, B, C, D, X(8), X(10), X(0), X(5));
+ BODY_40_59(57, D, E, T, A, B, C, X(9), X(11), X(1), X(6));
+ BODY_40_59(58, C, D, E, T, A, B, X(10), X(12), X(2), X(7));
+ BODY_40_59(59, B, C, D, E, T, A, X(11), X(13), X(3), X(8));
+
+ BODY_60_79(60, A, B, C, D, E, T, X(12), X(14), X(4), X(9));
+ BODY_60_79(61, T, A, B, C, D, E, X(13), X(15), X(5), X(10));
+ BODY_60_79(62, E, T, A, B, C, D, X(14), X(0), X(6), X(11));
+ BODY_60_79(63, D, E, T, A, B, C, X(15), X(1), X(7), X(12));
+ BODY_60_79(64, C, D, E, T, A, B, X(0), X(2), X(8), X(13));
+ BODY_60_79(65, B, C, D, E, T, A, X(1), X(3), X(9), X(14));
+ BODY_60_79(66, A, B, C, D, E, T, X(2), X(4), X(10), X(15));
+ BODY_60_79(67, T, A, B, C, D, E, X(3), X(5), X(11), X(0));
+ BODY_60_79(68, E, T, A, B, C, D, X(4), X(6), X(12), X(1));
+ BODY_60_79(69, D, E, T, A, B, C, X(5), X(7), X(13), X(2));
+ BODY_60_79(70, C, D, E, T, A, B, X(6), X(8), X(14), X(3));
+ BODY_60_79(71, B, C, D, E, T, A, X(7), X(9), X(15), X(4));
+ BODY_60_79(72, A, B, C, D, E, T, X(8), X(10), X(0), X(5));
+ BODY_60_79(73, T, A, B, C, D, E, X(9), X(11), X(1), X(6));
+ BODY_60_79(74, E, T, A, B, C, D, X(10), X(12), X(2), X(7));
+ BODY_60_79(75, D, E, T, A, B, C, X(11), X(13), X(3), X(8));
+ BODY_60_79(76, C, D, E, T, A, B, X(12), X(14), X(4), X(9));
+ BODY_60_79(77, B, C, D, E, T, A, X(13), X(15), X(5), X(10));
+ BODY_60_79(78, A, B, C, D, E, T, X(14), X(0), X(6), X(11));
+ BODY_60_79(79, T, A, B, C, D, E, X(15), X(1), X(7), X(12));
+
+ c->h0 = (c->h0 + E) & 0xffffffffL;
+ c->h1 = (c->h1 + T) & 0xffffffffL;
+ c->h2 = (c->h2 + A) & 0xffffffffL;
+ c->h3 = (c->h3 + B) & 0xffffffffL;
+ c->h4 = (c->h4 + C) & 0xffffffffL;
+
+ if (--num == 0)
+ break;
+
+ A = c->h0;
+ B = c->h1;
+ C = c->h2;
+ D = c->h3;
+ E = c->h4;
+
+ }
+}
+# endif
+
+#else /* OPENSSL_SMALL_FOOTPRINT */
+
+# define BODY_00_15(xi) do { \
+ T=E+K_00_19+F_00_19(B,C,D); \
+ E=D, D=C, C=ROTATE(B,30), B=A; \
+ A=ROTATE(A,5)+T+xi; } while(0)
+
+# define BODY_16_19(xa,xb,xc,xd) do { \
+ Xupdate(T,xa,xa,xb,xc,xd); \
+ T+=E+K_00_19+F_00_19(B,C,D); \
+ E=D, D=C, C=ROTATE(B,30), B=A; \
+ A=ROTATE(A,5)+T; } while(0)
+
+# define BODY_20_39(xa,xb,xc,xd) do { \
+ Xupdate(T,xa,xa,xb,xc,xd); \
+ T+=E+K_20_39+F_20_39(B,C,D); \
+ E=D, D=C, C=ROTATE(B,30), B=A; \
+ A=ROTATE(A,5)+T; } while(0)
+
+# define BODY_40_59(xa,xb,xc,xd) do { \
+ Xupdate(T,xa,xa,xb,xc,xd); \
+ T+=E+K_40_59+F_40_59(B,C,D); \
+ E=D, D=C, C=ROTATE(B,30), B=A; \
+ A=ROTATE(A,5)+T; } while(0)
+
+# define BODY_60_79(xa,xb,xc,xd) do { \
+ Xupdate(T,xa,xa,xb,xc,xd); \
+ T=E+K_60_79+F_60_79(B,C,D); \
+ E=D, D=C, C=ROTATE(B,30), B=A; \
+ A=ROTATE(A,5)+T+xa; } while(0)
+
+# if !defined(SHA1_ASM)
+static void HASH_BLOCK_DATA_ORDER(SHA_CTX *c, const void *p, size_t num)
+{
+ const unsigned char *data = p;
+ register unsigned MD32_REG_T A, B, C, D, E, T, l;
+ int i;
+ SHA_LONG X[16];
+
+ A = c->h0;
+ B = c->h1;
+ C = c->h2;
+ D = c->h3;
+ E = c->h4;
+
+ for (;;) {
+ for (i = 0; i < 16; i++) {
+ (void)HOST_c2l(data, l);
+ X[i] = l;
+ BODY_00_15(X[i]);
+ }
+ for (i = 0; i < 4; i++) {
+ BODY_16_19(X[i], X[i + 2], X[i + 8], X[(i + 13) & 15]);
+ }
+ for (; i < 24; i++) {
+ BODY_20_39(X[i & 15], X[(i + 2) & 15], X[(i + 8) & 15],
+ X[(i + 13) & 15]);
+ }
+ for (i = 0; i < 20; i++) {
+ BODY_40_59(X[(i + 8) & 15], X[(i + 10) & 15], X[i & 15],
+ X[(i + 5) & 15]);
+ }
+ for (i = 4; i < 24; i++) {
+ BODY_60_79(X[(i + 8) & 15], X[(i + 10) & 15], X[i & 15],
+ X[(i + 5) & 15]);
+ }
+
+ c->h0 = (c->h0 + A) & 0xffffffffL;
+ c->h1 = (c->h1 + B) & 0xffffffffL;
+ c->h2 = (c->h2 + C) & 0xffffffffL;
+ c->h3 = (c->h3 + D) & 0xffffffffL;
+ c->h4 = (c->h4 + E) & 0xffffffffL;
+
+ if (--num == 0)
+ break;
+
+ A = c->h0;
+ B = c->h1;
+ C = c->h2;
+ D = c->h3;
+ E = c->h4;
+
+ }
+}
+# endif
+
+#endif
+++ /dev/null
-/*
- * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-#include <stdlib.h>
-#include <string.h>
-
-#include <openssl/opensslconf.h>
-#include <openssl/sha.h>
-
-#define DATA_ORDER_IS_BIG_ENDIAN
-
-#define HASH_LONG SHA_LONG
-#define HASH_CTX SHA_CTX
-#define HASH_CBLOCK SHA_CBLOCK
-#define HASH_MAKE_STRING(c,s) do { \
- unsigned long ll; \
- ll=(c)->h0; (void)HOST_l2c(ll,(s)); \
- ll=(c)->h1; (void)HOST_l2c(ll,(s)); \
- ll=(c)->h2; (void)HOST_l2c(ll,(s)); \
- ll=(c)->h3; (void)HOST_l2c(ll,(s)); \
- ll=(c)->h4; (void)HOST_l2c(ll,(s)); \
- } while (0)
-
-#define HASH_UPDATE SHA1_Update
-#define HASH_TRANSFORM SHA1_Transform
-#define HASH_FINAL SHA1_Final
-#define HASH_INIT SHA1_Init
-#define HASH_BLOCK_DATA_ORDER sha1_block_data_order
-#define Xupdate(a,ix,ia,ib,ic,id) ( (a)=(ia^ib^ic^id), \
- ix=(a)=ROTATE((a),1) \
- )
-
-#ifndef SHA1_ASM
-static void sha1_block_data_order(SHA_CTX *c, const void *p, size_t num);
-#else
-void sha1_block_data_order(SHA_CTX *c, const void *p, size_t num);
-#endif
-
-#include "crypto/md32_common.h"
-
-#define INIT_DATA_h0 0x67452301UL
-#define INIT_DATA_h1 0xefcdab89UL
-#define INIT_DATA_h2 0x98badcfeUL
-#define INIT_DATA_h3 0x10325476UL
-#define INIT_DATA_h4 0xc3d2e1f0UL
-
-int HASH_INIT(SHA_CTX *c)
-{
- memset(c, 0, sizeof(*c));
- c->h0 = INIT_DATA_h0;
- c->h1 = INIT_DATA_h1;
- c->h2 = INIT_DATA_h2;
- c->h3 = INIT_DATA_h3;
- c->h4 = INIT_DATA_h4;
- return 1;
-}
-
-#define K_00_19 0x5a827999UL
-#define K_20_39 0x6ed9eba1UL
-#define K_40_59 0x8f1bbcdcUL
-#define K_60_79 0xca62c1d6UL
-
-/*
- * As pointed out by Wei Dai, F() below can be simplified to the code in
- * F_00_19. Wei attributes these optimizations to Peter Gutmann's SHS code,
- * and he attributes it to Rich Schroeppel.
- * #define F(x,y,z) (((x) & (y)) | ((~(x)) & (z)))
- * I've just become aware of another tweak to be made, again from Wei Dai,
- * in F_40_59, (x&a)|(y&a) -> (x|y)&a
- */
-#define F_00_19(b,c,d) ((((c) ^ (d)) & (b)) ^ (d))
-#define F_20_39(b,c,d) ((b) ^ (c) ^ (d))
-#define F_40_59(b,c,d) (((b) & (c)) | (((b)|(c)) & (d)))
-#define F_60_79(b,c,d) F_20_39(b,c,d)
-
-#ifndef OPENSSL_SMALL_FOOTPRINT
-
-# define BODY_00_15(i,a,b,c,d,e,f,xi) \
- (f)=xi+(e)+K_00_19+ROTATE((a),5)+F_00_19((b),(c),(d)); \
- (b)=ROTATE((b),30);
-
-# define BODY_16_19(i,a,b,c,d,e,f,xi,xa,xb,xc,xd) \
- Xupdate(f,xi,xa,xb,xc,xd); \
- (f)+=(e)+K_00_19+ROTATE((a),5)+F_00_19((b),(c),(d)); \
- (b)=ROTATE((b),30);
-
-# define BODY_20_31(i,a,b,c,d,e,f,xi,xa,xb,xc,xd) \
- Xupdate(f,xi,xa,xb,xc,xd); \
- (f)+=(e)+K_20_39+ROTATE((a),5)+F_20_39((b),(c),(d)); \
- (b)=ROTATE((b),30);
-
-# define BODY_32_39(i,a,b,c,d,e,f,xa,xb,xc,xd) \
- Xupdate(f,xa,xa,xb,xc,xd); \
- (f)+=(e)+K_20_39+ROTATE((a),5)+F_20_39((b),(c),(d)); \
- (b)=ROTATE((b),30);
-
-# define BODY_40_59(i,a,b,c,d,e,f,xa,xb,xc,xd) \
- Xupdate(f,xa,xa,xb,xc,xd); \
- (f)+=(e)+K_40_59+ROTATE((a),5)+F_40_59((b),(c),(d)); \
- (b)=ROTATE((b),30);
-
-# define BODY_60_79(i,a,b,c,d,e,f,xa,xb,xc,xd) \
- Xupdate(f,xa,xa,xb,xc,xd); \
- (f)=xa+(e)+K_60_79+ROTATE((a),5)+F_60_79((b),(c),(d)); \
- (b)=ROTATE((b),30);
-
-# ifdef X
-# undef X
-# endif
-# ifndef MD32_XARRAY
- /*
- * Originally X was an array. As it's automatic it's natural
- * to expect RISC compiler to accommodate at least part of it in
- * the register bank, isn't it? Unfortunately not all compilers
- * "find" this expectation reasonable:-( On order to make such
- * compilers generate better code I replace X[] with a bunch of
- * X0, X1, etc. See the function body below...
- */
-# define X(i) XX##i
-# else
- /*
- * However! Some compilers (most notably HP C) get overwhelmed by
- * that many local variables so that we have to have the way to
- * fall down to the original behavior.
- */
-# define X(i) XX[i]
-# endif
-
-# if !defined(SHA1_ASM)
-static void HASH_BLOCK_DATA_ORDER(SHA_CTX *c, const void *p, size_t num)
-{
- const unsigned char *data = p;
- register unsigned MD32_REG_T A, B, C, D, E, T, l;
-# ifndef MD32_XARRAY
- unsigned MD32_REG_T XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7,
- XX8, XX9, XX10, XX11, XX12, XX13, XX14, XX15;
-# else
- SHA_LONG XX[16];
-# endif
-
- A = c->h0;
- B = c->h1;
- C = c->h2;
- D = c->h3;
- E = c->h4;
-
- for (;;) {
- const union {
- long one;
- char little;
- } is_endian = {
- 1
- };
-
- if (!is_endian.little && sizeof(SHA_LONG) == 4
- && ((size_t)p % 4) == 0) {
- const SHA_LONG *W = (const SHA_LONG *)data;
-
- X(0) = W[0];
- X(1) = W[1];
- BODY_00_15(0, A, B, C, D, E, T, X(0));
- X(2) = W[2];
- BODY_00_15(1, T, A, B, C, D, E, X(1));
- X(3) = W[3];
- BODY_00_15(2, E, T, A, B, C, D, X(2));
- X(4) = W[4];
- BODY_00_15(3, D, E, T, A, B, C, X(3));
- X(5) = W[5];
- BODY_00_15(4, C, D, E, T, A, B, X(4));
- X(6) = W[6];
- BODY_00_15(5, B, C, D, E, T, A, X(5));
- X(7) = W[7];
- BODY_00_15(6, A, B, C, D, E, T, X(6));
- X(8) = W[8];
- BODY_00_15(7, T, A, B, C, D, E, X(7));
- X(9) = W[9];
- BODY_00_15(8, E, T, A, B, C, D, X(8));
- X(10) = W[10];
- BODY_00_15(9, D, E, T, A, B, C, X(9));
- X(11) = W[11];
- BODY_00_15(10, C, D, E, T, A, B, X(10));
- X(12) = W[12];
- BODY_00_15(11, B, C, D, E, T, A, X(11));
- X(13) = W[13];
- BODY_00_15(12, A, B, C, D, E, T, X(12));
- X(14) = W[14];
- BODY_00_15(13, T, A, B, C, D, E, X(13));
- X(15) = W[15];
- BODY_00_15(14, E, T, A, B, C, D, X(14));
- BODY_00_15(15, D, E, T, A, B, C, X(15));
-
- data += SHA_CBLOCK;
- } else {
- (void)HOST_c2l(data, l);
- X(0) = l;
- (void)HOST_c2l(data, l);
- X(1) = l;
- BODY_00_15(0, A, B, C, D, E, T, X(0));
- (void)HOST_c2l(data, l);
- X(2) = l;
- BODY_00_15(1, T, A, B, C, D, E, X(1));
- (void)HOST_c2l(data, l);
- X(3) = l;
- BODY_00_15(2, E, T, A, B, C, D, X(2));
- (void)HOST_c2l(data, l);
- X(4) = l;
- BODY_00_15(3, D, E, T, A, B, C, X(3));
- (void)HOST_c2l(data, l);
- X(5) = l;
- BODY_00_15(4, C, D, E, T, A, B, X(4));
- (void)HOST_c2l(data, l);
- X(6) = l;
- BODY_00_15(5, B, C, D, E, T, A, X(5));
- (void)HOST_c2l(data, l);
- X(7) = l;
- BODY_00_15(6, A, B, C, D, E, T, X(6));
- (void)HOST_c2l(data, l);
- X(8) = l;
- BODY_00_15(7, T, A, B, C, D, E, X(7));
- (void)HOST_c2l(data, l);
- X(9) = l;
- BODY_00_15(8, E, T, A, B, C, D, X(8));
- (void)HOST_c2l(data, l);
- X(10) = l;
- BODY_00_15(9, D, E, T, A, B, C, X(9));
- (void)HOST_c2l(data, l);
- X(11) = l;
- BODY_00_15(10, C, D, E, T, A, B, X(10));
- (void)HOST_c2l(data, l);
- X(12) = l;
- BODY_00_15(11, B, C, D, E, T, A, X(11));
- (void)HOST_c2l(data, l);
- X(13) = l;
- BODY_00_15(12, A, B, C, D, E, T, X(12));
- (void)HOST_c2l(data, l);
- X(14) = l;
- BODY_00_15(13, T, A, B, C, D, E, X(13));
- (void)HOST_c2l(data, l);
- X(15) = l;
- BODY_00_15(14, E, T, A, B, C, D, X(14));
- BODY_00_15(15, D, E, T, A, B, C, X(15));
- }
-
- BODY_16_19(16, C, D, E, T, A, B, X(0), X(0), X(2), X(8), X(13));
- BODY_16_19(17, B, C, D, E, T, A, X(1), X(1), X(3), X(9), X(14));
- BODY_16_19(18, A, B, C, D, E, T, X(2), X(2), X(4), X(10), X(15));
- BODY_16_19(19, T, A, B, C, D, E, X(3), X(3), X(5), X(11), X(0));
-
- BODY_20_31(20, E, T, A, B, C, D, X(4), X(4), X(6), X(12), X(1));
- BODY_20_31(21, D, E, T, A, B, C, X(5), X(5), X(7), X(13), X(2));
- BODY_20_31(22, C, D, E, T, A, B, X(6), X(6), X(8), X(14), X(3));
- BODY_20_31(23, B, C, D, E, T, A, X(7), X(7), X(9), X(15), X(4));
- BODY_20_31(24, A, B, C, D, E, T, X(8), X(8), X(10), X(0), X(5));
- BODY_20_31(25, T, A, B, C, D, E, X(9), X(9), X(11), X(1), X(6));
- BODY_20_31(26, E, T, A, B, C, D, X(10), X(10), X(12), X(2), X(7));
- BODY_20_31(27, D, E, T, A, B, C, X(11), X(11), X(13), X(3), X(8));
- BODY_20_31(28, C, D, E, T, A, B, X(12), X(12), X(14), X(4), X(9));
- BODY_20_31(29, B, C, D, E, T, A, X(13), X(13), X(15), X(5), X(10));
- BODY_20_31(30, A, B, C, D, E, T, X(14), X(14), X(0), X(6), X(11));
- BODY_20_31(31, T, A, B, C, D, E, X(15), X(15), X(1), X(7), X(12));
-
- BODY_32_39(32, E, T, A, B, C, D, X(0), X(2), X(8), X(13));
- BODY_32_39(33, D, E, T, A, B, C, X(1), X(3), X(9), X(14));
- BODY_32_39(34, C, D, E, T, A, B, X(2), X(4), X(10), X(15));
- BODY_32_39(35, B, C, D, E, T, A, X(3), X(5), X(11), X(0));
- BODY_32_39(36, A, B, C, D, E, T, X(4), X(6), X(12), X(1));
- BODY_32_39(37, T, A, B, C, D, E, X(5), X(7), X(13), X(2));
- BODY_32_39(38, E, T, A, B, C, D, X(6), X(8), X(14), X(3));
- BODY_32_39(39, D, E, T, A, B, C, X(7), X(9), X(15), X(4));
-
- BODY_40_59(40, C, D, E, T, A, B, X(8), X(10), X(0), X(5));
- BODY_40_59(41, B, C, D, E, T, A, X(9), X(11), X(1), X(6));
- BODY_40_59(42, A, B, C, D, E, T, X(10), X(12), X(2), X(7));
- BODY_40_59(43, T, A, B, C, D, E, X(11), X(13), X(3), X(8));
- BODY_40_59(44, E, T, A, B, C, D, X(12), X(14), X(4), X(9));
- BODY_40_59(45, D, E, T, A, B, C, X(13), X(15), X(5), X(10));
- BODY_40_59(46, C, D, E, T, A, B, X(14), X(0), X(6), X(11));
- BODY_40_59(47, B, C, D, E, T, A, X(15), X(1), X(7), X(12));
- BODY_40_59(48, A, B, C, D, E, T, X(0), X(2), X(8), X(13));
- BODY_40_59(49, T, A, B, C, D, E, X(1), X(3), X(9), X(14));
- BODY_40_59(50, E, T, A, B, C, D, X(2), X(4), X(10), X(15));
- BODY_40_59(51, D, E, T, A, B, C, X(3), X(5), X(11), X(0));
- BODY_40_59(52, C, D, E, T, A, B, X(4), X(6), X(12), X(1));
- BODY_40_59(53, B, C, D, E, T, A, X(5), X(7), X(13), X(2));
- BODY_40_59(54, A, B, C, D, E, T, X(6), X(8), X(14), X(3));
- BODY_40_59(55, T, A, B, C, D, E, X(7), X(9), X(15), X(4));
- BODY_40_59(56, E, T, A, B, C, D, X(8), X(10), X(0), X(5));
- BODY_40_59(57, D, E, T, A, B, C, X(9), X(11), X(1), X(6));
- BODY_40_59(58, C, D, E, T, A, B, X(10), X(12), X(2), X(7));
- BODY_40_59(59, B, C, D, E, T, A, X(11), X(13), X(3), X(8));
-
- BODY_60_79(60, A, B, C, D, E, T, X(12), X(14), X(4), X(9));
- BODY_60_79(61, T, A, B, C, D, E, X(13), X(15), X(5), X(10));
- BODY_60_79(62, E, T, A, B, C, D, X(14), X(0), X(6), X(11));
- BODY_60_79(63, D, E, T, A, B, C, X(15), X(1), X(7), X(12));
- BODY_60_79(64, C, D, E, T, A, B, X(0), X(2), X(8), X(13));
- BODY_60_79(65, B, C, D, E, T, A, X(1), X(3), X(9), X(14));
- BODY_60_79(66, A, B, C, D, E, T, X(2), X(4), X(10), X(15));
- BODY_60_79(67, T, A, B, C, D, E, X(3), X(5), X(11), X(0));
- BODY_60_79(68, E, T, A, B, C, D, X(4), X(6), X(12), X(1));
- BODY_60_79(69, D, E, T, A, B, C, X(5), X(7), X(13), X(2));
- BODY_60_79(70, C, D, E, T, A, B, X(6), X(8), X(14), X(3));
- BODY_60_79(71, B, C, D, E, T, A, X(7), X(9), X(15), X(4));
- BODY_60_79(72, A, B, C, D, E, T, X(8), X(10), X(0), X(5));
- BODY_60_79(73, T, A, B, C, D, E, X(9), X(11), X(1), X(6));
- BODY_60_79(74, E, T, A, B, C, D, X(10), X(12), X(2), X(7));
- BODY_60_79(75, D, E, T, A, B, C, X(11), X(13), X(3), X(8));
- BODY_60_79(76, C, D, E, T, A, B, X(12), X(14), X(4), X(9));
- BODY_60_79(77, B, C, D, E, T, A, X(13), X(15), X(5), X(10));
- BODY_60_79(78, A, B, C, D, E, T, X(14), X(0), X(6), X(11));
- BODY_60_79(79, T, A, B, C, D, E, X(15), X(1), X(7), X(12));
-
- c->h0 = (c->h0 + E) & 0xffffffffL;
- c->h1 = (c->h1 + T) & 0xffffffffL;
- c->h2 = (c->h2 + A) & 0xffffffffL;
- c->h3 = (c->h3 + B) & 0xffffffffL;
- c->h4 = (c->h4 + C) & 0xffffffffL;
-
- if (--num == 0)
- break;
-
- A = c->h0;
- B = c->h1;
- C = c->h2;
- D = c->h3;
- E = c->h4;
-
- }
-}
-# endif
-
-#else /* OPENSSL_SMALL_FOOTPRINT */
-
-# define BODY_00_15(xi) do { \
- T=E+K_00_19+F_00_19(B,C,D); \
- E=D, D=C, C=ROTATE(B,30), B=A; \
- A=ROTATE(A,5)+T+xi; } while(0)
-
-# define BODY_16_19(xa,xb,xc,xd) do { \
- Xupdate(T,xa,xa,xb,xc,xd); \
- T+=E+K_00_19+F_00_19(B,C,D); \
- E=D, D=C, C=ROTATE(B,30), B=A; \
- A=ROTATE(A,5)+T; } while(0)
-
-# define BODY_20_39(xa,xb,xc,xd) do { \
- Xupdate(T,xa,xa,xb,xc,xd); \
- T+=E+K_20_39+F_20_39(B,C,D); \
- E=D, D=C, C=ROTATE(B,30), B=A; \
- A=ROTATE(A,5)+T; } while(0)
-
-# define BODY_40_59(xa,xb,xc,xd) do { \
- Xupdate(T,xa,xa,xb,xc,xd); \
- T+=E+K_40_59+F_40_59(B,C,D); \
- E=D, D=C, C=ROTATE(B,30), B=A; \
- A=ROTATE(A,5)+T; } while(0)
-
-# define BODY_60_79(xa,xb,xc,xd) do { \
- Xupdate(T,xa,xa,xb,xc,xd); \
- T=E+K_60_79+F_60_79(B,C,D); \
- E=D, D=C, C=ROTATE(B,30), B=A; \
- A=ROTATE(A,5)+T+xa; } while(0)
-
-# if !defined(SHA1_ASM)
-static void HASH_BLOCK_DATA_ORDER(SHA_CTX *c, const void *p, size_t num)
-{
- const unsigned char *data = p;
- register unsigned MD32_REG_T A, B, C, D, E, T, l;
- int i;
- SHA_LONG X[16];
-
- A = c->h0;
- B = c->h1;
- C = c->h2;
- D = c->h3;
- E = c->h4;
-
- for (;;) {
- for (i = 0; i < 16; i++) {
- (void)HOST_c2l(data, l);
- X[i] = l;
- BODY_00_15(X[i]);
- }
- for (i = 0; i < 4; i++) {
- BODY_16_19(X[i], X[i + 2], X[i + 8], X[(i + 13) & 15]);
- }
- for (; i < 24; i++) {
- BODY_20_39(X[i & 15], X[(i + 2) & 15], X[(i + 8) & 15],
- X[(i + 13) & 15]);
- }
- for (i = 0; i < 20; i++) {
- BODY_40_59(X[(i + 8) & 15], X[(i + 10) & 15], X[i & 15],
- X[(i + 5) & 15]);
- }
- for (i = 4; i < 24; i++) {
- BODY_60_79(X[(i + 8) & 15], X[(i + 10) & 15], X[i & 15],
- X[(i + 5) & 15]);
- }
-
- c->h0 = (c->h0 + A) & 0xffffffffL;
- c->h1 = (c->h1 + B) & 0xffffffffL;
- c->h2 = (c->h2 + C) & 0xffffffffL;
- c->h3 = (c->h3 + D) & 0xffffffffL;
- c->h4 = (c->h4 + E) & 0xffffffffL;
-
- if (--num == 0)
- break;
-
- A = c->h0;
- B = c->h1;
- C = c->h2;
- D = c->h3;
- E = c->h4;
-
- }
-}
-# endif
-
-#endif
*/
#include <openssl/e_os2.h>
-#include "sm3_locl.h"
+#include "sm3_local.h"
int sm3_init(SM3_CTX *c)
{
--- /dev/null
+/*
+ * Copyright 2017 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2017 Ribose Inc. All Rights Reserved.
+ * Ported from Ribose contributions from Botan.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+#include <string.h>
+#include "internal/sm3.h"
+
+#define DATA_ORDER_IS_BIG_ENDIAN
+
+#define HASH_LONG SM3_WORD
+#define HASH_CTX SM3_CTX
+#define HASH_CBLOCK SM3_CBLOCK
+#define HASH_UPDATE sm3_update
+#define HASH_TRANSFORM sm3_transform
+#define HASH_FINAL sm3_final
+#define HASH_MAKE_STRING(c, s) \
+ do { \
+ unsigned long ll; \
+ ll=(c)->A; (void)HOST_l2c(ll, (s)); \
+ ll=(c)->B; (void)HOST_l2c(ll, (s)); \
+ ll=(c)->C; (void)HOST_l2c(ll, (s)); \
+ ll=(c)->D; (void)HOST_l2c(ll, (s)); \
+ ll=(c)->E; (void)HOST_l2c(ll, (s)); \
+ ll=(c)->F; (void)HOST_l2c(ll, (s)); \
+ ll=(c)->G; (void)HOST_l2c(ll, (s)); \
+ ll=(c)->H; (void)HOST_l2c(ll, (s)); \
+ } while (0)
+#define HASH_BLOCK_DATA_ORDER sm3_block_data_order
+
+void sm3_block_data_order(SM3_CTX *c, const void *p, size_t num);
+void sm3_transform(SM3_CTX *c, const unsigned char *data);
+
+#include "crypto/md32_common.h"
+
+#define P0(X) (X ^ ROTATE(X, 9) ^ ROTATE(X, 17))
+#define P1(X) (X ^ ROTATE(X, 15) ^ ROTATE(X, 23))
+
+#define FF0(X,Y,Z) (X ^ Y ^ Z)
+#define GG0(X,Y,Z) (X ^ Y ^ Z)
+
+#define FF1(X,Y,Z) ((X & Y) | ((X | Y) & Z))
+#define GG1(X,Y,Z) ((Z ^ (X & (Y ^ Z))))
+
+#define EXPAND(W0,W7,W13,W3,W10) \
+ (P1(W0 ^ W7 ^ ROTATE(W13, 15)) ^ ROTATE(W3, 7) ^ W10)
+
+#define RND(A, B, C, D, E, F, G, H, TJ, Wi, Wj, FF, GG) \
+ do { \
+ const SM3_WORD A12 = ROTATE(A, 12); \
+ const SM3_WORD A12_SM = A12 + E + TJ; \
+ const SM3_WORD SS1 = ROTATE(A12_SM, 7); \
+ const SM3_WORD TT1 = FF(A, B, C) + D + (SS1 ^ A12) + (Wj); \
+ const SM3_WORD TT2 = GG(E, F, G) + H + SS1 + Wi; \
+ B = ROTATE(B, 9); \
+ D = TT1; \
+ F = ROTATE(F, 19); \
+ H = P0(TT2); \
+ } while(0)
+
+#define R1(A,B,C,D,E,F,G,H,TJ,Wi,Wj) \
+ RND(A,B,C,D,E,F,G,H,TJ,Wi,Wj,FF0,GG0)
+
+#define R2(A,B,C,D,E,F,G,H,TJ,Wi,Wj) \
+ RND(A,B,C,D,E,F,G,H,TJ,Wi,Wj,FF1,GG1)
+
+#define SM3_A 0x7380166fUL
+#define SM3_B 0x4914b2b9UL
+#define SM3_C 0x172442d7UL
+#define SM3_D 0xda8a0600UL
+#define SM3_E 0xa96f30bcUL
+#define SM3_F 0x163138aaUL
+#define SM3_G 0xe38dee4dUL
+#define SM3_H 0xb0fb0e4eUL
+++ /dev/null
-/*
- * Copyright 2017 The OpenSSL Project Authors. All Rights Reserved.
- * Copyright 2017 Ribose Inc. All Rights Reserved.
- * Ported from Ribose contributions from Botan.
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-#include <string.h>
-#include "internal/sm3.h"
-
-#define DATA_ORDER_IS_BIG_ENDIAN
-
-#define HASH_LONG SM3_WORD
-#define HASH_CTX SM3_CTX
-#define HASH_CBLOCK SM3_CBLOCK
-#define HASH_UPDATE sm3_update
-#define HASH_TRANSFORM sm3_transform
-#define HASH_FINAL sm3_final
-#define HASH_MAKE_STRING(c, s) \
- do { \
- unsigned long ll; \
- ll=(c)->A; (void)HOST_l2c(ll, (s)); \
- ll=(c)->B; (void)HOST_l2c(ll, (s)); \
- ll=(c)->C; (void)HOST_l2c(ll, (s)); \
- ll=(c)->D; (void)HOST_l2c(ll, (s)); \
- ll=(c)->E; (void)HOST_l2c(ll, (s)); \
- ll=(c)->F; (void)HOST_l2c(ll, (s)); \
- ll=(c)->G; (void)HOST_l2c(ll, (s)); \
- ll=(c)->H; (void)HOST_l2c(ll, (s)); \
- } while (0)
-#define HASH_BLOCK_DATA_ORDER sm3_block_data_order
-
-void sm3_block_data_order(SM3_CTX *c, const void *p, size_t num);
-void sm3_transform(SM3_CTX *c, const unsigned char *data);
-
-#include "crypto/md32_common.h"
-
-#define P0(X) (X ^ ROTATE(X, 9) ^ ROTATE(X, 17))
-#define P1(X) (X ^ ROTATE(X, 15) ^ ROTATE(X, 23))
-
-#define FF0(X,Y,Z) (X ^ Y ^ Z)
-#define GG0(X,Y,Z) (X ^ Y ^ Z)
-
-#define FF1(X,Y,Z) ((X & Y) | ((X | Y) & Z))
-#define GG1(X,Y,Z) ((Z ^ (X & (Y ^ Z))))
-
-#define EXPAND(W0,W7,W13,W3,W10) \
- (P1(W0 ^ W7 ^ ROTATE(W13, 15)) ^ ROTATE(W3, 7) ^ W10)
-
-#define RND(A, B, C, D, E, F, G, H, TJ, Wi, Wj, FF, GG) \
- do { \
- const SM3_WORD A12 = ROTATE(A, 12); \
- const SM3_WORD A12_SM = A12 + E + TJ; \
- const SM3_WORD SS1 = ROTATE(A12_SM, 7); \
- const SM3_WORD TT1 = FF(A, B, C) + D + (SS1 ^ A12) + (Wj); \
- const SM3_WORD TT2 = GG(E, F, G) + H + SS1 + Wi; \
- B = ROTATE(B, 9); \
- D = TT1; \
- F = ROTATE(F, 19); \
- H = P0(TT2); \
- } while(0)
-
-#define R1(A,B,C,D,E,F,G,H,TJ,Wi,Wj) \
- RND(A,B,C,D,E,F,G,H,TJ,Wi,Wj,FF0,GG0)
-
-#define R2(A,B,C,D,E,F,G,H,TJ,Wi,Wj) \
- RND(A,B,C,D,E,F,G,H,TJ,Wi,Wj,FF1,GG1)
-
-#define SM3_A 0x7380166fUL
-#define SM3_B 0x4914b2b9UL
-#define SM3_C 0x172442d7UL
-#define SM3_D 0xda8a0600UL
-#define SM3_E 0xa96f30bcUL
-#define SM3_F 0x163138aaUL
-#define SM3_G 0xe38dee4dUL
-#define SM3_H 0xb0fb0e4eUL
#include "internal/o_dir.h"
#include "internal/cryptlib.h"
#include "crypto/store.h"
-#include "store_locl.h"
+#include "store_local.h"
#ifdef _WIN32
# define stat _stat
#include <openssl/err.h>
#include "crypto/store.h"
-#include "store_locl.h"
+#include "store_local.h"
static CRYPTO_ONCE store_init = CRYPTO_ONCE_STATIC_INIT;
DEFINE_RUN_ONCE_STATIC(do_store_init)
#include <openssl/store.h>
#include "internal/thread_once.h"
#include "crypto/store.h"
-#include "store_locl.h"
+#include "store_local.h"
struct ossl_store_ctx_st {
const OSSL_STORE_LOADER *loader;
--- /dev/null
+/*
+ * Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+#include "internal/thread_once.h"
+#include <openssl/dsa.h>
+#include <openssl/engine.h>
+#include <openssl/evp.h>
+#include <openssl/lhash.h>
+#include <openssl/x509.h>
+#include <openssl/store.h>
+
+/*-
+ * OSSL_STORE_INFO stuff
+ * ---------------------
+ */
+
+struct ossl_store_info_st {
+ int type;
+ union {
+ void *data; /* used internally as generic pointer */
+
+ struct {
+ BUF_MEM *blob;
+ char *pem_name;
+ } embedded; /* when type == OSSL_STORE_INFO_EMBEDDED */
+
+ struct {
+ char *name;
+ char *desc;
+ } name; /* when type == OSSL_STORE_INFO_NAME */
+
+ EVP_PKEY *params; /* when type == OSSL_STORE_INFO_PARAMS */
+ EVP_PKEY *pkey; /* when type == OSSL_STORE_INFO_PKEY */
+ X509 *x509; /* when type == OSSL_STORE_INFO_CERT */
+ X509_CRL *crl; /* when type == OSSL_STORE_INFO_CRL */
+ } _;
+};
+
+DEFINE_STACK_OF(OSSL_STORE_INFO)
+
+/*
+ * EMBEDDED is a special type of OSSL_STORE_INFO, specially for the file
+ * handlers. It should never reach a calling application or any engine.
+ * However, it can be used by a FILE_HANDLER's try_decode function to signal
+ * that it has decoded the incoming blob into a new blob, and that the
+ * attempted decoding should be immediately restarted with the new blob, using
+ * the new PEM name.
+ */
+/*
+ * Because this is an internal type, we don't make it public.
+ */
+#define OSSL_STORE_INFO_EMBEDDED -1
+OSSL_STORE_INFO *ossl_store_info_new_EMBEDDED(const char *new_pem_name,
+ BUF_MEM *embedded);
+BUF_MEM *ossl_store_info_get0_EMBEDDED_buffer(OSSL_STORE_INFO *info);
+char *ossl_store_info_get0_EMBEDDED_pem_name(OSSL_STORE_INFO *info);
+
+/*-
+ * OSSL_STORE_SEARCH stuff
+ * -----------------------
+ */
+
+struct ossl_store_search_st {
+ int search_type;
+
+ /*
+ * Used by OSSL_STORE_SEARCH_BY_NAME and
+ * OSSL_STORE_SEARCH_BY_ISSUER_SERIAL
+ */
+ X509_NAME *name;
+
+ /* Used by OSSL_STORE_SEARCH_BY_ISSUER_SERIAL */
+ const ASN1_INTEGER *serial;
+
+ /* Used by OSSL_STORE_SEARCH_BY_KEY_FINGERPRINT */
+ const EVP_MD *digest;
+
+ /*
+ * Used by OSSL_STORE_SEARCH_BY_KEY_FINGERPRINT and
+ * OSSL_STORE_SEARCH_BY_ALIAS
+ */
+ const unsigned char *string;
+ size_t stringlength;
+};
+
+/*-
+ * OSSL_STORE_LOADER stuff
+ * -----------------------
+ */
+
+int ossl_store_register_loader_int(OSSL_STORE_LOADER *loader);
+OSSL_STORE_LOADER *ossl_store_unregister_loader_int(const char *scheme);
+
+/* loader stuff */
+struct ossl_store_loader_st {
+ const char *scheme;
+ ENGINE *engine;
+ OSSL_STORE_open_fn open;
+ OSSL_STORE_ctrl_fn ctrl;
+ OSSL_STORE_expect_fn expect;
+ OSSL_STORE_find_fn find;
+ OSSL_STORE_load_fn load;
+ OSSL_STORE_eof_fn eof;
+ OSSL_STORE_error_fn error;
+ OSSL_STORE_close_fn close;
+};
+DEFINE_LHASH_OF(OSSL_STORE_LOADER);
+
+const OSSL_STORE_LOADER *ossl_store_get0_loader_int(const char *scheme);
+void ossl_store_destroy_loaders_int(void);
+
+/*-
+ * OSSL_STORE init stuff
+ * ---------------------
+ */
+
+int ossl_store_init_once(void);
+int ossl_store_file_loader_init(void);
+
+/*-
+ * 'file' scheme stuff
+ * -------------------
+ */
+
+OSSL_STORE_LOADER_CTX *ossl_store_file_attach_pem_bio_int(BIO *bp);
+int ossl_store_file_detach_pem_bio_int(OSSL_STORE_LOADER_CTX *ctx);
+++ /dev/null
-/*
- * Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-#include "internal/thread_once.h"
-#include <openssl/dsa.h>
-#include <openssl/engine.h>
-#include <openssl/evp.h>
-#include <openssl/lhash.h>
-#include <openssl/x509.h>
-#include <openssl/store.h>
-
-/*-
- * OSSL_STORE_INFO stuff
- * ---------------------
- */
-
-struct ossl_store_info_st {
- int type;
- union {
- void *data; /* used internally as generic pointer */
-
- struct {
- BUF_MEM *blob;
- char *pem_name;
- } embedded; /* when type == OSSL_STORE_INFO_EMBEDDED */
-
- struct {
- char *name;
- char *desc;
- } name; /* when type == OSSL_STORE_INFO_NAME */
-
- EVP_PKEY *params; /* when type == OSSL_STORE_INFO_PARAMS */
- EVP_PKEY *pkey; /* when type == OSSL_STORE_INFO_PKEY */
- X509 *x509; /* when type == OSSL_STORE_INFO_CERT */
- X509_CRL *crl; /* when type == OSSL_STORE_INFO_CRL */
- } _;
-};
-
-DEFINE_STACK_OF(OSSL_STORE_INFO)
-
-/*
- * EMBEDDED is a special type of OSSL_STORE_INFO, specially for the file
- * handlers. It should never reach a calling application or any engine.
- * However, it can be used by a FILE_HANDLER's try_decode function to signal
- * that it has decoded the incoming blob into a new blob, and that the
- * attempted decoding should be immediately restarted with the new blob, using
- * the new PEM name.
- */
-/*
- * Because this is an internal type, we don't make it public.
- */
-#define OSSL_STORE_INFO_EMBEDDED -1
-OSSL_STORE_INFO *ossl_store_info_new_EMBEDDED(const char *new_pem_name,
- BUF_MEM *embedded);
-BUF_MEM *ossl_store_info_get0_EMBEDDED_buffer(OSSL_STORE_INFO *info);
-char *ossl_store_info_get0_EMBEDDED_pem_name(OSSL_STORE_INFO *info);
-
-/*-
- * OSSL_STORE_SEARCH stuff
- * -----------------------
- */
-
-struct ossl_store_search_st {
- int search_type;
-
- /*
- * Used by OSSL_STORE_SEARCH_BY_NAME and
- * OSSL_STORE_SEARCH_BY_ISSUER_SERIAL
- */
- X509_NAME *name;
-
- /* Used by OSSL_STORE_SEARCH_BY_ISSUER_SERIAL */
- const ASN1_INTEGER *serial;
-
- /* Used by OSSL_STORE_SEARCH_BY_KEY_FINGERPRINT */
- const EVP_MD *digest;
-
- /*
- * Used by OSSL_STORE_SEARCH_BY_KEY_FINGERPRINT and
- * OSSL_STORE_SEARCH_BY_ALIAS
- */
- const unsigned char *string;
- size_t stringlength;
-};
-
-/*-
- * OSSL_STORE_LOADER stuff
- * -----------------------
- */
-
-int ossl_store_register_loader_int(OSSL_STORE_LOADER *loader);
-OSSL_STORE_LOADER *ossl_store_unregister_loader_int(const char *scheme);
-
-/* loader stuff */
-struct ossl_store_loader_st {
- const char *scheme;
- ENGINE *engine;
- OSSL_STORE_open_fn open;
- OSSL_STORE_ctrl_fn ctrl;
- OSSL_STORE_expect_fn expect;
- OSSL_STORE_find_fn find;
- OSSL_STORE_load_fn load;
- OSSL_STORE_eof_fn eof;
- OSSL_STORE_error_fn error;
- OSSL_STORE_close_fn close;
-};
-DEFINE_LHASH_OF(OSSL_STORE_LOADER);
-
-const OSSL_STORE_LOADER *ossl_store_get0_loader_int(const char *scheme);
-void ossl_store_destroy_loaders_int(void);
-
-/*-
- * OSSL_STORE init stuff
- * ---------------------
- */
-
-int ossl_store_init_once(void);
-int ossl_store_file_loader_init(void);
-
-/*-
- * 'file' scheme stuff
- * -------------------
- */
-
-OSSL_STORE_LOADER_CTX *ossl_store_file_attach_pem_bio_int(BIO *bp);
-int ossl_store_file_detach_pem_bio_int(OSSL_STORE_LOADER_CTX *ctx);
#include <openssl/err.h>
#include <openssl/lhash.h>
-#include "store_locl.h"
+#include "store_local.h"
static CRYPTO_RWLOCK *registry_lock;
static CRYPTO_ONCE registry_init = CRYPTO_ONCE_STATIC_INIT;
#include <openssl/ts.h>
#include <openssl/err.h>
#include <openssl/asn1t.h>
-#include "ts_lcl.h"
+#include "ts_local.h"
ASN1_SEQUENCE(TS_MSG_IMPRINT) = {
ASN1_SIMPLE(TS_MSG_IMPRINT, hash_algo, X509_ALGOR),
+++ /dev/null
-/*
- * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-/*-
- * MessageImprint ::= SEQUENCE {
- * hashAlgorithm AlgorithmIdentifier,
- * hashedMessage OCTET STRING }
- */
-struct TS_msg_imprint_st {
- X509_ALGOR *hash_algo;
- ASN1_OCTET_STRING *hashed_msg;
-};
-
-/*-
- * TimeStampResp ::= SEQUENCE {
- * status PKIStatusInfo,
- * timeStampToken TimeStampToken OPTIONAL }
- */
-struct TS_resp_st {
- TS_STATUS_INFO *status_info;
- PKCS7 *token;
- TS_TST_INFO *tst_info;
-};
-
-/*-
- * TimeStampReq ::= SEQUENCE {
- * version INTEGER { v1(1) },
- * messageImprint MessageImprint,
- * --a hash algorithm OID and the hash value of the data to be
- * --time-stamped
- * reqPolicy TSAPolicyId OPTIONAL,
- * nonce INTEGER OPTIONAL,
- * certReq BOOLEAN DEFAULT FALSE,
- * extensions [0] IMPLICIT Extensions OPTIONAL }
- */
-struct TS_req_st {
- ASN1_INTEGER *version;
- TS_MSG_IMPRINT *msg_imprint;
- ASN1_OBJECT *policy_id;
- ASN1_INTEGER *nonce;
- ASN1_BOOLEAN cert_req;
- STACK_OF(X509_EXTENSION) *extensions;
-};
-
-/*-
- * Accuracy ::= SEQUENCE {
- * seconds INTEGER OPTIONAL,
- * millis [0] INTEGER (1..999) OPTIONAL,
- * micros [1] INTEGER (1..999) OPTIONAL }
- */
-struct TS_accuracy_st {
- ASN1_INTEGER *seconds;
- ASN1_INTEGER *millis;
- ASN1_INTEGER *micros;
-};
-
-/*-
- * TSTInfo ::= SEQUENCE {
- * version INTEGER { v1(1) },
- * policy TSAPolicyId,
- * messageImprint MessageImprint,
- * -- MUST have the same value as the similar field in
- * -- TimeStampReq
- * serialNumber INTEGER,
- * -- Time-Stamping users MUST be ready to accommodate integers
- * -- up to 160 bits.
- * genTime GeneralizedTime,
- * accuracy Accuracy OPTIONAL,
- * ordering BOOLEAN DEFAULT FALSE,
- * nonce INTEGER OPTIONAL,
- * -- MUST be present if the similar field was present
- * -- in TimeStampReq. In that case it MUST have the same value.
- * tsa [0] GeneralName OPTIONAL,
- * extensions [1] IMPLICIT Extensions OPTIONAL }
- */
-struct TS_tst_info_st {
- ASN1_INTEGER *version;
- ASN1_OBJECT *policy_id;
- TS_MSG_IMPRINT *msg_imprint;
- ASN1_INTEGER *serial;
- ASN1_GENERALIZEDTIME *time;
- TS_ACCURACY *accuracy;
- ASN1_BOOLEAN ordering;
- ASN1_INTEGER *nonce;
- GENERAL_NAME *tsa;
- STACK_OF(X509_EXTENSION) *extensions;
-};
-
-struct TS_status_info_st {
- ASN1_INTEGER *status;
- STACK_OF(ASN1_UTF8STRING) *text;
- ASN1_BIT_STRING *failure_info;
-};
-
-struct TS_resp_ctx {
- X509 *signer_cert;
- EVP_PKEY *signer_key;
- const EVP_MD *signer_md;
- const EVP_MD *ess_cert_id_digest;
- STACK_OF(X509) *certs; /* Certs to include in signed data. */
- STACK_OF(ASN1_OBJECT) *policies; /* Acceptable policies. */
- ASN1_OBJECT *default_policy; /* It may appear in policies, too. */
- STACK_OF(EVP_MD) *mds; /* Acceptable message digests. */
- ASN1_INTEGER *seconds; /* accuracy, 0 means not specified. */
- ASN1_INTEGER *millis; /* accuracy, 0 means not specified. */
- ASN1_INTEGER *micros; /* accuracy, 0 means not specified. */
- unsigned clock_precision_digits; /* fraction of seconds in time stamp
- * token. */
- unsigned flags; /* Optional info, see values above. */
- /* Callback functions. */
- TS_serial_cb serial_cb;
- void *serial_cb_data; /* User data for serial_cb. */
- TS_time_cb time_cb;
- void *time_cb_data; /* User data for time_cb. */
- TS_extension_cb extension_cb;
- void *extension_cb_data; /* User data for extension_cb. */
- /* These members are used only while creating the response. */
- TS_REQ *request;
- TS_RESP *response;
- TS_TST_INFO *tst_info;
-};
-
-struct TS_verify_ctx {
- /* Set this to the union of TS_VFY_... flags you want to carry out. */
- unsigned flags;
- /* Must be set only with TS_VFY_SIGNATURE. certs is optional. */
- X509_STORE *store;
- STACK_OF(X509) *certs;
- /* Must be set only with TS_VFY_POLICY. */
- ASN1_OBJECT *policy;
- /*
- * Must be set only with TS_VFY_IMPRINT. If md_alg is NULL, the
- * algorithm from the response is used.
- */
- X509_ALGOR *md_alg;
- unsigned char *imprint;
- unsigned imprint_len;
- /* Must be set only with TS_VFY_DATA. */
- BIO *data;
- /* Must be set only with TS_VFY_TSA_NAME. */
- ASN1_INTEGER *nonce;
- /* Must be set only with TS_VFY_TSA_NAME. */
- GENERAL_NAME *tsa_name;
-};
#include <openssl/x509.h>
#include <openssl/x509v3.h>
#include <openssl/ts.h>
-#include "ts_lcl.h"
+#include "ts_local.h"
int TS_ASN1_INTEGER_print_bio(BIO *bio, const ASN1_INTEGER *num)
{
--- /dev/null
+/*
+ * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+/*-
+ * MessageImprint ::= SEQUENCE {
+ * hashAlgorithm AlgorithmIdentifier,
+ * hashedMessage OCTET STRING }
+ */
+struct TS_msg_imprint_st {
+ X509_ALGOR *hash_algo;
+ ASN1_OCTET_STRING *hashed_msg;
+};
+
+/*-
+ * TimeStampResp ::= SEQUENCE {
+ * status PKIStatusInfo,
+ * timeStampToken TimeStampToken OPTIONAL }
+ */
+struct TS_resp_st {
+ TS_STATUS_INFO *status_info;
+ PKCS7 *token;
+ TS_TST_INFO *tst_info;
+};
+
+/*-
+ * TimeStampReq ::= SEQUENCE {
+ * version INTEGER { v1(1) },
+ * messageImprint MessageImprint,
+ * --a hash algorithm OID and the hash value of the data to be
+ * --time-stamped
+ * reqPolicy TSAPolicyId OPTIONAL,
+ * nonce INTEGER OPTIONAL,
+ * certReq BOOLEAN DEFAULT FALSE,
+ * extensions [0] IMPLICIT Extensions OPTIONAL }
+ */
+struct TS_req_st {
+ ASN1_INTEGER *version;
+ TS_MSG_IMPRINT *msg_imprint;
+ ASN1_OBJECT *policy_id;
+ ASN1_INTEGER *nonce;
+ ASN1_BOOLEAN cert_req;
+ STACK_OF(X509_EXTENSION) *extensions;
+};
+
+/*-
+ * Accuracy ::= SEQUENCE {
+ * seconds INTEGER OPTIONAL,
+ * millis [0] INTEGER (1..999) OPTIONAL,
+ * micros [1] INTEGER (1..999) OPTIONAL }
+ */
+struct TS_accuracy_st {
+ ASN1_INTEGER *seconds;
+ ASN1_INTEGER *millis;
+ ASN1_INTEGER *micros;
+};
+
+/*-
+ * TSTInfo ::= SEQUENCE {
+ * version INTEGER { v1(1) },
+ * policy TSAPolicyId,
+ * messageImprint MessageImprint,
+ * -- MUST have the same value as the similar field in
+ * -- TimeStampReq
+ * serialNumber INTEGER,
+ * -- Time-Stamping users MUST be ready to accommodate integers
+ * -- up to 160 bits.
+ * genTime GeneralizedTime,
+ * accuracy Accuracy OPTIONAL,
+ * ordering BOOLEAN DEFAULT FALSE,
+ * nonce INTEGER OPTIONAL,
+ * -- MUST be present if the similar field was present
+ * -- in TimeStampReq. In that case it MUST have the same value.
+ * tsa [0] GeneralName OPTIONAL,
+ * extensions [1] IMPLICIT Extensions OPTIONAL }
+ */
+struct TS_tst_info_st {
+ ASN1_INTEGER *version;
+ ASN1_OBJECT *policy_id;
+ TS_MSG_IMPRINT *msg_imprint;
+ ASN1_INTEGER *serial;
+ ASN1_GENERALIZEDTIME *time;
+ TS_ACCURACY *accuracy;
+ ASN1_BOOLEAN ordering;
+ ASN1_INTEGER *nonce;
+ GENERAL_NAME *tsa;
+ STACK_OF(X509_EXTENSION) *extensions;
+};
+
+struct TS_status_info_st {
+ ASN1_INTEGER *status;
+ STACK_OF(ASN1_UTF8STRING) *text;
+ ASN1_BIT_STRING *failure_info;
+};
+
+struct TS_resp_ctx {
+ X509 *signer_cert;
+ EVP_PKEY *signer_key;
+ const EVP_MD *signer_md;
+ const EVP_MD *ess_cert_id_digest;
+ STACK_OF(X509) *certs; /* Certs to include in signed data. */
+ STACK_OF(ASN1_OBJECT) *policies; /* Acceptable policies. */
+ ASN1_OBJECT *default_policy; /* It may appear in policies, too. */
+ STACK_OF(EVP_MD) *mds; /* Acceptable message digests. */
+ ASN1_INTEGER *seconds; /* accuracy, 0 means not specified. */
+ ASN1_INTEGER *millis; /* accuracy, 0 means not specified. */
+ ASN1_INTEGER *micros; /* accuracy, 0 means not specified. */
+ unsigned clock_precision_digits; /* fraction of seconds in time stamp
+ * token. */
+ unsigned flags; /* Optional info, see values above. */
+ /* Callback functions. */
+ TS_serial_cb serial_cb;
+ void *serial_cb_data; /* User data for serial_cb. */
+ TS_time_cb time_cb;
+ void *time_cb_data; /* User data for time_cb. */
+ TS_extension_cb extension_cb;
+ void *extension_cb_data; /* User data for extension_cb. */
+ /* These members are used only while creating the response. */
+ TS_REQ *request;
+ TS_RESP *response;
+ TS_TST_INFO *tst_info;
+};
+
+struct TS_verify_ctx {
+ /* Set this to the union of TS_VFY_... flags you want to carry out. */
+ unsigned flags;
+ /* Must be set only with TS_VFY_SIGNATURE. certs is optional. */
+ X509_STORE *store;
+ STACK_OF(X509) *certs;
+ /* Must be set only with TS_VFY_POLICY. */
+ ASN1_OBJECT *policy;
+ /*
+ * Must be set only with TS_VFY_IMPRINT. If md_alg is NULL, the
+ * algorithm from the response is used.
+ */
+ X509_ALGOR *md_alg;
+ unsigned char *imprint;
+ unsigned imprint_len;
+ /* Must be set only with TS_VFY_DATA. */
+ BIO *data;
+ /* Must be set only with TS_VFY_TSA_NAME. */
+ ASN1_INTEGER *nonce;
+ /* Must be set only with TS_VFY_TSA_NAME. */
+ GENERAL_NAME *tsa_name;
+};
#include <openssl/bn.h>
#include <openssl/x509v3.h>
#include <openssl/ts.h>
-#include "ts_lcl.h"
+#include "ts_local.h"
int TS_REQ_print_bio(BIO *bio, TS_REQ *a)
{
#include <openssl/objects.h>
#include <openssl/x509v3.h>
#include <openssl/ts.h>
-#include "ts_lcl.h"
+#include "ts_local.h"
int TS_REQ_set_version(TS_REQ *a, long version)
{
#include <openssl/bn.h>
#include <openssl/x509v3.h>
#include <openssl/ts.h>
-#include "ts_lcl.h"
+#include "ts_local.h"
struct status_map_st {
int bit;
#include <openssl/ts.h>
#include <openssl/pkcs7.h>
#include <openssl/crypto.h>
-#include "ts_lcl.h"
+#include "ts_local.h"
#include "crypto/ess.h"
static ASN1_INTEGER *def_serial_cb(struct TS_resp_ctx *, void *);
#include <openssl/objects.h>
#include <openssl/ts.h>
#include <openssl/pkcs7.h>
-#include "ts_lcl.h"
+#include "ts_local.h"
int TS_RESP_set_status_info(TS_RESP *a, TS_STATUS_INFO *status_info)
{
#include <openssl/objects.h>
#include <openssl/ts.h>
#include <openssl/pkcs7.h>
-#include "ts_lcl.h"
+#include "ts_local.h"
#include "crypto/ess.h"
static int ts_verify_cert(X509_STORE *store, STACK_OF(X509) *untrusted,
#include "internal/cryptlib.h"
#include <openssl/objects.h>
#include <openssl/ts.h>
-#include "ts_lcl.h"
+#include "ts_local.h"
TS_VERIFY_CTX *TS_VERIFY_CTX_new(void)
{
#include <openssl/buffer.h>
#include <openssl/ui.h>
#include <openssl/err.h>
-#include "ui_locl.h"
+#include "ui_local.h"
UI *UI_new(void)
{
--- /dev/null
+/*
+ * Copyright 2001-2016 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+#ifndef HEADER_UI_LOCL_H
+# define HEADER_UI_LOCL_H
+
+# include <openssl/ui.h>
+# include <openssl/crypto.h>
+
+# ifdef _
+# undef _
+# endif
+
+struct ui_method_st {
+ char *name;
+ /*
+ * All the functions return 1 or non-NULL for success and 0 or NULL for
+ * failure
+ */
+ /*
+ * Open whatever channel for this, be it the console, an X window or
+ * whatever. This function should use the ex_data structure to save
+ * intermediate data.
+ */
+ int (*ui_open_session) (UI *ui);
+ int (*ui_write_string) (UI *ui, UI_STRING *uis);
+ /*
+ * Flush the output. If a GUI dialog box is used, this function can be
+ * used to actually display it.
+ */
+ int (*ui_flush) (UI *ui);
+ int (*ui_read_string) (UI *ui, UI_STRING *uis);
+ int (*ui_close_session) (UI *ui);
+ /*
+ * Duplicate the ui_data that often comes alongside a ui_method. This
+ * allows some backends to save away UI information for later use.
+ */
+ void *(*ui_duplicate_data) (UI *ui, void *ui_data);
+ void (*ui_destroy_data) (UI *ui, void *ui_data);
+ /*
+ * Construct a prompt in a user-defined manner. object_desc is a textual
+ * short description of the object, for example "pass phrase", and
+ * object_name is the name of the object (might be a card name or a file
+ * name. The returned string shall always be allocated on the heap with
+ * OPENSSL_malloc(), and need to be free'd with OPENSSL_free().
+ */
+ char *(*ui_construct_prompt) (UI *ui, const char *object_desc,
+ const char *object_name);
+ /*
+ * UI_METHOD specific application data.
+ */
+ CRYPTO_EX_DATA ex_data;
+};
+
+struct ui_string_st {
+ enum UI_string_types type; /* Input */
+ const char *out_string; /* Input */
+ int input_flags; /* Flags from the user */
+ /*
+ * The following parameters are completely irrelevant for UIT_INFO, and
+ * can therefore be set to 0 or NULL
+ */
+ char *result_buf; /* Input and Output: If not NULL,
+ * user-defined with size in result_maxsize.
+ * Otherwise, it may be allocated by the UI
+ * routine, meaning result_minsize is going
+ * to be overwritten. */
+ size_t result_len;
+ union {
+ struct {
+ int result_minsize; /* Input: minimum required size of the
+ * result. */
+ int result_maxsize; /* Input: maximum permitted size of the
+ * result */
+ const char *test_buf; /* Input: test string to verify against */
+ } string_data;
+ struct {
+ const char *action_desc; /* Input */
+ const char *ok_chars; /* Input */
+ const char *cancel_chars; /* Input */
+ } boolean_data;
+ } _;
+
+# define OUT_STRING_FREEABLE 0x01
+ int flags; /* flags for internal use */
+};
+
+struct ui_st {
+ const UI_METHOD *meth;
+ STACK_OF(UI_STRING) *strings; /* We might want to prompt for more than
+ * one thing at a time, and with different
+ * echoing status. */
+ void *user_data;
+ CRYPTO_EX_DATA ex_data;
+# define UI_FLAG_REDOABLE 0x0001
+# define UI_FLAG_DUPL_DATA 0x0002 /* user_data was duplicated */
+# define UI_FLAG_PRINT_ERRORS 0x0100
+ int flags;
+
+ CRYPTO_RWLOCK *lock;
+};
+
+#endif
+++ /dev/null
-/*
- * Copyright 2001-2016 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-#ifndef HEADER_UI_LOCL_H
-# define HEADER_UI_LOCL_H
-
-# include <openssl/ui.h>
-# include <openssl/crypto.h>
-
-# ifdef _
-# undef _
-# endif
-
-struct ui_method_st {
- char *name;
- /*
- * All the functions return 1 or non-NULL for success and 0 or NULL for
- * failure
- */
- /*
- * Open whatever channel for this, be it the console, an X window or
- * whatever. This function should use the ex_data structure to save
- * intermediate data.
- */
- int (*ui_open_session) (UI *ui);
- int (*ui_write_string) (UI *ui, UI_STRING *uis);
- /*
- * Flush the output. If a GUI dialog box is used, this function can be
- * used to actually display it.
- */
- int (*ui_flush) (UI *ui);
- int (*ui_read_string) (UI *ui, UI_STRING *uis);
- int (*ui_close_session) (UI *ui);
- /*
- * Duplicate the ui_data that often comes alongside a ui_method. This
- * allows some backends to save away UI information for later use.
- */
- void *(*ui_duplicate_data) (UI *ui, void *ui_data);
- void (*ui_destroy_data) (UI *ui, void *ui_data);
- /*
- * Construct a prompt in a user-defined manner. object_desc is a textual
- * short description of the object, for example "pass phrase", and
- * object_name is the name of the object (might be a card name or a file
- * name. The returned string shall always be allocated on the heap with
- * OPENSSL_malloc(), and need to be free'd with OPENSSL_free().
- */
- char *(*ui_construct_prompt) (UI *ui, const char *object_desc,
- const char *object_name);
- /*
- * UI_METHOD specific application data.
- */
- CRYPTO_EX_DATA ex_data;
-};
-
-struct ui_string_st {
- enum UI_string_types type; /* Input */
- const char *out_string; /* Input */
- int input_flags; /* Flags from the user */
- /*
- * The following parameters are completely irrelevant for UIT_INFO, and
- * can therefore be set to 0 or NULL
- */
- char *result_buf; /* Input and Output: If not NULL,
- * user-defined with size in result_maxsize.
- * Otherwise, it may be allocated by the UI
- * routine, meaning result_minsize is going
- * to be overwritten. */
- size_t result_len;
- union {
- struct {
- int result_minsize; /* Input: minimum required size of the
- * result. */
- int result_maxsize; /* Input: maximum permitted size of the
- * result */
- const char *test_buf; /* Input: test string to verify against */
- } string_data;
- struct {
- const char *action_desc; /* Input */
- const char *ok_chars; /* Input */
- const char *cancel_chars; /* Input */
- } boolean_data;
- } _;
-
-# define OUT_STRING_FREEABLE 0x01
- int flags; /* flags for internal use */
-};
-
-struct ui_st {
- const UI_METHOD *meth;
- STACK_OF(UI_STRING) *strings; /* We might want to prompt for more than
- * one thing at a time, and with different
- * echoing status. */
- void *user_data;
- CRYPTO_EX_DATA ex_data;
-# define UI_FLAG_REDOABLE 0x0001
-# define UI_FLAG_DUPL_DATA 0x0002 /* user_data was duplicated */
-# define UI_FLAG_PRINT_ERRORS 0x0100
- int flags;
-
- CRYPTO_RWLOCK *lock;
-};
-
-#endif
* https://www.openssl.org/source/license.html
*/
-#include "ui_locl.h"
+#include "ui_local.h"
static const UI_METHOD ui_null = {
"OpenSSL NULL UI",
# endif
# endif
-# include "ui_locl.h"
+# include "ui_local.h"
# include "internal/cryptlib.h"
# ifdef OPENSSL_SYS_VMS /* prototypes for sys$whatever */
#include <string.h>
#include "internal/thread_once.h"
-#include "ui_locl.h"
+#include "ui_local.h"
#ifndef BUFSIZ
#define BUFSIZ 256
*/
#include "internal/cryptlib.h"
-#include "wp_locl.h"
+#include "wp_local.h"
#include <string.h>
typedef unsigned char u8;
*/
#include <openssl/crypto.h>
-#include "wp_locl.h"
+#include "wp_local.h"
#include <string.h>
int WHIRLPOOL_Init(WHIRLPOOL_CTX *c)
--- /dev/null
+/*
+ * Copyright 2005-2016 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+#include <openssl/whrlpool.h>
+
+void whirlpool_block(WHIRLPOOL_CTX *, const void *, size_t);
+++ /dev/null
-/*
- * Copyright 2005-2016 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-#include <openssl/whrlpool.h>
-
-void whirlpool_block(WHIRLPOOL_CTX *, const void *, size_t);
#include <openssl/x509.h>
#include "crypto/x509.h"
-#include "x509_lcl.h"
+#include "x509_local.h"
struct lookup_dir_hashes_st {
unsigned long hash;
#include <openssl/buffer.h>
#include <openssl/x509.h>
#include <openssl/pem.h>
-#include "x509_lcl.h"
+#include "x509_local.h"
static int by_file_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc,
long argl, char **ret);
#include <openssl/x509v3.h>
#include "crypto/x509.h"
-#include "pcy_int.h"
+#include "pcy_local.h"
static int policy_data_cmp(const X509_POLICY_DATA *const *a,
const X509_POLICY_DATA *const *b);
#include <openssl/x509.h>
#include <openssl/x509v3.h>
-#include "pcy_int.h"
+#include "pcy_local.h"
/* Policy Node routines */
+++ /dev/null
-/*
- * Copyright 2004-2016 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-typedef struct X509_POLICY_DATA_st X509_POLICY_DATA;
-
-DEFINE_STACK_OF(X509_POLICY_DATA)
-
-/* Internal structures */
-
-/*
- * This structure and the field names correspond to the Policy 'node' of
- * RFC3280. NB this structure contains no pointers to parent or child data:
- * X509_POLICY_NODE contains that. This means that the main policy data can
- * be kept static and cached with the certificate.
- */
-
-struct X509_POLICY_DATA_st {
- unsigned int flags;
- /* Policy OID and qualifiers for this data */
- ASN1_OBJECT *valid_policy;
- STACK_OF(POLICYQUALINFO) *qualifier_set;
- STACK_OF(ASN1_OBJECT) *expected_policy_set;
-};
-
-/* X509_POLICY_DATA flags values */
-
-/*
- * This flag indicates the structure has been mapped using a policy mapping
- * extension. If policy mapping is not active its references get deleted.
- */
-
-#define POLICY_DATA_FLAG_MAPPED 0x1
-
-/*
- * This flag indicates the data doesn't correspond to a policy in Certificate
- * Policies: it has been mapped to any policy.
- */
-
-#define POLICY_DATA_FLAG_MAPPED_ANY 0x2
-
-/* AND with flags to see if any mapping has occurred */
-
-#define POLICY_DATA_FLAG_MAP_MASK 0x3
-
-/* qualifiers are shared and shouldn't be freed */
-
-#define POLICY_DATA_FLAG_SHARED_QUALIFIERS 0x4
-
-/* Parent node is an extra node and should be freed */
-
-#define POLICY_DATA_FLAG_EXTRA_NODE 0x8
-
-/* Corresponding CertificatePolicies is critical */
-
-#define POLICY_DATA_FLAG_CRITICAL 0x10
-
-/* This structure is cached with a certificate */
-
-struct X509_POLICY_CACHE_st {
- /* anyPolicy data or NULL if no anyPolicy */
- X509_POLICY_DATA *anyPolicy;
- /* other policy data */
- STACK_OF(X509_POLICY_DATA) *data;
- /* If InhibitAnyPolicy present this is its value or -1 if absent. */
- long any_skip;
- /*
- * If policyConstraints and requireExplicitPolicy present this is its
- * value or -1 if absent.
- */
- long explicit_skip;
- /*
- * If policyConstraints and policyMapping present this is its value or -1
- * if absent.
- */
- long map_skip;
-};
-
-/*
- * #define POLICY_CACHE_FLAG_CRITICAL POLICY_DATA_FLAG_CRITICAL
- */
-
-/* This structure represents the relationship between nodes */
-
-struct X509_POLICY_NODE_st {
- /* node data this refers to */
- const X509_POLICY_DATA *data;
- /* Parent node */
- X509_POLICY_NODE *parent;
- /* Number of child nodes */
- int nchild;
-};
-
-struct X509_POLICY_LEVEL_st {
- /* Cert for this level */
- X509 *cert;
- /* nodes at this level */
- STACK_OF(X509_POLICY_NODE) *nodes;
- /* anyPolicy node */
- X509_POLICY_NODE *anyPolicy;
- /* Extra data */
- /*
- * STACK_OF(X509_POLICY_DATA) *extra_data;
- */
- unsigned int flags;
-};
-
-struct X509_POLICY_TREE_st {
- /* This is the tree 'level' data */
- X509_POLICY_LEVEL *levels;
- int nlevel;
- /*
- * Extra policy data when additional nodes (not from the certificate) are
- * required.
- */
- STACK_OF(X509_POLICY_DATA) *extra_data;
- /* This is the authority constrained policy set */
- STACK_OF(X509_POLICY_NODE) *auth_policies;
- STACK_OF(X509_POLICY_NODE) *user_policies;
- unsigned int flags;
-};
-
-/* Set if anyPolicy present in user policies */
-#define POLICY_FLAG_ANY_POLICY 0x2
-
-/* Useful macros */
-
-#define node_data_critical(data) (data->flags & POLICY_DATA_FLAG_CRITICAL)
-#define node_critical(node) node_data_critical(node->data)
-
-/* Internal functions */
-
-X509_POLICY_DATA *policy_data_new(POLICYINFO *policy, const ASN1_OBJECT *id,
- int crit);
-void policy_data_free(X509_POLICY_DATA *data);
-
-X509_POLICY_DATA *policy_cache_find_data(const X509_POLICY_CACHE *cache,
- const ASN1_OBJECT *id);
-int policy_cache_set_mapping(X509 *x, POLICY_MAPPINGS *maps);
-
-STACK_OF(X509_POLICY_NODE) *policy_node_cmp_new(void);
-
-void policy_cache_init(void);
-
-void policy_cache_free(X509_POLICY_CACHE *cache);
-
-X509_POLICY_NODE *level_find_node(const X509_POLICY_LEVEL *level,
- const X509_POLICY_NODE *parent,
- const ASN1_OBJECT *id);
-
-X509_POLICY_NODE *tree_find_sk(STACK_OF(X509_POLICY_NODE) *sk,
- const ASN1_OBJECT *id);
-
-X509_POLICY_NODE *level_add_node(X509_POLICY_LEVEL *level,
- X509_POLICY_DATA *data,
- X509_POLICY_NODE *parent,
- X509_POLICY_TREE *tree);
-void policy_node_free(X509_POLICY_NODE *node);
-int policy_node_match(const X509_POLICY_LEVEL *lvl,
- const X509_POLICY_NODE *node, const ASN1_OBJECT *oid);
-
-const X509_POLICY_CACHE *policy_cache_set(X509 *x);
#include <openssl/x509.h>
#include <openssl/x509v3.h>
-#include "pcy_int.h"
+#include "pcy_local.h"
/* accessor functions */
--- /dev/null
+/*
+ * Copyright 2004-2016 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+typedef struct X509_POLICY_DATA_st X509_POLICY_DATA;
+
+DEFINE_STACK_OF(X509_POLICY_DATA)
+
+/* Internal structures */
+
+/*
+ * This structure and the field names correspond to the Policy 'node' of
+ * RFC3280. NB this structure contains no pointers to parent or child data:
+ * X509_POLICY_NODE contains that. This means that the main policy data can
+ * be kept static and cached with the certificate.
+ */
+
+struct X509_POLICY_DATA_st {
+ unsigned int flags;
+ /* Policy OID and qualifiers for this data */
+ ASN1_OBJECT *valid_policy;
+ STACK_OF(POLICYQUALINFO) *qualifier_set;
+ STACK_OF(ASN1_OBJECT) *expected_policy_set;
+};
+
+/* X509_POLICY_DATA flags values */
+
+/*
+ * This flag indicates the structure has been mapped using a policy mapping
+ * extension. If policy mapping is not active its references get deleted.
+ */
+
+#define POLICY_DATA_FLAG_MAPPED 0x1
+
+/*
+ * This flag indicates the data doesn't correspond to a policy in Certificate
+ * Policies: it has been mapped to any policy.
+ */
+
+#define POLICY_DATA_FLAG_MAPPED_ANY 0x2
+
+/* AND with flags to see if any mapping has occurred */
+
+#define POLICY_DATA_FLAG_MAP_MASK 0x3
+
+/* qualifiers are shared and shouldn't be freed */
+
+#define POLICY_DATA_FLAG_SHARED_QUALIFIERS 0x4
+
+/* Parent node is an extra node and should be freed */
+
+#define POLICY_DATA_FLAG_EXTRA_NODE 0x8
+
+/* Corresponding CertificatePolicies is critical */
+
+#define POLICY_DATA_FLAG_CRITICAL 0x10
+
+/* This structure is cached with a certificate */
+
+struct X509_POLICY_CACHE_st {
+ /* anyPolicy data or NULL if no anyPolicy */
+ X509_POLICY_DATA *anyPolicy;
+ /* other policy data */
+ STACK_OF(X509_POLICY_DATA) *data;
+ /* If InhibitAnyPolicy present this is its value or -1 if absent. */
+ long any_skip;
+ /*
+ * If policyConstraints and requireExplicitPolicy present this is its
+ * value or -1 if absent.
+ */
+ long explicit_skip;
+ /*
+ * If policyConstraints and policyMapping present this is its value or -1
+ * if absent.
+ */
+ long map_skip;
+};
+
+/*
+ * #define POLICY_CACHE_FLAG_CRITICAL POLICY_DATA_FLAG_CRITICAL
+ */
+
+/* This structure represents the relationship between nodes */
+
+struct X509_POLICY_NODE_st {
+ /* node data this refers to */
+ const X509_POLICY_DATA *data;
+ /* Parent node */
+ X509_POLICY_NODE *parent;
+ /* Number of child nodes */
+ int nchild;
+};
+
+struct X509_POLICY_LEVEL_st {
+ /* Cert for this level */
+ X509 *cert;
+ /* nodes at this level */
+ STACK_OF(X509_POLICY_NODE) *nodes;
+ /* anyPolicy node */
+ X509_POLICY_NODE *anyPolicy;
+ /* Extra data */
+ /*
+ * STACK_OF(X509_POLICY_DATA) *extra_data;
+ */
+ unsigned int flags;
+};
+
+struct X509_POLICY_TREE_st {
+ /* This is the tree 'level' data */
+ X509_POLICY_LEVEL *levels;
+ int nlevel;
+ /*
+ * Extra policy data when additional nodes (not from the certificate) are
+ * required.
+ */
+ STACK_OF(X509_POLICY_DATA) *extra_data;
+ /* This is the authority constrained policy set */
+ STACK_OF(X509_POLICY_NODE) *auth_policies;
+ STACK_OF(X509_POLICY_NODE) *user_policies;
+ unsigned int flags;
+};
+
+/* Set if anyPolicy present in user policies */
+#define POLICY_FLAG_ANY_POLICY 0x2
+
+/* Useful macros */
+
+#define node_data_critical(data) (data->flags & POLICY_DATA_FLAG_CRITICAL)
+#define node_critical(node) node_data_critical(node->data)
+
+/* Internal functions */
+
+X509_POLICY_DATA *policy_data_new(POLICYINFO *policy, const ASN1_OBJECT *id,
+ int crit);
+void policy_data_free(X509_POLICY_DATA *data);
+
+X509_POLICY_DATA *policy_cache_find_data(const X509_POLICY_CACHE *cache,
+ const ASN1_OBJECT *id);
+int policy_cache_set_mapping(X509 *x, POLICY_MAPPINGS *maps);
+
+STACK_OF(X509_POLICY_NODE) *policy_node_cmp_new(void);
+
+void policy_cache_init(void);
+
+void policy_cache_free(X509_POLICY_CACHE *cache);
+
+X509_POLICY_NODE *level_find_node(const X509_POLICY_LEVEL *level,
+ const X509_POLICY_NODE *parent,
+ const ASN1_OBJECT *id);
+
+X509_POLICY_NODE *tree_find_sk(STACK_OF(X509_POLICY_NODE) *sk,
+ const ASN1_OBJECT *id);
+
+X509_POLICY_NODE *level_add_node(X509_POLICY_LEVEL *level,
+ X509_POLICY_DATA *data,
+ X509_POLICY_NODE *parent,
+ X509_POLICY_TREE *tree);
+void policy_node_free(X509_POLICY_NODE *node);
+int policy_node_match(const X509_POLICY_LEVEL *lvl,
+ const X509_POLICY_NODE *node, const ASN1_OBJECT *oid);
+
+const X509_POLICY_CACHE *policy_cache_set(X509 *x);
#include <openssl/x509v3.h>
#include "crypto/x509.h"
-#include "pcy_int.h"
+#include "pcy_local.h"
/*
* Set policy mapping entries in cache. Note: this modifies the passed
#include <openssl/x509v3.h>
#include <openssl/err.h>
-#include "pcy_int.h"
+#include "pcy_local.h"
static int node_cmp(const X509_POLICY_NODE *const *a,
const X509_POLICY_NODE *const *b)
#include <openssl/x509.h>
#include <openssl/x509v3.h>
-#include "pcy_int.h"
+#include "pcy_local.h"
static void expected_print(BIO *channel,
X509_POLICY_LEVEL *lev, X509_POLICY_NODE *node,
#include <openssl/asn1t.h>
#include <openssl/x509v3.h>
-#include "pcy_int.h"
+#include "pcy_local.h"
#include "ext_dat.h"
/* Certificate policies extension support: this one is a bit complex... */
#include <openssl/evp.h>
#include <openssl/x509.h>
#include <openssl/x509v3.h>
-#include "x509_lcl.h"
+#include "x509_local.h"
int X509at_get_attr_count(const STACK_OF(X509_ATTRIBUTE) *x)
{
+++ /dev/null
-/*
- * Copyright 2014-2018 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-#include "internal/refcount.h"
-
-/*
- * This structure holds all parameters associated with a verify operation by
- * including an X509_VERIFY_PARAM structure in related structures the
- * parameters used can be customized
- */
-
-struct X509_VERIFY_PARAM_st {
- char *name;
- time_t check_time; /* Time to use */
- uint32_t inh_flags; /* Inheritance flags */
- unsigned long flags; /* Various verify flags */
- int purpose; /* purpose to check untrusted certificates */
- int trust; /* trust setting to check */
- int depth; /* Verify depth */
- int auth_level; /* Security level for chain verification */
- STACK_OF(ASN1_OBJECT) *policies; /* Permissible policies */
- /* Peer identity details */
- STACK_OF(OPENSSL_STRING) *hosts; /* Set of acceptable names */
- unsigned int hostflags; /* Flags to control matching features */
- char *peername; /* Matching hostname in peer certificate */
- char *email; /* If not NULL email address to match */
- size_t emaillen;
- unsigned char *ip; /* If not NULL IP address to match */
- size_t iplen; /* Length of IP address */
-};
-
-/* No error callback if depth < 0 */
-int x509_check_cert_time(X509_STORE_CTX *ctx, X509 *x, int depth);
-
-/* a sequence of these are used */
-struct x509_attributes_st {
- ASN1_OBJECT *object;
- STACK_OF(ASN1_TYPE) *set;
-};
-
-struct X509_extension_st {
- ASN1_OBJECT *object;
- ASN1_BOOLEAN critical;
- ASN1_OCTET_STRING value;
-};
-
-/*
- * Method to handle CRL access. In general a CRL could be very large (several
- * Mb) and can consume large amounts of resources if stored in memory by
- * multiple processes. This method allows general CRL operations to be
- * redirected to more efficient callbacks: for example a CRL entry database.
- */
-
-#define X509_CRL_METHOD_DYNAMIC 1
-
-struct x509_crl_method_st {
- int flags;
- int (*crl_init) (X509_CRL *crl);
- int (*crl_free) (X509_CRL *crl);
- int (*crl_lookup) (X509_CRL *crl, X509_REVOKED **ret,
- ASN1_INTEGER *ser, X509_NAME *issuer);
- int (*crl_verify) (X509_CRL *crl, EVP_PKEY *pk);
-};
-
-struct x509_lookup_method_st {
- char *name;
- int (*new_item) (X509_LOOKUP *ctx);
- void (*free) (X509_LOOKUP *ctx);
- int (*init) (X509_LOOKUP *ctx);
- int (*shutdown) (X509_LOOKUP *ctx);
- int (*ctrl) (X509_LOOKUP *ctx, int cmd, const char *argc, long argl,
- char **ret);
- int (*get_by_subject) (X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
- X509_NAME *name, X509_OBJECT *ret);
- int (*get_by_issuer_serial) (X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
- X509_NAME *name, ASN1_INTEGER *serial,
- X509_OBJECT *ret);
- int (*get_by_fingerprint) (X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
- const unsigned char *bytes, int len,
- X509_OBJECT *ret);
- int (*get_by_alias) (X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
- const char *str, int len, X509_OBJECT *ret);
-};
-
-/* This is the functions plus an instance of the local variables. */
-struct x509_lookup_st {
- int init; /* have we been started */
- int skip; /* don't use us. */
- X509_LOOKUP_METHOD *method; /* the functions */
- void *method_data; /* method data */
- X509_STORE *store_ctx; /* who owns us */
-};
-
-/*
- * This is used to hold everything. It is used for all certificate
- * validation. Once we have a certificate chain, the 'verify' function is
- * then called to actually check the cert chain.
- */
-struct x509_store_st {
- /* The following is a cache of trusted certs */
- int cache; /* if true, stash any hits */
- STACK_OF(X509_OBJECT) *objs; /* Cache of all objects */
- /* These are external lookup methods */
- STACK_OF(X509_LOOKUP) *get_cert_methods;
- X509_VERIFY_PARAM *param;
- /* Callbacks for various operations */
- /* called to verify a certificate */
- int (*verify) (X509_STORE_CTX *ctx);
- /* error callback */
- int (*verify_cb) (int ok, X509_STORE_CTX *ctx);
- /* get issuers cert from ctx */
- int (*get_issuer) (X509 **issuer, X509_STORE_CTX *ctx, X509 *x);
- /* check issued */
- int (*check_issued) (X509_STORE_CTX *ctx, X509 *x, X509 *issuer);
- /* Check revocation status of chain */
- int (*check_revocation) (X509_STORE_CTX *ctx);
- /* retrieve CRL */
- int (*get_crl) (X509_STORE_CTX *ctx, X509_CRL **crl, X509 *x);
- /* Check CRL validity */
- int (*check_crl) (X509_STORE_CTX *ctx, X509_CRL *crl);
- /* Check certificate against CRL */
- int (*cert_crl) (X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x);
- /* Check policy status of the chain */
- int (*check_policy) (X509_STORE_CTX *ctx);
- STACK_OF(X509) *(*lookup_certs) (X509_STORE_CTX *ctx, X509_NAME *nm);
- STACK_OF(X509_CRL) *(*lookup_crls) (X509_STORE_CTX *ctx, X509_NAME *nm);
- int (*cleanup) (X509_STORE_CTX *ctx);
- CRYPTO_EX_DATA ex_data;
- CRYPTO_REF_COUNT references;
- CRYPTO_RWLOCK *lock;
-};
-
-typedef struct lookup_dir_hashes_st BY_DIR_HASH;
-typedef struct lookup_dir_entry_st BY_DIR_ENTRY;
-DEFINE_STACK_OF(BY_DIR_HASH)
-DEFINE_STACK_OF(BY_DIR_ENTRY)
-typedef STACK_OF(X509_NAME_ENTRY) STACK_OF_X509_NAME_ENTRY;
-DEFINE_STACK_OF(STACK_OF_X509_NAME_ENTRY)
-
-void x509_set_signature_info(X509_SIG_INFO *siginf, const X509_ALGOR *alg,
- const ASN1_STRING *sig);
--- /dev/null
+/*
+ * Copyright 2014-2018 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+#include "internal/refcount.h"
+
+/*
+ * This structure holds all parameters associated with a verify operation by
+ * including an X509_VERIFY_PARAM structure in related structures the
+ * parameters used can be customized
+ */
+
+struct X509_VERIFY_PARAM_st {
+ char *name;
+ time_t check_time; /* Time to use */
+ uint32_t inh_flags; /* Inheritance flags */
+ unsigned long flags; /* Various verify flags */
+ int purpose; /* purpose to check untrusted certificates */
+ int trust; /* trust setting to check */
+ int depth; /* Verify depth */
+ int auth_level; /* Security level for chain verification */
+ STACK_OF(ASN1_OBJECT) *policies; /* Permissible policies */
+ /* Peer identity details */
+ STACK_OF(OPENSSL_STRING) *hosts; /* Set of acceptable names */
+ unsigned int hostflags; /* Flags to control matching features */
+ char *peername; /* Matching hostname in peer certificate */
+ char *email; /* If not NULL email address to match */
+ size_t emaillen;
+ unsigned char *ip; /* If not NULL IP address to match */
+ size_t iplen; /* Length of IP address */
+};
+
+/* No error callback if depth < 0 */
+int x509_check_cert_time(X509_STORE_CTX *ctx, X509 *x, int depth);
+
+/* a sequence of these are used */
+struct x509_attributes_st {
+ ASN1_OBJECT *object;
+ STACK_OF(ASN1_TYPE) *set;
+};
+
+struct X509_extension_st {
+ ASN1_OBJECT *object;
+ ASN1_BOOLEAN critical;
+ ASN1_OCTET_STRING value;
+};
+
+/*
+ * Method to handle CRL access. In general a CRL could be very large (several
+ * Mb) and can consume large amounts of resources if stored in memory by
+ * multiple processes. This method allows general CRL operations to be
+ * redirected to more efficient callbacks: for example a CRL entry database.
+ */
+
+#define X509_CRL_METHOD_DYNAMIC 1
+
+struct x509_crl_method_st {
+ int flags;
+ int (*crl_init) (X509_CRL *crl);
+ int (*crl_free) (X509_CRL *crl);
+ int (*crl_lookup) (X509_CRL *crl, X509_REVOKED **ret,
+ ASN1_INTEGER *ser, X509_NAME *issuer);
+ int (*crl_verify) (X509_CRL *crl, EVP_PKEY *pk);
+};
+
+struct x509_lookup_method_st {
+ char *name;
+ int (*new_item) (X509_LOOKUP *ctx);
+ void (*free) (X509_LOOKUP *ctx);
+ int (*init) (X509_LOOKUP *ctx);
+ int (*shutdown) (X509_LOOKUP *ctx);
+ int (*ctrl) (X509_LOOKUP *ctx, int cmd, const char *argc, long argl,
+ char **ret);
+ int (*get_by_subject) (X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
+ X509_NAME *name, X509_OBJECT *ret);
+ int (*get_by_issuer_serial) (X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
+ X509_NAME *name, ASN1_INTEGER *serial,
+ X509_OBJECT *ret);
+ int (*get_by_fingerprint) (X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
+ const unsigned char *bytes, int len,
+ X509_OBJECT *ret);
+ int (*get_by_alias) (X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
+ const char *str, int len, X509_OBJECT *ret);
+};
+
+/* This is the functions plus an instance of the local variables. */
+struct x509_lookup_st {
+ int init; /* have we been started */
+ int skip; /* don't use us. */
+ X509_LOOKUP_METHOD *method; /* the functions */
+ void *method_data; /* method data */
+ X509_STORE *store_ctx; /* who owns us */
+};
+
+/*
+ * This is used to hold everything. It is used for all certificate
+ * validation. Once we have a certificate chain, the 'verify' function is
+ * then called to actually check the cert chain.
+ */
+struct x509_store_st {
+ /* The following is a cache of trusted certs */
+ int cache; /* if true, stash any hits */
+ STACK_OF(X509_OBJECT) *objs; /* Cache of all objects */
+ /* These are external lookup methods */
+ STACK_OF(X509_LOOKUP) *get_cert_methods;
+ X509_VERIFY_PARAM *param;
+ /* Callbacks for various operations */
+ /* called to verify a certificate */
+ int (*verify) (X509_STORE_CTX *ctx);
+ /* error callback */
+ int (*verify_cb) (int ok, X509_STORE_CTX *ctx);
+ /* get issuers cert from ctx */
+ int (*get_issuer) (X509 **issuer, X509_STORE_CTX *ctx, X509 *x);
+ /* check issued */
+ int (*check_issued) (X509_STORE_CTX *ctx, X509 *x, X509 *issuer);
+ /* Check revocation status of chain */
+ int (*check_revocation) (X509_STORE_CTX *ctx);
+ /* retrieve CRL */
+ int (*get_crl) (X509_STORE_CTX *ctx, X509_CRL **crl, X509 *x);
+ /* Check CRL validity */
+ int (*check_crl) (X509_STORE_CTX *ctx, X509_CRL *crl);
+ /* Check certificate against CRL */
+ int (*cert_crl) (X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x);
+ /* Check policy status of the chain */
+ int (*check_policy) (X509_STORE_CTX *ctx);
+ STACK_OF(X509) *(*lookup_certs) (X509_STORE_CTX *ctx, X509_NAME *nm);
+ STACK_OF(X509_CRL) *(*lookup_crls) (X509_STORE_CTX *ctx, X509_NAME *nm);
+ int (*cleanup) (X509_STORE_CTX *ctx);
+ CRYPTO_EX_DATA ex_data;
+ CRYPTO_REF_COUNT references;
+ CRYPTO_RWLOCK *lock;
+};
+
+typedef struct lookup_dir_hashes_st BY_DIR_HASH;
+typedef struct lookup_dir_entry_st BY_DIR_ENTRY;
+DEFINE_STACK_OF(BY_DIR_HASH)
+DEFINE_STACK_OF(BY_DIR_ENTRY)
+typedef STACK_OF(X509_NAME_ENTRY) STACK_OF_X509_NAME_ENTRY;
+DEFINE_STACK_OF(STACK_OF_X509_NAME_ENTRY)
+
+void x509_set_signature_info(X509_SIG_INFO *siginf, const X509_ALGOR *alg,
+ const ASN1_STRING *sig);
#include <openssl/x509.h>
#include "crypto/x509.h"
#include <openssl/x509v3.h>
-#include "x509_lcl.h"
+#include "x509_local.h"
X509_LOOKUP *X509_LOOKUP_new(X509_LOOKUP_METHOD *method)
{
#include <openssl/asn1.h>
#include <openssl/x509.h>
#include <openssl/ossl_typ.h>
-#include "x509_lcl.h"
+#include "x509_local.h"
X509_LOOKUP_METHOD *X509_LOOKUP_meth_new(const char *name)
{
#include <openssl/x509v3.h>
#include "crypto/asn1.h"
#include "crypto/x509.h"
-#include "x509_lcl.h"
+#include "x509_local.h"
int X509_set_version(X509 *x, long version)
{
#include <openssl/evp.h>
#include <openssl/x509.h>
#include <openssl/x509v3.h>
-#include "x509_lcl.h"
+#include "x509_local.h"
int X509v3_get_ext_count(const STACK_OF(X509_EXTENSION) *x)
{
#include <openssl/objects.h>
#include "internal/dane.h"
#include "crypto/x509.h"
-#include "x509_lcl.h"
+#include "x509_local.h"
/* CRL score values */
#include <openssl/x509v3.h>
#include "crypto/x509.h"
-#include "x509_lcl.h"
+#include "x509_local.h"
/* X509_VERIFY_PARAM functions */
#include <openssl/objects.h>
#include <openssl/asn1t.h>
#include <openssl/x509.h>
-#include "x509_lcl.h"
+#include "x509_local.h"
/*-
* X509_ATTRIBUTE: this has the following form:
#include <openssl/x509.h>
#include "crypto/x509.h"
#include <openssl/x509v3.h>
-#include "x509_lcl.h"
+#include "x509_local.h"
static int X509_REVOKED_cmp(const X509_REVOKED *const *a,
const X509_REVOKED *const *b);
#include <openssl/x509.h>
#include <openssl/asn1.h>
#include <openssl/asn1t.h>
-#include "x509_lcl.h"
+#include "x509_local.h"
ASN1_SEQUENCE(X509_EXTENSION) = {
ASN1_SIMPLE(X509_EXTENSION, object, ASN1_OBJECT),
#include <openssl/x509.h>
#include "crypto/x509.h"
#include "crypto/asn1.h"
-#include "x509_lcl.h"
+#include "x509_local.h"
/*
* Maximum length of X509_NAME: much larger than anything we should
=head1 SYNOPSIS
/* Only for EVP source */
- #include "evp_locl.h"
+ #include "evp_local.h"
void *evp_generic_fetch(OPENSSL_CTX *libctx, int operation_id,
const char *name, const char *properties,
=head1 SYNOPSIS
- #include "cmp_int.h"
+ #include "cmp_local.h"
const char *ossl_cmp_log_parse_metadata(const char *buf,
OSSL_CMP_severity *level, char **func,
--- /dev/null
+/*
+ * Copyright 2014-2018 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+#ifndef HEADER_CONSTANT_TIME_LOCL_H
+# define HEADER_CONSTANT_TIME_LOCL_H
+
+# include <stdlib.h>
+# include <string.h>
+# include <openssl/e_os2.h> /* For 'ossl_inline' */
+
+/*-
+ * The boolean methods return a bitmask of all ones (0xff...f) for true
+ * and 0 for false. This is useful for choosing a value based on the result
+ * of a conditional in constant time. For example,
+ * if (a < b) {
+ * c = a;
+ * } else {
+ * c = b;
+ * }
+ * can be written as
+ * unsigned int lt = constant_time_lt(a, b);
+ * c = constant_time_select(lt, a, b);
+ */
+
+/* Returns the given value with the MSB copied to all the other bits. */
+static ossl_inline unsigned int constant_time_msb(unsigned int a);
+/* Convenience method for uint32_t. */
+static ossl_inline uint32_t constant_time_msb_32(uint32_t a);
+/* Convenience method for uint64_t. */
+static ossl_inline uint64_t constant_time_msb_64(uint64_t a);
+
+/* Returns 0xff..f if a < b and 0 otherwise. */
+static ossl_inline unsigned int constant_time_lt(unsigned int a,
+ unsigned int b);
+/* Convenience method for getting an 8-bit mask. */
+static ossl_inline unsigned char constant_time_lt_8(unsigned int a,
+ unsigned int b);
+/* Convenience method for uint64_t. */
+static ossl_inline uint64_t constant_time_lt_64(uint64_t a, uint64_t b);
+
+/* Returns 0xff..f if a >= b and 0 otherwise. */
+static ossl_inline unsigned int constant_time_ge(unsigned int a,
+ unsigned int b);
+/* Convenience method for getting an 8-bit mask. */
+static ossl_inline unsigned char constant_time_ge_8(unsigned int a,
+ unsigned int b);
+
+/* Returns 0xff..f if a == 0 and 0 otherwise. */
+static ossl_inline unsigned int constant_time_is_zero(unsigned int a);
+/* Convenience method for getting an 8-bit mask. */
+static ossl_inline unsigned char constant_time_is_zero_8(unsigned int a);
+/* Convenience method for getting a 32-bit mask. */
+static ossl_inline uint32_t constant_time_is_zero_32(uint32_t a);
+
+/* Returns 0xff..f if a == b and 0 otherwise. */
+static ossl_inline unsigned int constant_time_eq(unsigned int a,
+ unsigned int b);
+/* Convenience method for getting an 8-bit mask. */
+static ossl_inline unsigned char constant_time_eq_8(unsigned int a,
+ unsigned int b);
+/* Signed integers. */
+static ossl_inline unsigned int constant_time_eq_int(int a, int b);
+/* Convenience method for getting an 8-bit mask. */
+static ossl_inline unsigned char constant_time_eq_int_8(int a, int b);
+
+/*-
+ * Returns (mask & a) | (~mask & b).
+ *
+ * When |mask| is all 1s or all 0s (as returned by the methods above),
+ * the select methods return either |a| (if |mask| is nonzero) or |b|
+ * (if |mask| is zero).
+ */
+static ossl_inline unsigned int constant_time_select(unsigned int mask,
+ unsigned int a,
+ unsigned int b);
+/* Convenience method for unsigned chars. */
+static ossl_inline unsigned char constant_time_select_8(unsigned char mask,
+ unsigned char a,
+ unsigned char b);
+
+/* Convenience method for uint32_t. */
+static ossl_inline uint32_t constant_time_select_32(uint32_t mask, uint32_t a,
+ uint32_t b);
+
+/* Convenience method for uint64_t. */
+static ossl_inline uint64_t constant_time_select_64(uint64_t mask, uint64_t a,
+ uint64_t b);
+/* Convenience method for signed integers. */
+static ossl_inline int constant_time_select_int(unsigned int mask, int a,
+ int b);
+
+
+static ossl_inline unsigned int constant_time_msb(unsigned int a)
+{
+ return 0 - (a >> (sizeof(a) * 8 - 1));
+}
+
+
+static ossl_inline uint32_t constant_time_msb_32(uint32_t a)
+{
+ return 0 - (a >> 31);
+}
+
+static ossl_inline uint64_t constant_time_msb_64(uint64_t a)
+{
+ return 0 - (a >> 63);
+}
+
+static ossl_inline size_t constant_time_msb_s(size_t a)
+{
+ return 0 - (a >> (sizeof(a) * 8 - 1));
+}
+
+static ossl_inline unsigned int constant_time_lt(unsigned int a,
+ unsigned int b)
+{
+ return constant_time_msb(a ^ ((a ^ b) | ((a - b) ^ b)));
+}
+
+static ossl_inline size_t constant_time_lt_s(size_t a, size_t b)
+{
+ return constant_time_msb_s(a ^ ((a ^ b) | ((a - b) ^ b)));
+}
+
+static ossl_inline unsigned char constant_time_lt_8(unsigned int a,
+ unsigned int b)
+{
+ return (unsigned char)constant_time_lt(a, b);
+}
+
+static ossl_inline uint64_t constant_time_lt_64(uint64_t a, uint64_t b)
+{
+ return constant_time_msb_64(a ^ ((a ^ b) | ((a - b) ^ b)));
+}
+
+static ossl_inline unsigned int constant_time_ge(unsigned int a,
+ unsigned int b)
+{
+ return ~constant_time_lt(a, b);
+}
+
+static ossl_inline size_t constant_time_ge_s(size_t a, size_t b)
+{
+ return ~constant_time_lt_s(a, b);
+}
+
+static ossl_inline unsigned char constant_time_ge_8(unsigned int a,
+ unsigned int b)
+{
+ return (unsigned char)constant_time_ge(a, b);
+}
+
+static ossl_inline unsigned char constant_time_ge_8_s(size_t a, size_t b)
+{
+ return (unsigned char)constant_time_ge_s(a, b);
+}
+
+static ossl_inline unsigned int constant_time_is_zero(unsigned int a)
+{
+ return constant_time_msb(~a & (a - 1));
+}
+
+static ossl_inline size_t constant_time_is_zero_s(size_t a)
+{
+ return constant_time_msb_s(~a & (a - 1));
+}
+
+static ossl_inline unsigned char constant_time_is_zero_8(unsigned int a)
+{
+ return (unsigned char)constant_time_is_zero(a);
+}
+
+static ossl_inline uint32_t constant_time_is_zero_32(uint32_t a)
+{
+ return constant_time_msb_32(~a & (a - 1));
+}
+
+static ossl_inline unsigned int constant_time_eq(unsigned int a,
+ unsigned int b)
+{
+ return constant_time_is_zero(a ^ b);
+}
+
+static ossl_inline size_t constant_time_eq_s(size_t a, size_t b)
+{
+ return constant_time_is_zero_s(a ^ b);
+}
+
+static ossl_inline unsigned char constant_time_eq_8(unsigned int a,
+ unsigned int b)
+{
+ return (unsigned char)constant_time_eq(a, b);
+}
+
+static ossl_inline unsigned char constant_time_eq_8_s(size_t a, size_t b)
+{
+ return (unsigned char)constant_time_eq_s(a, b);
+}
+
+static ossl_inline unsigned int constant_time_eq_int(int a, int b)
+{
+ return constant_time_eq((unsigned)(a), (unsigned)(b));
+}
+
+static ossl_inline unsigned char constant_time_eq_int_8(int a, int b)
+{
+ return constant_time_eq_8((unsigned)(a), (unsigned)(b));
+}
+
+/*
+ * Returns the value unmodified, but avoids optimizations.
+ * The barriers prevent the compiler from narrowing down the
+ * possible value range of the mask and ~mask in the select
+ * statements, which avoids the recognition of the select
+ * and turning it into a conditional load or branch.
+ */
+static ossl_inline unsigned int value_barrier(unsigned int a)
+{
+#if !defined(OPENSSL_NO_ASM) && defined(__GNUC__)
+ unsigned int r;
+ __asm__("" : "=r"(r) : "0"(a));
+#else
+ volatile unsigned int r = a;
+#endif
+ return r;
+}
+
+/* Convenience method for uint32_t. */
+static ossl_inline uint32_t value_barrier_32(uint32_t a)
+{
+#if !defined(OPENSSL_NO_ASM) && defined(__GNUC__)
+ uint32_t r;
+ __asm__("" : "=r"(r) : "0"(a));
+#else
+ volatile uint32_t r = a;
+#endif
+ return r;
+}
+
+/* Convenience method for uint64_t. */
+static ossl_inline uint64_t value_barrier_64(uint64_t a)
+{
+#if !defined(OPENSSL_NO_ASM) && defined(__GNUC__)
+ uint64_t r;
+ __asm__("" : "=r"(r) : "0"(a));
+#else
+ volatile uint64_t r = a;
+#endif
+ return r;
+}
+
+/* Convenience method for size_t. */
+static ossl_inline size_t value_barrier_s(size_t a)
+{
+#if !defined(OPENSSL_NO_ASM) && defined(__GNUC__)
+ size_t r;
+ __asm__("" : "=r"(r) : "0"(a));
+#else
+ volatile size_t r = a;
+#endif
+ return r;
+}
+
+static ossl_inline unsigned int constant_time_select(unsigned int mask,
+ unsigned int a,
+ unsigned int b)
+{
+ return (value_barrier(mask) & a) | (value_barrier(~mask) & b);
+}
+
+static ossl_inline size_t constant_time_select_s(size_t mask,
+ size_t a,
+ size_t b)
+{
+ return (value_barrier_s(mask) & a) | (value_barrier_s(~mask) & b);
+}
+
+static ossl_inline unsigned char constant_time_select_8(unsigned char mask,
+ unsigned char a,
+ unsigned char b)
+{
+ return (unsigned char)constant_time_select(mask, a, b);
+}
+
+static ossl_inline int constant_time_select_int(unsigned int mask, int a,
+ int b)
+{
+ return (int)constant_time_select(mask, (unsigned)(a), (unsigned)(b));
+}
+
+static ossl_inline int constant_time_select_int_s(size_t mask, int a, int b)
+{
+ return (int)constant_time_select((unsigned)mask, (unsigned)(a),
+ (unsigned)(b));
+}
+
+static ossl_inline uint32_t constant_time_select_32(uint32_t mask, uint32_t a,
+ uint32_t b)
+{
+ return (value_barrier_32(mask) & a) | (value_barrier_32(~mask) & b);
+}
+
+static ossl_inline uint64_t constant_time_select_64(uint64_t mask, uint64_t a,
+ uint64_t b)
+{
+ return (value_barrier_64(mask) & a) | (value_barrier_64(~mask) & b);
+}
+
+/*
+ * mask must be 0xFFFFFFFF or 0x00000000.
+ *
+ * if (mask) {
+ * uint32_t tmp = *a;
+ *
+ * *a = *b;
+ * *b = tmp;
+ * }
+ */
+static ossl_inline void constant_time_cond_swap_32(uint32_t mask, uint32_t *a,
+ uint32_t *b)
+{
+ uint32_t xor = *a ^ *b;
+
+ xor &= mask;
+ *a ^= xor;
+ *b ^= xor;
+}
+
+/*
+ * mask must be 0xFFFFFFFF or 0x00000000.
+ *
+ * if (mask) {
+ * uint64_t tmp = *a;
+ *
+ * *a = *b;
+ * *b = tmp;
+ * }
+ */
+static ossl_inline void constant_time_cond_swap_64(uint64_t mask, uint64_t *a,
+ uint64_t *b)
+{
+ uint64_t xor = *a ^ *b;
+
+ xor &= mask;
+ *a ^= xor;
+ *b ^= xor;
+}
+
+/*
+ * table is a two dimensional array of bytes. Each row has rowsize elements.
+ * Copies row number idx into out. rowsize and numrows are not considered
+ * private.
+ */
+static ossl_inline void constant_time_lookup(void *out,
+ const void *table,
+ size_t rowsize,
+ size_t numrows,
+ size_t idx)
+{
+ size_t i, j;
+ const unsigned char *tablec = (const unsigned char *)table;
+ unsigned char *outc = (unsigned char *)out;
+ unsigned char mask;
+
+ memset(out, 0, rowsize);
+
+ /* Note idx may underflow - but that is well defined */
+ for (i = 0; i < numrows; i++, idx--) {
+ mask = (unsigned char)constant_time_is_zero_s(idx);
+ for (j = 0; j < rowsize; j++)
+ *(outc + j) |= constant_time_select_8(mask, *(tablec++), 0);
+ }
+}
+
+/*
+ * Expected usage pattern is to unconditionally set error and then
+ * wipe it if there was no actual error. |clear| is 1 or 0.
+ */
+void err_clear_last_constant_time(int clear);
+
+#endif /* HEADER_CONSTANT_TIME_LOCL_H */
+++ /dev/null
-/*
- * Copyright 2014-2018 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-#ifndef HEADER_CONSTANT_TIME_LOCL_H
-# define HEADER_CONSTANT_TIME_LOCL_H
-
-# include <stdlib.h>
-# include <string.h>
-# include <openssl/e_os2.h> /* For 'ossl_inline' */
-
-/*-
- * The boolean methods return a bitmask of all ones (0xff...f) for true
- * and 0 for false. This is useful for choosing a value based on the result
- * of a conditional in constant time. For example,
- * if (a < b) {
- * c = a;
- * } else {
- * c = b;
- * }
- * can be written as
- * unsigned int lt = constant_time_lt(a, b);
- * c = constant_time_select(lt, a, b);
- */
-
-/* Returns the given value with the MSB copied to all the other bits. */
-static ossl_inline unsigned int constant_time_msb(unsigned int a);
-/* Convenience method for uint32_t. */
-static ossl_inline uint32_t constant_time_msb_32(uint32_t a);
-/* Convenience method for uint64_t. */
-static ossl_inline uint64_t constant_time_msb_64(uint64_t a);
-
-/* Returns 0xff..f if a < b and 0 otherwise. */
-static ossl_inline unsigned int constant_time_lt(unsigned int a,
- unsigned int b);
-/* Convenience method for getting an 8-bit mask. */
-static ossl_inline unsigned char constant_time_lt_8(unsigned int a,
- unsigned int b);
-/* Convenience method for uint64_t. */
-static ossl_inline uint64_t constant_time_lt_64(uint64_t a, uint64_t b);
-
-/* Returns 0xff..f if a >= b and 0 otherwise. */
-static ossl_inline unsigned int constant_time_ge(unsigned int a,
- unsigned int b);
-/* Convenience method for getting an 8-bit mask. */
-static ossl_inline unsigned char constant_time_ge_8(unsigned int a,
- unsigned int b);
-
-/* Returns 0xff..f if a == 0 and 0 otherwise. */
-static ossl_inline unsigned int constant_time_is_zero(unsigned int a);
-/* Convenience method for getting an 8-bit mask. */
-static ossl_inline unsigned char constant_time_is_zero_8(unsigned int a);
-/* Convenience method for getting a 32-bit mask. */
-static ossl_inline uint32_t constant_time_is_zero_32(uint32_t a);
-
-/* Returns 0xff..f if a == b and 0 otherwise. */
-static ossl_inline unsigned int constant_time_eq(unsigned int a,
- unsigned int b);
-/* Convenience method for getting an 8-bit mask. */
-static ossl_inline unsigned char constant_time_eq_8(unsigned int a,
- unsigned int b);
-/* Signed integers. */
-static ossl_inline unsigned int constant_time_eq_int(int a, int b);
-/* Convenience method for getting an 8-bit mask. */
-static ossl_inline unsigned char constant_time_eq_int_8(int a, int b);
-
-/*-
- * Returns (mask & a) | (~mask & b).
- *
- * When |mask| is all 1s or all 0s (as returned by the methods above),
- * the select methods return either |a| (if |mask| is nonzero) or |b|
- * (if |mask| is zero).
- */
-static ossl_inline unsigned int constant_time_select(unsigned int mask,
- unsigned int a,
- unsigned int b);
-/* Convenience method for unsigned chars. */
-static ossl_inline unsigned char constant_time_select_8(unsigned char mask,
- unsigned char a,
- unsigned char b);
-
-/* Convenience method for uint32_t. */
-static ossl_inline uint32_t constant_time_select_32(uint32_t mask, uint32_t a,
- uint32_t b);
-
-/* Convenience method for uint64_t. */
-static ossl_inline uint64_t constant_time_select_64(uint64_t mask, uint64_t a,
- uint64_t b);
-/* Convenience method for signed integers. */
-static ossl_inline int constant_time_select_int(unsigned int mask, int a,
- int b);
-
-
-static ossl_inline unsigned int constant_time_msb(unsigned int a)
-{
- return 0 - (a >> (sizeof(a) * 8 - 1));
-}
-
-
-static ossl_inline uint32_t constant_time_msb_32(uint32_t a)
-{
- return 0 - (a >> 31);
-}
-
-static ossl_inline uint64_t constant_time_msb_64(uint64_t a)
-{
- return 0 - (a >> 63);
-}
-
-static ossl_inline size_t constant_time_msb_s(size_t a)
-{
- return 0 - (a >> (sizeof(a) * 8 - 1));
-}
-
-static ossl_inline unsigned int constant_time_lt(unsigned int a,
- unsigned int b)
-{
- return constant_time_msb(a ^ ((a ^ b) | ((a - b) ^ b)));
-}
-
-static ossl_inline size_t constant_time_lt_s(size_t a, size_t b)
-{
- return constant_time_msb_s(a ^ ((a ^ b) | ((a - b) ^ b)));
-}
-
-static ossl_inline unsigned char constant_time_lt_8(unsigned int a,
- unsigned int b)
-{
- return (unsigned char)constant_time_lt(a, b);
-}
-
-static ossl_inline uint64_t constant_time_lt_64(uint64_t a, uint64_t b)
-{
- return constant_time_msb_64(a ^ ((a ^ b) | ((a - b) ^ b)));
-}
-
-static ossl_inline unsigned int constant_time_ge(unsigned int a,
- unsigned int b)
-{
- return ~constant_time_lt(a, b);
-}
-
-static ossl_inline size_t constant_time_ge_s(size_t a, size_t b)
-{
- return ~constant_time_lt_s(a, b);
-}
-
-static ossl_inline unsigned char constant_time_ge_8(unsigned int a,
- unsigned int b)
-{
- return (unsigned char)constant_time_ge(a, b);
-}
-
-static ossl_inline unsigned char constant_time_ge_8_s(size_t a, size_t b)
-{
- return (unsigned char)constant_time_ge_s(a, b);
-}
-
-static ossl_inline unsigned int constant_time_is_zero(unsigned int a)
-{
- return constant_time_msb(~a & (a - 1));
-}
-
-static ossl_inline size_t constant_time_is_zero_s(size_t a)
-{
- return constant_time_msb_s(~a & (a - 1));
-}
-
-static ossl_inline unsigned char constant_time_is_zero_8(unsigned int a)
-{
- return (unsigned char)constant_time_is_zero(a);
-}
-
-static ossl_inline uint32_t constant_time_is_zero_32(uint32_t a)
-{
- return constant_time_msb_32(~a & (a - 1));
-}
-
-static ossl_inline unsigned int constant_time_eq(unsigned int a,
- unsigned int b)
-{
- return constant_time_is_zero(a ^ b);
-}
-
-static ossl_inline size_t constant_time_eq_s(size_t a, size_t b)
-{
- return constant_time_is_zero_s(a ^ b);
-}
-
-static ossl_inline unsigned char constant_time_eq_8(unsigned int a,
- unsigned int b)
-{
- return (unsigned char)constant_time_eq(a, b);
-}
-
-static ossl_inline unsigned char constant_time_eq_8_s(size_t a, size_t b)
-{
- return (unsigned char)constant_time_eq_s(a, b);
-}
-
-static ossl_inline unsigned int constant_time_eq_int(int a, int b)
-{
- return constant_time_eq((unsigned)(a), (unsigned)(b));
-}
-
-static ossl_inline unsigned char constant_time_eq_int_8(int a, int b)
-{
- return constant_time_eq_8((unsigned)(a), (unsigned)(b));
-}
-
-/*
- * Returns the value unmodified, but avoids optimizations.
- * The barriers prevent the compiler from narrowing down the
- * possible value range of the mask and ~mask in the select
- * statements, which avoids the recognition of the select
- * and turning it into a conditional load or branch.
- */
-static ossl_inline unsigned int value_barrier(unsigned int a)
-{
-#if !defined(OPENSSL_NO_ASM) && defined(__GNUC__)
- unsigned int r;
- __asm__("" : "=r"(r) : "0"(a));
-#else
- volatile unsigned int r = a;
-#endif
- return r;
-}
-
-/* Convenience method for uint32_t. */
-static ossl_inline uint32_t value_barrier_32(uint32_t a)
-{
-#if !defined(OPENSSL_NO_ASM) && defined(__GNUC__)
- uint32_t r;
- __asm__("" : "=r"(r) : "0"(a));
-#else
- volatile uint32_t r = a;
-#endif
- return r;
-}
-
-/* Convenience method for uint64_t. */
-static ossl_inline uint64_t value_barrier_64(uint64_t a)
-{
-#if !defined(OPENSSL_NO_ASM) && defined(__GNUC__)
- uint64_t r;
- __asm__("" : "=r"(r) : "0"(a));
-#else
- volatile uint64_t r = a;
-#endif
- return r;
-}
-
-/* Convenience method for size_t. */
-static ossl_inline size_t value_barrier_s(size_t a)
-{
-#if !defined(OPENSSL_NO_ASM) && defined(__GNUC__)
- size_t r;
- __asm__("" : "=r"(r) : "0"(a));
-#else
- volatile size_t r = a;
-#endif
- return r;
-}
-
-static ossl_inline unsigned int constant_time_select(unsigned int mask,
- unsigned int a,
- unsigned int b)
-{
- return (value_barrier(mask) & a) | (value_barrier(~mask) & b);
-}
-
-static ossl_inline size_t constant_time_select_s(size_t mask,
- size_t a,
- size_t b)
-{
- return (value_barrier_s(mask) & a) | (value_barrier_s(~mask) & b);
-}
-
-static ossl_inline unsigned char constant_time_select_8(unsigned char mask,
- unsigned char a,
- unsigned char b)
-{
- return (unsigned char)constant_time_select(mask, a, b);
-}
-
-static ossl_inline int constant_time_select_int(unsigned int mask, int a,
- int b)
-{
- return (int)constant_time_select(mask, (unsigned)(a), (unsigned)(b));
-}
-
-static ossl_inline int constant_time_select_int_s(size_t mask, int a, int b)
-{
- return (int)constant_time_select((unsigned)mask, (unsigned)(a),
- (unsigned)(b));
-}
-
-static ossl_inline uint32_t constant_time_select_32(uint32_t mask, uint32_t a,
- uint32_t b)
-{
- return (value_barrier_32(mask) & a) | (value_barrier_32(~mask) & b);
-}
-
-static ossl_inline uint64_t constant_time_select_64(uint64_t mask, uint64_t a,
- uint64_t b)
-{
- return (value_barrier_64(mask) & a) | (value_barrier_64(~mask) & b);
-}
-
-/*
- * mask must be 0xFFFFFFFF or 0x00000000.
- *
- * if (mask) {
- * uint32_t tmp = *a;
- *
- * *a = *b;
- * *b = tmp;
- * }
- */
-static ossl_inline void constant_time_cond_swap_32(uint32_t mask, uint32_t *a,
- uint32_t *b)
-{
- uint32_t xor = *a ^ *b;
-
- xor &= mask;
- *a ^= xor;
- *b ^= xor;
-}
-
-/*
- * mask must be 0xFFFFFFFF or 0x00000000.
- *
- * if (mask) {
- * uint64_t tmp = *a;
- *
- * *a = *b;
- * *b = tmp;
- * }
- */
-static ossl_inline void constant_time_cond_swap_64(uint64_t mask, uint64_t *a,
- uint64_t *b)
-{
- uint64_t xor = *a ^ *b;
-
- xor &= mask;
- *a ^= xor;
- *b ^= xor;
-}
-
-/*
- * table is a two dimensional array of bytes. Each row has rowsize elements.
- * Copies row number idx into out. rowsize and numrows are not considered
- * private.
- */
-static ossl_inline void constant_time_lookup(void *out,
- const void *table,
- size_t rowsize,
- size_t numrows,
- size_t idx)
-{
- size_t i, j;
- const unsigned char *tablec = (const unsigned char *)table;
- unsigned char *outc = (unsigned char *)out;
- unsigned char mask;
-
- memset(out, 0, rowsize);
-
- /* Note idx may underflow - but that is well defined */
- for (i = 0; i < numrows; i++, idx--) {
- mask = (unsigned char)constant_time_is_zero_s(idx);
- for (j = 0; j < rowsize; j++)
- *(outc + j) |= constant_time_select_8(mask, *(tablec++), 0);
- }
-}
-
-/*
- * Expected usage pattern is to unconditionally set error and then
- * wipe it if there was no actual error. |clear| is 1 or 0.
- */
-void err_clear_last_constant_time(int clear);
-
-#endif /* HEADER_CONSTANT_TIME_LOCL_H */
*/
#include <assert.h>
-#include "cipher_locl.h"
+#include "cipher_local.h"
#include "internal/providercommonerr.h"
/*
/* Dispatch functions for AES CCM mode */
-#include "cipher_locl.h"
+#include "cipher_local.h"
#include "internal/ciphers/cipher_ccm.h"
#include "internal/provider_algs.h"
/* AES CCM mode */
-#include "cipher_locl.h"
+#include "cipher_local.h"
#include "internal/ciphers/cipher_ccm.h"
#define AES_HW_CCM_SET_KEY_FN(fn_set_enc_key, fn_blk, fn_ccm_enc, fn_ccm_dec) \
/* Dispatch functions for AES GCM mode */
-#include "cipher_locl.h"
+#include "cipher_local.h"
#include "internal/ciphers/cipher_gcm.h"
#include "internal/provider_algs.h"
/* Dispatch functions for AES GCM mode */
-#include "cipher_locl.h"
+#include "cipher_local.h"
#include "internal/ciphers/cipher_gcm.h"
static int generic_aes_gcm_initkey(PROV_GCM_CTX *ctx, const unsigned char *key,
/* Dispatch functions for ccm mode */
-#include "cipher_locl.h"
+#include "cipher_local.h"
#include "internal/ciphers/cipher_ccm.h"
#include "internal/providercommonerr.h"
* Generic dispatch table functions for ciphers.
*/
-#include "cipher_locl.h"
+#include "cipher_local.h"
#include "internal/provider_ctx.h"
#include "internal/providercommonerr.h"
* https://www.openssl.org/source/license.html
*/
-#include "cipher_locl.h"
+#include "cipher_local.h"
/*-
* The generic cipher functions for cipher modes cbc, ecb, ofb, cfb and ctr.
/* Dispatch functions for gcm mode */
-#include "cipher_locl.h"
+#include "cipher_local.h"
#include "internal/ciphers/cipher_gcm.h"
#include "internal/providercommonerr.h"
#include "crypto/rand.h"
* https://www.openssl.org/source/license.html
*/
-#include "cipher_locl.h"
+#include "cipher_local.h"
#include "internal/ciphers/cipher_gcm.h"
--- /dev/null
+/*
+ * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+#include "internal/ciphers/ciphercommon.h"
+
+#define CIPHER_DEFAULT_GETTABLE_CTX_PARAMS_START(name) \
+static const OSSL_PARAM name##_known_gettable_ctx_params[] = { \
+ OSSL_PARAM_size_t(OSSL_CIPHER_PARAM_KEYLEN, NULL), \
+ OSSL_PARAM_size_t(OSSL_CIPHER_PARAM_IVLEN, NULL), \
+ OSSL_PARAM_uint(OSSL_CIPHER_PARAM_PADDING, NULL), \
+ OSSL_PARAM_uint(OSSL_CIPHER_PARAM_NUM, NULL), \
+ OSSL_PARAM_octet_string(OSSL_CIPHER_PARAM_IV, NULL, 0),
+
+#define CIPHER_DEFAULT_GETTABLE_CTX_PARAMS_END(name) \
+ OSSL_PARAM_END \
+}; \
+const OSSL_PARAM * name##_gettable_ctx_params(void) \
+{ \
+ return name##_known_gettable_ctx_params; \
+}
+
+void padblock(unsigned char *buf, size_t *buflen, size_t blocksize);
+int unpadblock(unsigned char *buf, size_t *buflen, size_t blocksize);
+++ /dev/null
-/*
- * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-#include "internal/ciphers/ciphercommon.h"
-
-#define CIPHER_DEFAULT_GETTABLE_CTX_PARAMS_START(name) \
-static const OSSL_PARAM name##_known_gettable_ctx_params[] = { \
- OSSL_PARAM_size_t(OSSL_CIPHER_PARAM_KEYLEN, NULL), \
- OSSL_PARAM_size_t(OSSL_CIPHER_PARAM_IVLEN, NULL), \
- OSSL_PARAM_uint(OSSL_CIPHER_PARAM_PADDING, NULL), \
- OSSL_PARAM_uint(OSSL_CIPHER_PARAM_NUM, NULL), \
- OSSL_PARAM_octet_string(OSSL_CIPHER_PARAM_IV, NULL, 0),
-
-#define CIPHER_DEFAULT_GETTABLE_CTX_PARAMS_END(name) \
- OSSL_PARAM_END \
-}; \
-const OSSL_PARAM * name##_gettable_ctx_params(void) \
-{ \
- return name##_known_gettable_ctx_params; \
-}
-
-void padblock(unsigned char *buf, size_t *buflen, size_t blocksize);
-int unpadblock(unsigned char *buf, size_t *buflen, size_t blocksize);
* https://www.openssl.org/source/license.html
*/
-#include "cipher_locl.h"
+#include "cipher_local.h"
#include "internal/ciphers/cipher_tdes.h"
#include "crypto/rand.h"
#include "internal/provider_algs.h"
* https://www.openssl.org/source/license.html
*/
-#include "cipher_locl.h"
+#include "cipher_local.h"
#include "internal/ciphers/cipher_tdes.h"
#define ks1 tks.ks[0]
* https://www.openssl.org/source/license.html
*/
-#include "cipher_locl.h"
+#include "cipher_local.h"
#include "cipher_des.h"
#include "crypto/rand.h"
#include "internal/provider_algs.h"
#include <openssl/crypto.h>
#include "internal/bio.h"
#include <openssl/err.h>
-#include "ssl_locl.h"
+#include "ssl_local.h"
static int ssl_write(BIO *h, const char *buf, size_t size, size_t *written);
static int ssl_read(BIO *b, char *buf, size_t size, size_t *readbytes);
#include <stdio.h>
#include <openssl/objects.h>
#include <openssl/rand.h>
-#include "ssl_locl.h"
+#include "ssl_local.h"
static void get_current_time(struct timeval *t);
static int dtls1_handshake_write(SSL *s);
* https://www.openssl.org/source/license.html
*/
-#include "ssl_locl.h"
+#include "ssl_local.h"
int dtls1_write_app_data_bytes(SSL *s, int type, const void *buf_, size_t len,
size_t *written)
#include <stdio.h>
#include <openssl/objects.h>
-#include "ssl_locl.h"
+#include "ssl_local.h"
#ifndef OPENSSL_NO_SRTP
#include <stdio.h>
#include <openssl/objects.h>
-#include "ssl_locl.h"
+#include "ssl_local.h"
/*-
* TLS/SSLv3 methods
* https://www.openssl.org/source/license.html
*/
-#include "ssl_locl.h"
+#include "ssl_local.h"
#include <openssl/bn.h>
struct pqueue_st {
3) A set of accessor macros
All struct definitions are in record.h. The functions and macros are either
-defined in record.h or record_locl.h dependent on whether they are intended to
+defined in record.h or record_local.h dependent on whether they are intended to
be private to the record layer, or whether they form part of the API to the rest
of libssl.
|| rec_layer_d1.c ||
||____________________||
|______________________|
- record_locl.h ^ ^ ^
+ record_local.h ^ ^ ^
_________________| | |_________________
| | |
_____V_________ ______V________ _______V________
* https://www.openssl.org/source/license.html
*/
-#include "../ssl_locl.h"
-#include "record_locl.h"
+#include "../ssl_local.h"
+#include "record_local.h"
/* mod 128 saturating subtract of two 64-bit values in big-endian order */
static int satsub64be(const unsigned char *v1, const unsigned char *v2)
#include <stdio.h>
#include <errno.h>
-#include "../ssl_locl.h"
+#include "../ssl_local.h"
#include <openssl/evp.h>
#include <openssl/buffer.h>
-#include "record_locl.h"
+#include "record_local.h"
#include "internal/packet.h"
#include "internal/cryptlib.h"
#include <stdio.h>
#include <limits.h>
#include <errno.h>
-#include "../ssl_locl.h"
+#include "../ssl_local.h"
#include <openssl/evp.h>
#include <openssl/buffer.h>
#include <openssl/rand.h>
-#include "record_locl.h"
+#include "record_local.h"
#include "internal/packet.h"
#if defined(OPENSSL_SMALL_FOOTPRINT) || \
--- /dev/null
+/*
+ * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+/*****************************************************************************
+ * *
+ * The following macros/functions are PRIVATE to the record layer. They *
+ * should NOT be used outside of the record layer. *
+ * *
+ *****************************************************************************/
+
+#define MAX_WARN_ALERT_COUNT 5
+
+/* Functions/macros provided by the RECORD_LAYER component */
+
+#define RECORD_LAYER_get_rrec(rl) ((rl)->rrec)
+#define RECORD_LAYER_set_packet(rl, p) ((rl)->packet = (p))
+#define RECORD_LAYER_reset_packet_length(rl) ((rl)->packet_length = 0)
+#define RECORD_LAYER_get_rstate(rl) ((rl)->rstate)
+#define RECORD_LAYER_set_rstate(rl, st) ((rl)->rstate = (st))
+#define RECORD_LAYER_get_read_sequence(rl) ((rl)->read_sequence)
+#define RECORD_LAYER_get_write_sequence(rl) ((rl)->write_sequence)
+#define RECORD_LAYER_get_numrpipes(rl) ((rl)->numrpipes)
+#define RECORD_LAYER_set_numrpipes(rl, n) ((rl)->numrpipes = (n))
+#define RECORD_LAYER_inc_empty_record_count(rl) ((rl)->empty_record_count++)
+#define RECORD_LAYER_reset_empty_record_count(rl) \
+ ((rl)->empty_record_count = 0)
+#define RECORD_LAYER_get_empty_record_count(rl) ((rl)->empty_record_count)
+#define RECORD_LAYER_is_first_record(rl) ((rl)->is_first_record)
+#define RECORD_LAYER_set_first_record(rl) ((rl)->is_first_record = 1)
+#define RECORD_LAYER_clear_first_record(rl) ((rl)->is_first_record = 0)
+#define DTLS_RECORD_LAYER_get_r_epoch(rl) ((rl)->d->r_epoch)
+
+__owur int ssl3_read_n(SSL *s, size_t n, size_t max, int extend, int clearold,
+ size_t *readbytes);
+
+DTLS1_BITMAP *dtls1_get_bitmap(SSL *s, SSL3_RECORD *rr,
+ unsigned int *is_next_epoch);
+int dtls1_process_buffered_records(SSL *s);
+int dtls1_retrieve_buffered_record(SSL *s, record_pqueue *queue);
+int dtls1_buffer_record(SSL *s, record_pqueue *q, unsigned char *priority);
+void ssl3_record_sequence_update(unsigned char *seq);
+
+/* Functions provided by the DTLS1_BITMAP component */
+
+int dtls1_record_replay_check(SSL *s, DTLS1_BITMAP *bitmap);
+void dtls1_record_bitmap_update(SSL *s, DTLS1_BITMAP *bitmap);
+
+/* Macros/functions provided by the SSL3_BUFFER component */
+
+#define SSL3_BUFFER_get_buf(b) ((b)->buf)
+#define SSL3_BUFFER_set_buf(b, n) ((b)->buf = (n))
+#define SSL3_BUFFER_get_len(b) ((b)->len)
+#define SSL3_BUFFER_set_len(b, l) ((b)->len = (l))
+#define SSL3_BUFFER_get_left(b) ((b)->left)
+#define SSL3_BUFFER_set_left(b, l) ((b)->left = (l))
+#define SSL3_BUFFER_sub_left(b, l) ((b)->left -= (l))
+#define SSL3_BUFFER_get_offset(b) ((b)->offset)
+#define SSL3_BUFFER_set_offset(b, o) ((b)->offset = (o))
+#define SSL3_BUFFER_add_offset(b, o) ((b)->offset += (o))
+#define SSL3_BUFFER_is_initialised(b) ((b)->buf != NULL)
+#define SSL3_BUFFER_set_default_len(b, l) ((b)->default_len = (l))
+
+void SSL3_BUFFER_clear(SSL3_BUFFER *b);
+void SSL3_BUFFER_set_data(SSL3_BUFFER *b, const unsigned char *d, size_t n);
+void SSL3_BUFFER_release(SSL3_BUFFER *b);
+__owur int ssl3_setup_read_buffer(SSL *s);
+__owur int ssl3_setup_write_buffer(SSL *s, size_t numwpipes, size_t len);
+int ssl3_release_read_buffer(SSL *s);
+int ssl3_release_write_buffer(SSL *s);
+
+/* Macros/functions provided by the SSL3_RECORD component */
+
+#define SSL3_RECORD_get_type(r) ((r)->type)
+#define SSL3_RECORD_set_type(r, t) ((r)->type = (t))
+#define SSL3_RECORD_set_rec_version(r, v) ((r)->rec_version = (v))
+#define SSL3_RECORD_get_length(r) ((r)->length)
+#define SSL3_RECORD_set_length(r, l) ((r)->length = (l))
+#define SSL3_RECORD_add_length(r, l) ((r)->length += (l))
+#define SSL3_RECORD_sub_length(r, l) ((r)->length -= (l))
+#define SSL3_RECORD_get_data(r) ((r)->data)
+#define SSL3_RECORD_set_data(r, d) ((r)->data = (d))
+#define SSL3_RECORD_get_input(r) ((r)->input)
+#define SSL3_RECORD_set_input(r, i) ((r)->input = (i))
+#define SSL3_RECORD_reset_input(r) ((r)->input = (r)->data)
+#define SSL3_RECORD_reset_data(r) ((r)->data = (r)->input)
+#define SSL3_RECORD_get_seq_num(r) ((r)->seq_num)
+#define SSL3_RECORD_get_off(r) ((r)->off)
+#define SSL3_RECORD_set_off(r, o) ((r)->off = (o))
+#define SSL3_RECORD_add_off(r, o) ((r)->off += (o))
+#define SSL3_RECORD_get_epoch(r) ((r)->epoch)
+#define SSL3_RECORD_is_sslv2_record(r) \
+ ((r)->rec_version == SSL2_VERSION)
+#define SSL3_RECORD_is_read(r) ((r)->read)
+#define SSL3_RECORD_set_read(r) ((r)->read = 1)
+
+void SSL3_RECORD_clear(SSL3_RECORD *r, size_t);
+void SSL3_RECORD_release(SSL3_RECORD *r, size_t num_recs);
+void SSL3_RECORD_set_seq_num(SSL3_RECORD *r, const unsigned char *seq_num);
+int ssl3_get_record(SSL *s);
+__owur int ssl3_do_compress(SSL *ssl, SSL3_RECORD *wr);
+__owur int ssl3_do_uncompress(SSL *ssl, SSL3_RECORD *rr);
+int ssl3_cbc_copy_mac(unsigned char *out,
+ const SSL3_RECORD *rec, size_t md_size);
+__owur int ssl3_cbc_remove_padding(SSL3_RECORD *rec,
+ size_t block_size, size_t mac_size);
+__owur int tls1_cbc_remove_padding(const SSL *s,
+ SSL3_RECORD *rec,
+ size_t block_size, size_t mac_size);
+int dtls1_process_record(SSL *s, DTLS1_BITMAP *bitmap);
+__owur int dtls1_get_record(SSL *s);
+int early_data_count_ok(SSL *s, size_t length, size_t overhead, int send);
+++ /dev/null
-/*
- * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-/*****************************************************************************
- * *
- * The following macros/functions are PRIVATE to the record layer. They *
- * should NOT be used outside of the record layer. *
- * *
- *****************************************************************************/
-
-#define MAX_WARN_ALERT_COUNT 5
-
-/* Functions/macros provided by the RECORD_LAYER component */
-
-#define RECORD_LAYER_get_rrec(rl) ((rl)->rrec)
-#define RECORD_LAYER_set_packet(rl, p) ((rl)->packet = (p))
-#define RECORD_LAYER_reset_packet_length(rl) ((rl)->packet_length = 0)
-#define RECORD_LAYER_get_rstate(rl) ((rl)->rstate)
-#define RECORD_LAYER_set_rstate(rl, st) ((rl)->rstate = (st))
-#define RECORD_LAYER_get_read_sequence(rl) ((rl)->read_sequence)
-#define RECORD_LAYER_get_write_sequence(rl) ((rl)->write_sequence)
-#define RECORD_LAYER_get_numrpipes(rl) ((rl)->numrpipes)
-#define RECORD_LAYER_set_numrpipes(rl, n) ((rl)->numrpipes = (n))
-#define RECORD_LAYER_inc_empty_record_count(rl) ((rl)->empty_record_count++)
-#define RECORD_LAYER_reset_empty_record_count(rl) \
- ((rl)->empty_record_count = 0)
-#define RECORD_LAYER_get_empty_record_count(rl) ((rl)->empty_record_count)
-#define RECORD_LAYER_is_first_record(rl) ((rl)->is_first_record)
-#define RECORD_LAYER_set_first_record(rl) ((rl)->is_first_record = 1)
-#define RECORD_LAYER_clear_first_record(rl) ((rl)->is_first_record = 0)
-#define DTLS_RECORD_LAYER_get_r_epoch(rl) ((rl)->d->r_epoch)
-
-__owur int ssl3_read_n(SSL *s, size_t n, size_t max, int extend, int clearold,
- size_t *readbytes);
-
-DTLS1_BITMAP *dtls1_get_bitmap(SSL *s, SSL3_RECORD *rr,
- unsigned int *is_next_epoch);
-int dtls1_process_buffered_records(SSL *s);
-int dtls1_retrieve_buffered_record(SSL *s, record_pqueue *queue);
-int dtls1_buffer_record(SSL *s, record_pqueue *q, unsigned char *priority);
-void ssl3_record_sequence_update(unsigned char *seq);
-
-/* Functions provided by the DTLS1_BITMAP component */
-
-int dtls1_record_replay_check(SSL *s, DTLS1_BITMAP *bitmap);
-void dtls1_record_bitmap_update(SSL *s, DTLS1_BITMAP *bitmap);
-
-/* Macros/functions provided by the SSL3_BUFFER component */
-
-#define SSL3_BUFFER_get_buf(b) ((b)->buf)
-#define SSL3_BUFFER_set_buf(b, n) ((b)->buf = (n))
-#define SSL3_BUFFER_get_len(b) ((b)->len)
-#define SSL3_BUFFER_set_len(b, l) ((b)->len = (l))
-#define SSL3_BUFFER_get_left(b) ((b)->left)
-#define SSL3_BUFFER_set_left(b, l) ((b)->left = (l))
-#define SSL3_BUFFER_sub_left(b, l) ((b)->left -= (l))
-#define SSL3_BUFFER_get_offset(b) ((b)->offset)
-#define SSL3_BUFFER_set_offset(b, o) ((b)->offset = (o))
-#define SSL3_BUFFER_add_offset(b, o) ((b)->offset += (o))
-#define SSL3_BUFFER_is_initialised(b) ((b)->buf != NULL)
-#define SSL3_BUFFER_set_default_len(b, l) ((b)->default_len = (l))
-
-void SSL3_BUFFER_clear(SSL3_BUFFER *b);
-void SSL3_BUFFER_set_data(SSL3_BUFFER *b, const unsigned char *d, size_t n);
-void SSL3_BUFFER_release(SSL3_BUFFER *b);
-__owur int ssl3_setup_read_buffer(SSL *s);
-__owur int ssl3_setup_write_buffer(SSL *s, size_t numwpipes, size_t len);
-int ssl3_release_read_buffer(SSL *s);
-int ssl3_release_write_buffer(SSL *s);
-
-/* Macros/functions provided by the SSL3_RECORD component */
-
-#define SSL3_RECORD_get_type(r) ((r)->type)
-#define SSL3_RECORD_set_type(r, t) ((r)->type = (t))
-#define SSL3_RECORD_set_rec_version(r, v) ((r)->rec_version = (v))
-#define SSL3_RECORD_get_length(r) ((r)->length)
-#define SSL3_RECORD_set_length(r, l) ((r)->length = (l))
-#define SSL3_RECORD_add_length(r, l) ((r)->length += (l))
-#define SSL3_RECORD_sub_length(r, l) ((r)->length -= (l))
-#define SSL3_RECORD_get_data(r) ((r)->data)
-#define SSL3_RECORD_set_data(r, d) ((r)->data = (d))
-#define SSL3_RECORD_get_input(r) ((r)->input)
-#define SSL3_RECORD_set_input(r, i) ((r)->input = (i))
-#define SSL3_RECORD_reset_input(r) ((r)->input = (r)->data)
-#define SSL3_RECORD_reset_data(r) ((r)->data = (r)->input)
-#define SSL3_RECORD_get_seq_num(r) ((r)->seq_num)
-#define SSL3_RECORD_get_off(r) ((r)->off)
-#define SSL3_RECORD_set_off(r, o) ((r)->off = (o))
-#define SSL3_RECORD_add_off(r, o) ((r)->off += (o))
-#define SSL3_RECORD_get_epoch(r) ((r)->epoch)
-#define SSL3_RECORD_is_sslv2_record(r) \
- ((r)->rec_version == SSL2_VERSION)
-#define SSL3_RECORD_is_read(r) ((r)->read)
-#define SSL3_RECORD_set_read(r) ((r)->read = 1)
-
-void SSL3_RECORD_clear(SSL3_RECORD *r, size_t);
-void SSL3_RECORD_release(SSL3_RECORD *r, size_t num_recs);
-void SSL3_RECORD_set_seq_num(SSL3_RECORD *r, const unsigned char *seq_num);
-int ssl3_get_record(SSL *s);
-__owur int ssl3_do_compress(SSL *ssl, SSL3_RECORD *wr);
-__owur int ssl3_do_uncompress(SSL *ssl, SSL3_RECORD *rr);
-int ssl3_cbc_copy_mac(unsigned char *out,
- const SSL3_RECORD *rec, size_t md_size);
-__owur int ssl3_cbc_remove_padding(SSL3_RECORD *rec,
- size_t block_size, size_t mac_size);
-__owur int tls1_cbc_remove_padding(const SSL *s,
- SSL3_RECORD *rec,
- size_t block_size, size_t mac_size);
-int dtls1_process_record(SSL *s, DTLS1_BITMAP *bitmap);
-__owur int dtls1_get_record(SSL *s);
-int early_data_count_ok(SSL *s, size_t length, size_t overhead, int send);
* https://www.openssl.org/source/license.html
*/
-#include "../ssl_locl.h"
-#include "record_locl.h"
+#include "../ssl_local.h"
+#include "record_local.h"
void SSL3_BUFFER_set_data(SSL3_BUFFER *b, const unsigned char *d, size_t n)
{
* https://www.openssl.org/source/license.html
*/
-#include "../ssl_locl.h"
-#include "internal/constant_time_locl.h"
+#include "../ssl_local.h"
+#include "internal/constant_time.h"
#include <openssl/trace.h>
#include <openssl/rand.h>
-#include "record_locl.h"
+#include "record_local.h"
#include "internal/cryptlib.h"
static const unsigned char ssl3_pad_1[48] = {
* https://www.openssl.org/source/license.html
*/
-#include "../ssl_locl.h"
-#include "record_locl.h"
+#include "../ssl_local.h"
+#include "record_local.h"
#include "internal/cryptlib.h"
/*-
* https://www.openssl.org/source/license.html
*/
-#include "internal/constant_time_locl.h"
-#include "ssl_locl.h"
+#include "internal/constant_time.h"
+#include "ssl_local.h"
#include "internal/cryptlib.h"
#include <openssl/md5.h>
*/
#include <stdio.h>
-#include "ssl_locl.h"
+#include "ssl_local.h"
#include <openssl/evp.h>
#include <openssl/md5.h>
#include <openssl/core_names.h>
#include <stdio.h>
#include <openssl/objects.h>
#include "internal/nelem.h"
-#include "ssl_locl.h"
+#include "ssl_local.h"
#include <openssl/md5.h>
#include <openssl/dh.h>
#include <openssl/rand.h>
* https://www.openssl.org/source/license.html
*/
-#include "ssl_locl.h"
+#include "ssl_local.h"
int ssl3_do_change_cipher_spec(SSL *s)
{
#include <stdio.h>
#include <stdlib.h>
-#include "ssl_locl.h"
+#include "ssl_local.h"
#include <openssl/asn1t.h>
#include <openssl/x509.h>
#include <openssl/bn.h>
#include <openssl/crypto.h>
#include "internal/refcount.h"
-#include "ssl_locl.h"
+#include "ssl_local.h"
#include "ssl_cert_table.h"
#include "internal/thread_once.h"
#include <openssl/conf.h>
#include <openssl/trace.h>
#include "internal/nelem.h"
-#include "ssl_locl.h"
+#include "ssl_local.h"
#include "internal/thread_once.h"
#include "internal/cryptlib.h"
/*
* Constant SSL_MAX_DIGEST equal to size of digests array should be defined
- * in the ssl_locl.h
+ * in the ssl_local.h
*/
#define SSL_MD_NUM_IDX SSL_MAX_DIGEST
*/
#include <stdio.h>
-#include "ssl_locl.h"
+#include "ssl_local.h"
#include <openssl/conf.h>
#include <openssl/objects.h>
#include <openssl/dh.h>
#include <openssl/crypto.h>
#include <openssl/evp.h>
#include <openssl/trace.h>
-#include "ssl_locl.h"
+#include "ssl_local.h"
#include "internal/thread_once.h"
static int stopped;
*/
#include <stdio.h>
-#include "ssl_locl.h"
+#include "ssl_local.h"
#include "e_os.h"
#include <openssl/objects.h>
#include <openssl/x509v3.h>
--- /dev/null
+/*
+ * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved
+ * Copyright 2005 Nokia. All rights reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+#ifndef HEADER_SSL_LOCL_H
+# define HEADER_SSL_LOCL_H
+
+# include "e_os.h" /* struct timeval for DTLS */
+# include <stdlib.h>
+# include <time.h>
+# include <string.h>
+# include <errno.h>
+
+# include <openssl/buffer.h>
+# include <openssl/comp.h>
+# include <openssl/bio.h>
+# include <openssl/rsa.h>
+# include <openssl/dsa.h>
+# include <openssl/err.h>
+# include <openssl/ssl.h>
+# include <openssl/async.h>
+# include <openssl/symhacks.h>
+# include <openssl/ct.h>
+# include "record/record.h"
+# include "statem/statem.h"
+# include "internal/packet.h"
+# include "internal/dane.h"
+# include "internal/refcount.h"
+# include "internal/tsan_assist.h"
+# include "internal/bio.h"
+
+# ifdef OPENSSL_BUILD_SHLIBSSL
+# undef OPENSSL_EXTERN
+# define OPENSSL_EXTERN OPENSSL_EXPORT
+# endif
+
+# define c2l(c,l) (l = ((unsigned long)(*((c)++))) , \
+ l|=(((unsigned long)(*((c)++)))<< 8), \
+ l|=(((unsigned long)(*((c)++)))<<16), \
+ l|=(((unsigned long)(*((c)++)))<<24))
+
+/* NOTE - c is not incremented as per c2l */
+# define c2ln(c,l1,l2,n) { \
+ c+=n; \
+ l1=l2=0; \
+ switch (n) { \
+ case 8: l2 =((unsigned long)(*(--(c))))<<24; \
+ case 7: l2|=((unsigned long)(*(--(c))))<<16; \
+ case 6: l2|=((unsigned long)(*(--(c))))<< 8; \
+ case 5: l2|=((unsigned long)(*(--(c)))); \
+ case 4: l1 =((unsigned long)(*(--(c))))<<24; \
+ case 3: l1|=((unsigned long)(*(--(c))))<<16; \
+ case 2: l1|=((unsigned long)(*(--(c))))<< 8; \
+ case 1: l1|=((unsigned long)(*(--(c)))); \
+ } \
+ }
+
+# define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \
+ *((c)++)=(unsigned char)(((l)>> 8)&0xff), \
+ *((c)++)=(unsigned char)(((l)>>16)&0xff), \
+ *((c)++)=(unsigned char)(((l)>>24)&0xff))
+
+# define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24, \
+ l|=((unsigned long)(*((c)++)))<<16, \
+ l|=((unsigned long)(*((c)++)))<< 8, \
+ l|=((unsigned long)(*((c)++))))
+
+# define n2l8(c,l) (l =((uint64_t)(*((c)++)))<<56, \
+ l|=((uint64_t)(*((c)++)))<<48, \
+ l|=((uint64_t)(*((c)++)))<<40, \
+ l|=((uint64_t)(*((c)++)))<<32, \
+ l|=((uint64_t)(*((c)++)))<<24, \
+ l|=((uint64_t)(*((c)++)))<<16, \
+ l|=((uint64_t)(*((c)++)))<< 8, \
+ l|=((uint64_t)(*((c)++))))
+
+
+# define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24)&0xff), \
+ *((c)++)=(unsigned char)(((l)>>16)&0xff), \
+ *((c)++)=(unsigned char)(((l)>> 8)&0xff), \
+ *((c)++)=(unsigned char)(((l) )&0xff))
+
+# define l2n6(l,c) (*((c)++)=(unsigned char)(((l)>>40)&0xff), \
+ *((c)++)=(unsigned char)(((l)>>32)&0xff), \
+ *((c)++)=(unsigned char)(((l)>>24)&0xff), \
+ *((c)++)=(unsigned char)(((l)>>16)&0xff), \
+ *((c)++)=(unsigned char)(((l)>> 8)&0xff), \
+ *((c)++)=(unsigned char)(((l) )&0xff))
+
+# define l2n8(l,c) (*((c)++)=(unsigned char)(((l)>>56)&0xff), \
+ *((c)++)=(unsigned char)(((l)>>48)&0xff), \
+ *((c)++)=(unsigned char)(((l)>>40)&0xff), \
+ *((c)++)=(unsigned char)(((l)>>32)&0xff), \
+ *((c)++)=(unsigned char)(((l)>>24)&0xff), \
+ *((c)++)=(unsigned char)(((l)>>16)&0xff), \
+ *((c)++)=(unsigned char)(((l)>> 8)&0xff), \
+ *((c)++)=(unsigned char)(((l) )&0xff))
+
+/* NOTE - c is not incremented as per l2c */
+# define l2cn(l1,l2,c,n) { \
+ c+=n; \
+ switch (n) { \
+ case 8: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \
+ case 7: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \
+ case 6: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \
+ case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \
+ case 4: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \
+ case 3: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \
+ case 2: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \
+ case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \
+ } \
+ }
+
+# define n2s(c,s) ((s=(((unsigned int)((c)[0]))<< 8)| \
+ (((unsigned int)((c)[1])) )),(c)+=2)
+# define s2n(s,c) (((c)[0]=(unsigned char)(((s)>> 8)&0xff), \
+ (c)[1]=(unsigned char)(((s) )&0xff)),(c)+=2)
+
+# define n2l3(c,l) ((l =(((unsigned long)((c)[0]))<<16)| \
+ (((unsigned long)((c)[1]))<< 8)| \
+ (((unsigned long)((c)[2])) )),(c)+=3)
+
+# define l2n3(l,c) (((c)[0]=(unsigned char)(((l)>>16)&0xff), \
+ (c)[1]=(unsigned char)(((l)>> 8)&0xff), \
+ (c)[2]=(unsigned char)(((l) )&0xff)),(c)+=3)
+
+# define TLS_MAX_VERSION_INTERNAL TLS1_3_VERSION
+# define DTLS_MAX_VERSION_INTERNAL DTLS1_2_VERSION
+
+/*
+ * DTLS version numbers are strange because they're inverted. Except for
+ * DTLS1_BAD_VER, which should be considered "lower" than the rest.
+ */
+# define dtls_ver_ordinal(v1) (((v1) == DTLS1_BAD_VER) ? 0xff00 : (v1))
+# define DTLS_VERSION_GT(v1, v2) (dtls_ver_ordinal(v1) < dtls_ver_ordinal(v2))
+# define DTLS_VERSION_GE(v1, v2) (dtls_ver_ordinal(v1) <= dtls_ver_ordinal(v2))
+# define DTLS_VERSION_LT(v1, v2) (dtls_ver_ordinal(v1) > dtls_ver_ordinal(v2))
+# define DTLS_VERSION_LE(v1, v2) (dtls_ver_ordinal(v1) >= dtls_ver_ordinal(v2))
+
+
+/*
+ * Define the Bitmasks for SSL_CIPHER.algorithms.
+ * This bits are used packed as dense as possible. If new methods/ciphers
+ * etc will be added, the bits a likely to change, so this information
+ * is for internal library use only, even though SSL_CIPHER.algorithms
+ * can be publicly accessed.
+ * Use the according functions for cipher management instead.
+ *
+ * The bit mask handling in the selection and sorting scheme in
+ * ssl_create_cipher_list() has only limited capabilities, reflecting
+ * that the different entities within are mutually exclusive:
+ * ONLY ONE BIT PER MASK CAN BE SET AT A TIME.
+ */
+
+/* Bits for algorithm_mkey (key exchange algorithm) */
+/* RSA key exchange */
+# define SSL_kRSA 0x00000001U
+/* tmp DH key no DH cert */
+# define SSL_kDHE 0x00000002U
+/* synonym */
+# define SSL_kEDH SSL_kDHE
+/* ephemeral ECDH */
+# define SSL_kECDHE 0x00000004U
+/* synonym */
+# define SSL_kEECDH SSL_kECDHE
+/* PSK */
+# define SSL_kPSK 0x00000008U
+/* GOST key exchange */
+# define SSL_kGOST 0x00000010U
+/* SRP */
+# define SSL_kSRP 0x00000020U
+
+# define SSL_kRSAPSK 0x00000040U
+# define SSL_kECDHEPSK 0x00000080U
+# define SSL_kDHEPSK 0x00000100U
+
+/* all PSK */
+
+# define SSL_PSK (SSL_kPSK | SSL_kRSAPSK | SSL_kECDHEPSK | SSL_kDHEPSK)
+
+/* Any appropriate key exchange algorithm (for TLS 1.3 ciphersuites) */
+# define SSL_kANY 0x00000000U
+
+/* Bits for algorithm_auth (server authentication) */
+/* RSA auth */
+# define SSL_aRSA 0x00000001U
+/* DSS auth */
+# define SSL_aDSS 0x00000002U
+/* no auth (i.e. use ADH or AECDH) */
+# define SSL_aNULL 0x00000004U
+/* ECDSA auth*/
+# define SSL_aECDSA 0x00000008U
+/* PSK auth */
+# define SSL_aPSK 0x00000010U
+/* GOST R 34.10-2001 signature auth */
+# define SSL_aGOST01 0x00000020U
+/* SRP auth */
+# define SSL_aSRP 0x00000040U
+/* GOST R 34.10-2012 signature auth */
+# define SSL_aGOST12 0x00000080U
+/* Any appropriate signature auth (for TLS 1.3 ciphersuites) */
+# define SSL_aANY 0x00000000U
+/* All bits requiring a certificate */
+#define SSL_aCERT \
+ (SSL_aRSA | SSL_aDSS | SSL_aECDSA | SSL_aGOST01 | SSL_aGOST12)
+
+/* Bits for algorithm_enc (symmetric encryption) */
+# define SSL_DES 0x00000001U
+# define SSL_3DES 0x00000002U
+# define SSL_RC4 0x00000004U
+# define SSL_RC2 0x00000008U
+# define SSL_IDEA 0x00000010U
+# define SSL_eNULL 0x00000020U
+# define SSL_AES128 0x00000040U
+# define SSL_AES256 0x00000080U
+# define SSL_CAMELLIA128 0x00000100U
+# define SSL_CAMELLIA256 0x00000200U
+# define SSL_eGOST2814789CNT 0x00000400U
+# define SSL_SEED 0x00000800U
+# define SSL_AES128GCM 0x00001000U
+# define SSL_AES256GCM 0x00002000U
+# define SSL_AES128CCM 0x00004000U
+# define SSL_AES256CCM 0x00008000U
+# define SSL_AES128CCM8 0x00010000U
+# define SSL_AES256CCM8 0x00020000U
+# define SSL_eGOST2814789CNT12 0x00040000U
+# define SSL_CHACHA20POLY1305 0x00080000U
+# define SSL_ARIA128GCM 0x00100000U
+# define SSL_ARIA256GCM 0x00200000U
+
+# define SSL_AESGCM (SSL_AES128GCM | SSL_AES256GCM)
+# define SSL_AESCCM (SSL_AES128CCM | SSL_AES256CCM | SSL_AES128CCM8 | SSL_AES256CCM8)
+# define SSL_AES (SSL_AES128|SSL_AES256|SSL_AESGCM|SSL_AESCCM)
+# define SSL_CAMELLIA (SSL_CAMELLIA128|SSL_CAMELLIA256)
+# define SSL_CHACHA20 (SSL_CHACHA20POLY1305)
+# define SSL_ARIAGCM (SSL_ARIA128GCM | SSL_ARIA256GCM)
+# define SSL_ARIA (SSL_ARIAGCM)
+
+/* Bits for algorithm_mac (symmetric authentication) */
+
+# define SSL_MD5 0x00000001U
+# define SSL_SHA1 0x00000002U
+# define SSL_GOST94 0x00000004U
+# define SSL_GOST89MAC 0x00000008U
+# define SSL_SHA256 0x00000010U
+# define SSL_SHA384 0x00000020U
+/* Not a real MAC, just an indication it is part of cipher */
+# define SSL_AEAD 0x00000040U
+# define SSL_GOST12_256 0x00000080U
+# define SSL_GOST89MAC12 0x00000100U
+# define SSL_GOST12_512 0x00000200U
+
+/*
+ * When adding new digest in the ssl_ciph.c and increment SSL_MD_NUM_IDX make
+ * sure to update this constant too
+ */
+
+# define SSL_MD_MD5_IDX 0
+# define SSL_MD_SHA1_IDX 1
+# define SSL_MD_GOST94_IDX 2
+# define SSL_MD_GOST89MAC_IDX 3
+# define SSL_MD_SHA256_IDX 4
+# define SSL_MD_SHA384_IDX 5
+# define SSL_MD_GOST12_256_IDX 6
+# define SSL_MD_GOST89MAC12_IDX 7
+# define SSL_MD_GOST12_512_IDX 8
+# define SSL_MD_MD5_SHA1_IDX 9
+# define SSL_MD_SHA224_IDX 10
+# define SSL_MD_SHA512_IDX 11
+# define SSL_MAX_DIGEST 12
+
+/* Bits for algorithm2 (handshake digests and other extra flags) */
+
+/* Bits 0-7 are handshake MAC */
+# define SSL_HANDSHAKE_MAC_MASK 0xFF
+# define SSL_HANDSHAKE_MAC_MD5_SHA1 SSL_MD_MD5_SHA1_IDX
+# define SSL_HANDSHAKE_MAC_SHA256 SSL_MD_SHA256_IDX
+# define SSL_HANDSHAKE_MAC_SHA384 SSL_MD_SHA384_IDX
+# define SSL_HANDSHAKE_MAC_GOST94 SSL_MD_GOST94_IDX
+# define SSL_HANDSHAKE_MAC_GOST12_256 SSL_MD_GOST12_256_IDX
+# define SSL_HANDSHAKE_MAC_GOST12_512 SSL_MD_GOST12_512_IDX
+# define SSL_HANDSHAKE_MAC_DEFAULT SSL_HANDSHAKE_MAC_MD5_SHA1
+
+/* Bits 8-15 bits are PRF */
+# define TLS1_PRF_DGST_SHIFT 8
+# define TLS1_PRF_SHA1_MD5 (SSL_MD_MD5_SHA1_IDX << TLS1_PRF_DGST_SHIFT)
+# define TLS1_PRF_SHA256 (SSL_MD_SHA256_IDX << TLS1_PRF_DGST_SHIFT)
+# define TLS1_PRF_SHA384 (SSL_MD_SHA384_IDX << TLS1_PRF_DGST_SHIFT)
+# define TLS1_PRF_GOST94 (SSL_MD_GOST94_IDX << TLS1_PRF_DGST_SHIFT)
+# define TLS1_PRF_GOST12_256 (SSL_MD_GOST12_256_IDX << TLS1_PRF_DGST_SHIFT)
+# define TLS1_PRF_GOST12_512 (SSL_MD_GOST12_512_IDX << TLS1_PRF_DGST_SHIFT)
+# define TLS1_PRF (SSL_MD_MD5_SHA1_IDX << TLS1_PRF_DGST_SHIFT)
+
+/*
+ * Stream MAC for GOST ciphersuites from cryptopro draft (currently this also
+ * goes into algorithm2)
+ */
+# define TLS1_STREAM_MAC 0x10000
+
+# define SSL_STRONG_MASK 0x0000001FU
+# define SSL_DEFAULT_MASK 0X00000020U
+
+# define SSL_STRONG_NONE 0x00000001U
+# define SSL_LOW 0x00000002U
+# define SSL_MEDIUM 0x00000004U
+# define SSL_HIGH 0x00000008U
+# define SSL_FIPS 0x00000010U
+# define SSL_NOT_DEFAULT 0x00000020U
+
+/* we have used 0000003f - 26 bits left to go */
+
+/* Flag used on OpenSSL ciphersuite ids to indicate they are for SSLv3+ */
+# define SSL3_CK_CIPHERSUITE_FLAG 0x03000000
+
+/* Check if an SSL structure is using DTLS */
+# define SSL_IS_DTLS(s) (s->method->ssl3_enc->enc_flags & SSL_ENC_FLAG_DTLS)
+
+/* Check if we are using TLSv1.3 */
+# define SSL_IS_TLS13(s) (!SSL_IS_DTLS(s) \
+ && (s)->method->version >= TLS1_3_VERSION \
+ && (s)->method->version != TLS_ANY_VERSION)
+
+# define SSL_TREAT_AS_TLS13(s) \
+ (SSL_IS_TLS13(s) || (s)->early_data_state == SSL_EARLY_DATA_CONNECTING \
+ || (s)->early_data_state == SSL_EARLY_DATA_CONNECT_RETRY \
+ || (s)->early_data_state == SSL_EARLY_DATA_WRITING \
+ || (s)->early_data_state == SSL_EARLY_DATA_WRITE_RETRY \
+ || (s)->hello_retry_request == SSL_HRR_PENDING)
+
+# define SSL_IS_FIRST_HANDSHAKE(S) ((s)->s3.tmp.finish_md_len == 0 \
+ || (s)->s3.tmp.peer_finish_md_len == 0)
+
+/* See if we need explicit IV */
+# define SSL_USE_EXPLICIT_IV(s) \
+ (s->method->ssl3_enc->enc_flags & SSL_ENC_FLAG_EXPLICIT_IV)
+/*
+ * See if we use signature algorithms extension and signature algorithm
+ * before signatures.
+ */
+# define SSL_USE_SIGALGS(s) \
+ (s->method->ssl3_enc->enc_flags & SSL_ENC_FLAG_SIGALGS)
+/*
+ * Allow TLS 1.2 ciphersuites: applies to DTLS 1.2 as well as TLS 1.2: may
+ * apply to others in future.
+ */
+# define SSL_USE_TLS1_2_CIPHERS(s) \
+ (s->method->ssl3_enc->enc_flags & SSL_ENC_FLAG_TLS1_2_CIPHERS)
+/*
+ * Determine if a client can use TLS 1.2 ciphersuites: can't rely on method
+ * flags because it may not be set to correct version yet.
+ */
+# define SSL_CLIENT_USE_TLS1_2_CIPHERS(s) \
+ ((!SSL_IS_DTLS(s) && s->client_version >= TLS1_2_VERSION) || \
+ (SSL_IS_DTLS(s) && DTLS_VERSION_GE(s->client_version, DTLS1_2_VERSION)))
+/*
+ * Determine if a client should send signature algorithms extension:
+ * as with TLS1.2 cipher we can't rely on method flags.
+ */
+# define SSL_CLIENT_USE_SIGALGS(s) \
+ SSL_CLIENT_USE_TLS1_2_CIPHERS(s)
+
+# define IS_MAX_FRAGMENT_LENGTH_EXT_VALID(value) \
+ (((value) >= TLSEXT_max_fragment_length_512) && \
+ ((value) <= TLSEXT_max_fragment_length_4096))
+# define USE_MAX_FRAGMENT_LENGTH_EXT(session) \
+ IS_MAX_FRAGMENT_LENGTH_EXT_VALID(session->ext.max_fragment_len_mode)
+# define GET_MAX_FRAGMENT_LENGTH(session) \
+ (512U << (session->ext.max_fragment_len_mode - 1))
+
+# define SSL_READ_ETM(s) (s->s3.flags & TLS1_FLAGS_ENCRYPT_THEN_MAC_READ)
+# define SSL_WRITE_ETM(s) (s->s3.flags & TLS1_FLAGS_ENCRYPT_THEN_MAC_WRITE)
+
+/* Mostly for SSLv3 */
+# define SSL_PKEY_RSA 0
+# define SSL_PKEY_RSA_PSS_SIGN 1
+# define SSL_PKEY_DSA_SIGN 2
+# define SSL_PKEY_ECC 3
+# define SSL_PKEY_GOST01 4
+# define SSL_PKEY_GOST12_256 5
+# define SSL_PKEY_GOST12_512 6
+# define SSL_PKEY_ED25519 7
+# define SSL_PKEY_ED448 8
+# define SSL_PKEY_NUM 9
+
+/*-
+ * SSL_kRSA <- RSA_ENC
+ * SSL_kDH <- DH_ENC & (RSA_ENC | RSA_SIGN | DSA_SIGN)
+ * SSL_kDHE <- RSA_ENC | RSA_SIGN | DSA_SIGN
+ * SSL_aRSA <- RSA_ENC | RSA_SIGN
+ * SSL_aDSS <- DSA_SIGN
+ */
+
+/*-
+#define CERT_INVALID 0
+#define CERT_PUBLIC_KEY 1
+#define CERT_PRIVATE_KEY 2
+*/
+
+/* Post-Handshake Authentication state */
+typedef enum {
+ SSL_PHA_NONE = 0,
+ SSL_PHA_EXT_SENT, /* client-side only: extension sent */
+ SSL_PHA_EXT_RECEIVED, /* server-side only: extension received */
+ SSL_PHA_REQUEST_PENDING, /* server-side only: request pending */
+ SSL_PHA_REQUESTED /* request received by client, or sent by server */
+} SSL_PHA_STATE;
+
+/* CipherSuite length. SSLv3 and all TLS versions. */
+# define TLS_CIPHER_LEN 2
+/* used to hold info on the particular ciphers used */
+struct ssl_cipher_st {
+ uint32_t valid;
+ const char *name; /* text name */
+ const char *stdname; /* RFC name */
+ uint32_t id; /* id, 4 bytes, first is version */
+ /*
+ * changed in 1.0.0: these four used to be portions of a single value
+ * 'algorithms'
+ */
+ uint32_t algorithm_mkey; /* key exchange algorithm */
+ uint32_t algorithm_auth; /* server authentication */
+ uint32_t algorithm_enc; /* symmetric encryption */
+ uint32_t algorithm_mac; /* symmetric authentication */
+ int min_tls; /* minimum SSL/TLS protocol version */
+ int max_tls; /* maximum SSL/TLS protocol version */
+ int min_dtls; /* minimum DTLS protocol version */
+ int max_dtls; /* maximum DTLS protocol version */
+ uint32_t algo_strength; /* strength and export flags */
+ uint32_t algorithm2; /* Extra flags */
+ int32_t strength_bits; /* Number of bits really used */
+ uint32_t alg_bits; /* Number of bits for algorithm */
+};
+
+/* Used to hold SSL/TLS functions */
+struct ssl_method_st {
+ int version;
+ unsigned flags;
+ unsigned long mask;
+ int (*ssl_new) (SSL *s);
+ int (*ssl_clear) (SSL *s);
+ void (*ssl_free) (SSL *s);
+ int (*ssl_accept) (SSL *s);
+ int (*ssl_connect) (SSL *s);
+ int (*ssl_read) (SSL *s, void *buf, size_t len, size_t *readbytes);
+ int (*ssl_peek) (SSL *s, void *buf, size_t len, size_t *readbytes);
+ int (*ssl_write) (SSL *s, const void *buf, size_t len, size_t *written);
+ int (*ssl_shutdown) (SSL *s);
+ int (*ssl_renegotiate) (SSL *s);
+ int (*ssl_renegotiate_check) (SSL *s, int);
+ int (*ssl_read_bytes) (SSL *s, int type, int *recvd_type,
+ unsigned char *buf, size_t len, int peek,
+ size_t *readbytes);
+ int (*ssl_write_bytes) (SSL *s, int type, const void *buf_, size_t len,
+ size_t *written);
+ int (*ssl_dispatch_alert) (SSL *s);
+ long (*ssl_ctrl) (SSL *s, int cmd, long larg, void *parg);
+ long (*ssl_ctx_ctrl) (SSL_CTX *ctx, int cmd, long larg, void *parg);
+ const SSL_CIPHER *(*get_cipher_by_char) (const unsigned char *ptr);
+ int (*put_cipher_by_char) (const SSL_CIPHER *cipher, WPACKET *pkt,
+ size_t *len);
+ size_t (*ssl_pending) (const SSL *s);
+ int (*num_ciphers) (void);
+ const SSL_CIPHER *(*get_cipher) (unsigned ncipher);
+ long (*get_timeout) (void);
+ const struct ssl3_enc_method *ssl3_enc; /* Extra SSLv3/TLS stuff */
+ int (*ssl_version) (void);
+ long (*ssl_callback_ctrl) (SSL *s, int cb_id, void (*fp) (void));
+ long (*ssl_ctx_callback_ctrl) (SSL_CTX *s, int cb_id, void (*fp) (void));
+};
+
+/*
+ * Matches the length of PSK_MAX_PSK_LEN. We keep it the same value for
+ * consistency, even in the event of OPENSSL_NO_PSK being defined.
+ */
+# define TLS13_MAX_RESUMPTION_PSK_LENGTH 256
+
+/*-
+ * Lets make this into an ASN.1 type structure as follows
+ * SSL_SESSION_ID ::= SEQUENCE {
+ * version INTEGER, -- structure version number
+ * SSLversion INTEGER, -- SSL version number
+ * Cipher OCTET STRING, -- the 3 byte cipher ID
+ * Session_ID OCTET STRING, -- the Session ID
+ * Master_key OCTET STRING, -- the master key
+ * Key_Arg [ 0 ] IMPLICIT OCTET STRING, -- the optional Key argument
+ * Time [ 1 ] EXPLICIT INTEGER, -- optional Start Time
+ * Timeout [ 2 ] EXPLICIT INTEGER, -- optional Timeout ins seconds
+ * Peer [ 3 ] EXPLICIT X509, -- optional Peer Certificate
+ * Session_ID_context [ 4 ] EXPLICIT OCTET STRING, -- the Session ID context
+ * Verify_result [ 5 ] EXPLICIT INTEGER, -- X509_V_... code for `Peer'
+ * HostName [ 6 ] EXPLICIT OCTET STRING, -- optional HostName from servername TLS extension
+ * PSK_identity_hint [ 7 ] EXPLICIT OCTET STRING, -- optional PSK identity hint
+ * PSK_identity [ 8 ] EXPLICIT OCTET STRING, -- optional PSK identity
+ * Ticket_lifetime_hint [9] EXPLICIT INTEGER, -- server's lifetime hint for session ticket
+ * Ticket [10] EXPLICIT OCTET STRING, -- session ticket (clients only)
+ * Compression_meth [11] EXPLICIT OCTET STRING, -- optional compression method
+ * SRP_username [ 12 ] EXPLICIT OCTET STRING -- optional SRP username
+ * flags [ 13 ] EXPLICIT INTEGER -- optional flags
+ * }
+ * Look in ssl/ssl_asn1.c for more details
+ * I'm using EXPLICIT tags so I can read the damn things using asn1parse :-).
+ */
+struct ssl_session_st {
+ int ssl_version; /* what ssl version session info is being kept
+ * in here? */
+ size_t master_key_length;
+
+ /* TLSv1.3 early_secret used for external PSKs */
+ unsigned char early_secret[EVP_MAX_MD_SIZE];
+ /*
+ * For <=TLS1.2 this is the master_key. For TLS1.3 this is the resumption
+ * PSK
+ */
+ unsigned char master_key[TLS13_MAX_RESUMPTION_PSK_LENGTH];
+ /* session_id - valid? */
+ size_t session_id_length;
+ unsigned char session_id[SSL_MAX_SSL_SESSION_ID_LENGTH];
+ /*
+ * this is used to determine whether the session is being reused in the
+ * appropriate context. It is up to the application to set this, via
+ * SSL_new
+ */
+ size_t sid_ctx_length;
+ unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH];
+# ifndef OPENSSL_NO_PSK
+ char *psk_identity_hint;
+ char *psk_identity;
+# endif
+ /*
+ * Used to indicate that session resumption is not allowed. Applications
+ * can also set this bit for a new session via not_resumable_session_cb
+ * to disable session caching and tickets.
+ */
+ int not_resumable;
+ /* This is the cert and type for the other end. */
+ X509 *peer;
+ int peer_type;
+ /* Certificate chain peer sent. */
+ STACK_OF(X509) *peer_chain;
+ /*
+ * when app_verify_callback accepts a session where the peer's
+ * certificate is not ok, we must remember the error for session reuse:
+ */
+ long verify_result; /* only for servers */
+ CRYPTO_REF_COUNT references;
+ long timeout;
+ long time;
+ unsigned int compress_meth; /* Need to lookup the method */
+ const SSL_CIPHER *cipher;
+ unsigned long cipher_id; /* when ASN.1 loaded, this needs to be used to
+ * load the 'cipher' structure */
+ CRYPTO_EX_DATA ex_data; /* application specific data */
+ /*
+ * These are used to make removal of session-ids more efficient and to
+ * implement a maximum cache size.
+ */
+ struct ssl_session_st *prev, *next;
+
+ struct {
+ char *hostname;
+ /* RFC4507 info */
+ unsigned char *tick; /* Session ticket */
+ size_t ticklen; /* Session ticket length */
+ /* Session lifetime hint in seconds */
+ unsigned long tick_lifetime_hint;
+ uint32_t tick_age_add;
+ /* Max number of bytes that can be sent as early data */
+ uint32_t max_early_data;
+ /* The ALPN protocol selected for this session */
+ unsigned char *alpn_selected;
+ size_t alpn_selected_len;
+ /*
+ * Maximum Fragment Length as per RFC 4366.
+ * If this value does not contain RFC 4366 allowed values (1-4) then
+ * either the Maximum Fragment Length Negotiation failed or was not
+ * performed at all.
+ */
+ uint8_t max_fragment_len_mode;
+ } ext;
+# ifndef OPENSSL_NO_SRP
+ char *srp_username;
+# endif
+ unsigned char *ticket_appdata;
+ size_t ticket_appdata_len;
+ uint32_t flags;
+ CRYPTO_RWLOCK *lock;
+};
+
+/* Extended master secret support */
+# define SSL_SESS_FLAG_EXTMS 0x1
+
+# ifndef OPENSSL_NO_SRP
+
+typedef struct srp_ctx_st {
+ /* param for all the callbacks */
+ void *SRP_cb_arg;
+ /* set client Hello login callback */
+ int (*TLS_ext_srp_username_callback) (SSL *, int *, void *);
+ /* set SRP N/g param callback for verification */
+ int (*SRP_verify_param_callback) (SSL *, void *);
+ /* set SRP client passwd callback */
+ char *(*SRP_give_srp_client_pwd_callback) (SSL *, void *);
+ char *login;
+ BIGNUM *N, *g, *s, *B, *A;
+ BIGNUM *a, *b, *v;
+ char *info;
+ int strength;
+ unsigned long srp_Mask;
+} SRP_CTX;
+
+# endif
+
+typedef enum {
+ SSL_EARLY_DATA_NONE = 0,
+ SSL_EARLY_DATA_CONNECT_RETRY,
+ SSL_EARLY_DATA_CONNECTING,
+ SSL_EARLY_DATA_WRITE_RETRY,
+ SSL_EARLY_DATA_WRITING,
+ SSL_EARLY_DATA_WRITE_FLUSH,
+ SSL_EARLY_DATA_UNAUTH_WRITING,
+ SSL_EARLY_DATA_FINISHED_WRITING,
+ SSL_EARLY_DATA_ACCEPT_RETRY,
+ SSL_EARLY_DATA_ACCEPTING,
+ SSL_EARLY_DATA_READ_RETRY,
+ SSL_EARLY_DATA_READING,
+ SSL_EARLY_DATA_FINISHED_READING
+} SSL_EARLY_DATA_STATE;
+
+/*
+ * We check that the amount of unreadable early data doesn't exceed
+ * max_early_data. max_early_data is given in plaintext bytes. However if it is
+ * unreadable then we only know the number of ciphertext bytes. We also don't
+ * know how much the overhead should be because it depends on the ciphersuite.
+ * We make a small allowance. We assume 5 records of actual data plus the end
+ * of early data alert record. Each record has a tag and a content type byte.
+ * The longest tag length we know of is EVP_GCM_TLS_TAG_LEN. We don't count the
+ * content of the alert record either which is 2 bytes.
+ */
+# define EARLY_DATA_CIPHERTEXT_OVERHEAD ((6 * (EVP_GCM_TLS_TAG_LEN + 1)) + 2)
+
+/*
+ * The allowance we have between the client's calculated ticket age and our own.
+ * We allow for 10 seconds (units are in ms). If a ticket is presented and the
+ * client's age calculation is different by more than this than our own then we
+ * do not allow that ticket for early_data.
+ */
+# define TICKET_AGE_ALLOWANCE (10 * 1000)
+
+#define MAX_COMPRESSIONS_SIZE 255
+
+struct ssl_comp_st {
+ int id;
+ const char *name;
+ COMP_METHOD *method;
+};
+
+typedef struct raw_extension_st {
+ /* Raw packet data for the extension */
+ PACKET data;
+ /* Set to 1 if the extension is present or 0 otherwise */
+ int present;
+ /* Set to 1 if we have already parsed the extension or 0 otherwise */
+ int parsed;
+ /* The type of this extension, i.e. a TLSEXT_TYPE_* value */
+ unsigned int type;
+ /* Track what order extensions are received in (0-based). */
+ size_t received_order;
+} RAW_EXTENSION;
+
+typedef struct {
+ unsigned int isv2;
+ unsigned int legacy_version;
+ unsigned char random[SSL3_RANDOM_SIZE];
+ size_t session_id_len;
+ unsigned char session_id[SSL_MAX_SSL_SESSION_ID_LENGTH];
+ size_t dtls_cookie_len;
+ unsigned char dtls_cookie[DTLS1_COOKIE_LENGTH];
+ PACKET ciphersuites;
+ size_t compressions_len;
+ unsigned char compressions[MAX_COMPRESSIONS_SIZE];
+ PACKET extensions;
+ size_t pre_proc_exts_len;
+ RAW_EXTENSION *pre_proc_exts;
+} CLIENTHELLO_MSG;
+
+/*
+ * Extension index values NOTE: Any updates to these defines should be mirrored
+ * with equivalent updates to ext_defs in extensions.c
+ */
+typedef enum tlsext_index_en {
+ TLSEXT_IDX_renegotiate,
+ TLSEXT_IDX_server_name,
+ TLSEXT_IDX_max_fragment_length,
+ TLSEXT_IDX_srp,
+ TLSEXT_IDX_ec_point_formats,
+ TLSEXT_IDX_supported_groups,
+ TLSEXT_IDX_session_ticket,
+ TLSEXT_IDX_status_request,
+ TLSEXT_IDX_next_proto_neg,
+ TLSEXT_IDX_application_layer_protocol_negotiation,
+ TLSEXT_IDX_use_srtp,
+ TLSEXT_IDX_encrypt_then_mac,
+ TLSEXT_IDX_signed_certificate_timestamp,
+ TLSEXT_IDX_extended_master_secret,
+ TLSEXT_IDX_signature_algorithms_cert,
+ TLSEXT_IDX_post_handshake_auth,
+ TLSEXT_IDX_signature_algorithms,
+ TLSEXT_IDX_supported_versions,
+ TLSEXT_IDX_psk_kex_modes,
+ TLSEXT_IDX_key_share,
+ TLSEXT_IDX_cookie,
+ TLSEXT_IDX_cryptopro_bug,
+ TLSEXT_IDX_early_data,
+ TLSEXT_IDX_certificate_authorities,
+ TLSEXT_IDX_padding,
+ TLSEXT_IDX_psk,
+ /* Dummy index - must always be the last entry */
+ TLSEXT_IDX_num_builtins
+} TLSEXT_INDEX;
+
+DEFINE_LHASH_OF(SSL_SESSION);
+/* Needed in ssl_cert.c */
+DEFINE_LHASH_OF(X509_NAME);
+
+# define TLSEXT_KEYNAME_LENGTH 16
+# define TLSEXT_TICK_KEY_LENGTH 32
+
+typedef struct ssl_ctx_ext_secure_st {
+ unsigned char tick_hmac_key[TLSEXT_TICK_KEY_LENGTH];
+ unsigned char tick_aes_key[TLSEXT_TICK_KEY_LENGTH];
+} SSL_CTX_EXT_SECURE;
+
+struct ssl_ctx_st {
+ const SSL_METHOD *method;
+ STACK_OF(SSL_CIPHER) *cipher_list;
+ /* same as above but sorted for lookup */
+ STACK_OF(SSL_CIPHER) *cipher_list_by_id;
+ /* TLSv1.3 specific ciphersuites */
+ STACK_OF(SSL_CIPHER) *tls13_ciphersuites;
+ struct x509_store_st /* X509_STORE */ *cert_store;
+ LHASH_OF(SSL_SESSION) *sessions;
+ /*
+ * Most session-ids that will be cached, default is
+ * SSL_SESSION_CACHE_MAX_SIZE_DEFAULT. 0 is unlimited.
+ */
+ size_t session_cache_size;
+ struct ssl_session_st *session_cache_head;
+ struct ssl_session_st *session_cache_tail;
+ /*
+ * This can have one of 2 values, ored together, SSL_SESS_CACHE_CLIENT,
+ * SSL_SESS_CACHE_SERVER, Default is SSL_SESSION_CACHE_SERVER, which
+ * means only SSL_accept will cache SSL_SESSIONS.
+ */
+ uint32_t session_cache_mode;
+ /*
+ * If timeout is not 0, it is the default timeout value set when
+ * SSL_new() is called. This has been put in to make life easier to set
+ * things up
+ */
+ long session_timeout;
+ /*
+ * If this callback is not null, it will be called each time a session id
+ * is added to the cache. If this function returns 1, it means that the
+ * callback will do a SSL_SESSION_free() when it has finished using it.
+ * Otherwise, on 0, it means the callback has finished with it. If
+ * remove_session_cb is not null, it will be called when a session-id is
+ * removed from the cache. After the call, OpenSSL will
+ * SSL_SESSION_free() it.
+ */
+ int (*new_session_cb) (struct ssl_st *ssl, SSL_SESSION *sess);
+ void (*remove_session_cb) (struct ssl_ctx_st *ctx, SSL_SESSION *sess);
+ SSL_SESSION *(*get_session_cb) (struct ssl_st *ssl,
+ const unsigned char *data, int len,
+ int *copy);
+ struct {
+ TSAN_QUALIFIER int sess_connect; /* SSL new conn - started */
+ TSAN_QUALIFIER int sess_connect_renegotiate; /* SSL reneg - requested */
+ TSAN_QUALIFIER int sess_connect_good; /* SSL new conne/reneg - finished */
+ TSAN_QUALIFIER int sess_accept; /* SSL new accept - started */
+ TSAN_QUALIFIER int sess_accept_renegotiate; /* SSL reneg - requested */
+ TSAN_QUALIFIER int sess_accept_good; /* SSL accept/reneg - finished */
+ TSAN_QUALIFIER int sess_miss; /* session lookup misses */
+ TSAN_QUALIFIER int sess_timeout; /* reuse attempt on timeouted session */
+ TSAN_QUALIFIER int sess_cache_full; /* session removed due to full cache */
+ TSAN_QUALIFIER int sess_hit; /* session reuse actually done */
+ TSAN_QUALIFIER int sess_cb_hit; /* session-id that was not in
+ * the cache was passed back via
+ * the callback. This indicates
+ * that the application is
+ * supplying session-id's from
+ * other processes - spooky
+ * :-) */
+ } stats;
+
+ CRYPTO_REF_COUNT references;
+
+ /* if defined, these override the X509_verify_cert() calls */
+ int (*app_verify_callback) (X509_STORE_CTX *, void *);
+ void *app_verify_arg;
+ /*
+ * before OpenSSL 0.9.7, 'app_verify_arg' was ignored
+ * ('app_verify_callback' was called with just one argument)
+ */
+
+ /* Default password callback. */
+ pem_password_cb *default_passwd_callback;
+
+ /* Default password callback user data. */
+ void *default_passwd_callback_userdata;
+
+ /* get client cert callback */
+ int (*client_cert_cb) (SSL *ssl, X509 **x509, EVP_PKEY **pkey);
+
+ /* cookie generate callback */
+ int (*app_gen_cookie_cb) (SSL *ssl, unsigned char *cookie,
+ unsigned int *cookie_len);
+
+ /* verify cookie callback */
+ int (*app_verify_cookie_cb) (SSL *ssl, const unsigned char *cookie,
+ unsigned int cookie_len);
+
+ /* TLS1.3 app-controlled cookie generate callback */
+ int (*gen_stateless_cookie_cb) (SSL *ssl, unsigned char *cookie,
+ size_t *cookie_len);
+
+ /* TLS1.3 verify app-controlled cookie callback */
+ int (*verify_stateless_cookie_cb) (SSL *ssl, const unsigned char *cookie,
+ size_t cookie_len);
+
+ CRYPTO_EX_DATA ex_data;
+
+ const EVP_MD *md5; /* For SSLv3/TLSv1 'ssl3-md5' */
+ const EVP_MD *sha1; /* For SSLv3/TLSv1 'ssl3->sha1' */
+
+ STACK_OF(X509) *extra_certs;
+ STACK_OF(SSL_COMP) *comp_methods; /* stack of SSL_COMP, SSLv3/TLSv1 */
+
+ /* Default values used when no per-SSL value is defined follow */
+
+ /* used if SSL's info_callback is NULL */
+ void (*info_callback) (const SSL *ssl, int type, int val);
+
+ /*
+ * What we put in certificate_authorities extension for TLS 1.3
+ * (ClientHello and CertificateRequest) or just client cert requests for
+ * earlier versions. If client_ca_names is populated then it is only used
+ * for client cert requests, and in preference to ca_names.
+ */
+ STACK_OF(X509_NAME) *ca_names;
+ STACK_OF(X509_NAME) *client_ca_names;
+
+ /*
+ * Default values to use in SSL structures follow (these are copied by
+ * SSL_new)
+ */
+
+ uint32_t options;
+ uint32_t mode;
+ int min_proto_version;
+ int max_proto_version;
+ size_t max_cert_list;
+
+ struct cert_st /* CERT */ *cert;
+ int read_ahead;
+
+ /* callback that allows applications to peek at protocol messages */
+ void (*msg_callback) (int write_p, int version, int content_type,
+ const void *buf, size_t len, SSL *ssl, void *arg);
+ void *msg_callback_arg;
+
+ uint32_t verify_mode;
+ size_t sid_ctx_length;
+ unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH];
+ /* called 'verify_callback' in the SSL */
+ int (*default_verify_callback) (int ok, X509_STORE_CTX *ctx);
+
+ /* Default generate session ID callback. */
+ GEN_SESSION_CB generate_session_id;
+
+ X509_VERIFY_PARAM *param;
+
+ int quiet_shutdown;
+
+# ifndef OPENSSL_NO_CT
+ CTLOG_STORE *ctlog_store; /* CT Log Store */
+ /*
+ * Validates that the SCTs (Signed Certificate Timestamps) are sufficient.
+ * If they are not, the connection should be aborted.
+ */
+ ssl_ct_validation_cb ct_validation_callback;
+ void *ct_validation_callback_arg;
+# endif
+
+ /*
+ * If we're using more than one pipeline how should we divide the data
+ * up between the pipes?
+ */
+ size_t split_send_fragment;
+ /*
+ * Maximum amount of data to send in one fragment. actual record size can
+ * be more than this due to padding and MAC overheads.
+ */
+ size_t max_send_fragment;
+
+ /* Up to how many pipelines should we use? If 0 then 1 is assumed */
+ size_t max_pipelines;
+
+ /* The default read buffer length to use (0 means not set) */
+ size_t default_read_buf_len;
+
+# ifndef OPENSSL_NO_ENGINE
+ /*
+ * Engine to pass requests for client certs to
+ */
+ ENGINE *client_cert_engine;
+# endif
+
+ /* ClientHello callback. Mostly for extensions, but not entirely. */
+ SSL_client_hello_cb_fn client_hello_cb;
+ void *client_hello_cb_arg;
+
+ /* TLS extensions. */
+ struct {
+ /* TLS extensions servername callback */
+ int (*servername_cb) (SSL *, int *, void *);
+ void *servername_arg;
+ /* RFC 4507 session ticket keys */
+ unsigned char tick_key_name[TLSEXT_KEYNAME_LENGTH];
+ SSL_CTX_EXT_SECURE *secure;
+ /* Callback to support customisation of ticket key setting */
+ int (*ticket_key_cb) (SSL *ssl,
+ unsigned char *name, unsigned char *iv,
+ EVP_CIPHER_CTX *ectx, HMAC_CTX *hctx, int enc);
+
+ /* certificate status request info */
+ /* Callback for status request */
+ int (*status_cb) (SSL *ssl, void *arg);
+ void *status_arg;
+ /* ext status type used for CSR extension (OCSP Stapling) */
+ int status_type;
+ /* RFC 4366 Maximum Fragment Length Negotiation */
+ uint8_t max_fragment_len_mode;
+
+# ifndef OPENSSL_NO_EC
+ /* EC extension values inherited by SSL structure */
+ size_t ecpointformats_len;
+ unsigned char *ecpointformats;
+# endif /* OPENSSL_NO_EC */
+
+ size_t supportedgroups_len;
+ uint16_t *supportedgroups;
+
+ /*
+ * ALPN information (we are in the process of transitioning from NPN to
+ * ALPN.)
+ */
+
+ /*-
+ * For a server, this contains a callback function that allows the
+ * server to select the protocol for the connection.
+ * out: on successful return, this must point to the raw protocol
+ * name (without the length prefix).
+ * outlen: on successful return, this contains the length of |*out|.
+ * in: points to the client's list of supported protocols in
+ * wire-format.
+ * inlen: the length of |in|.
+ */
+ int (*alpn_select_cb) (SSL *s,
+ const unsigned char **out,
+ unsigned char *outlen,
+ const unsigned char *in,
+ unsigned int inlen, void *arg);
+ void *alpn_select_cb_arg;
+
+ /*
+ * For a client, this contains the list of supported protocols in wire
+ * format.
+ */
+ unsigned char *alpn;
+ size_t alpn_len;
+
+# ifndef OPENSSL_NO_NEXTPROTONEG
+ /* Next protocol negotiation information */
+
+ /*
+ * For a server, this contains a callback function by which the set of
+ * advertised protocols can be provided.
+ */
+ SSL_CTX_npn_advertised_cb_func npn_advertised_cb;
+ void *npn_advertised_cb_arg;
+ /*
+ * For a client, this contains a callback function that selects the next
+ * protocol from the list provided by the server.
+ */
+ SSL_CTX_npn_select_cb_func npn_select_cb;
+ void *npn_select_cb_arg;
+# endif
+
+ unsigned char cookie_hmac_key[SHA256_DIGEST_LENGTH];
+ } ext;
+
+# ifndef OPENSSL_NO_PSK
+ SSL_psk_client_cb_func psk_client_callback;
+ SSL_psk_server_cb_func psk_server_callback;
+# endif
+ SSL_psk_find_session_cb_func psk_find_session_cb;
+ SSL_psk_use_session_cb_func psk_use_session_cb;
+
+# ifndef OPENSSL_NO_SRP
+ SRP_CTX srp_ctx; /* ctx for SRP authentication */
+# endif
+
+ /* Shared DANE context */
+ struct dane_ctx_st dane;
+
+# ifndef OPENSSL_NO_SRTP
+ /* SRTP profiles we are willing to do from RFC 5764 */
+ STACK_OF(SRTP_PROTECTION_PROFILE) *srtp_profiles;
+# endif
+ /*
+ * Callback for disabling session caching and ticket support on a session
+ * basis, depending on the chosen cipher.
+ */
+ int (*not_resumable_session_cb) (SSL *ssl, int is_forward_secure);
+
+ CRYPTO_RWLOCK *lock;
+
+ /*
+ * Callback for logging key material for use with debugging tools like
+ * Wireshark. The callback should log `line` followed by a newline.
+ */
+ SSL_CTX_keylog_cb_func keylog_callback;
+
+ /*
+ * The maximum number of bytes advertised in session tickets that can be
+ * sent as early data.
+ */
+ uint32_t max_early_data;
+
+ /*
+ * The maximum number of bytes of early data that a server will tolerate
+ * (which should be at least as much as max_early_data).
+ */
+ uint32_t recv_max_early_data;
+
+ /* TLS1.3 padding callback */
+ size_t (*record_padding_cb)(SSL *s, int type, size_t len, void *arg);
+ void *record_padding_arg;
+ size_t block_padding;
+
+ /* Session ticket appdata */
+ SSL_CTX_generate_session_ticket_fn generate_ticket_cb;
+ SSL_CTX_decrypt_session_ticket_fn decrypt_ticket_cb;
+ void *ticket_cb_data;
+
+ /* The number of TLS1.3 tickets to automatically send */
+ size_t num_tickets;
+
+ /* Callback to determine if early_data is acceptable or not */
+ SSL_allow_early_data_cb_fn allow_early_data_cb;
+ void *allow_early_data_cb_data;
+
+ /* Do we advertise Post-handshake auth support? */
+ int pha_enabled;
+
+ /* Callback for SSL async handling */
+ SSL_async_callback_fn async_cb;
+ void *async_cb_arg;
+};
+
+typedef struct cert_pkey_st CERT_PKEY;
+
+struct ssl_st {
+ /*
+ * protocol version (one of SSL2_VERSION, SSL3_VERSION, TLS1_VERSION,
+ * DTLS1_VERSION)
+ */
+ int version;
+ /* SSLv3 */
+ const SSL_METHOD *method;
+ /*
+ * There are 2 BIO's even though they are normally both the same. This
+ * is so data can be read and written to different handlers
+ */
+ /* used by SSL_read */
+ BIO *rbio;
+ /* used by SSL_write */
+ BIO *wbio;
+ /* used during session-id reuse to concatenate messages */
+ BIO *bbio;
+ /*
+ * This holds a variable that indicates what we were doing when a 0 or -1
+ * is returned. This is needed for non-blocking IO so we know what
+ * request needs re-doing when in SSL_accept or SSL_connect
+ */
+ int rwstate;
+ int (*handshake_func) (SSL *);
+ /*
+ * Imagine that here's a boolean member "init" that is switched as soon
+ * as SSL_set_{accept/connect}_state is called for the first time, so
+ * that "state" and "handshake_func" are properly initialized. But as
+ * handshake_func is == 0 until then, we use this test instead of an
+ * "init" member.
+ */
+ /* are we the server side? */
+ int server;
+ /*
+ * Generate a new session or reuse an old one.
+ * NB: For servers, the 'new' session may actually be a previously
+ * cached session or even the previous session unless
+ * SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION is set
+ */
+ int new_session;
+ /* don't send shutdown packets */
+ int quiet_shutdown;
+ /* we have shut things down, 0x01 sent, 0x02 for received */
+ int shutdown;
+ /* where we are */
+ OSSL_STATEM statem;
+ SSL_EARLY_DATA_STATE early_data_state;
+ BUF_MEM *init_buf; /* buffer used during init */
+ void *init_msg; /* pointer to handshake message body, set by
+ * ssl3_get_message() */
+ size_t init_num; /* amount read/written */
+ size_t init_off; /* amount read/written */
+
+ struct {
+ long flags;
+ size_t read_mac_secret_size;
+ unsigned char read_mac_secret[EVP_MAX_MD_SIZE];
+ size_t write_mac_secret_size;
+ unsigned char write_mac_secret[EVP_MAX_MD_SIZE];
+ unsigned char server_random[SSL3_RANDOM_SIZE];
+ unsigned char client_random[SSL3_RANDOM_SIZE];
+ /* flags for countermeasure against known-IV weakness */
+ int need_empty_fragments;
+ int empty_fragment_done;
+ /* used during startup, digest all incoming/outgoing packets */
+ BIO *handshake_buffer;
+ /*
+ * When handshake digest is determined, buffer is hashed and
+ * freed and MD_CTX for the required digest is stored here.
+ */
+ EVP_MD_CTX *handshake_dgst;
+ /*
+ * Set whenever an expected ChangeCipherSpec message is processed.
+ * Unset when the peer's Finished message is received.
+ * Unexpected ChangeCipherSpec messages trigger a fatal alert.
+ */
+ int change_cipher_spec;
+ int warn_alert;
+ int fatal_alert;
+ /*
+ * we allow one fatal and one warning alert to be outstanding, send close
+ * alert via the warning alert
+ */
+ int alert_dispatch;
+ unsigned char send_alert[2];
+ /*
+ * This flag is set when we should renegotiate ASAP, basically when there
+ * is no more data in the read or write buffers
+ */
+ int renegotiate;
+ int total_renegotiations;
+ int num_renegotiations;
+ int in_read_app_data;
+ struct {
+ /* actually only need to be 16+20 for SSLv3 and 12 for TLS */
+ unsigned char finish_md[EVP_MAX_MD_SIZE * 2];
+ size_t finish_md_len;
+ unsigned char peer_finish_md[EVP_MAX_MD_SIZE * 2];
+ size_t peer_finish_md_len;
+ size_t message_size;
+ int message_type;
+ /* used to hold the new cipher we are going to use */
+ const SSL_CIPHER *new_cipher;
+# if !defined(OPENSSL_NO_EC) || !defined(OPENSSL_NO_DH)
+ EVP_PKEY *pkey; /* holds short lived DH/ECDH key */
+# endif
+ /* used for certificate requests */
+ int cert_req;
+ /* Certificate types in certificate request message. */
+ uint8_t *ctype;
+ size_t ctype_len;
+ /* Certificate authorities list peer sent */
+ STACK_OF(X509_NAME) *peer_ca_names;
+ size_t key_block_length;
+ unsigned char *key_block;
+ const EVP_CIPHER *new_sym_enc;
+ const EVP_MD *new_hash;
+ int new_mac_pkey_type;
+ size_t new_mac_secret_size;
+# ifndef OPENSSL_NO_COMP
+ const SSL_COMP *new_compression;
+# else
+ char *new_compression;
+# endif
+ int cert_request;
+ /* Raw values of the cipher list from a client */
+ unsigned char *ciphers_raw;
+ size_t ciphers_rawlen;
+ /* Temporary storage for premaster secret */
+ unsigned char *pms;
+ size_t pmslen;
+# ifndef OPENSSL_NO_PSK
+ /* Temporary storage for PSK key */
+ unsigned char *psk;
+ size_t psklen;
+# endif
+ /* Signature algorithm we actually use */
+ const struct sigalg_lookup_st *sigalg;
+ /* Pointer to certificate we use */
+ CERT_PKEY *cert;
+ /*
+ * signature algorithms peer reports: e.g. supported signature
+ * algorithms extension for server or as part of a certificate
+ * request for client.
+ * Keep track of the algorithms for TLS and X.509 usage separately.
+ */
+ uint16_t *peer_sigalgs;
+ uint16_t *peer_cert_sigalgs;
+ /* Size of above arrays */
+ size_t peer_sigalgslen;
+ size_t peer_cert_sigalgslen;
+ /* Sigalg peer actually uses */
+ const struct sigalg_lookup_st *peer_sigalg;
+ /*
+ * Set if corresponding CERT_PKEY can be used with current
+ * SSL session: e.g. appropriate curve, signature algorithms etc.
+ * If zero it can't be used at all.
+ */
+ uint32_t valid_flags[SSL_PKEY_NUM];
+ /*
+ * For servers the following masks are for the key and auth algorithms
+ * that are supported by the certs below. For clients they are masks of
+ * *disabled* algorithms based on the current session.
+ */
+ uint32_t mask_k;
+ uint32_t mask_a;
+ /*
+ * The following are used by the client to see if a cipher is allowed or
+ * not. It contains the minimum and maximum version the client's using
+ * based on what it knows so far.
+ */
+ int min_ver;
+ int max_ver;
+ } tmp;
+
+ /* Connection binding to prevent renegotiation attacks */
+ unsigned char previous_client_finished[EVP_MAX_MD_SIZE];
+ size_t previous_client_finished_len;
+ unsigned char previous_server_finished[EVP_MAX_MD_SIZE];
+ size_t previous_server_finished_len;
+ int send_connection_binding; /* TODOEKR */
+
+# ifndef OPENSSL_NO_NEXTPROTONEG
+ /*
+ * Set if we saw the Next Protocol Negotiation extension from our peer.
+ */
+ int npn_seen;
+# endif
+
+ /*
+ * ALPN information (we are in the process of transitioning from NPN to
+ * ALPN.)
+ */
+
+ /*
+ * In a server these point to the selected ALPN protocol after the
+ * ClientHello has been processed. In a client these contain the protocol
+ * that the server selected once the ServerHello has been processed.
+ */
+ unsigned char *alpn_selected;
+ size_t alpn_selected_len;
+ /* used by the server to know what options were proposed */
+ unsigned char *alpn_proposed;
+ size_t alpn_proposed_len;
+ /* used by the client to know if it actually sent alpn */
+ int alpn_sent;
+
+# ifndef OPENSSL_NO_EC
+ /*
+ * This is set to true if we believe that this is a version of Safari
+ * running on OS X 10.6 or newer. We wish to know this because Safari on
+ * 10.8 .. 10.8.3 has broken ECDHE-ECDSA support.
+ */
+ char is_probably_safari;
+# endif /* !OPENSSL_NO_EC */
+
+ /* For clients: peer temporary key */
+# if !defined(OPENSSL_NO_EC) || !defined(OPENSSL_NO_DH)
+ /* The group_id for the DH/ECDH key */
+ uint16_t group_id;
+ EVP_PKEY *peer_tmp;
+# endif
+
+ } s3;
+
+ struct dtls1_state_st *d1; /* DTLSv1 variables */
+ /* callback that allows applications to peek at protocol messages */
+ void (*msg_callback) (int write_p, int version, int content_type,
+ const void *buf, size_t len, SSL *ssl, void *arg);
+ void *msg_callback_arg;
+ int hit; /* reusing a previous session */
+ X509_VERIFY_PARAM *param;
+ /* Per connection DANE state */
+ SSL_DANE dane;
+ /* crypto */
+ STACK_OF(SSL_CIPHER) *peer_ciphers;
+ STACK_OF(SSL_CIPHER) *cipher_list;
+ STACK_OF(SSL_CIPHER) *cipher_list_by_id;
+ /* TLSv1.3 specific ciphersuites */
+ STACK_OF(SSL_CIPHER) *tls13_ciphersuites;
+ /*
+ * These are the ones being used, the ones in SSL_SESSION are the ones to
+ * be 'copied' into these ones
+ */
+ uint32_t mac_flags;
+ /*
+ * The TLS1.3 secrets.
+ */
+ unsigned char early_secret[EVP_MAX_MD_SIZE];
+ unsigned char handshake_secret[EVP_MAX_MD_SIZE];
+ unsigned char master_secret[EVP_MAX_MD_SIZE];
+ unsigned char resumption_master_secret[EVP_MAX_MD_SIZE];
+ unsigned char client_finished_secret[EVP_MAX_MD_SIZE];
+ unsigned char server_finished_secret[EVP_MAX_MD_SIZE];
+ unsigned char server_finished_hash[EVP_MAX_MD_SIZE];
+ unsigned char handshake_traffic_hash[EVP_MAX_MD_SIZE];
+ unsigned char client_app_traffic_secret[EVP_MAX_MD_SIZE];
+ unsigned char server_app_traffic_secret[EVP_MAX_MD_SIZE];
+ unsigned char exporter_master_secret[EVP_MAX_MD_SIZE];
+ unsigned char early_exporter_master_secret[EVP_MAX_MD_SIZE];
+ EVP_CIPHER_CTX *enc_read_ctx; /* cryptographic state */
+ unsigned char read_iv[EVP_MAX_IV_LENGTH]; /* TLSv1.3 static read IV */
+ EVP_MD_CTX *read_hash; /* used for mac generation */
+ COMP_CTX *compress; /* compression */
+ COMP_CTX *expand; /* uncompress */
+ EVP_CIPHER_CTX *enc_write_ctx; /* cryptographic state */
+ unsigned char write_iv[EVP_MAX_IV_LENGTH]; /* TLSv1.3 static write IV */
+ EVP_MD_CTX *write_hash; /* used for mac generation */
+ /* session info */
+ /* client cert? */
+ /* This is used to hold the server certificate used */
+ struct cert_st /* CERT */ *cert;
+
+ /*
+ * The hash of all messages prior to the CertificateVerify, and the length
+ * of that hash.
+ */
+ unsigned char cert_verify_hash[EVP_MAX_MD_SIZE];
+ size_t cert_verify_hash_len;
+
+ /* Flag to indicate whether we should send a HelloRetryRequest or not */
+ enum {SSL_HRR_NONE = 0, SSL_HRR_PENDING, SSL_HRR_COMPLETE}
+ hello_retry_request;
+
+ /*
+ * the session_id_context is used to ensure sessions are only reused in
+ * the appropriate context
+ */
+ size_t sid_ctx_length;
+ unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH];
+ /* This can also be in the session once a session is established */
+ SSL_SESSION *session;
+ /* TLSv1.3 PSK session */
+ SSL_SESSION *psksession;
+ unsigned char *psksession_id;
+ size_t psksession_id_len;
+ /* Default generate session ID callback. */
+ GEN_SESSION_CB generate_session_id;
+ /*
+ * The temporary TLSv1.3 session id. This isn't really a session id at all
+ * but is a random value sent in the legacy session id field.
+ */
+ unsigned char tmp_session_id[SSL_MAX_SSL_SESSION_ID_LENGTH];
+ size_t tmp_session_id_len;
+ /* Used in SSL3 */
+ /*
+ * 0 don't care about verify failure.
+ * 1 fail if verify fails
+ */
+ uint32_t verify_mode;
+ /* fail if callback returns 0 */
+ int (*verify_callback) (int ok, X509_STORE_CTX *ctx);
+ /* optional informational callback */
+ void (*info_callback) (const SSL *ssl, int type, int val);
+ /* error bytes to be written */
+ int error;
+ /* actual code */
+ int error_code;
+# ifndef OPENSSL_NO_PSK
+ SSL_psk_client_cb_func psk_client_callback;
+ SSL_psk_server_cb_func psk_server_callback;
+# endif
+ SSL_psk_find_session_cb_func psk_find_session_cb;
+ SSL_psk_use_session_cb_func psk_use_session_cb;
+
+ SSL_CTX *ctx;
+ /* Verified chain of peer */
+ STACK_OF(X509) *verified_chain;
+ long verify_result;
+ /* extra application data */
+ CRYPTO_EX_DATA ex_data;
+ /*
+ * What we put in certificate_authorities extension for TLS 1.3
+ * (ClientHello and CertificateRequest) or just client cert requests for
+ * earlier versions. If client_ca_names is populated then it is only used
+ * for client cert requests, and in preference to ca_names.
+ */
+ STACK_OF(X509_NAME) *ca_names;
+ STACK_OF(X509_NAME) *client_ca_names;
+ CRYPTO_REF_COUNT references;
+ /* protocol behaviour */
+ uint32_t options;
+ /* API behaviour */
+ uint32_t mode;
+ int min_proto_version;
+ int max_proto_version;
+ size_t max_cert_list;
+ int first_packet;
+ /*
+ * What was passed in ClientHello.legacy_version. Used for RSA pre-master
+ * secret and SSLv3/TLS (<=1.2) rollback check
+ */
+ int client_version;
+ /*
+ * If we're using more than one pipeline how should we divide the data
+ * up between the pipes?
+ */
+ size_t split_send_fragment;
+ /*
+ * Maximum amount of data to send in one fragment. actual record size can
+ * be more than this due to padding and MAC overheads.
+ */
+ size_t max_send_fragment;
+ /* Up to how many pipelines should we use? If 0 then 1 is assumed */
+ size_t max_pipelines;
+
+ struct {
+ /* Built-in extension flags */
+ uint8_t extflags[TLSEXT_IDX_num_builtins];
+ /* TLS extension debug callback */
+ void (*debug_cb)(SSL *s, int client_server, int type,
+ const unsigned char *data, int len, void *arg);
+ void *debug_arg;
+ char *hostname;
+ /* certificate status request info */
+ /* Status type or -1 if no status type */
+ int status_type;
+ /* Raw extension data, if seen */
+ unsigned char *scts;
+ /* Length of raw extension data, if seen */
+ uint16_t scts_len;
+ /* Expect OCSP CertificateStatus message */
+ int status_expected;
+
+ struct {
+ /* OCSP status request only */
+ STACK_OF(OCSP_RESPID) *ids;
+ X509_EXTENSIONS *exts;
+ /* OCSP response received or to be sent */
+ unsigned char *resp;
+ size_t resp_len;
+ } ocsp;
+
+ /* RFC4507 session ticket expected to be received or sent */
+ int ticket_expected;
+# ifndef OPENSSL_NO_EC
+ size_t ecpointformats_len;
+ /* our list */
+ unsigned char *ecpointformats;
+
+ size_t peer_ecpointformats_len;
+ /* peer's list */
+ unsigned char *peer_ecpointformats;
+# endif /* OPENSSL_NO_EC */
+ size_t supportedgroups_len;
+ /* our list */
+ uint16_t *supportedgroups;
+
+ size_t peer_supportedgroups_len;
+ /* peer's list */
+ uint16_t *peer_supportedgroups;
+
+ /* TLS Session Ticket extension override */
+ TLS_SESSION_TICKET_EXT *session_ticket;
+ /* TLS Session Ticket extension callback */
+ tls_session_ticket_ext_cb_fn session_ticket_cb;
+ void *session_ticket_cb_arg;
+ /* TLS pre-shared secret session resumption */
+ tls_session_secret_cb_fn session_secret_cb;
+ void *session_secret_cb_arg;
+ /*
+ * For a client, this contains the list of supported protocols in wire
+ * format.
+ */
+ unsigned char *alpn;
+ size_t alpn_len;
+ /*
+ * Next protocol negotiation. For the client, this is the protocol that
+ * we sent in NextProtocol and is set when handling ServerHello
+ * extensions. For a server, this is the client's selected_protocol from
+ * NextProtocol and is set when handling the NextProtocol message, before
+ * the Finished message.
+ */
+ unsigned char *npn;
+ size_t npn_len;
+
+ /* The available PSK key exchange modes */
+ int psk_kex_mode;
+
+ /* Set to one if we have negotiated ETM */
+ int use_etm;
+
+ /* Are we expecting to receive early data? */
+ int early_data;
+ /* Is the session suitable for early data? */
+ int early_data_ok;
+
+ /* May be sent by a server in HRR. Must be echoed back in ClientHello */
+ unsigned char *tls13_cookie;
+ size_t tls13_cookie_len;
+ /* Have we received a cookie from the client? */
+ int cookieok;
+
+ /*
+ * Maximum Fragment Length as per RFC 4366.
+ * If this member contains one of the allowed values (1-4)
+ * then we should include Maximum Fragment Length Negotiation
+ * extension in Client Hello.
+ * Please note that value of this member does not have direct
+ * effect. The actual (binding) value is stored in SSL_SESSION,
+ * as this extension is optional on server side.
+ */
+ uint8_t max_fragment_len_mode;
+
+ /*
+ * On the client side the number of ticket identities we sent in the
+ * ClientHello. On the server side the identity of the ticket we
+ * selected.
+ */
+ int tick_identity;
+ } ext;
+
+ /*
+ * Parsed form of the ClientHello, kept around across client_hello_cb
+ * calls.
+ */
+ CLIENTHELLO_MSG *clienthello;
+
+ /*-
+ * no further mod of servername
+ * 0 : call the servername extension callback.
+ * 1 : prepare 2, allow last ack just after in server callback.
+ * 2 : don't call servername callback, no ack in server hello
+ */
+ int servername_done;
+# ifndef OPENSSL_NO_CT
+ /*
+ * Validates that the SCTs (Signed Certificate Timestamps) are sufficient.
+ * If they are not, the connection should be aborted.
+ */
+ ssl_ct_validation_cb ct_validation_callback;
+ /* User-supplied argument that is passed to the ct_validation_callback */
+ void *ct_validation_callback_arg;
+ /*
+ * Consolidated stack of SCTs from all sources.
+ * Lazily populated by CT_get_peer_scts(SSL*)
+ */
+ STACK_OF(SCT) *scts;
+ /* Have we attempted to find/parse SCTs yet? */
+ int scts_parsed;
+# endif
+ SSL_CTX *session_ctx; /* initial ctx, used to store sessions */
+# ifndef OPENSSL_NO_SRTP
+ /* What we'll do */
+ STACK_OF(SRTP_PROTECTION_PROFILE) *srtp_profiles;
+ /* What's been chosen */
+ SRTP_PROTECTION_PROFILE *srtp_profile;
+# endif
+ /*-
+ * 1 if we are renegotiating.
+ * 2 if we are a server and are inside a handshake
+ * (i.e. not just sending a HelloRequest)
+ */
+ int renegotiate;
+ /* If sending a KeyUpdate is pending */
+ int key_update;
+ /* Post-handshake authentication state */
+ SSL_PHA_STATE post_handshake_auth;
+ int pha_enabled;
+ uint8_t* pha_context;
+ size_t pha_context_len;
+ int certreqs_sent;
+ EVP_MD_CTX *pha_dgst; /* this is just the digest through ClientFinished */
+
+# ifndef OPENSSL_NO_SRP
+ /* ctx for SRP authentication */
+ SRP_CTX srp_ctx;
+# endif
+ /*
+ * Callback for disabling session caching and ticket support on a session
+ * basis, depending on the chosen cipher.
+ */
+ int (*not_resumable_session_cb) (SSL *ssl, int is_forward_secure);
+ RECORD_LAYER rlayer;
+ /* Default password callback. */
+ pem_password_cb *default_passwd_callback;
+ /* Default password callback user data. */
+ void *default_passwd_callback_userdata;
+ /* Async Job info */
+ ASYNC_JOB *job;
+ ASYNC_WAIT_CTX *waitctx;
+ size_t asyncrw;
+
+ /*
+ * The maximum number of bytes advertised in session tickets that can be
+ * sent as early data.
+ */
+ uint32_t max_early_data;
+ /*
+ * The maximum number of bytes of early data that a server will tolerate
+ * (which should be at least as much as max_early_data).
+ */
+ uint32_t recv_max_early_data;
+
+ /*
+ * The number of bytes of early data received so far. If we accepted early
+ * data then this is a count of the plaintext bytes. If we rejected it then
+ * this is a count of the ciphertext bytes.
+ */
+ uint32_t early_data_count;
+
+ /* TLS1.3 padding callback */
+ size_t (*record_padding_cb)(SSL *s, int type, size_t len, void *arg);
+ void *record_padding_arg;
+ size_t block_padding;
+
+ CRYPTO_RWLOCK *lock;
+
+ /* The number of TLS1.3 tickets to automatically send */
+ size_t num_tickets;
+ /* The number of TLS1.3 tickets actually sent so far */
+ size_t sent_tickets;
+ /* The next nonce value to use when we send a ticket on this connection */
+ uint64_t next_ticket_nonce;
+
+ /* Callback to determine if early_data is acceptable or not */
+ SSL_allow_early_data_cb_fn allow_early_data_cb;
+ void *allow_early_data_cb_data;
+
+ /* Callback for SSL async handling */
+ SSL_async_callback_fn async_cb;
+ void *async_cb_arg;
+
+ /*
+ * Signature algorithms shared by client and server: cached because these
+ * are used most often.
+ */
+ const struct sigalg_lookup_st **shared_sigalgs;
+ size_t shared_sigalgslen;
+};
+
+/*
+ * Structure containing table entry of values associated with the signature
+ * algorithms (signature scheme) extension
+*/
+typedef struct sigalg_lookup_st {
+ /* TLS 1.3 signature scheme name */
+ const char *name;
+ /* Raw value used in extension */
+ uint16_t sigalg;
+ /* NID of hash algorithm or NID_undef if no hash */
+ int hash;
+ /* Index of hash algorithm or -1 if no hash algorithm */
+ int hash_idx;
+ /* NID of signature algorithm */
+ int sig;
+ /* Index of signature algorithm */
+ int sig_idx;
+ /* Combined hash and signature NID, if any */
+ int sigandhash;
+ /* Required public key curve (ECDSA only) */
+ int curve;
+} SIGALG_LOOKUP;
+
+typedef struct tls_group_info_st {
+ int nid; /* Curve NID */
+ int secbits; /* Bits of security (from SP800-57) */
+ uint32_t flags; /* For group type and applicable TLS versions */
+ uint16_t group_id; /* Group ID */
+} TLS_GROUP_INFO;
+
+/* flags values */
+# define TLS_GROUP_TYPE 0x0000000FU /* Mask for group type */
+# define TLS_GROUP_CURVE_PRIME 0x00000001U
+# define TLS_GROUP_CURVE_CHAR2 0x00000002U
+# define TLS_GROUP_CURVE_CUSTOM 0x00000004U
+# define TLS_GROUP_FFDHE 0x00000008U
+# define TLS_GROUP_ONLY_FOR_TLS1_3 0x00000010U
+
+# define TLS_GROUP_FFDHE_FOR_TLS1_3 (TLS_GROUP_FFDHE|TLS_GROUP_ONLY_FOR_TLS1_3)
+
+/*
+ * Structure containing table entry of certificate info corresponding to
+ * CERT_PKEY entries
+ */
+typedef struct {
+ int nid; /* NID of public key algorithm */
+ uint32_t amask; /* authmask corresponding to key type */
+} SSL_CERT_LOOKUP;
+
+/* DTLS structures */
+
+# ifndef OPENSSL_NO_SCTP
+# define DTLS1_SCTP_AUTH_LABEL "EXPORTER_DTLS_OVER_SCTP"
+# endif
+
+/* Max MTU overhead we know about so far is 40 for IPv6 + 8 for UDP */
+# define DTLS1_MAX_MTU_OVERHEAD 48
+
+/*
+ * Flag used in message reuse to indicate the buffer contains the record
+ * header as well as the handshake message header.
+ */
+# define DTLS1_SKIP_RECORD_HEADER 2
+
+struct dtls1_retransmit_state {
+ EVP_CIPHER_CTX *enc_write_ctx; /* cryptographic state */
+ EVP_MD_CTX *write_hash; /* used for mac generation */
+ COMP_CTX *compress; /* compression */
+ SSL_SESSION *session;
+ unsigned short epoch;
+};
+
+struct hm_header_st {
+ unsigned char type;
+ size_t msg_len;
+ unsigned short seq;
+ size_t frag_off;
+ size_t frag_len;
+ unsigned int is_ccs;
+ struct dtls1_retransmit_state saved_retransmit_state;
+};
+
+struct dtls1_timeout_st {
+ /* Number of read timeouts so far */
+ unsigned int read_timeouts;
+ /* Number of write timeouts so far */
+ unsigned int write_timeouts;
+ /* Number of alerts received so far */
+ unsigned int num_alerts;
+};
+
+typedef struct hm_fragment_st {
+ struct hm_header_st msg_header;
+ unsigned char *fragment;
+ unsigned char *reassembly;
+} hm_fragment;
+
+typedef struct pqueue_st pqueue;
+typedef struct pitem_st pitem;
+
+struct pitem_st {
+ unsigned char priority[8]; /* 64-bit value in big-endian encoding */
+ void *data;
+ pitem *next;
+};
+
+typedef struct pitem_st *piterator;
+
+pitem *pitem_new(unsigned char *prio64be, void *data);
+void pitem_free(pitem *item);
+pqueue *pqueue_new(void);
+void pqueue_free(pqueue *pq);
+pitem *pqueue_insert(pqueue *pq, pitem *item);
+pitem *pqueue_peek(pqueue *pq);
+pitem *pqueue_pop(pqueue *pq);
+pitem *pqueue_find(pqueue *pq, unsigned char *prio64be);
+pitem *pqueue_iterator(pqueue *pq);
+pitem *pqueue_next(piterator *iter);
+size_t pqueue_size(pqueue *pq);
+
+typedef struct dtls1_state_st {
+ unsigned char cookie[DTLS1_COOKIE_LENGTH];
+ size_t cookie_len;
+ unsigned int cookie_verified;
+ /* handshake message numbers */
+ unsigned short handshake_write_seq;
+ unsigned short next_handshake_write_seq;
+ unsigned short handshake_read_seq;
+ /* Buffered handshake messages */
+ pqueue *buffered_messages;
+ /* Buffered (sent) handshake records */
+ pqueue *sent_messages;
+ size_t link_mtu; /* max on-the-wire DTLS packet size */
+ size_t mtu; /* max DTLS packet size */
+ struct hm_header_st w_msg_hdr;
+ struct hm_header_st r_msg_hdr;
+ struct dtls1_timeout_st timeout;
+ /*
+ * Indicates when the last handshake msg sent will timeout
+ */
+ struct timeval next_timeout;
+ /* Timeout duration */
+ unsigned int timeout_duration_us;
+
+ unsigned int retransmitting;
+# ifndef OPENSSL_NO_SCTP
+ int shutdown_received;
+# endif
+
+ DTLS_timer_cb timer_cb;
+
+} DTLS1_STATE;
+
+# ifndef OPENSSL_NO_EC
+/*
+ * From ECC-TLS draft, used in encoding the curve type in ECParameters
+ */
+# define EXPLICIT_PRIME_CURVE_TYPE 1
+# define EXPLICIT_CHAR2_CURVE_TYPE 2
+# define NAMED_CURVE_TYPE 3
+# endif /* OPENSSL_NO_EC */
+
+struct cert_pkey_st {
+ X509 *x509;
+ EVP_PKEY *privatekey;
+ /* Chain for this certificate */
+ STACK_OF(X509) *chain;
+ /*-
+ * serverinfo data for this certificate. The data is in TLS Extension
+ * wire format, specifically it's a series of records like:
+ * uint16_t extension_type; // (RFC 5246, 7.4.1.4, Extension)
+ * uint16_t length;
+ * uint8_t data[length];
+ */
+ unsigned char *serverinfo;
+ size_t serverinfo_length;
+};
+/* Retrieve Suite B flags */
+# define tls1_suiteb(s) (s->cert->cert_flags & SSL_CERT_FLAG_SUITEB_128_LOS)
+/* Uses to check strict mode: suite B modes are always strict */
+# define SSL_CERT_FLAGS_CHECK_TLS_STRICT \
+ (SSL_CERT_FLAG_SUITEB_128_LOS|SSL_CERT_FLAG_TLS_STRICT)
+
+typedef enum {
+ ENDPOINT_CLIENT = 0,
+ ENDPOINT_SERVER,
+ ENDPOINT_BOTH
+} ENDPOINT;
+
+
+typedef struct {
+ unsigned short ext_type;
+ ENDPOINT role;
+ /* The context which this extension applies to */
+ unsigned int context;
+ /*
+ * Per-connection flags relating to this extension type: not used if
+ * part of an SSL_CTX structure.
+ */
+ uint32_t ext_flags;
+ SSL_custom_ext_add_cb_ex add_cb;
+ SSL_custom_ext_free_cb_ex free_cb;
+ void *add_arg;
+ SSL_custom_ext_parse_cb_ex parse_cb;
+ void *parse_arg;
+} custom_ext_method;
+
+/* ext_flags values */
+
+/*
+ * Indicates an extension has been received. Used to check for unsolicited or
+ * duplicate extensions.
+ */
+# define SSL_EXT_FLAG_RECEIVED 0x1
+/*
+ * Indicates an extension has been sent: used to enable sending of
+ * corresponding ServerHello extension.
+ */
+# define SSL_EXT_FLAG_SENT 0x2
+
+typedef struct {
+ custom_ext_method *meths;
+ size_t meths_count;
+} custom_ext_methods;
+
+typedef struct cert_st {
+ /* Current active set */
+ /*
+ * ALWAYS points to an element of the pkeys array
+ * Probably it would make more sense to store
+ * an index, not a pointer.
+ */
+ CERT_PKEY *key;
+# ifndef OPENSSL_NO_DH
+ EVP_PKEY *dh_tmp;
+ DH *(*dh_tmp_cb) (SSL *ssl, int is_export, int keysize);
+ int dh_tmp_auto;
+# endif
+ /* Flags related to certificates */
+ uint32_t cert_flags;
+ CERT_PKEY pkeys[SSL_PKEY_NUM];
+ /* Custom certificate types sent in certificate request message. */
+ uint8_t *ctype;
+ size_t ctype_len;
+ /*
+ * supported signature algorithms. When set on a client this is sent in
+ * the client hello as the supported signature algorithms extension. For
+ * servers it represents the signature algorithms we are willing to use.
+ */
+ uint16_t *conf_sigalgs;
+ /* Size of above array */
+ size_t conf_sigalgslen;
+ /*
+ * Client authentication signature algorithms, if not set then uses
+ * conf_sigalgs. On servers these will be the signature algorithms sent
+ * to the client in a certificate request for TLS 1.2. On a client this
+ * represents the signature algorithms we are willing to use for client
+ * authentication.
+ */
+ uint16_t *client_sigalgs;
+ /* Size of above array */
+ size_t client_sigalgslen;
+ /*
+ * Certificate setup callback: if set is called whenever a certificate
+ * may be required (client or server). the callback can then examine any
+ * appropriate parameters and setup any certificates required. This
+ * allows advanced applications to select certificates on the fly: for
+ * example based on supported signature algorithms or curves.
+ */
+ int (*cert_cb) (SSL *ssl, void *arg);
+ void *cert_cb_arg;
+ /*
+ * Optional X509_STORE for chain building or certificate validation If
+ * NULL the parent SSL_CTX store is used instead.
+ */
+ X509_STORE *chain_store;
+ X509_STORE *verify_store;
+ /* Custom extensions */
+ custom_ext_methods custext;
+ /* Security callback */
+ int (*sec_cb) (const SSL *s, const SSL_CTX *ctx, int op, int bits, int nid,
+ void *other, void *ex);
+ /* Security level */
+ int sec_level;
+ void *sec_ex;
+# ifndef OPENSSL_NO_PSK
+ /* If not NULL psk identity hint to use for servers */
+ char *psk_identity_hint;
+# endif
+ CRYPTO_REF_COUNT references; /* >1 only if SSL_copy_session_id is used */
+ CRYPTO_RWLOCK *lock;
+} CERT;
+
+# define FP_ICC (int (*)(const void *,const void *))
+
+/*
+ * This is for the SSLv3/TLSv1.0 differences in crypto/hash stuff It is a bit
+ * of a mess of functions, but hell, think of it as an opaque structure :-)
+ */
+typedef struct ssl3_enc_method {
+ int (*enc) (SSL *, SSL3_RECORD *, size_t, int);
+ int (*mac) (SSL *, SSL3_RECORD *, unsigned char *, int);
+ int (*setup_key_block) (SSL *);
+ int (*generate_master_secret) (SSL *, unsigned char *, unsigned char *,
+ size_t, size_t *);
+ int (*change_cipher_state) (SSL *, int);
+ size_t (*final_finish_mac) (SSL *, const char *, size_t, unsigned char *);
+ const char *client_finished_label;
+ size_t client_finished_label_len;
+ const char *server_finished_label;
+ size_t server_finished_label_len;
+ int (*alert_value) (int);
+ int (*export_keying_material) (SSL *, unsigned char *, size_t,
+ const char *, size_t,
+ const unsigned char *, size_t,
+ int use_context);
+ /* Various flags indicating protocol version requirements */
+ uint32_t enc_flags;
+ /* Set the handshake header */
+ int (*set_handshake_header) (SSL *s, WPACKET *pkt, int type);
+ /* Close construction of the handshake message */
+ int (*close_construct_packet) (SSL *s, WPACKET *pkt, int htype);
+ /* Write out handshake message */
+ int (*do_write) (SSL *s);
+} SSL3_ENC_METHOD;
+
+# define ssl_set_handshake_header(s, pkt, htype) \
+ s->method->ssl3_enc->set_handshake_header((s), (pkt), (htype))
+# define ssl_close_construct_packet(s, pkt, htype) \
+ s->method->ssl3_enc->close_construct_packet((s), (pkt), (htype))
+# define ssl_do_write(s) s->method->ssl3_enc->do_write(s)
+
+/* Values for enc_flags */
+
+/* Uses explicit IV for CBC mode */
+# define SSL_ENC_FLAG_EXPLICIT_IV 0x1
+/* Uses signature algorithms extension */
+# define SSL_ENC_FLAG_SIGALGS 0x2
+/* Uses SHA256 default PRF */
+# define SSL_ENC_FLAG_SHA256_PRF 0x4
+/* Is DTLS */
+# define SSL_ENC_FLAG_DTLS 0x8
+/*
+ * Allow TLS 1.2 ciphersuites: applies to DTLS 1.2 as well as TLS 1.2: may
+ * apply to others in future.
+ */
+# define SSL_ENC_FLAG_TLS1_2_CIPHERS 0x10
+
+# ifndef OPENSSL_NO_COMP
+/* Used for holding the relevant compression methods loaded into SSL_CTX */
+typedef struct ssl3_comp_st {
+ int comp_id; /* The identifier byte for this compression
+ * type */
+ char *name; /* Text name used for the compression type */
+ COMP_METHOD *method; /* The method :-) */
+} SSL3_COMP;
+# endif
+
+typedef enum downgrade_en {
+ DOWNGRADE_NONE,
+ DOWNGRADE_TO_1_2,
+ DOWNGRADE_TO_1_1
+} DOWNGRADE;
+
+/*
+ * Dummy status type for the status_type extension. Indicates no status type
+ * set
+ */
+#define TLSEXT_STATUSTYPE_nothing -1
+
+/* Sigalgs values */
+#define TLSEXT_SIGALG_ecdsa_secp256r1_sha256 0x0403
+#define TLSEXT_SIGALG_ecdsa_secp384r1_sha384 0x0503
+#define TLSEXT_SIGALG_ecdsa_secp521r1_sha512 0x0603
+#define TLSEXT_SIGALG_ecdsa_sha224 0x0303
+#define TLSEXT_SIGALG_ecdsa_sha1 0x0203
+#define TLSEXT_SIGALG_rsa_pss_rsae_sha256 0x0804
+#define TLSEXT_SIGALG_rsa_pss_rsae_sha384 0x0805
+#define TLSEXT_SIGALG_rsa_pss_rsae_sha512 0x0806
+#define TLSEXT_SIGALG_rsa_pss_pss_sha256 0x0809
+#define TLSEXT_SIGALG_rsa_pss_pss_sha384 0x080a
+#define TLSEXT_SIGALG_rsa_pss_pss_sha512 0x080b
+#define TLSEXT_SIGALG_rsa_pkcs1_sha256 0x0401
+#define TLSEXT_SIGALG_rsa_pkcs1_sha384 0x0501
+#define TLSEXT_SIGALG_rsa_pkcs1_sha512 0x0601
+#define TLSEXT_SIGALG_rsa_pkcs1_sha224 0x0301
+#define TLSEXT_SIGALG_rsa_pkcs1_sha1 0x0201
+#define TLSEXT_SIGALG_dsa_sha256 0x0402
+#define TLSEXT_SIGALG_dsa_sha384 0x0502
+#define TLSEXT_SIGALG_dsa_sha512 0x0602
+#define TLSEXT_SIGALG_dsa_sha224 0x0302
+#define TLSEXT_SIGALG_dsa_sha1 0x0202
+#define TLSEXT_SIGALG_gostr34102012_256_gostr34112012_256 0xeeee
+#define TLSEXT_SIGALG_gostr34102012_512_gostr34112012_512 0xefef
+#define TLSEXT_SIGALG_gostr34102001_gostr3411 0xeded
+
+#define TLSEXT_SIGALG_ed25519 0x0807
+#define TLSEXT_SIGALG_ed448 0x0808
+
+/* Known PSK key exchange modes */
+#define TLSEXT_KEX_MODE_KE 0x00
+#define TLSEXT_KEX_MODE_KE_DHE 0x01
+
+/*
+ * Internal representations of key exchange modes
+ */
+#define TLSEXT_KEX_MODE_FLAG_NONE 0
+#define TLSEXT_KEX_MODE_FLAG_KE 1
+#define TLSEXT_KEX_MODE_FLAG_KE_DHE 2
+
+#define SSL_USE_PSS(s) (s->s3.tmp.peer_sigalg != NULL && \
+ s->s3.tmp.peer_sigalg->sig == EVP_PKEY_RSA_PSS)
+
+/* A dummy signature value not valid for TLSv1.2 signature algs */
+#define TLSEXT_signature_rsa_pss 0x0101
+
+/* TLSv1.3 downgrade protection sentinel values */
+extern const unsigned char tls11downgrade[8];
+extern const unsigned char tls12downgrade[8];
+
+extern SSL3_ENC_METHOD ssl3_undef_enc_method;
+
+__owur const SSL_METHOD *ssl_bad_method(int ver);
+__owur const SSL_METHOD *sslv3_method(void);
+__owur const SSL_METHOD *sslv3_server_method(void);
+__owur const SSL_METHOD *sslv3_client_method(void);
+__owur const SSL_METHOD *tlsv1_method(void);
+__owur const SSL_METHOD *tlsv1_server_method(void);
+__owur const SSL_METHOD *tlsv1_client_method(void);
+__owur const SSL_METHOD *tlsv1_1_method(void);
+__owur const SSL_METHOD *tlsv1_1_server_method(void);
+__owur const SSL_METHOD *tlsv1_1_client_method(void);
+__owur const SSL_METHOD *tlsv1_2_method(void);
+__owur const SSL_METHOD *tlsv1_2_server_method(void);
+__owur const SSL_METHOD *tlsv1_2_client_method(void);
+__owur const SSL_METHOD *tlsv1_3_method(void);
+__owur const SSL_METHOD *tlsv1_3_server_method(void);
+__owur const SSL_METHOD *tlsv1_3_client_method(void);
+__owur const SSL_METHOD *dtlsv1_method(void);
+__owur const SSL_METHOD *dtlsv1_server_method(void);
+__owur const SSL_METHOD *dtlsv1_client_method(void);
+__owur const SSL_METHOD *dtls_bad_ver_client_method(void);
+__owur const SSL_METHOD *dtlsv1_2_method(void);
+__owur const SSL_METHOD *dtlsv1_2_server_method(void);
+__owur const SSL_METHOD *dtlsv1_2_client_method(void);
+
+extern const SSL3_ENC_METHOD TLSv1_enc_data;
+extern const SSL3_ENC_METHOD TLSv1_1_enc_data;
+extern const SSL3_ENC_METHOD TLSv1_2_enc_data;
+extern const SSL3_ENC_METHOD TLSv1_3_enc_data;
+extern const SSL3_ENC_METHOD SSLv3_enc_data;
+extern const SSL3_ENC_METHOD DTLSv1_enc_data;
+extern const SSL3_ENC_METHOD DTLSv1_2_enc_data;
+
+/*
+ * Flags for SSL methods
+ */
+# define SSL_METHOD_NO_FIPS (1U<<0)
+# define SSL_METHOD_NO_SUITEB (1U<<1)
+
+# define IMPLEMENT_tls_meth_func(version, flags, mask, func_name, s_accept, \
+ s_connect, enc_data) \
+const SSL_METHOD *func_name(void) \
+ { \
+ static const SSL_METHOD func_name##_data= { \
+ version, \
+ flags, \
+ mask, \
+ tls1_new, \
+ tls1_clear, \
+ tls1_free, \
+ s_accept, \
+ s_connect, \
+ ssl3_read, \
+ ssl3_peek, \
+ ssl3_write, \
+ ssl3_shutdown, \
+ ssl3_renegotiate, \
+ ssl3_renegotiate_check, \
+ ssl3_read_bytes, \
+ ssl3_write_bytes, \
+ ssl3_dispatch_alert, \
+ ssl3_ctrl, \
+ ssl3_ctx_ctrl, \
+ ssl3_get_cipher_by_char, \
+ ssl3_put_cipher_by_char, \
+ ssl3_pending, \
+ ssl3_num_ciphers, \
+ ssl3_get_cipher, \
+ tls1_default_timeout, \
+ &enc_data, \
+ ssl_undefined_void_function, \
+ ssl3_callback_ctrl, \
+ ssl3_ctx_callback_ctrl, \
+ }; \
+ return &func_name##_data; \
+ }
+
+# define IMPLEMENT_ssl3_meth_func(func_name, s_accept, s_connect) \
+const SSL_METHOD *func_name(void) \
+ { \
+ static const SSL_METHOD func_name##_data= { \
+ SSL3_VERSION, \
+ SSL_METHOD_NO_FIPS | SSL_METHOD_NO_SUITEB, \
+ SSL_OP_NO_SSLv3, \
+ ssl3_new, \
+ ssl3_clear, \
+ ssl3_free, \
+ s_accept, \
+ s_connect, \
+ ssl3_read, \
+ ssl3_peek, \
+ ssl3_write, \
+ ssl3_shutdown, \
+ ssl3_renegotiate, \
+ ssl3_renegotiate_check, \
+ ssl3_read_bytes, \
+ ssl3_write_bytes, \
+ ssl3_dispatch_alert, \
+ ssl3_ctrl, \
+ ssl3_ctx_ctrl, \
+ ssl3_get_cipher_by_char, \
+ ssl3_put_cipher_by_char, \
+ ssl3_pending, \
+ ssl3_num_ciphers, \
+ ssl3_get_cipher, \
+ ssl3_default_timeout, \
+ &SSLv3_enc_data, \
+ ssl_undefined_void_function, \
+ ssl3_callback_ctrl, \
+ ssl3_ctx_callback_ctrl, \
+ }; \
+ return &func_name##_data; \
+ }
+
+# define IMPLEMENT_dtls1_meth_func(version, flags, mask, func_name, s_accept, \
+ s_connect, enc_data) \
+const SSL_METHOD *func_name(void) \
+ { \
+ static const SSL_METHOD func_name##_data= { \
+ version, \
+ flags, \
+ mask, \
+ dtls1_new, \
+ dtls1_clear, \
+ dtls1_free, \
+ s_accept, \
+ s_connect, \
+ ssl3_read, \
+ ssl3_peek, \
+ ssl3_write, \
+ dtls1_shutdown, \
+ ssl3_renegotiate, \
+ ssl3_renegotiate_check, \
+ dtls1_read_bytes, \
+ dtls1_write_app_data_bytes, \
+ dtls1_dispatch_alert, \
+ dtls1_ctrl, \
+ ssl3_ctx_ctrl, \
+ ssl3_get_cipher_by_char, \
+ ssl3_put_cipher_by_char, \
+ ssl3_pending, \
+ ssl3_num_ciphers, \
+ ssl3_get_cipher, \
+ dtls1_default_timeout, \
+ &enc_data, \
+ ssl_undefined_void_function, \
+ ssl3_callback_ctrl, \
+ ssl3_ctx_callback_ctrl, \
+ }; \
+ return &func_name##_data; \
+ }
+
+struct openssl_ssl_test_functions {
+ int (*p_ssl_init_wbio_buffer) (SSL *s);
+ int (*p_ssl3_setup_buffers) (SSL *s);
+};
+
+const char *ssl_protocol_to_string(int version);
+
+/* Returns true if certificate and private key for 'idx' are present */
+static ossl_inline int ssl_has_cert(const SSL *s, int idx)
+{
+ if (idx < 0 || idx >= SSL_PKEY_NUM)
+ return 0;
+ return s->cert->pkeys[idx].x509 != NULL
+ && s->cert->pkeys[idx].privatekey != NULL;
+}
+
+static ossl_inline void tls1_get_peer_groups(SSL *s, const uint16_t **pgroups,
+ size_t *pgroupslen)
+{
+ *pgroups = s->ext.peer_supportedgroups;
+ *pgroupslen = s->ext.peer_supportedgroups_len;
+}
+
+# ifndef OPENSSL_UNIT_TEST
+
+__owur int ssl_read_internal(SSL *s, void *buf, size_t num, size_t *readbytes);
+__owur int ssl_write_internal(SSL *s, const void *buf, size_t num, size_t *written);
+void ssl_clear_cipher_ctx(SSL *s);
+int ssl_clear_bad_session(SSL *s);
+__owur CERT *ssl_cert_new(void);
+__owur CERT *ssl_cert_dup(CERT *cert);
+void ssl_cert_clear_certs(CERT *c);
+void ssl_cert_free(CERT *c);
+__owur int ssl_generate_session_id(SSL *s, SSL_SESSION *ss);
+__owur int ssl_get_new_session(SSL *s, int session);
+__owur SSL_SESSION *lookup_sess_in_cache(SSL *s, const unsigned char *sess_id,
+ size_t sess_id_len);
+__owur int ssl_get_prev_session(SSL *s, CLIENTHELLO_MSG *hello);
+__owur SSL_SESSION *ssl_session_dup(const SSL_SESSION *src, int ticket);
+__owur int ssl_cipher_id_cmp(const SSL_CIPHER *a, const SSL_CIPHER *b);
+DECLARE_OBJ_BSEARCH_GLOBAL_CMP_FN(SSL_CIPHER, SSL_CIPHER, ssl_cipher_id);
+__owur int ssl_cipher_ptr_id_cmp(const SSL_CIPHER *const *ap,
+ const SSL_CIPHER *const *bp);
+__owur STACK_OF(SSL_CIPHER) *ssl_create_cipher_list(const SSL_METHOD *ssl_method,
+ STACK_OF(SSL_CIPHER) *tls13_ciphersuites,
+ STACK_OF(SSL_CIPHER) **cipher_list,
+ STACK_OF(SSL_CIPHER) **cipher_list_by_id,
+ const char *rule_str,
+ CERT *c);
+__owur int ssl_cache_cipherlist(SSL *s, PACKET *cipher_suites, int sslv2format);
+__owur int bytes_to_cipher_list(SSL *s, PACKET *cipher_suites,
+ STACK_OF(SSL_CIPHER) **skp,
+ STACK_OF(SSL_CIPHER) **scsvs, int sslv2format,
+ int fatal);
+void ssl_update_cache(SSL *s, int mode);
+__owur int ssl_cipher_get_evp(const SSL_SESSION *s, const EVP_CIPHER **enc,
+ const EVP_MD **md, int *mac_pkey_type,
+ size_t *mac_secret_size, SSL_COMP **comp,
+ int use_etm);
+__owur int ssl_cipher_get_overhead(const SSL_CIPHER *c, size_t *mac_overhead,
+ size_t *int_overhead, size_t *blocksize,
+ size_t *ext_overhead);
+__owur int ssl_cert_is_disabled(size_t idx);
+__owur const SSL_CIPHER *ssl_get_cipher_by_char(SSL *ssl,
+ const unsigned char *ptr,
+ int all);
+__owur int ssl_cert_set0_chain(SSL *s, SSL_CTX *ctx, STACK_OF(X509) *chain);
+__owur int ssl_cert_set1_chain(SSL *s, SSL_CTX *ctx, STACK_OF(X509) *chain);
+__owur int ssl_cert_add0_chain_cert(SSL *s, SSL_CTX *ctx, X509 *x);
+__owur int ssl_cert_add1_chain_cert(SSL *s, SSL_CTX *ctx, X509 *x);
+__owur int ssl_cert_select_current(CERT *c, X509 *x);
+__owur int ssl_cert_set_current(CERT *c, long arg);
+void ssl_cert_set_cert_cb(CERT *c, int (*cb) (SSL *ssl, void *arg), void *arg);
+
+__owur int ssl_verify_cert_chain(SSL *s, STACK_OF(X509) *sk);
+__owur int ssl_build_cert_chain(SSL *s, SSL_CTX *ctx, int flags);
+__owur int ssl_cert_set_cert_store(CERT *c, X509_STORE *store, int chain,
+ int ref);
+
+__owur int ssl_security(const SSL *s, int op, int bits, int nid, void *other);
+__owur int ssl_ctx_security(const SSL_CTX *ctx, int op, int bits, int nid,
+ void *other);
+
+__owur int ssl_cert_lookup_by_nid(int nid, size_t *pidx);
+__owur const SSL_CERT_LOOKUP *ssl_cert_lookup_by_pkey(const EVP_PKEY *pk,
+ size_t *pidx);
+__owur const SSL_CERT_LOOKUP *ssl_cert_lookup_by_idx(size_t idx);
+
+int ssl_undefined_function(SSL *s);
+__owur int ssl_undefined_void_function(void);
+__owur int ssl_undefined_const_function(const SSL *s);
+__owur int ssl_get_server_cert_serverinfo(SSL *s,
+ const unsigned char **serverinfo,
+ size_t *serverinfo_length);
+void ssl_set_masks(SSL *s);
+__owur STACK_OF(SSL_CIPHER) *ssl_get_ciphers_by_id(SSL *s);
+__owur int ssl_x509err2alert(int type);
+void ssl_sort_cipher_list(void);
+int ssl_load_ciphers(void);
+__owur int ssl_fill_hello_random(SSL *s, int server, unsigned char *field,
+ size_t len, DOWNGRADE dgrd);
+__owur int ssl_generate_master_secret(SSL *s, unsigned char *pms, size_t pmslen,
+ int free_pms);
+__owur EVP_PKEY *ssl_generate_pkey(EVP_PKEY *pm);
+__owur int ssl_derive(SSL *s, EVP_PKEY *privkey, EVP_PKEY *pubkey,
+ int genmaster);
+__owur EVP_PKEY *ssl_dh_to_pkey(DH *dh);
+__owur unsigned int ssl_get_max_send_fragment(const SSL *ssl);
+__owur unsigned int ssl_get_split_send_fragment(const SSL *ssl);
+
+__owur const SSL_CIPHER *ssl3_get_cipher_by_id(uint32_t id);
+__owur const SSL_CIPHER *ssl3_get_cipher_by_std_name(const char *stdname);
+__owur const SSL_CIPHER *ssl3_get_cipher_by_char(const unsigned char *p);
+__owur int ssl3_put_cipher_by_char(const SSL_CIPHER *c, WPACKET *pkt,
+ size_t *len);
+int ssl3_init_finished_mac(SSL *s);
+__owur int ssl3_setup_key_block(SSL *s);
+__owur int ssl3_change_cipher_state(SSL *s, int which);
+void ssl3_cleanup_key_block(SSL *s);
+__owur int ssl3_do_write(SSL *s, int type);
+int ssl3_send_alert(SSL *s, int level, int desc);
+__owur int ssl3_generate_master_secret(SSL *s, unsigned char *out,
+ unsigned char *p, size_t len,
+ size_t *secret_size);
+__owur int ssl3_get_req_cert_type(SSL *s, WPACKET *pkt);
+__owur int ssl3_num_ciphers(void);
+__owur const SSL_CIPHER *ssl3_get_cipher(unsigned int u);
+int ssl3_renegotiate(SSL *ssl);
+int ssl3_renegotiate_check(SSL *ssl, int initok);
+void ssl3_digest_master_key_set_params(const SSL_SESSION *session,
+ OSSL_PARAM params[]);
+__owur int ssl3_dispatch_alert(SSL *s);
+__owur size_t ssl3_final_finish_mac(SSL *s, const char *sender, size_t slen,
+ unsigned char *p);
+__owur int ssl3_finish_mac(SSL *s, const unsigned char *buf, size_t len);
+void ssl3_free_digest_list(SSL *s);
+__owur unsigned long ssl3_output_cert_chain(SSL *s, WPACKET *pkt,
+ CERT_PKEY *cpk);
+__owur const SSL_CIPHER *ssl3_choose_cipher(SSL *ssl,
+ STACK_OF(SSL_CIPHER) *clnt,
+ STACK_OF(SSL_CIPHER) *srvr);
+__owur int ssl3_digest_cached_records(SSL *s, int keep);
+__owur int ssl3_new(SSL *s);
+void ssl3_free(SSL *s);
+__owur int ssl3_read(SSL *s, void *buf, size_t len, size_t *readbytes);
+__owur int ssl3_peek(SSL *s, void *buf, size_t len, size_t *readbytes);
+__owur int ssl3_write(SSL *s, const void *buf, size_t len, size_t *written);
+__owur int ssl3_shutdown(SSL *s);
+int ssl3_clear(SSL *s);
+__owur long ssl3_ctrl(SSL *s, int cmd, long larg, void *parg);
+__owur long ssl3_ctx_ctrl(SSL_CTX *s, int cmd, long larg, void *parg);
+__owur long ssl3_callback_ctrl(SSL *s, int cmd, void (*fp) (void));
+__owur long ssl3_ctx_callback_ctrl(SSL_CTX *s, int cmd, void (*fp) (void));
+
+__owur int ssl3_do_change_cipher_spec(SSL *ssl);
+__owur long ssl3_default_timeout(void);
+
+__owur int ssl3_set_handshake_header(SSL *s, WPACKET *pkt, int htype);
+__owur int tls_close_construct_packet(SSL *s, WPACKET *pkt, int htype);
+__owur int tls_setup_handshake(SSL *s);
+__owur int dtls1_set_handshake_header(SSL *s, WPACKET *pkt, int htype);
+__owur int dtls1_close_construct_packet(SSL *s, WPACKET *pkt, int htype);
+__owur int ssl3_handshake_write(SSL *s);
+
+__owur int ssl_allow_compression(SSL *s);
+
+__owur int ssl_version_supported(const SSL *s, int version,
+ const SSL_METHOD **meth);
+
+__owur int ssl_set_client_hello_version(SSL *s);
+__owur int ssl_check_version_downgrade(SSL *s);
+__owur int ssl_set_version_bound(int method_version, int version, int *bound);
+__owur int ssl_choose_server_version(SSL *s, CLIENTHELLO_MSG *hello,
+ DOWNGRADE *dgrd);
+__owur int ssl_choose_client_version(SSL *s, int version,
+ RAW_EXTENSION *extensions);
+__owur int ssl_get_min_max_version(const SSL *s, int *min_version,
+ int *max_version, int *real_max);
+
+__owur long tls1_default_timeout(void);
+__owur int dtls1_do_write(SSL *s, int type);
+void dtls1_set_message_header(SSL *s,
+ unsigned char mt,
+ size_t len,
+ size_t frag_off, size_t frag_len);
+
+int dtls1_write_app_data_bytes(SSL *s, int type, const void *buf_, size_t len,
+ size_t *written);
+
+__owur int dtls1_read_failed(SSL *s, int code);
+__owur int dtls1_buffer_message(SSL *s, int ccs);
+__owur int dtls1_retransmit_message(SSL *s, unsigned short seq, int *found);
+__owur int dtls1_get_queue_priority(unsigned short seq, int is_ccs);
+int dtls1_retransmit_buffered_messages(SSL *s);
+void dtls1_clear_received_buffer(SSL *s);
+void dtls1_clear_sent_buffer(SSL *s);
+void dtls1_get_message_header(unsigned char *data,
+ struct hm_header_st *msg_hdr);
+__owur long dtls1_default_timeout(void);
+__owur struct timeval *dtls1_get_timeout(SSL *s, struct timeval *timeleft);
+__owur int dtls1_check_timeout_num(SSL *s);
+__owur int dtls1_handle_timeout(SSL *s);
+void dtls1_start_timer(SSL *s);
+void dtls1_stop_timer(SSL *s);
+__owur int dtls1_is_timer_expired(SSL *s);
+void dtls1_double_timeout(SSL *s);
+__owur int dtls_raw_hello_verify_request(WPACKET *pkt, unsigned char *cookie,
+ size_t cookie_len);
+__owur size_t dtls1_min_mtu(SSL *s);
+void dtls1_hm_fragment_free(hm_fragment *frag);
+__owur int dtls1_query_mtu(SSL *s);
+
+__owur int tls1_new(SSL *s);
+void tls1_free(SSL *s);
+int tls1_clear(SSL *s);
+
+__owur int dtls1_new(SSL *s);
+void dtls1_free(SSL *s);
+int dtls1_clear(SSL *s);
+long dtls1_ctrl(SSL *s, int cmd, long larg, void *parg);
+__owur int dtls1_shutdown(SSL *s);
+
+__owur int dtls1_dispatch_alert(SSL *s);
+
+__owur int ssl_init_wbio_buffer(SSL *s);
+int ssl_free_wbio_buffer(SSL *s);
+
+__owur int tls1_change_cipher_state(SSL *s, int which);
+__owur int tls1_setup_key_block(SSL *s);
+__owur size_t tls1_final_finish_mac(SSL *s, const char *str, size_t slen,
+ unsigned char *p);
+__owur int tls1_generate_master_secret(SSL *s, unsigned char *out,
+ unsigned char *p, size_t len,
+ size_t *secret_size);
+__owur int tls13_setup_key_block(SSL *s);
+__owur size_t tls13_final_finish_mac(SSL *s, const char *str, size_t slen,
+ unsigned char *p);
+__owur int tls13_change_cipher_state(SSL *s, int which);
+__owur int tls13_update_key(SSL *s, int send);
+__owur int tls13_hkdf_expand(SSL *s, const EVP_MD *md,
+ const unsigned char *secret,
+ const unsigned char *label, size_t labellen,
+ const unsigned char *data, size_t datalen,
+ unsigned char *out, size_t outlen, int fatal);
+__owur int tls13_derive_key(SSL *s, const EVP_MD *md,
+ const unsigned char *secret, unsigned char *key,
+ size_t keylen);
+__owur int tls13_derive_iv(SSL *s, const EVP_MD *md,
+ const unsigned char *secret, unsigned char *iv,
+ size_t ivlen);
+__owur int tls13_derive_finishedkey(SSL *s, const EVP_MD *md,
+ const unsigned char *secret,
+ unsigned char *fin, size_t finlen);
+int tls13_generate_secret(SSL *s, const EVP_MD *md,
+ const unsigned char *prevsecret,
+ const unsigned char *insecret,
+ size_t insecretlen,
+ unsigned char *outsecret);
+__owur int tls13_generate_handshake_secret(SSL *s,
+ const unsigned char *insecret,
+ size_t insecretlen);
+__owur int tls13_generate_master_secret(SSL *s, unsigned char *out,
+ unsigned char *prev, size_t prevlen,
+ size_t *secret_size);
+__owur int tls1_export_keying_material(SSL *s, unsigned char *out, size_t olen,
+ const char *label, size_t llen,
+ const unsigned char *p, size_t plen,
+ int use_context);
+__owur int tls13_export_keying_material(SSL *s, unsigned char *out, size_t olen,
+ const char *label, size_t llen,
+ const unsigned char *context,
+ size_t contextlen, int use_context);
+__owur int tls13_export_keying_material_early(SSL *s, unsigned char *out,
+ size_t olen, const char *label,
+ size_t llen,
+ const unsigned char *context,
+ size_t contextlen);
+__owur int tls1_alert_code(int code);
+__owur int tls13_alert_code(int code);
+__owur int ssl3_alert_code(int code);
+
+# ifndef OPENSSL_NO_EC
+__owur int ssl_check_srvr_ecc_cert_and_alg(X509 *x, SSL *s);
+# endif
+
+SSL_COMP *ssl3_comp_find(STACK_OF(SSL_COMP) *sk, int n);
+
+__owur const TLS_GROUP_INFO *tls1_group_id_lookup(uint16_t curve_id);
+__owur int tls1_group_id2nid(uint16_t group_id);
+__owur int tls1_check_group_id(SSL *s, uint16_t group_id, int check_own_curves);
+__owur uint16_t tls1_shared_group(SSL *s, int nmatch);
+__owur int tls1_set_groups(uint16_t **pext, size_t *pextlen,
+ int *curves, size_t ncurves);
+__owur int tls1_set_groups_list(uint16_t **pext, size_t *pextlen,
+ const char *str);
+__owur EVP_PKEY *ssl_generate_pkey_group(SSL *s, uint16_t id);
+__owur int tls_valid_group(SSL *s, uint16_t group_id, int version);
+__owur EVP_PKEY *ssl_generate_param_group(uint16_t id);
+# ifndef OPENSSL_NO_EC
+void tls1_get_formatlist(SSL *s, const unsigned char **pformats,
+ size_t *num_formats);
+__owur int tls1_check_ec_tmp_key(SSL *s, unsigned long id);
+# endif /* OPENSSL_NO_EC */
+
+__owur int tls_group_allowed(SSL *s, uint16_t curve, int op);
+void tls1_get_supported_groups(SSL *s, const uint16_t **pgroups,
+ size_t *pgroupslen);
+
+__owur int tls1_set_server_sigalgs(SSL *s);
+
+__owur SSL_TICKET_STATUS tls_get_ticket_from_client(SSL *s, CLIENTHELLO_MSG *hello,
+ SSL_SESSION **ret);
+__owur SSL_TICKET_STATUS tls_decrypt_ticket(SSL *s, const unsigned char *etick,
+ size_t eticklen,
+ const unsigned char *sess_id,
+ size_t sesslen, SSL_SESSION **psess);
+
+__owur int tls_use_ticket(SSL *s);
+
+void ssl_set_sig_mask(uint32_t *pmask_a, SSL *s, int op);
+
+__owur int tls1_set_sigalgs_list(CERT *c, const char *str, int client);
+__owur int tls1_set_raw_sigalgs(CERT *c, const uint16_t *psigs, size_t salglen,
+ int client);
+__owur int tls1_set_sigalgs(CERT *c, const int *salg, size_t salglen,
+ int client);
+int tls1_check_chain(SSL *s, X509 *x, EVP_PKEY *pk, STACK_OF(X509) *chain,
+ int idx);
+void tls1_set_cert_validity(SSL *s);
+
+# ifndef OPENSSL_NO_CT
+__owur int ssl_validate_ct(SSL *s);
+# endif
+
+# ifndef OPENSSL_NO_DH
+__owur DH *ssl_get_auto_dh(SSL *s);
+# endif
+
+__owur int ssl_security_cert(SSL *s, SSL_CTX *ctx, X509 *x, int vfy, int is_ee);
+__owur int ssl_security_cert_chain(SSL *s, STACK_OF(X509) *sk, X509 *ex,
+ int vfy);
+
+int tls_choose_sigalg(SSL *s, int fatalerrs);
+
+__owur EVP_MD_CTX *ssl_replace_hash(EVP_MD_CTX **hash, const EVP_MD *md);
+void ssl_clear_hash_ctx(EVP_MD_CTX **hash);
+__owur long ssl_get_algorithm2(SSL *s);
+__owur int tls12_copy_sigalgs(SSL *s, WPACKET *pkt,
+ const uint16_t *psig, size_t psiglen);
+__owur int tls1_save_u16(PACKET *pkt, uint16_t **pdest, size_t *pdestlen);
+__owur int tls1_save_sigalgs(SSL *s, PACKET *pkt, int cert);
+__owur int tls1_process_sigalgs(SSL *s);
+__owur int tls1_set_peer_legacy_sigalg(SSL *s, const EVP_PKEY *pkey);
+__owur int tls1_lookup_md(const SIGALG_LOOKUP *lu, const EVP_MD **pmd);
+__owur size_t tls12_get_psigalgs(SSL *s, int sent, const uint16_t **psigs);
+# ifndef OPENSSL_NO_EC
+__owur int tls_check_sigalg_curve(const SSL *s, int curve);
+# endif
+__owur int tls12_check_peer_sigalg(SSL *s, uint16_t, EVP_PKEY *pkey);
+__owur int ssl_set_client_disabled(SSL *s);
+__owur int ssl_cipher_disabled(SSL *s, const SSL_CIPHER *c, int op, int echde);
+
+__owur int ssl_handshake_hash(SSL *s, unsigned char *out, size_t outlen,
+ size_t *hashlen);
+__owur const EVP_MD *ssl_md(int idx);
+__owur const EVP_MD *ssl_handshake_md(SSL *s);
+__owur const EVP_MD *ssl_prf_md(SSL *s);
+
+/*
+ * ssl_log_rsa_client_key_exchange logs |premaster| to the SSL_CTX associated
+ * with |ssl|, if logging is enabled. It returns one on success and zero on
+ * failure. The entry is identified by the first 8 bytes of
+ * |encrypted_premaster|.
+ */
+__owur int ssl_log_rsa_client_key_exchange(SSL *ssl,
+ const uint8_t *encrypted_premaster,
+ size_t encrypted_premaster_len,
+ const uint8_t *premaster,
+ size_t premaster_len);
+
+/*
+ * ssl_log_secret logs |secret| to the SSL_CTX associated with |ssl|, if
+ * logging is available. It returns one on success and zero on failure. It tags
+ * the entry with |label|.
+ */
+__owur int ssl_log_secret(SSL *ssl, const char *label,
+ const uint8_t *secret, size_t secret_len);
+
+#define MASTER_SECRET_LABEL "CLIENT_RANDOM"
+#define CLIENT_EARLY_LABEL "CLIENT_EARLY_TRAFFIC_SECRET"
+#define CLIENT_HANDSHAKE_LABEL "CLIENT_HANDSHAKE_TRAFFIC_SECRET"
+#define SERVER_HANDSHAKE_LABEL "SERVER_HANDSHAKE_TRAFFIC_SECRET"
+#define CLIENT_APPLICATION_LABEL "CLIENT_TRAFFIC_SECRET_0"
+#define SERVER_APPLICATION_LABEL "SERVER_TRAFFIC_SECRET_0"
+#define EARLY_EXPORTER_SECRET_LABEL "EARLY_EXPORTER_SECRET"
+#define EXPORTER_SECRET_LABEL "EXPORTER_SECRET"
+
+/* s3_cbc.c */
+__owur char ssl3_cbc_record_digest_supported(const EVP_MD_CTX *ctx);
+__owur int ssl3_cbc_digest_record(const EVP_MD_CTX *ctx,
+ unsigned char *md_out,
+ size_t *md_out_size,
+ const unsigned char header[13],
+ const unsigned char *data,
+ size_t data_plus_mac_size,
+ size_t data_plus_mac_plus_padding_size,
+ const unsigned char *mac_secret,
+ size_t mac_secret_length, char is_sslv3);
+
+__owur int srp_generate_server_master_secret(SSL *s);
+__owur int srp_generate_client_master_secret(SSL *s);
+__owur int srp_verify_server_param(SSL *s);
+
+/* statem/statem_srvr.c */
+
+__owur int send_certificate_request(SSL *s);
+
+/* statem/extensions_cust.c */
+
+custom_ext_method *custom_ext_find(const custom_ext_methods *exts,
+ ENDPOINT role, unsigned int ext_type,
+ size_t *idx);
+
+void custom_ext_init(custom_ext_methods *meths);
+
+__owur int custom_ext_parse(SSL *s, unsigned int context, unsigned int ext_type,
+ const unsigned char *ext_data, size_t ext_size,
+ X509 *x, size_t chainidx);
+__owur int custom_ext_add(SSL *s, int context, WPACKET *pkt, X509 *x,
+ size_t chainidx, int maxversion);
+
+__owur int custom_exts_copy(custom_ext_methods *dst,
+ const custom_ext_methods *src);
+__owur int custom_exts_copy_flags(custom_ext_methods *dst,
+ const custom_ext_methods *src);
+void custom_exts_free(custom_ext_methods *exts);
+
+void ssl_comp_free_compression_methods_int(void);
+
+/* ssl_mcnf.c */
+void ssl_ctx_system_config(SSL_CTX *ctx);
+
+# else /* OPENSSL_UNIT_TEST */
+
+# define ssl_init_wbio_buffer SSL_test_functions()->p_ssl_init_wbio_buffer
+# define ssl3_setup_buffers SSL_test_functions()->p_ssl3_setup_buffers
+
+# endif
+#endif
+++ /dev/null
-/*
- * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
- * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved
- * Copyright 2005 Nokia. All rights reserved.
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-#ifndef HEADER_SSL_LOCL_H
-# define HEADER_SSL_LOCL_H
-
-# include "e_os.h" /* struct timeval for DTLS */
-# include <stdlib.h>
-# include <time.h>
-# include <string.h>
-# include <errno.h>
-
-# include <openssl/buffer.h>
-# include <openssl/comp.h>
-# include <openssl/bio.h>
-# include <openssl/rsa.h>
-# include <openssl/dsa.h>
-# include <openssl/err.h>
-# include <openssl/ssl.h>
-# include <openssl/async.h>
-# include <openssl/symhacks.h>
-# include <openssl/ct.h>
-# include "record/record.h"
-# include "statem/statem.h"
-# include "internal/packet.h"
-# include "internal/dane.h"
-# include "internal/refcount.h"
-# include "internal/tsan_assist.h"
-# include "internal/bio.h"
-
-# ifdef OPENSSL_BUILD_SHLIBSSL
-# undef OPENSSL_EXTERN
-# define OPENSSL_EXTERN OPENSSL_EXPORT
-# endif
-
-# define c2l(c,l) (l = ((unsigned long)(*((c)++))) , \
- l|=(((unsigned long)(*((c)++)))<< 8), \
- l|=(((unsigned long)(*((c)++)))<<16), \
- l|=(((unsigned long)(*((c)++)))<<24))
-
-/* NOTE - c is not incremented as per c2l */
-# define c2ln(c,l1,l2,n) { \
- c+=n; \
- l1=l2=0; \
- switch (n) { \
- case 8: l2 =((unsigned long)(*(--(c))))<<24; \
- case 7: l2|=((unsigned long)(*(--(c))))<<16; \
- case 6: l2|=((unsigned long)(*(--(c))))<< 8; \
- case 5: l2|=((unsigned long)(*(--(c)))); \
- case 4: l1 =((unsigned long)(*(--(c))))<<24; \
- case 3: l1|=((unsigned long)(*(--(c))))<<16; \
- case 2: l1|=((unsigned long)(*(--(c))))<< 8; \
- case 1: l1|=((unsigned long)(*(--(c)))); \
- } \
- }
-
-# define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \
- *((c)++)=(unsigned char)(((l)>> 8)&0xff), \
- *((c)++)=(unsigned char)(((l)>>16)&0xff), \
- *((c)++)=(unsigned char)(((l)>>24)&0xff))
-
-# define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24, \
- l|=((unsigned long)(*((c)++)))<<16, \
- l|=((unsigned long)(*((c)++)))<< 8, \
- l|=((unsigned long)(*((c)++))))
-
-# define n2l8(c,l) (l =((uint64_t)(*((c)++)))<<56, \
- l|=((uint64_t)(*((c)++)))<<48, \
- l|=((uint64_t)(*((c)++)))<<40, \
- l|=((uint64_t)(*((c)++)))<<32, \
- l|=((uint64_t)(*((c)++)))<<24, \
- l|=((uint64_t)(*((c)++)))<<16, \
- l|=((uint64_t)(*((c)++)))<< 8, \
- l|=((uint64_t)(*((c)++))))
-
-
-# define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24)&0xff), \
- *((c)++)=(unsigned char)(((l)>>16)&0xff), \
- *((c)++)=(unsigned char)(((l)>> 8)&0xff), \
- *((c)++)=(unsigned char)(((l) )&0xff))
-
-# define l2n6(l,c) (*((c)++)=(unsigned char)(((l)>>40)&0xff), \
- *((c)++)=(unsigned char)(((l)>>32)&0xff), \
- *((c)++)=(unsigned char)(((l)>>24)&0xff), \
- *((c)++)=(unsigned char)(((l)>>16)&0xff), \
- *((c)++)=(unsigned char)(((l)>> 8)&0xff), \
- *((c)++)=(unsigned char)(((l) )&0xff))
-
-# define l2n8(l,c) (*((c)++)=(unsigned char)(((l)>>56)&0xff), \
- *((c)++)=(unsigned char)(((l)>>48)&0xff), \
- *((c)++)=(unsigned char)(((l)>>40)&0xff), \
- *((c)++)=(unsigned char)(((l)>>32)&0xff), \
- *((c)++)=(unsigned char)(((l)>>24)&0xff), \
- *((c)++)=(unsigned char)(((l)>>16)&0xff), \
- *((c)++)=(unsigned char)(((l)>> 8)&0xff), \
- *((c)++)=(unsigned char)(((l) )&0xff))
-
-/* NOTE - c is not incremented as per l2c */
-# define l2cn(l1,l2,c,n) { \
- c+=n; \
- switch (n) { \
- case 8: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \
- case 7: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \
- case 6: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \
- case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \
- case 4: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \
- case 3: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \
- case 2: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \
- case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \
- } \
- }
-
-# define n2s(c,s) ((s=(((unsigned int)((c)[0]))<< 8)| \
- (((unsigned int)((c)[1])) )),(c)+=2)
-# define s2n(s,c) (((c)[0]=(unsigned char)(((s)>> 8)&0xff), \
- (c)[1]=(unsigned char)(((s) )&0xff)),(c)+=2)
-
-# define n2l3(c,l) ((l =(((unsigned long)((c)[0]))<<16)| \
- (((unsigned long)((c)[1]))<< 8)| \
- (((unsigned long)((c)[2])) )),(c)+=3)
-
-# define l2n3(l,c) (((c)[0]=(unsigned char)(((l)>>16)&0xff), \
- (c)[1]=(unsigned char)(((l)>> 8)&0xff), \
- (c)[2]=(unsigned char)(((l) )&0xff)),(c)+=3)
-
-# define TLS_MAX_VERSION_INTERNAL TLS1_3_VERSION
-# define DTLS_MAX_VERSION_INTERNAL DTLS1_2_VERSION
-
-/*
- * DTLS version numbers are strange because they're inverted. Except for
- * DTLS1_BAD_VER, which should be considered "lower" than the rest.
- */
-# define dtls_ver_ordinal(v1) (((v1) == DTLS1_BAD_VER) ? 0xff00 : (v1))
-# define DTLS_VERSION_GT(v1, v2) (dtls_ver_ordinal(v1) < dtls_ver_ordinal(v2))
-# define DTLS_VERSION_GE(v1, v2) (dtls_ver_ordinal(v1) <= dtls_ver_ordinal(v2))
-# define DTLS_VERSION_LT(v1, v2) (dtls_ver_ordinal(v1) > dtls_ver_ordinal(v2))
-# define DTLS_VERSION_LE(v1, v2) (dtls_ver_ordinal(v1) >= dtls_ver_ordinal(v2))
-
-
-/*
- * Define the Bitmasks for SSL_CIPHER.algorithms.
- * This bits are used packed as dense as possible. If new methods/ciphers
- * etc will be added, the bits a likely to change, so this information
- * is for internal library use only, even though SSL_CIPHER.algorithms
- * can be publicly accessed.
- * Use the according functions for cipher management instead.
- *
- * The bit mask handling in the selection and sorting scheme in
- * ssl_create_cipher_list() has only limited capabilities, reflecting
- * that the different entities within are mutually exclusive:
- * ONLY ONE BIT PER MASK CAN BE SET AT A TIME.
- */
-
-/* Bits for algorithm_mkey (key exchange algorithm) */
-/* RSA key exchange */
-# define SSL_kRSA 0x00000001U
-/* tmp DH key no DH cert */
-# define SSL_kDHE 0x00000002U
-/* synonym */
-# define SSL_kEDH SSL_kDHE
-/* ephemeral ECDH */
-# define SSL_kECDHE 0x00000004U
-/* synonym */
-# define SSL_kEECDH SSL_kECDHE
-/* PSK */
-# define SSL_kPSK 0x00000008U
-/* GOST key exchange */
-# define SSL_kGOST 0x00000010U
-/* SRP */
-# define SSL_kSRP 0x00000020U
-
-# define SSL_kRSAPSK 0x00000040U
-# define SSL_kECDHEPSK 0x00000080U
-# define SSL_kDHEPSK 0x00000100U
-
-/* all PSK */
-
-# define SSL_PSK (SSL_kPSK | SSL_kRSAPSK | SSL_kECDHEPSK | SSL_kDHEPSK)
-
-/* Any appropriate key exchange algorithm (for TLS 1.3 ciphersuites) */
-# define SSL_kANY 0x00000000U
-
-/* Bits for algorithm_auth (server authentication) */
-/* RSA auth */
-# define SSL_aRSA 0x00000001U
-/* DSS auth */
-# define SSL_aDSS 0x00000002U
-/* no auth (i.e. use ADH or AECDH) */
-# define SSL_aNULL 0x00000004U
-/* ECDSA auth*/
-# define SSL_aECDSA 0x00000008U
-/* PSK auth */
-# define SSL_aPSK 0x00000010U
-/* GOST R 34.10-2001 signature auth */
-# define SSL_aGOST01 0x00000020U
-/* SRP auth */
-# define SSL_aSRP 0x00000040U
-/* GOST R 34.10-2012 signature auth */
-# define SSL_aGOST12 0x00000080U
-/* Any appropriate signature auth (for TLS 1.3 ciphersuites) */
-# define SSL_aANY 0x00000000U
-/* All bits requiring a certificate */
-#define SSL_aCERT \
- (SSL_aRSA | SSL_aDSS | SSL_aECDSA | SSL_aGOST01 | SSL_aGOST12)
-
-/* Bits for algorithm_enc (symmetric encryption) */
-# define SSL_DES 0x00000001U
-# define SSL_3DES 0x00000002U
-# define SSL_RC4 0x00000004U
-# define SSL_RC2 0x00000008U
-# define SSL_IDEA 0x00000010U
-# define SSL_eNULL 0x00000020U
-# define SSL_AES128 0x00000040U
-# define SSL_AES256 0x00000080U
-# define SSL_CAMELLIA128 0x00000100U
-# define SSL_CAMELLIA256 0x00000200U
-# define SSL_eGOST2814789CNT 0x00000400U
-# define SSL_SEED 0x00000800U
-# define SSL_AES128GCM 0x00001000U
-# define SSL_AES256GCM 0x00002000U
-# define SSL_AES128CCM 0x00004000U
-# define SSL_AES256CCM 0x00008000U
-# define SSL_AES128CCM8 0x00010000U
-# define SSL_AES256CCM8 0x00020000U
-# define SSL_eGOST2814789CNT12 0x00040000U
-# define SSL_CHACHA20POLY1305 0x00080000U
-# define SSL_ARIA128GCM 0x00100000U
-# define SSL_ARIA256GCM 0x00200000U
-
-# define SSL_AESGCM (SSL_AES128GCM | SSL_AES256GCM)
-# define SSL_AESCCM (SSL_AES128CCM | SSL_AES256CCM | SSL_AES128CCM8 | SSL_AES256CCM8)
-# define SSL_AES (SSL_AES128|SSL_AES256|SSL_AESGCM|SSL_AESCCM)
-# define SSL_CAMELLIA (SSL_CAMELLIA128|SSL_CAMELLIA256)
-# define SSL_CHACHA20 (SSL_CHACHA20POLY1305)
-# define SSL_ARIAGCM (SSL_ARIA128GCM | SSL_ARIA256GCM)
-# define SSL_ARIA (SSL_ARIAGCM)
-
-/* Bits for algorithm_mac (symmetric authentication) */
-
-# define SSL_MD5 0x00000001U
-# define SSL_SHA1 0x00000002U
-# define SSL_GOST94 0x00000004U
-# define SSL_GOST89MAC 0x00000008U
-# define SSL_SHA256 0x00000010U
-# define SSL_SHA384 0x00000020U
-/* Not a real MAC, just an indication it is part of cipher */
-# define SSL_AEAD 0x00000040U
-# define SSL_GOST12_256 0x00000080U
-# define SSL_GOST89MAC12 0x00000100U
-# define SSL_GOST12_512 0x00000200U
-
-/*
- * When adding new digest in the ssl_ciph.c and increment SSL_MD_NUM_IDX make
- * sure to update this constant too
- */
-
-# define SSL_MD_MD5_IDX 0
-# define SSL_MD_SHA1_IDX 1
-# define SSL_MD_GOST94_IDX 2
-# define SSL_MD_GOST89MAC_IDX 3
-# define SSL_MD_SHA256_IDX 4
-# define SSL_MD_SHA384_IDX 5
-# define SSL_MD_GOST12_256_IDX 6
-# define SSL_MD_GOST89MAC12_IDX 7
-# define SSL_MD_GOST12_512_IDX 8
-# define SSL_MD_MD5_SHA1_IDX 9
-# define SSL_MD_SHA224_IDX 10
-# define SSL_MD_SHA512_IDX 11
-# define SSL_MAX_DIGEST 12
-
-/* Bits for algorithm2 (handshake digests and other extra flags) */
-
-/* Bits 0-7 are handshake MAC */
-# define SSL_HANDSHAKE_MAC_MASK 0xFF
-# define SSL_HANDSHAKE_MAC_MD5_SHA1 SSL_MD_MD5_SHA1_IDX
-# define SSL_HANDSHAKE_MAC_SHA256 SSL_MD_SHA256_IDX
-# define SSL_HANDSHAKE_MAC_SHA384 SSL_MD_SHA384_IDX
-# define SSL_HANDSHAKE_MAC_GOST94 SSL_MD_GOST94_IDX
-# define SSL_HANDSHAKE_MAC_GOST12_256 SSL_MD_GOST12_256_IDX
-# define SSL_HANDSHAKE_MAC_GOST12_512 SSL_MD_GOST12_512_IDX
-# define SSL_HANDSHAKE_MAC_DEFAULT SSL_HANDSHAKE_MAC_MD5_SHA1
-
-/* Bits 8-15 bits are PRF */
-# define TLS1_PRF_DGST_SHIFT 8
-# define TLS1_PRF_SHA1_MD5 (SSL_MD_MD5_SHA1_IDX << TLS1_PRF_DGST_SHIFT)
-# define TLS1_PRF_SHA256 (SSL_MD_SHA256_IDX << TLS1_PRF_DGST_SHIFT)
-# define TLS1_PRF_SHA384 (SSL_MD_SHA384_IDX << TLS1_PRF_DGST_SHIFT)
-# define TLS1_PRF_GOST94 (SSL_MD_GOST94_IDX << TLS1_PRF_DGST_SHIFT)
-# define TLS1_PRF_GOST12_256 (SSL_MD_GOST12_256_IDX << TLS1_PRF_DGST_SHIFT)
-# define TLS1_PRF_GOST12_512 (SSL_MD_GOST12_512_IDX << TLS1_PRF_DGST_SHIFT)
-# define TLS1_PRF (SSL_MD_MD5_SHA1_IDX << TLS1_PRF_DGST_SHIFT)
-
-/*
- * Stream MAC for GOST ciphersuites from cryptopro draft (currently this also
- * goes into algorithm2)
- */
-# define TLS1_STREAM_MAC 0x10000
-
-# define SSL_STRONG_MASK 0x0000001FU
-# define SSL_DEFAULT_MASK 0X00000020U
-
-# define SSL_STRONG_NONE 0x00000001U
-# define SSL_LOW 0x00000002U
-# define SSL_MEDIUM 0x00000004U
-# define SSL_HIGH 0x00000008U
-# define SSL_FIPS 0x00000010U
-# define SSL_NOT_DEFAULT 0x00000020U
-
-/* we have used 0000003f - 26 bits left to go */
-
-/* Flag used on OpenSSL ciphersuite ids to indicate they are for SSLv3+ */
-# define SSL3_CK_CIPHERSUITE_FLAG 0x03000000
-
-/* Check if an SSL structure is using DTLS */
-# define SSL_IS_DTLS(s) (s->method->ssl3_enc->enc_flags & SSL_ENC_FLAG_DTLS)
-
-/* Check if we are using TLSv1.3 */
-# define SSL_IS_TLS13(s) (!SSL_IS_DTLS(s) \
- && (s)->method->version >= TLS1_3_VERSION \
- && (s)->method->version != TLS_ANY_VERSION)
-
-# define SSL_TREAT_AS_TLS13(s) \
- (SSL_IS_TLS13(s) || (s)->early_data_state == SSL_EARLY_DATA_CONNECTING \
- || (s)->early_data_state == SSL_EARLY_DATA_CONNECT_RETRY \
- || (s)->early_data_state == SSL_EARLY_DATA_WRITING \
- || (s)->early_data_state == SSL_EARLY_DATA_WRITE_RETRY \
- || (s)->hello_retry_request == SSL_HRR_PENDING)
-
-# define SSL_IS_FIRST_HANDSHAKE(S) ((s)->s3.tmp.finish_md_len == 0 \
- || (s)->s3.tmp.peer_finish_md_len == 0)
-
-/* See if we need explicit IV */
-# define SSL_USE_EXPLICIT_IV(s) \
- (s->method->ssl3_enc->enc_flags & SSL_ENC_FLAG_EXPLICIT_IV)
-/*
- * See if we use signature algorithms extension and signature algorithm
- * before signatures.
- */
-# define SSL_USE_SIGALGS(s) \
- (s->method->ssl3_enc->enc_flags & SSL_ENC_FLAG_SIGALGS)
-/*
- * Allow TLS 1.2 ciphersuites: applies to DTLS 1.2 as well as TLS 1.2: may
- * apply to others in future.
- */
-# define SSL_USE_TLS1_2_CIPHERS(s) \
- (s->method->ssl3_enc->enc_flags & SSL_ENC_FLAG_TLS1_2_CIPHERS)
-/*
- * Determine if a client can use TLS 1.2 ciphersuites: can't rely on method
- * flags because it may not be set to correct version yet.
- */
-# define SSL_CLIENT_USE_TLS1_2_CIPHERS(s) \
- ((!SSL_IS_DTLS(s) && s->client_version >= TLS1_2_VERSION) || \
- (SSL_IS_DTLS(s) && DTLS_VERSION_GE(s->client_version, DTLS1_2_VERSION)))
-/*
- * Determine if a client should send signature algorithms extension:
- * as with TLS1.2 cipher we can't rely on method flags.
- */
-# define SSL_CLIENT_USE_SIGALGS(s) \
- SSL_CLIENT_USE_TLS1_2_CIPHERS(s)
-
-# define IS_MAX_FRAGMENT_LENGTH_EXT_VALID(value) \
- (((value) >= TLSEXT_max_fragment_length_512) && \
- ((value) <= TLSEXT_max_fragment_length_4096))
-# define USE_MAX_FRAGMENT_LENGTH_EXT(session) \
- IS_MAX_FRAGMENT_LENGTH_EXT_VALID(session->ext.max_fragment_len_mode)
-# define GET_MAX_FRAGMENT_LENGTH(session) \
- (512U << (session->ext.max_fragment_len_mode - 1))
-
-# define SSL_READ_ETM(s) (s->s3.flags & TLS1_FLAGS_ENCRYPT_THEN_MAC_READ)
-# define SSL_WRITE_ETM(s) (s->s3.flags & TLS1_FLAGS_ENCRYPT_THEN_MAC_WRITE)
-
-/* Mostly for SSLv3 */
-# define SSL_PKEY_RSA 0
-# define SSL_PKEY_RSA_PSS_SIGN 1
-# define SSL_PKEY_DSA_SIGN 2
-# define SSL_PKEY_ECC 3
-# define SSL_PKEY_GOST01 4
-# define SSL_PKEY_GOST12_256 5
-# define SSL_PKEY_GOST12_512 6
-# define SSL_PKEY_ED25519 7
-# define SSL_PKEY_ED448 8
-# define SSL_PKEY_NUM 9
-
-/*-
- * SSL_kRSA <- RSA_ENC
- * SSL_kDH <- DH_ENC & (RSA_ENC | RSA_SIGN | DSA_SIGN)
- * SSL_kDHE <- RSA_ENC | RSA_SIGN | DSA_SIGN
- * SSL_aRSA <- RSA_ENC | RSA_SIGN
- * SSL_aDSS <- DSA_SIGN
- */
-
-/*-
-#define CERT_INVALID 0
-#define CERT_PUBLIC_KEY 1
-#define CERT_PRIVATE_KEY 2
-*/
-
-/* Post-Handshake Authentication state */
-typedef enum {
- SSL_PHA_NONE = 0,
- SSL_PHA_EXT_SENT, /* client-side only: extension sent */
- SSL_PHA_EXT_RECEIVED, /* server-side only: extension received */
- SSL_PHA_REQUEST_PENDING, /* server-side only: request pending */
- SSL_PHA_REQUESTED /* request received by client, or sent by server */
-} SSL_PHA_STATE;
-
-/* CipherSuite length. SSLv3 and all TLS versions. */
-# define TLS_CIPHER_LEN 2
-/* used to hold info on the particular ciphers used */
-struct ssl_cipher_st {
- uint32_t valid;
- const char *name; /* text name */
- const char *stdname; /* RFC name */
- uint32_t id; /* id, 4 bytes, first is version */
- /*
- * changed in 1.0.0: these four used to be portions of a single value
- * 'algorithms'
- */
- uint32_t algorithm_mkey; /* key exchange algorithm */
- uint32_t algorithm_auth; /* server authentication */
- uint32_t algorithm_enc; /* symmetric encryption */
- uint32_t algorithm_mac; /* symmetric authentication */
- int min_tls; /* minimum SSL/TLS protocol version */
- int max_tls; /* maximum SSL/TLS protocol version */
- int min_dtls; /* minimum DTLS protocol version */
- int max_dtls; /* maximum DTLS protocol version */
- uint32_t algo_strength; /* strength and export flags */
- uint32_t algorithm2; /* Extra flags */
- int32_t strength_bits; /* Number of bits really used */
- uint32_t alg_bits; /* Number of bits for algorithm */
-};
-
-/* Used to hold SSL/TLS functions */
-struct ssl_method_st {
- int version;
- unsigned flags;
- unsigned long mask;
- int (*ssl_new) (SSL *s);
- int (*ssl_clear) (SSL *s);
- void (*ssl_free) (SSL *s);
- int (*ssl_accept) (SSL *s);
- int (*ssl_connect) (SSL *s);
- int (*ssl_read) (SSL *s, void *buf, size_t len, size_t *readbytes);
- int (*ssl_peek) (SSL *s, void *buf, size_t len, size_t *readbytes);
- int (*ssl_write) (SSL *s, const void *buf, size_t len, size_t *written);
- int (*ssl_shutdown) (SSL *s);
- int (*ssl_renegotiate) (SSL *s);
- int (*ssl_renegotiate_check) (SSL *s, int);
- int (*ssl_read_bytes) (SSL *s, int type, int *recvd_type,
- unsigned char *buf, size_t len, int peek,
- size_t *readbytes);
- int (*ssl_write_bytes) (SSL *s, int type, const void *buf_, size_t len,
- size_t *written);
- int (*ssl_dispatch_alert) (SSL *s);
- long (*ssl_ctrl) (SSL *s, int cmd, long larg, void *parg);
- long (*ssl_ctx_ctrl) (SSL_CTX *ctx, int cmd, long larg, void *parg);
- const SSL_CIPHER *(*get_cipher_by_char) (const unsigned char *ptr);
- int (*put_cipher_by_char) (const SSL_CIPHER *cipher, WPACKET *pkt,
- size_t *len);
- size_t (*ssl_pending) (const SSL *s);
- int (*num_ciphers) (void);
- const SSL_CIPHER *(*get_cipher) (unsigned ncipher);
- long (*get_timeout) (void);
- const struct ssl3_enc_method *ssl3_enc; /* Extra SSLv3/TLS stuff */
- int (*ssl_version) (void);
- long (*ssl_callback_ctrl) (SSL *s, int cb_id, void (*fp) (void));
- long (*ssl_ctx_callback_ctrl) (SSL_CTX *s, int cb_id, void (*fp) (void));
-};
-
-/*
- * Matches the length of PSK_MAX_PSK_LEN. We keep it the same value for
- * consistency, even in the event of OPENSSL_NO_PSK being defined.
- */
-# define TLS13_MAX_RESUMPTION_PSK_LENGTH 256
-
-/*-
- * Lets make this into an ASN.1 type structure as follows
- * SSL_SESSION_ID ::= SEQUENCE {
- * version INTEGER, -- structure version number
- * SSLversion INTEGER, -- SSL version number
- * Cipher OCTET STRING, -- the 3 byte cipher ID
- * Session_ID OCTET STRING, -- the Session ID
- * Master_key OCTET STRING, -- the master key
- * Key_Arg [ 0 ] IMPLICIT OCTET STRING, -- the optional Key argument
- * Time [ 1 ] EXPLICIT INTEGER, -- optional Start Time
- * Timeout [ 2 ] EXPLICIT INTEGER, -- optional Timeout ins seconds
- * Peer [ 3 ] EXPLICIT X509, -- optional Peer Certificate
- * Session_ID_context [ 4 ] EXPLICIT OCTET STRING, -- the Session ID context
- * Verify_result [ 5 ] EXPLICIT INTEGER, -- X509_V_... code for `Peer'
- * HostName [ 6 ] EXPLICIT OCTET STRING, -- optional HostName from servername TLS extension
- * PSK_identity_hint [ 7 ] EXPLICIT OCTET STRING, -- optional PSK identity hint
- * PSK_identity [ 8 ] EXPLICIT OCTET STRING, -- optional PSK identity
- * Ticket_lifetime_hint [9] EXPLICIT INTEGER, -- server's lifetime hint for session ticket
- * Ticket [10] EXPLICIT OCTET STRING, -- session ticket (clients only)
- * Compression_meth [11] EXPLICIT OCTET STRING, -- optional compression method
- * SRP_username [ 12 ] EXPLICIT OCTET STRING -- optional SRP username
- * flags [ 13 ] EXPLICIT INTEGER -- optional flags
- * }
- * Look in ssl/ssl_asn1.c for more details
- * I'm using EXPLICIT tags so I can read the damn things using asn1parse :-).
- */
-struct ssl_session_st {
- int ssl_version; /* what ssl version session info is being kept
- * in here? */
- size_t master_key_length;
-
- /* TLSv1.3 early_secret used for external PSKs */
- unsigned char early_secret[EVP_MAX_MD_SIZE];
- /*
- * For <=TLS1.2 this is the master_key. For TLS1.3 this is the resumption
- * PSK
- */
- unsigned char master_key[TLS13_MAX_RESUMPTION_PSK_LENGTH];
- /* session_id - valid? */
- size_t session_id_length;
- unsigned char session_id[SSL_MAX_SSL_SESSION_ID_LENGTH];
- /*
- * this is used to determine whether the session is being reused in the
- * appropriate context. It is up to the application to set this, via
- * SSL_new
- */
- size_t sid_ctx_length;
- unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH];
-# ifndef OPENSSL_NO_PSK
- char *psk_identity_hint;
- char *psk_identity;
-# endif
- /*
- * Used to indicate that session resumption is not allowed. Applications
- * can also set this bit for a new session via not_resumable_session_cb
- * to disable session caching and tickets.
- */
- int not_resumable;
- /* This is the cert and type for the other end. */
- X509 *peer;
- int peer_type;
- /* Certificate chain peer sent. */
- STACK_OF(X509) *peer_chain;
- /*
- * when app_verify_callback accepts a session where the peer's
- * certificate is not ok, we must remember the error for session reuse:
- */
- long verify_result; /* only for servers */
- CRYPTO_REF_COUNT references;
- long timeout;
- long time;
- unsigned int compress_meth; /* Need to lookup the method */
- const SSL_CIPHER *cipher;
- unsigned long cipher_id; /* when ASN.1 loaded, this needs to be used to
- * load the 'cipher' structure */
- CRYPTO_EX_DATA ex_data; /* application specific data */
- /*
- * These are used to make removal of session-ids more efficient and to
- * implement a maximum cache size.
- */
- struct ssl_session_st *prev, *next;
-
- struct {
- char *hostname;
- /* RFC4507 info */
- unsigned char *tick; /* Session ticket */
- size_t ticklen; /* Session ticket length */
- /* Session lifetime hint in seconds */
- unsigned long tick_lifetime_hint;
- uint32_t tick_age_add;
- /* Max number of bytes that can be sent as early data */
- uint32_t max_early_data;
- /* The ALPN protocol selected for this session */
- unsigned char *alpn_selected;
- size_t alpn_selected_len;
- /*
- * Maximum Fragment Length as per RFC 4366.
- * If this value does not contain RFC 4366 allowed values (1-4) then
- * either the Maximum Fragment Length Negotiation failed or was not
- * performed at all.
- */
- uint8_t max_fragment_len_mode;
- } ext;
-# ifndef OPENSSL_NO_SRP
- char *srp_username;
-# endif
- unsigned char *ticket_appdata;
- size_t ticket_appdata_len;
- uint32_t flags;
- CRYPTO_RWLOCK *lock;
-};
-
-/* Extended master secret support */
-# define SSL_SESS_FLAG_EXTMS 0x1
-
-# ifndef OPENSSL_NO_SRP
-
-typedef struct srp_ctx_st {
- /* param for all the callbacks */
- void *SRP_cb_arg;
- /* set client Hello login callback */
- int (*TLS_ext_srp_username_callback) (SSL *, int *, void *);
- /* set SRP N/g param callback for verification */
- int (*SRP_verify_param_callback) (SSL *, void *);
- /* set SRP client passwd callback */
- char *(*SRP_give_srp_client_pwd_callback) (SSL *, void *);
- char *login;
- BIGNUM *N, *g, *s, *B, *A;
- BIGNUM *a, *b, *v;
- char *info;
- int strength;
- unsigned long srp_Mask;
-} SRP_CTX;
-
-# endif
-
-typedef enum {
- SSL_EARLY_DATA_NONE = 0,
- SSL_EARLY_DATA_CONNECT_RETRY,
- SSL_EARLY_DATA_CONNECTING,
- SSL_EARLY_DATA_WRITE_RETRY,
- SSL_EARLY_DATA_WRITING,
- SSL_EARLY_DATA_WRITE_FLUSH,
- SSL_EARLY_DATA_UNAUTH_WRITING,
- SSL_EARLY_DATA_FINISHED_WRITING,
- SSL_EARLY_DATA_ACCEPT_RETRY,
- SSL_EARLY_DATA_ACCEPTING,
- SSL_EARLY_DATA_READ_RETRY,
- SSL_EARLY_DATA_READING,
- SSL_EARLY_DATA_FINISHED_READING
-} SSL_EARLY_DATA_STATE;
-
-/*
- * We check that the amount of unreadable early data doesn't exceed
- * max_early_data. max_early_data is given in plaintext bytes. However if it is
- * unreadable then we only know the number of ciphertext bytes. We also don't
- * know how much the overhead should be because it depends on the ciphersuite.
- * We make a small allowance. We assume 5 records of actual data plus the end
- * of early data alert record. Each record has a tag and a content type byte.
- * The longest tag length we know of is EVP_GCM_TLS_TAG_LEN. We don't count the
- * content of the alert record either which is 2 bytes.
- */
-# define EARLY_DATA_CIPHERTEXT_OVERHEAD ((6 * (EVP_GCM_TLS_TAG_LEN + 1)) + 2)
-
-/*
- * The allowance we have between the client's calculated ticket age and our own.
- * We allow for 10 seconds (units are in ms). If a ticket is presented and the
- * client's age calculation is different by more than this than our own then we
- * do not allow that ticket for early_data.
- */
-# define TICKET_AGE_ALLOWANCE (10 * 1000)
-
-#define MAX_COMPRESSIONS_SIZE 255
-
-struct ssl_comp_st {
- int id;
- const char *name;
- COMP_METHOD *method;
-};
-
-typedef struct raw_extension_st {
- /* Raw packet data for the extension */
- PACKET data;
- /* Set to 1 if the extension is present or 0 otherwise */
- int present;
- /* Set to 1 if we have already parsed the extension or 0 otherwise */
- int parsed;
- /* The type of this extension, i.e. a TLSEXT_TYPE_* value */
- unsigned int type;
- /* Track what order extensions are received in (0-based). */
- size_t received_order;
-} RAW_EXTENSION;
-
-typedef struct {
- unsigned int isv2;
- unsigned int legacy_version;
- unsigned char random[SSL3_RANDOM_SIZE];
- size_t session_id_len;
- unsigned char session_id[SSL_MAX_SSL_SESSION_ID_LENGTH];
- size_t dtls_cookie_len;
- unsigned char dtls_cookie[DTLS1_COOKIE_LENGTH];
- PACKET ciphersuites;
- size_t compressions_len;
- unsigned char compressions[MAX_COMPRESSIONS_SIZE];
- PACKET extensions;
- size_t pre_proc_exts_len;
- RAW_EXTENSION *pre_proc_exts;
-} CLIENTHELLO_MSG;
-
-/*
- * Extension index values NOTE: Any updates to these defines should be mirrored
- * with equivalent updates to ext_defs in extensions.c
- */
-typedef enum tlsext_index_en {
- TLSEXT_IDX_renegotiate,
- TLSEXT_IDX_server_name,
- TLSEXT_IDX_max_fragment_length,
- TLSEXT_IDX_srp,
- TLSEXT_IDX_ec_point_formats,
- TLSEXT_IDX_supported_groups,
- TLSEXT_IDX_session_ticket,
- TLSEXT_IDX_status_request,
- TLSEXT_IDX_next_proto_neg,
- TLSEXT_IDX_application_layer_protocol_negotiation,
- TLSEXT_IDX_use_srtp,
- TLSEXT_IDX_encrypt_then_mac,
- TLSEXT_IDX_signed_certificate_timestamp,
- TLSEXT_IDX_extended_master_secret,
- TLSEXT_IDX_signature_algorithms_cert,
- TLSEXT_IDX_post_handshake_auth,
- TLSEXT_IDX_signature_algorithms,
- TLSEXT_IDX_supported_versions,
- TLSEXT_IDX_psk_kex_modes,
- TLSEXT_IDX_key_share,
- TLSEXT_IDX_cookie,
- TLSEXT_IDX_cryptopro_bug,
- TLSEXT_IDX_early_data,
- TLSEXT_IDX_certificate_authorities,
- TLSEXT_IDX_padding,
- TLSEXT_IDX_psk,
- /* Dummy index - must always be the last entry */
- TLSEXT_IDX_num_builtins
-} TLSEXT_INDEX;
-
-DEFINE_LHASH_OF(SSL_SESSION);
-/* Needed in ssl_cert.c */
-DEFINE_LHASH_OF(X509_NAME);
-
-# define TLSEXT_KEYNAME_LENGTH 16
-# define TLSEXT_TICK_KEY_LENGTH 32
-
-typedef struct ssl_ctx_ext_secure_st {
- unsigned char tick_hmac_key[TLSEXT_TICK_KEY_LENGTH];
- unsigned char tick_aes_key[TLSEXT_TICK_KEY_LENGTH];
-} SSL_CTX_EXT_SECURE;
-
-struct ssl_ctx_st {
- const SSL_METHOD *method;
- STACK_OF(SSL_CIPHER) *cipher_list;
- /* same as above but sorted for lookup */
- STACK_OF(SSL_CIPHER) *cipher_list_by_id;
- /* TLSv1.3 specific ciphersuites */
- STACK_OF(SSL_CIPHER) *tls13_ciphersuites;
- struct x509_store_st /* X509_STORE */ *cert_store;
- LHASH_OF(SSL_SESSION) *sessions;
- /*
- * Most session-ids that will be cached, default is
- * SSL_SESSION_CACHE_MAX_SIZE_DEFAULT. 0 is unlimited.
- */
- size_t session_cache_size;
- struct ssl_session_st *session_cache_head;
- struct ssl_session_st *session_cache_tail;
- /*
- * This can have one of 2 values, ored together, SSL_SESS_CACHE_CLIENT,
- * SSL_SESS_CACHE_SERVER, Default is SSL_SESSION_CACHE_SERVER, which
- * means only SSL_accept will cache SSL_SESSIONS.
- */
- uint32_t session_cache_mode;
- /*
- * If timeout is not 0, it is the default timeout value set when
- * SSL_new() is called. This has been put in to make life easier to set
- * things up
- */
- long session_timeout;
- /*
- * If this callback is not null, it will be called each time a session id
- * is added to the cache. If this function returns 1, it means that the
- * callback will do a SSL_SESSION_free() when it has finished using it.
- * Otherwise, on 0, it means the callback has finished with it. If
- * remove_session_cb is not null, it will be called when a session-id is
- * removed from the cache. After the call, OpenSSL will
- * SSL_SESSION_free() it.
- */
- int (*new_session_cb) (struct ssl_st *ssl, SSL_SESSION *sess);
- void (*remove_session_cb) (struct ssl_ctx_st *ctx, SSL_SESSION *sess);
- SSL_SESSION *(*get_session_cb) (struct ssl_st *ssl,
- const unsigned char *data, int len,
- int *copy);
- struct {
- TSAN_QUALIFIER int sess_connect; /* SSL new conn - started */
- TSAN_QUALIFIER int sess_connect_renegotiate; /* SSL reneg - requested */
- TSAN_QUALIFIER int sess_connect_good; /* SSL new conne/reneg - finished */
- TSAN_QUALIFIER int sess_accept; /* SSL new accept - started */
- TSAN_QUALIFIER int sess_accept_renegotiate; /* SSL reneg - requested */
- TSAN_QUALIFIER int sess_accept_good; /* SSL accept/reneg - finished */
- TSAN_QUALIFIER int sess_miss; /* session lookup misses */
- TSAN_QUALIFIER int sess_timeout; /* reuse attempt on timeouted session */
- TSAN_QUALIFIER int sess_cache_full; /* session removed due to full cache */
- TSAN_QUALIFIER int sess_hit; /* session reuse actually done */
- TSAN_QUALIFIER int sess_cb_hit; /* session-id that was not in
- * the cache was passed back via
- * the callback. This indicates
- * that the application is
- * supplying session-id's from
- * other processes - spooky
- * :-) */
- } stats;
-
- CRYPTO_REF_COUNT references;
-
- /* if defined, these override the X509_verify_cert() calls */
- int (*app_verify_callback) (X509_STORE_CTX *, void *);
- void *app_verify_arg;
- /*
- * before OpenSSL 0.9.7, 'app_verify_arg' was ignored
- * ('app_verify_callback' was called with just one argument)
- */
-
- /* Default password callback. */
- pem_password_cb *default_passwd_callback;
-
- /* Default password callback user data. */
- void *default_passwd_callback_userdata;
-
- /* get client cert callback */
- int (*client_cert_cb) (SSL *ssl, X509 **x509, EVP_PKEY **pkey);
-
- /* cookie generate callback */
- int (*app_gen_cookie_cb) (SSL *ssl, unsigned char *cookie,
- unsigned int *cookie_len);
-
- /* verify cookie callback */
- int (*app_verify_cookie_cb) (SSL *ssl, const unsigned char *cookie,
- unsigned int cookie_len);
-
- /* TLS1.3 app-controlled cookie generate callback */
- int (*gen_stateless_cookie_cb) (SSL *ssl, unsigned char *cookie,
- size_t *cookie_len);
-
- /* TLS1.3 verify app-controlled cookie callback */
- int (*verify_stateless_cookie_cb) (SSL *ssl, const unsigned char *cookie,
- size_t cookie_len);
-
- CRYPTO_EX_DATA ex_data;
-
- const EVP_MD *md5; /* For SSLv3/TLSv1 'ssl3-md5' */
- const EVP_MD *sha1; /* For SSLv3/TLSv1 'ssl3->sha1' */
-
- STACK_OF(X509) *extra_certs;
- STACK_OF(SSL_COMP) *comp_methods; /* stack of SSL_COMP, SSLv3/TLSv1 */
-
- /* Default values used when no per-SSL value is defined follow */
-
- /* used if SSL's info_callback is NULL */
- void (*info_callback) (const SSL *ssl, int type, int val);
-
- /*
- * What we put in certificate_authorities extension for TLS 1.3
- * (ClientHello and CertificateRequest) or just client cert requests for
- * earlier versions. If client_ca_names is populated then it is only used
- * for client cert requests, and in preference to ca_names.
- */
- STACK_OF(X509_NAME) *ca_names;
- STACK_OF(X509_NAME) *client_ca_names;
-
- /*
- * Default values to use in SSL structures follow (these are copied by
- * SSL_new)
- */
-
- uint32_t options;
- uint32_t mode;
- int min_proto_version;
- int max_proto_version;
- size_t max_cert_list;
-
- struct cert_st /* CERT */ *cert;
- int read_ahead;
-
- /* callback that allows applications to peek at protocol messages */
- void (*msg_callback) (int write_p, int version, int content_type,
- const void *buf, size_t len, SSL *ssl, void *arg);
- void *msg_callback_arg;
-
- uint32_t verify_mode;
- size_t sid_ctx_length;
- unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH];
- /* called 'verify_callback' in the SSL */
- int (*default_verify_callback) (int ok, X509_STORE_CTX *ctx);
-
- /* Default generate session ID callback. */
- GEN_SESSION_CB generate_session_id;
-
- X509_VERIFY_PARAM *param;
-
- int quiet_shutdown;
-
-# ifndef OPENSSL_NO_CT
- CTLOG_STORE *ctlog_store; /* CT Log Store */
- /*
- * Validates that the SCTs (Signed Certificate Timestamps) are sufficient.
- * If they are not, the connection should be aborted.
- */
- ssl_ct_validation_cb ct_validation_callback;
- void *ct_validation_callback_arg;
-# endif
-
- /*
- * If we're using more than one pipeline how should we divide the data
- * up between the pipes?
- */
- size_t split_send_fragment;
- /*
- * Maximum amount of data to send in one fragment. actual record size can
- * be more than this due to padding and MAC overheads.
- */
- size_t max_send_fragment;
-
- /* Up to how many pipelines should we use? If 0 then 1 is assumed */
- size_t max_pipelines;
-
- /* The default read buffer length to use (0 means not set) */
- size_t default_read_buf_len;
-
-# ifndef OPENSSL_NO_ENGINE
- /*
- * Engine to pass requests for client certs to
- */
- ENGINE *client_cert_engine;
-# endif
-
- /* ClientHello callback. Mostly for extensions, but not entirely. */
- SSL_client_hello_cb_fn client_hello_cb;
- void *client_hello_cb_arg;
-
- /* TLS extensions. */
- struct {
- /* TLS extensions servername callback */
- int (*servername_cb) (SSL *, int *, void *);
- void *servername_arg;
- /* RFC 4507 session ticket keys */
- unsigned char tick_key_name[TLSEXT_KEYNAME_LENGTH];
- SSL_CTX_EXT_SECURE *secure;
- /* Callback to support customisation of ticket key setting */
- int (*ticket_key_cb) (SSL *ssl,
- unsigned char *name, unsigned char *iv,
- EVP_CIPHER_CTX *ectx, HMAC_CTX *hctx, int enc);
-
- /* certificate status request info */
- /* Callback for status request */
- int (*status_cb) (SSL *ssl, void *arg);
- void *status_arg;
- /* ext status type used for CSR extension (OCSP Stapling) */
- int status_type;
- /* RFC 4366 Maximum Fragment Length Negotiation */
- uint8_t max_fragment_len_mode;
-
-# ifndef OPENSSL_NO_EC
- /* EC extension values inherited by SSL structure */
- size_t ecpointformats_len;
- unsigned char *ecpointformats;
-# endif /* OPENSSL_NO_EC */
-
- size_t supportedgroups_len;
- uint16_t *supportedgroups;
-
- /*
- * ALPN information (we are in the process of transitioning from NPN to
- * ALPN.)
- */
-
- /*-
- * For a server, this contains a callback function that allows the
- * server to select the protocol for the connection.
- * out: on successful return, this must point to the raw protocol
- * name (without the length prefix).
- * outlen: on successful return, this contains the length of |*out|.
- * in: points to the client's list of supported protocols in
- * wire-format.
- * inlen: the length of |in|.
- */
- int (*alpn_select_cb) (SSL *s,
- const unsigned char **out,
- unsigned char *outlen,
- const unsigned char *in,
- unsigned int inlen, void *arg);
- void *alpn_select_cb_arg;
-
- /*
- * For a client, this contains the list of supported protocols in wire
- * format.
- */
- unsigned char *alpn;
- size_t alpn_len;
-
-# ifndef OPENSSL_NO_NEXTPROTONEG
- /* Next protocol negotiation information */
-
- /*
- * For a server, this contains a callback function by which the set of
- * advertised protocols can be provided.
- */
- SSL_CTX_npn_advertised_cb_func npn_advertised_cb;
- void *npn_advertised_cb_arg;
- /*
- * For a client, this contains a callback function that selects the next
- * protocol from the list provided by the server.
- */
- SSL_CTX_npn_select_cb_func npn_select_cb;
- void *npn_select_cb_arg;
-# endif
-
- unsigned char cookie_hmac_key[SHA256_DIGEST_LENGTH];
- } ext;
-
-# ifndef OPENSSL_NO_PSK
- SSL_psk_client_cb_func psk_client_callback;
- SSL_psk_server_cb_func psk_server_callback;
-# endif
- SSL_psk_find_session_cb_func psk_find_session_cb;
- SSL_psk_use_session_cb_func psk_use_session_cb;
-
-# ifndef OPENSSL_NO_SRP
- SRP_CTX srp_ctx; /* ctx for SRP authentication */
-# endif
-
- /* Shared DANE context */
- struct dane_ctx_st dane;
-
-# ifndef OPENSSL_NO_SRTP
- /* SRTP profiles we are willing to do from RFC 5764 */
- STACK_OF(SRTP_PROTECTION_PROFILE) *srtp_profiles;
-# endif
- /*
- * Callback for disabling session caching and ticket support on a session
- * basis, depending on the chosen cipher.
- */
- int (*not_resumable_session_cb) (SSL *ssl, int is_forward_secure);
-
- CRYPTO_RWLOCK *lock;
-
- /*
- * Callback for logging key material for use with debugging tools like
- * Wireshark. The callback should log `line` followed by a newline.
- */
- SSL_CTX_keylog_cb_func keylog_callback;
-
- /*
- * The maximum number of bytes advertised in session tickets that can be
- * sent as early data.
- */
- uint32_t max_early_data;
-
- /*
- * The maximum number of bytes of early data that a server will tolerate
- * (which should be at least as much as max_early_data).
- */
- uint32_t recv_max_early_data;
-
- /* TLS1.3 padding callback */
- size_t (*record_padding_cb)(SSL *s, int type, size_t len, void *arg);
- void *record_padding_arg;
- size_t block_padding;
-
- /* Session ticket appdata */
- SSL_CTX_generate_session_ticket_fn generate_ticket_cb;
- SSL_CTX_decrypt_session_ticket_fn decrypt_ticket_cb;
- void *ticket_cb_data;
-
- /* The number of TLS1.3 tickets to automatically send */
- size_t num_tickets;
-
- /* Callback to determine if early_data is acceptable or not */
- SSL_allow_early_data_cb_fn allow_early_data_cb;
- void *allow_early_data_cb_data;
-
- /* Do we advertise Post-handshake auth support? */
- int pha_enabled;
-
- /* Callback for SSL async handling */
- SSL_async_callback_fn async_cb;
- void *async_cb_arg;
-};
-
-typedef struct cert_pkey_st CERT_PKEY;
-
-struct ssl_st {
- /*
- * protocol version (one of SSL2_VERSION, SSL3_VERSION, TLS1_VERSION,
- * DTLS1_VERSION)
- */
- int version;
- /* SSLv3 */
- const SSL_METHOD *method;
- /*
- * There are 2 BIO's even though they are normally both the same. This
- * is so data can be read and written to different handlers
- */
- /* used by SSL_read */
- BIO *rbio;
- /* used by SSL_write */
- BIO *wbio;
- /* used during session-id reuse to concatenate messages */
- BIO *bbio;
- /*
- * This holds a variable that indicates what we were doing when a 0 or -1
- * is returned. This is needed for non-blocking IO so we know what
- * request needs re-doing when in SSL_accept or SSL_connect
- */
- int rwstate;
- int (*handshake_func) (SSL *);
- /*
- * Imagine that here's a boolean member "init" that is switched as soon
- * as SSL_set_{accept/connect}_state is called for the first time, so
- * that "state" and "handshake_func" are properly initialized. But as
- * handshake_func is == 0 until then, we use this test instead of an
- * "init" member.
- */
- /* are we the server side? */
- int server;
- /*
- * Generate a new session or reuse an old one.
- * NB: For servers, the 'new' session may actually be a previously
- * cached session or even the previous session unless
- * SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION is set
- */
- int new_session;
- /* don't send shutdown packets */
- int quiet_shutdown;
- /* we have shut things down, 0x01 sent, 0x02 for received */
- int shutdown;
- /* where we are */
- OSSL_STATEM statem;
- SSL_EARLY_DATA_STATE early_data_state;
- BUF_MEM *init_buf; /* buffer used during init */
- void *init_msg; /* pointer to handshake message body, set by
- * ssl3_get_message() */
- size_t init_num; /* amount read/written */
- size_t init_off; /* amount read/written */
-
- struct {
- long flags;
- size_t read_mac_secret_size;
- unsigned char read_mac_secret[EVP_MAX_MD_SIZE];
- size_t write_mac_secret_size;
- unsigned char write_mac_secret[EVP_MAX_MD_SIZE];
- unsigned char server_random[SSL3_RANDOM_SIZE];
- unsigned char client_random[SSL3_RANDOM_SIZE];
- /* flags for countermeasure against known-IV weakness */
- int need_empty_fragments;
- int empty_fragment_done;
- /* used during startup, digest all incoming/outgoing packets */
- BIO *handshake_buffer;
- /*
- * When handshake digest is determined, buffer is hashed and
- * freed and MD_CTX for the required digest is stored here.
- */
- EVP_MD_CTX *handshake_dgst;
- /*
- * Set whenever an expected ChangeCipherSpec message is processed.
- * Unset when the peer's Finished message is received.
- * Unexpected ChangeCipherSpec messages trigger a fatal alert.
- */
- int change_cipher_spec;
- int warn_alert;
- int fatal_alert;
- /*
- * we allow one fatal and one warning alert to be outstanding, send close
- * alert via the warning alert
- */
- int alert_dispatch;
- unsigned char send_alert[2];
- /*
- * This flag is set when we should renegotiate ASAP, basically when there
- * is no more data in the read or write buffers
- */
- int renegotiate;
- int total_renegotiations;
- int num_renegotiations;
- int in_read_app_data;
- struct {
- /* actually only need to be 16+20 for SSLv3 and 12 for TLS */
- unsigned char finish_md[EVP_MAX_MD_SIZE * 2];
- size_t finish_md_len;
- unsigned char peer_finish_md[EVP_MAX_MD_SIZE * 2];
- size_t peer_finish_md_len;
- size_t message_size;
- int message_type;
- /* used to hold the new cipher we are going to use */
- const SSL_CIPHER *new_cipher;
-# if !defined(OPENSSL_NO_EC) || !defined(OPENSSL_NO_DH)
- EVP_PKEY *pkey; /* holds short lived DH/ECDH key */
-# endif
- /* used for certificate requests */
- int cert_req;
- /* Certificate types in certificate request message. */
- uint8_t *ctype;
- size_t ctype_len;
- /* Certificate authorities list peer sent */
- STACK_OF(X509_NAME) *peer_ca_names;
- size_t key_block_length;
- unsigned char *key_block;
- const EVP_CIPHER *new_sym_enc;
- const EVP_MD *new_hash;
- int new_mac_pkey_type;
- size_t new_mac_secret_size;
-# ifndef OPENSSL_NO_COMP
- const SSL_COMP *new_compression;
-# else
- char *new_compression;
-# endif
- int cert_request;
- /* Raw values of the cipher list from a client */
- unsigned char *ciphers_raw;
- size_t ciphers_rawlen;
- /* Temporary storage for premaster secret */
- unsigned char *pms;
- size_t pmslen;
-# ifndef OPENSSL_NO_PSK
- /* Temporary storage for PSK key */
- unsigned char *psk;
- size_t psklen;
-# endif
- /* Signature algorithm we actually use */
- const struct sigalg_lookup_st *sigalg;
- /* Pointer to certificate we use */
- CERT_PKEY *cert;
- /*
- * signature algorithms peer reports: e.g. supported signature
- * algorithms extension for server or as part of a certificate
- * request for client.
- * Keep track of the algorithms for TLS and X.509 usage separately.
- */
- uint16_t *peer_sigalgs;
- uint16_t *peer_cert_sigalgs;
- /* Size of above arrays */
- size_t peer_sigalgslen;
- size_t peer_cert_sigalgslen;
- /* Sigalg peer actually uses */
- const struct sigalg_lookup_st *peer_sigalg;
- /*
- * Set if corresponding CERT_PKEY can be used with current
- * SSL session: e.g. appropriate curve, signature algorithms etc.
- * If zero it can't be used at all.
- */
- uint32_t valid_flags[SSL_PKEY_NUM];
- /*
- * For servers the following masks are for the key and auth algorithms
- * that are supported by the certs below. For clients they are masks of
- * *disabled* algorithms based on the current session.
- */
- uint32_t mask_k;
- uint32_t mask_a;
- /*
- * The following are used by the client to see if a cipher is allowed or
- * not. It contains the minimum and maximum version the client's using
- * based on what it knows so far.
- */
- int min_ver;
- int max_ver;
- } tmp;
-
- /* Connection binding to prevent renegotiation attacks */
- unsigned char previous_client_finished[EVP_MAX_MD_SIZE];
- size_t previous_client_finished_len;
- unsigned char previous_server_finished[EVP_MAX_MD_SIZE];
- size_t previous_server_finished_len;
- int send_connection_binding; /* TODOEKR */
-
-# ifndef OPENSSL_NO_NEXTPROTONEG
- /*
- * Set if we saw the Next Protocol Negotiation extension from our peer.
- */
- int npn_seen;
-# endif
-
- /*
- * ALPN information (we are in the process of transitioning from NPN to
- * ALPN.)
- */
-
- /*
- * In a server these point to the selected ALPN protocol after the
- * ClientHello has been processed. In a client these contain the protocol
- * that the server selected once the ServerHello has been processed.
- */
- unsigned char *alpn_selected;
- size_t alpn_selected_len;
- /* used by the server to know what options were proposed */
- unsigned char *alpn_proposed;
- size_t alpn_proposed_len;
- /* used by the client to know if it actually sent alpn */
- int alpn_sent;
-
-# ifndef OPENSSL_NO_EC
- /*
- * This is set to true if we believe that this is a version of Safari
- * running on OS X 10.6 or newer. We wish to know this because Safari on
- * 10.8 .. 10.8.3 has broken ECDHE-ECDSA support.
- */
- char is_probably_safari;
-# endif /* !OPENSSL_NO_EC */
-
- /* For clients: peer temporary key */
-# if !defined(OPENSSL_NO_EC) || !defined(OPENSSL_NO_DH)
- /* The group_id for the DH/ECDH key */
- uint16_t group_id;
- EVP_PKEY *peer_tmp;
-# endif
-
- } s3;
-
- struct dtls1_state_st *d1; /* DTLSv1 variables */
- /* callback that allows applications to peek at protocol messages */
- void (*msg_callback) (int write_p, int version, int content_type,
- const void *buf, size_t len, SSL *ssl, void *arg);
- void *msg_callback_arg;
- int hit; /* reusing a previous session */
- X509_VERIFY_PARAM *param;
- /* Per connection DANE state */
- SSL_DANE dane;
- /* crypto */
- STACK_OF(SSL_CIPHER) *peer_ciphers;
- STACK_OF(SSL_CIPHER) *cipher_list;
- STACK_OF(SSL_CIPHER) *cipher_list_by_id;
- /* TLSv1.3 specific ciphersuites */
- STACK_OF(SSL_CIPHER) *tls13_ciphersuites;
- /*
- * These are the ones being used, the ones in SSL_SESSION are the ones to
- * be 'copied' into these ones
- */
- uint32_t mac_flags;
- /*
- * The TLS1.3 secrets.
- */
- unsigned char early_secret[EVP_MAX_MD_SIZE];
- unsigned char handshake_secret[EVP_MAX_MD_SIZE];
- unsigned char master_secret[EVP_MAX_MD_SIZE];
- unsigned char resumption_master_secret[EVP_MAX_MD_SIZE];
- unsigned char client_finished_secret[EVP_MAX_MD_SIZE];
- unsigned char server_finished_secret[EVP_MAX_MD_SIZE];
- unsigned char server_finished_hash[EVP_MAX_MD_SIZE];
- unsigned char handshake_traffic_hash[EVP_MAX_MD_SIZE];
- unsigned char client_app_traffic_secret[EVP_MAX_MD_SIZE];
- unsigned char server_app_traffic_secret[EVP_MAX_MD_SIZE];
- unsigned char exporter_master_secret[EVP_MAX_MD_SIZE];
- unsigned char early_exporter_master_secret[EVP_MAX_MD_SIZE];
- EVP_CIPHER_CTX *enc_read_ctx; /* cryptographic state */
- unsigned char read_iv[EVP_MAX_IV_LENGTH]; /* TLSv1.3 static read IV */
- EVP_MD_CTX *read_hash; /* used for mac generation */
- COMP_CTX *compress; /* compression */
- COMP_CTX *expand; /* uncompress */
- EVP_CIPHER_CTX *enc_write_ctx; /* cryptographic state */
- unsigned char write_iv[EVP_MAX_IV_LENGTH]; /* TLSv1.3 static write IV */
- EVP_MD_CTX *write_hash; /* used for mac generation */
- /* session info */
- /* client cert? */
- /* This is used to hold the server certificate used */
- struct cert_st /* CERT */ *cert;
-
- /*
- * The hash of all messages prior to the CertificateVerify, and the length
- * of that hash.
- */
- unsigned char cert_verify_hash[EVP_MAX_MD_SIZE];
- size_t cert_verify_hash_len;
-
- /* Flag to indicate whether we should send a HelloRetryRequest or not */
- enum {SSL_HRR_NONE = 0, SSL_HRR_PENDING, SSL_HRR_COMPLETE}
- hello_retry_request;
-
- /*
- * the session_id_context is used to ensure sessions are only reused in
- * the appropriate context
- */
- size_t sid_ctx_length;
- unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH];
- /* This can also be in the session once a session is established */
- SSL_SESSION *session;
- /* TLSv1.3 PSK session */
- SSL_SESSION *psksession;
- unsigned char *psksession_id;
- size_t psksession_id_len;
- /* Default generate session ID callback. */
- GEN_SESSION_CB generate_session_id;
- /*
- * The temporary TLSv1.3 session id. This isn't really a session id at all
- * but is a random value sent in the legacy session id field.
- */
- unsigned char tmp_session_id[SSL_MAX_SSL_SESSION_ID_LENGTH];
- size_t tmp_session_id_len;
- /* Used in SSL3 */
- /*
- * 0 don't care about verify failure.
- * 1 fail if verify fails
- */
- uint32_t verify_mode;
- /* fail if callback returns 0 */
- int (*verify_callback) (int ok, X509_STORE_CTX *ctx);
- /* optional informational callback */
- void (*info_callback) (const SSL *ssl, int type, int val);
- /* error bytes to be written */
- int error;
- /* actual code */
- int error_code;
-# ifndef OPENSSL_NO_PSK
- SSL_psk_client_cb_func psk_client_callback;
- SSL_psk_server_cb_func psk_server_callback;
-# endif
- SSL_psk_find_session_cb_func psk_find_session_cb;
- SSL_psk_use_session_cb_func psk_use_session_cb;
-
- SSL_CTX *ctx;
- /* Verified chain of peer */
- STACK_OF(X509) *verified_chain;
- long verify_result;
- /* extra application data */
- CRYPTO_EX_DATA ex_data;
- /*
- * What we put in certificate_authorities extension for TLS 1.3
- * (ClientHello and CertificateRequest) or just client cert requests for
- * earlier versions. If client_ca_names is populated then it is only used
- * for client cert requests, and in preference to ca_names.
- */
- STACK_OF(X509_NAME) *ca_names;
- STACK_OF(X509_NAME) *client_ca_names;
- CRYPTO_REF_COUNT references;
- /* protocol behaviour */
- uint32_t options;
- /* API behaviour */
- uint32_t mode;
- int min_proto_version;
- int max_proto_version;
- size_t max_cert_list;
- int first_packet;
- /*
- * What was passed in ClientHello.legacy_version. Used for RSA pre-master
- * secret and SSLv3/TLS (<=1.2) rollback check
- */
- int client_version;
- /*
- * If we're using more than one pipeline how should we divide the data
- * up between the pipes?
- */
- size_t split_send_fragment;
- /*
- * Maximum amount of data to send in one fragment. actual record size can
- * be more than this due to padding and MAC overheads.
- */
- size_t max_send_fragment;
- /* Up to how many pipelines should we use? If 0 then 1 is assumed */
- size_t max_pipelines;
-
- struct {
- /* Built-in extension flags */
- uint8_t extflags[TLSEXT_IDX_num_builtins];
- /* TLS extension debug callback */
- void (*debug_cb)(SSL *s, int client_server, int type,
- const unsigned char *data, int len, void *arg);
- void *debug_arg;
- char *hostname;
- /* certificate status request info */
- /* Status type or -1 if no status type */
- int status_type;
- /* Raw extension data, if seen */
- unsigned char *scts;
- /* Length of raw extension data, if seen */
- uint16_t scts_len;
- /* Expect OCSP CertificateStatus message */
- int status_expected;
-
- struct {
- /* OCSP status request only */
- STACK_OF(OCSP_RESPID) *ids;
- X509_EXTENSIONS *exts;
- /* OCSP response received or to be sent */
- unsigned char *resp;
- size_t resp_len;
- } ocsp;
-
- /* RFC4507 session ticket expected to be received or sent */
- int ticket_expected;
-# ifndef OPENSSL_NO_EC
- size_t ecpointformats_len;
- /* our list */
- unsigned char *ecpointformats;
-
- size_t peer_ecpointformats_len;
- /* peer's list */
- unsigned char *peer_ecpointformats;
-# endif /* OPENSSL_NO_EC */
- size_t supportedgroups_len;
- /* our list */
- uint16_t *supportedgroups;
-
- size_t peer_supportedgroups_len;
- /* peer's list */
- uint16_t *peer_supportedgroups;
-
- /* TLS Session Ticket extension override */
- TLS_SESSION_TICKET_EXT *session_ticket;
- /* TLS Session Ticket extension callback */
- tls_session_ticket_ext_cb_fn session_ticket_cb;
- void *session_ticket_cb_arg;
- /* TLS pre-shared secret session resumption */
- tls_session_secret_cb_fn session_secret_cb;
- void *session_secret_cb_arg;
- /*
- * For a client, this contains the list of supported protocols in wire
- * format.
- */
- unsigned char *alpn;
- size_t alpn_len;
- /*
- * Next protocol negotiation. For the client, this is the protocol that
- * we sent in NextProtocol and is set when handling ServerHello
- * extensions. For a server, this is the client's selected_protocol from
- * NextProtocol and is set when handling the NextProtocol message, before
- * the Finished message.
- */
- unsigned char *npn;
- size_t npn_len;
-
- /* The available PSK key exchange modes */
- int psk_kex_mode;
-
- /* Set to one if we have negotiated ETM */
- int use_etm;
-
- /* Are we expecting to receive early data? */
- int early_data;
- /* Is the session suitable for early data? */
- int early_data_ok;
-
- /* May be sent by a server in HRR. Must be echoed back in ClientHello */
- unsigned char *tls13_cookie;
- size_t tls13_cookie_len;
- /* Have we received a cookie from the client? */
- int cookieok;
-
- /*
- * Maximum Fragment Length as per RFC 4366.
- * If this member contains one of the allowed values (1-4)
- * then we should include Maximum Fragment Length Negotiation
- * extension in Client Hello.
- * Please note that value of this member does not have direct
- * effect. The actual (binding) value is stored in SSL_SESSION,
- * as this extension is optional on server side.
- */
- uint8_t max_fragment_len_mode;
-
- /*
- * On the client side the number of ticket identities we sent in the
- * ClientHello. On the server side the identity of the ticket we
- * selected.
- */
- int tick_identity;
- } ext;
-
- /*
- * Parsed form of the ClientHello, kept around across client_hello_cb
- * calls.
- */
- CLIENTHELLO_MSG *clienthello;
-
- /*-
- * no further mod of servername
- * 0 : call the servername extension callback.
- * 1 : prepare 2, allow last ack just after in server callback.
- * 2 : don't call servername callback, no ack in server hello
- */
- int servername_done;
-# ifndef OPENSSL_NO_CT
- /*
- * Validates that the SCTs (Signed Certificate Timestamps) are sufficient.
- * If they are not, the connection should be aborted.
- */
- ssl_ct_validation_cb ct_validation_callback;
- /* User-supplied argument that is passed to the ct_validation_callback */
- void *ct_validation_callback_arg;
- /*
- * Consolidated stack of SCTs from all sources.
- * Lazily populated by CT_get_peer_scts(SSL*)
- */
- STACK_OF(SCT) *scts;
- /* Have we attempted to find/parse SCTs yet? */
- int scts_parsed;
-# endif
- SSL_CTX *session_ctx; /* initial ctx, used to store sessions */
-# ifndef OPENSSL_NO_SRTP
- /* What we'll do */
- STACK_OF(SRTP_PROTECTION_PROFILE) *srtp_profiles;
- /* What's been chosen */
- SRTP_PROTECTION_PROFILE *srtp_profile;
-# endif
- /*-
- * 1 if we are renegotiating.
- * 2 if we are a server and are inside a handshake
- * (i.e. not just sending a HelloRequest)
- */
- int renegotiate;
- /* If sending a KeyUpdate is pending */
- int key_update;
- /* Post-handshake authentication state */
- SSL_PHA_STATE post_handshake_auth;
- int pha_enabled;
- uint8_t* pha_context;
- size_t pha_context_len;
- int certreqs_sent;
- EVP_MD_CTX *pha_dgst; /* this is just the digest through ClientFinished */
-
-# ifndef OPENSSL_NO_SRP
- /* ctx for SRP authentication */
- SRP_CTX srp_ctx;
-# endif
- /*
- * Callback for disabling session caching and ticket support on a session
- * basis, depending on the chosen cipher.
- */
- int (*not_resumable_session_cb) (SSL *ssl, int is_forward_secure);
- RECORD_LAYER rlayer;
- /* Default password callback. */
- pem_password_cb *default_passwd_callback;
- /* Default password callback user data. */
- void *default_passwd_callback_userdata;
- /* Async Job info */
- ASYNC_JOB *job;
- ASYNC_WAIT_CTX *waitctx;
- size_t asyncrw;
-
- /*
- * The maximum number of bytes advertised in session tickets that can be
- * sent as early data.
- */
- uint32_t max_early_data;
- /*
- * The maximum number of bytes of early data that a server will tolerate
- * (which should be at least as much as max_early_data).
- */
- uint32_t recv_max_early_data;
-
- /*
- * The number of bytes of early data received so far. If we accepted early
- * data then this is a count of the plaintext bytes. If we rejected it then
- * this is a count of the ciphertext bytes.
- */
- uint32_t early_data_count;
-
- /* TLS1.3 padding callback */
- size_t (*record_padding_cb)(SSL *s, int type, size_t len, void *arg);
- void *record_padding_arg;
- size_t block_padding;
-
- CRYPTO_RWLOCK *lock;
-
- /* The number of TLS1.3 tickets to automatically send */
- size_t num_tickets;
- /* The number of TLS1.3 tickets actually sent so far */
- size_t sent_tickets;
- /* The next nonce value to use when we send a ticket on this connection */
- uint64_t next_ticket_nonce;
-
- /* Callback to determine if early_data is acceptable or not */
- SSL_allow_early_data_cb_fn allow_early_data_cb;
- void *allow_early_data_cb_data;
-
- /* Callback for SSL async handling */
- SSL_async_callback_fn async_cb;
- void *async_cb_arg;
-
- /*
- * Signature algorithms shared by client and server: cached because these
- * are used most often.
- */
- const struct sigalg_lookup_st **shared_sigalgs;
- size_t shared_sigalgslen;
-};
-
-/*
- * Structure containing table entry of values associated with the signature
- * algorithms (signature scheme) extension
-*/
-typedef struct sigalg_lookup_st {
- /* TLS 1.3 signature scheme name */
- const char *name;
- /* Raw value used in extension */
- uint16_t sigalg;
- /* NID of hash algorithm or NID_undef if no hash */
- int hash;
- /* Index of hash algorithm or -1 if no hash algorithm */
- int hash_idx;
- /* NID of signature algorithm */
- int sig;
- /* Index of signature algorithm */
- int sig_idx;
- /* Combined hash and signature NID, if any */
- int sigandhash;
- /* Required public key curve (ECDSA only) */
- int curve;
-} SIGALG_LOOKUP;
-
-typedef struct tls_group_info_st {
- int nid; /* Curve NID */
- int secbits; /* Bits of security (from SP800-57) */
- uint32_t flags; /* For group type and applicable TLS versions */
- uint16_t group_id; /* Group ID */
-} TLS_GROUP_INFO;
-
-/* flags values */
-# define TLS_GROUP_TYPE 0x0000000FU /* Mask for group type */
-# define TLS_GROUP_CURVE_PRIME 0x00000001U
-# define TLS_GROUP_CURVE_CHAR2 0x00000002U
-# define TLS_GROUP_CURVE_CUSTOM 0x00000004U
-# define TLS_GROUP_FFDHE 0x00000008U
-# define TLS_GROUP_ONLY_FOR_TLS1_3 0x00000010U
-
-# define TLS_GROUP_FFDHE_FOR_TLS1_3 (TLS_GROUP_FFDHE|TLS_GROUP_ONLY_FOR_TLS1_3)
-
-/*
- * Structure containing table entry of certificate info corresponding to
- * CERT_PKEY entries
- */
-typedef struct {
- int nid; /* NID of public key algorithm */
- uint32_t amask; /* authmask corresponding to key type */
-} SSL_CERT_LOOKUP;
-
-/* DTLS structures */
-
-# ifndef OPENSSL_NO_SCTP
-# define DTLS1_SCTP_AUTH_LABEL "EXPORTER_DTLS_OVER_SCTP"
-# endif
-
-/* Max MTU overhead we know about so far is 40 for IPv6 + 8 for UDP */
-# define DTLS1_MAX_MTU_OVERHEAD 48
-
-/*
- * Flag used in message reuse to indicate the buffer contains the record
- * header as well as the handshake message header.
- */
-# define DTLS1_SKIP_RECORD_HEADER 2
-
-struct dtls1_retransmit_state {
- EVP_CIPHER_CTX *enc_write_ctx; /* cryptographic state */
- EVP_MD_CTX *write_hash; /* used for mac generation */
- COMP_CTX *compress; /* compression */
- SSL_SESSION *session;
- unsigned short epoch;
-};
-
-struct hm_header_st {
- unsigned char type;
- size_t msg_len;
- unsigned short seq;
- size_t frag_off;
- size_t frag_len;
- unsigned int is_ccs;
- struct dtls1_retransmit_state saved_retransmit_state;
-};
-
-struct dtls1_timeout_st {
- /* Number of read timeouts so far */
- unsigned int read_timeouts;
- /* Number of write timeouts so far */
- unsigned int write_timeouts;
- /* Number of alerts received so far */
- unsigned int num_alerts;
-};
-
-typedef struct hm_fragment_st {
- struct hm_header_st msg_header;
- unsigned char *fragment;
- unsigned char *reassembly;
-} hm_fragment;
-
-typedef struct pqueue_st pqueue;
-typedef struct pitem_st pitem;
-
-struct pitem_st {
- unsigned char priority[8]; /* 64-bit value in big-endian encoding */
- void *data;
- pitem *next;
-};
-
-typedef struct pitem_st *piterator;
-
-pitem *pitem_new(unsigned char *prio64be, void *data);
-void pitem_free(pitem *item);
-pqueue *pqueue_new(void);
-void pqueue_free(pqueue *pq);
-pitem *pqueue_insert(pqueue *pq, pitem *item);
-pitem *pqueue_peek(pqueue *pq);
-pitem *pqueue_pop(pqueue *pq);
-pitem *pqueue_find(pqueue *pq, unsigned char *prio64be);
-pitem *pqueue_iterator(pqueue *pq);
-pitem *pqueue_next(piterator *iter);
-size_t pqueue_size(pqueue *pq);
-
-typedef struct dtls1_state_st {
- unsigned char cookie[DTLS1_COOKIE_LENGTH];
- size_t cookie_len;
- unsigned int cookie_verified;
- /* handshake message numbers */
- unsigned short handshake_write_seq;
- unsigned short next_handshake_write_seq;
- unsigned short handshake_read_seq;
- /* Buffered handshake messages */
- pqueue *buffered_messages;
- /* Buffered (sent) handshake records */
- pqueue *sent_messages;
- size_t link_mtu; /* max on-the-wire DTLS packet size */
- size_t mtu; /* max DTLS packet size */
- struct hm_header_st w_msg_hdr;
- struct hm_header_st r_msg_hdr;
- struct dtls1_timeout_st timeout;
- /*
- * Indicates when the last handshake msg sent will timeout
- */
- struct timeval next_timeout;
- /* Timeout duration */
- unsigned int timeout_duration_us;
-
- unsigned int retransmitting;
-# ifndef OPENSSL_NO_SCTP
- int shutdown_received;
-# endif
-
- DTLS_timer_cb timer_cb;
-
-} DTLS1_STATE;
-
-# ifndef OPENSSL_NO_EC
-/*
- * From ECC-TLS draft, used in encoding the curve type in ECParameters
- */
-# define EXPLICIT_PRIME_CURVE_TYPE 1
-# define EXPLICIT_CHAR2_CURVE_TYPE 2
-# define NAMED_CURVE_TYPE 3
-# endif /* OPENSSL_NO_EC */
-
-struct cert_pkey_st {
- X509 *x509;
- EVP_PKEY *privatekey;
- /* Chain for this certificate */
- STACK_OF(X509) *chain;
- /*-
- * serverinfo data for this certificate. The data is in TLS Extension
- * wire format, specifically it's a series of records like:
- * uint16_t extension_type; // (RFC 5246, 7.4.1.4, Extension)
- * uint16_t length;
- * uint8_t data[length];
- */
- unsigned char *serverinfo;
- size_t serverinfo_length;
-};
-/* Retrieve Suite B flags */
-# define tls1_suiteb(s) (s->cert->cert_flags & SSL_CERT_FLAG_SUITEB_128_LOS)
-/* Uses to check strict mode: suite B modes are always strict */
-# define SSL_CERT_FLAGS_CHECK_TLS_STRICT \
- (SSL_CERT_FLAG_SUITEB_128_LOS|SSL_CERT_FLAG_TLS_STRICT)
-
-typedef enum {
- ENDPOINT_CLIENT = 0,
- ENDPOINT_SERVER,
- ENDPOINT_BOTH
-} ENDPOINT;
-
-
-typedef struct {
- unsigned short ext_type;
- ENDPOINT role;
- /* The context which this extension applies to */
- unsigned int context;
- /*
- * Per-connection flags relating to this extension type: not used if
- * part of an SSL_CTX structure.
- */
- uint32_t ext_flags;
- SSL_custom_ext_add_cb_ex add_cb;
- SSL_custom_ext_free_cb_ex free_cb;
- void *add_arg;
- SSL_custom_ext_parse_cb_ex parse_cb;
- void *parse_arg;
-} custom_ext_method;
-
-/* ext_flags values */
-
-/*
- * Indicates an extension has been received. Used to check for unsolicited or
- * duplicate extensions.
- */
-# define SSL_EXT_FLAG_RECEIVED 0x1
-/*
- * Indicates an extension has been sent: used to enable sending of
- * corresponding ServerHello extension.
- */
-# define SSL_EXT_FLAG_SENT 0x2
-
-typedef struct {
- custom_ext_method *meths;
- size_t meths_count;
-} custom_ext_methods;
-
-typedef struct cert_st {
- /* Current active set */
- /*
- * ALWAYS points to an element of the pkeys array
- * Probably it would make more sense to store
- * an index, not a pointer.
- */
- CERT_PKEY *key;
-# ifndef OPENSSL_NO_DH
- EVP_PKEY *dh_tmp;
- DH *(*dh_tmp_cb) (SSL *ssl, int is_export, int keysize);
- int dh_tmp_auto;
-# endif
- /* Flags related to certificates */
- uint32_t cert_flags;
- CERT_PKEY pkeys[SSL_PKEY_NUM];
- /* Custom certificate types sent in certificate request message. */
- uint8_t *ctype;
- size_t ctype_len;
- /*
- * supported signature algorithms. When set on a client this is sent in
- * the client hello as the supported signature algorithms extension. For
- * servers it represents the signature algorithms we are willing to use.
- */
- uint16_t *conf_sigalgs;
- /* Size of above array */
- size_t conf_sigalgslen;
- /*
- * Client authentication signature algorithms, if not set then uses
- * conf_sigalgs. On servers these will be the signature algorithms sent
- * to the client in a certificate request for TLS 1.2. On a client this
- * represents the signature algorithms we are willing to use for client
- * authentication.
- */
- uint16_t *client_sigalgs;
- /* Size of above array */
- size_t client_sigalgslen;
- /*
- * Certificate setup callback: if set is called whenever a certificate
- * may be required (client or server). the callback can then examine any
- * appropriate parameters and setup any certificates required. This
- * allows advanced applications to select certificates on the fly: for
- * example based on supported signature algorithms or curves.
- */
- int (*cert_cb) (SSL *ssl, void *arg);
- void *cert_cb_arg;
- /*
- * Optional X509_STORE for chain building or certificate validation If
- * NULL the parent SSL_CTX store is used instead.
- */
- X509_STORE *chain_store;
- X509_STORE *verify_store;
- /* Custom extensions */
- custom_ext_methods custext;
- /* Security callback */
- int (*sec_cb) (const SSL *s, const SSL_CTX *ctx, int op, int bits, int nid,
- void *other, void *ex);
- /* Security level */
- int sec_level;
- void *sec_ex;
-# ifndef OPENSSL_NO_PSK
- /* If not NULL psk identity hint to use for servers */
- char *psk_identity_hint;
-# endif
- CRYPTO_REF_COUNT references; /* >1 only if SSL_copy_session_id is used */
- CRYPTO_RWLOCK *lock;
-} CERT;
-
-# define FP_ICC (int (*)(const void *,const void *))
-
-/*
- * This is for the SSLv3/TLSv1.0 differences in crypto/hash stuff It is a bit
- * of a mess of functions, but hell, think of it as an opaque structure :-)
- */
-typedef struct ssl3_enc_method {
- int (*enc) (SSL *, SSL3_RECORD *, size_t, int);
- int (*mac) (SSL *, SSL3_RECORD *, unsigned char *, int);
- int (*setup_key_block) (SSL *);
- int (*generate_master_secret) (SSL *, unsigned char *, unsigned char *,
- size_t, size_t *);
- int (*change_cipher_state) (SSL *, int);
- size_t (*final_finish_mac) (SSL *, const char *, size_t, unsigned char *);
- const char *client_finished_label;
- size_t client_finished_label_len;
- const char *server_finished_label;
- size_t server_finished_label_len;
- int (*alert_value) (int);
- int (*export_keying_material) (SSL *, unsigned char *, size_t,
- const char *, size_t,
- const unsigned char *, size_t,
- int use_context);
- /* Various flags indicating protocol version requirements */
- uint32_t enc_flags;
- /* Set the handshake header */
- int (*set_handshake_header) (SSL *s, WPACKET *pkt, int type);
- /* Close construction of the handshake message */
- int (*close_construct_packet) (SSL *s, WPACKET *pkt, int htype);
- /* Write out handshake message */
- int (*do_write) (SSL *s);
-} SSL3_ENC_METHOD;
-
-# define ssl_set_handshake_header(s, pkt, htype) \
- s->method->ssl3_enc->set_handshake_header((s), (pkt), (htype))
-# define ssl_close_construct_packet(s, pkt, htype) \
- s->method->ssl3_enc->close_construct_packet((s), (pkt), (htype))
-# define ssl_do_write(s) s->method->ssl3_enc->do_write(s)
-
-/* Values for enc_flags */
-
-/* Uses explicit IV for CBC mode */
-# define SSL_ENC_FLAG_EXPLICIT_IV 0x1
-/* Uses signature algorithms extension */
-# define SSL_ENC_FLAG_SIGALGS 0x2
-/* Uses SHA256 default PRF */
-# define SSL_ENC_FLAG_SHA256_PRF 0x4
-/* Is DTLS */
-# define SSL_ENC_FLAG_DTLS 0x8
-/*
- * Allow TLS 1.2 ciphersuites: applies to DTLS 1.2 as well as TLS 1.2: may
- * apply to others in future.
- */
-# define SSL_ENC_FLAG_TLS1_2_CIPHERS 0x10
-
-# ifndef OPENSSL_NO_COMP
-/* Used for holding the relevant compression methods loaded into SSL_CTX */
-typedef struct ssl3_comp_st {
- int comp_id; /* The identifier byte for this compression
- * type */
- char *name; /* Text name used for the compression type */
- COMP_METHOD *method; /* The method :-) */
-} SSL3_COMP;
-# endif
-
-typedef enum downgrade_en {
- DOWNGRADE_NONE,
- DOWNGRADE_TO_1_2,
- DOWNGRADE_TO_1_1
-} DOWNGRADE;
-
-/*
- * Dummy status type for the status_type extension. Indicates no status type
- * set
- */
-#define TLSEXT_STATUSTYPE_nothing -1
-
-/* Sigalgs values */
-#define TLSEXT_SIGALG_ecdsa_secp256r1_sha256 0x0403
-#define TLSEXT_SIGALG_ecdsa_secp384r1_sha384 0x0503
-#define TLSEXT_SIGALG_ecdsa_secp521r1_sha512 0x0603
-#define TLSEXT_SIGALG_ecdsa_sha224 0x0303
-#define TLSEXT_SIGALG_ecdsa_sha1 0x0203
-#define TLSEXT_SIGALG_rsa_pss_rsae_sha256 0x0804
-#define TLSEXT_SIGALG_rsa_pss_rsae_sha384 0x0805
-#define TLSEXT_SIGALG_rsa_pss_rsae_sha512 0x0806
-#define TLSEXT_SIGALG_rsa_pss_pss_sha256 0x0809
-#define TLSEXT_SIGALG_rsa_pss_pss_sha384 0x080a
-#define TLSEXT_SIGALG_rsa_pss_pss_sha512 0x080b
-#define TLSEXT_SIGALG_rsa_pkcs1_sha256 0x0401
-#define TLSEXT_SIGALG_rsa_pkcs1_sha384 0x0501
-#define TLSEXT_SIGALG_rsa_pkcs1_sha512 0x0601
-#define TLSEXT_SIGALG_rsa_pkcs1_sha224 0x0301
-#define TLSEXT_SIGALG_rsa_pkcs1_sha1 0x0201
-#define TLSEXT_SIGALG_dsa_sha256 0x0402
-#define TLSEXT_SIGALG_dsa_sha384 0x0502
-#define TLSEXT_SIGALG_dsa_sha512 0x0602
-#define TLSEXT_SIGALG_dsa_sha224 0x0302
-#define TLSEXT_SIGALG_dsa_sha1 0x0202
-#define TLSEXT_SIGALG_gostr34102012_256_gostr34112012_256 0xeeee
-#define TLSEXT_SIGALG_gostr34102012_512_gostr34112012_512 0xefef
-#define TLSEXT_SIGALG_gostr34102001_gostr3411 0xeded
-
-#define TLSEXT_SIGALG_ed25519 0x0807
-#define TLSEXT_SIGALG_ed448 0x0808
-
-/* Known PSK key exchange modes */
-#define TLSEXT_KEX_MODE_KE 0x00
-#define TLSEXT_KEX_MODE_KE_DHE 0x01
-
-/*
- * Internal representations of key exchange modes
- */
-#define TLSEXT_KEX_MODE_FLAG_NONE 0
-#define TLSEXT_KEX_MODE_FLAG_KE 1
-#define TLSEXT_KEX_MODE_FLAG_KE_DHE 2
-
-#define SSL_USE_PSS(s) (s->s3.tmp.peer_sigalg != NULL && \
- s->s3.tmp.peer_sigalg->sig == EVP_PKEY_RSA_PSS)
-
-/* A dummy signature value not valid for TLSv1.2 signature algs */
-#define TLSEXT_signature_rsa_pss 0x0101
-
-/* TLSv1.3 downgrade protection sentinel values */
-extern const unsigned char tls11downgrade[8];
-extern const unsigned char tls12downgrade[8];
-
-extern SSL3_ENC_METHOD ssl3_undef_enc_method;
-
-__owur const SSL_METHOD *ssl_bad_method(int ver);
-__owur const SSL_METHOD *sslv3_method(void);
-__owur const SSL_METHOD *sslv3_server_method(void);
-__owur const SSL_METHOD *sslv3_client_method(void);
-__owur const SSL_METHOD *tlsv1_method(void);
-__owur const SSL_METHOD *tlsv1_server_method(void);
-__owur const SSL_METHOD *tlsv1_client_method(void);
-__owur const SSL_METHOD *tlsv1_1_method(void);
-__owur const SSL_METHOD *tlsv1_1_server_method(void);
-__owur const SSL_METHOD *tlsv1_1_client_method(void);
-__owur const SSL_METHOD *tlsv1_2_method(void);
-__owur const SSL_METHOD *tlsv1_2_server_method(void);
-__owur const SSL_METHOD *tlsv1_2_client_method(void);
-__owur const SSL_METHOD *tlsv1_3_method(void);
-__owur const SSL_METHOD *tlsv1_3_server_method(void);
-__owur const SSL_METHOD *tlsv1_3_client_method(void);
-__owur const SSL_METHOD *dtlsv1_method(void);
-__owur const SSL_METHOD *dtlsv1_server_method(void);
-__owur const SSL_METHOD *dtlsv1_client_method(void);
-__owur const SSL_METHOD *dtls_bad_ver_client_method(void);
-__owur const SSL_METHOD *dtlsv1_2_method(void);
-__owur const SSL_METHOD *dtlsv1_2_server_method(void);
-__owur const SSL_METHOD *dtlsv1_2_client_method(void);
-
-extern const SSL3_ENC_METHOD TLSv1_enc_data;
-extern const SSL3_ENC_METHOD TLSv1_1_enc_data;
-extern const SSL3_ENC_METHOD TLSv1_2_enc_data;
-extern const SSL3_ENC_METHOD TLSv1_3_enc_data;
-extern const SSL3_ENC_METHOD SSLv3_enc_data;
-extern const SSL3_ENC_METHOD DTLSv1_enc_data;
-extern const SSL3_ENC_METHOD DTLSv1_2_enc_data;
-
-/*
- * Flags for SSL methods
- */
-# define SSL_METHOD_NO_FIPS (1U<<0)
-# define SSL_METHOD_NO_SUITEB (1U<<1)
-
-# define IMPLEMENT_tls_meth_func(version, flags, mask, func_name, s_accept, \
- s_connect, enc_data) \
-const SSL_METHOD *func_name(void) \
- { \
- static const SSL_METHOD func_name##_data= { \
- version, \
- flags, \
- mask, \
- tls1_new, \
- tls1_clear, \
- tls1_free, \
- s_accept, \
- s_connect, \
- ssl3_read, \
- ssl3_peek, \
- ssl3_write, \
- ssl3_shutdown, \
- ssl3_renegotiate, \
- ssl3_renegotiate_check, \
- ssl3_read_bytes, \
- ssl3_write_bytes, \
- ssl3_dispatch_alert, \
- ssl3_ctrl, \
- ssl3_ctx_ctrl, \
- ssl3_get_cipher_by_char, \
- ssl3_put_cipher_by_char, \
- ssl3_pending, \
- ssl3_num_ciphers, \
- ssl3_get_cipher, \
- tls1_default_timeout, \
- &enc_data, \
- ssl_undefined_void_function, \
- ssl3_callback_ctrl, \
- ssl3_ctx_callback_ctrl, \
- }; \
- return &func_name##_data; \
- }
-
-# define IMPLEMENT_ssl3_meth_func(func_name, s_accept, s_connect) \
-const SSL_METHOD *func_name(void) \
- { \
- static const SSL_METHOD func_name##_data= { \
- SSL3_VERSION, \
- SSL_METHOD_NO_FIPS | SSL_METHOD_NO_SUITEB, \
- SSL_OP_NO_SSLv3, \
- ssl3_new, \
- ssl3_clear, \
- ssl3_free, \
- s_accept, \
- s_connect, \
- ssl3_read, \
- ssl3_peek, \
- ssl3_write, \
- ssl3_shutdown, \
- ssl3_renegotiate, \
- ssl3_renegotiate_check, \
- ssl3_read_bytes, \
- ssl3_write_bytes, \
- ssl3_dispatch_alert, \
- ssl3_ctrl, \
- ssl3_ctx_ctrl, \
- ssl3_get_cipher_by_char, \
- ssl3_put_cipher_by_char, \
- ssl3_pending, \
- ssl3_num_ciphers, \
- ssl3_get_cipher, \
- ssl3_default_timeout, \
- &SSLv3_enc_data, \
- ssl_undefined_void_function, \
- ssl3_callback_ctrl, \
- ssl3_ctx_callback_ctrl, \
- }; \
- return &func_name##_data; \
- }
-
-# define IMPLEMENT_dtls1_meth_func(version, flags, mask, func_name, s_accept, \
- s_connect, enc_data) \
-const SSL_METHOD *func_name(void) \
- { \
- static const SSL_METHOD func_name##_data= { \
- version, \
- flags, \
- mask, \
- dtls1_new, \
- dtls1_clear, \
- dtls1_free, \
- s_accept, \
- s_connect, \
- ssl3_read, \
- ssl3_peek, \
- ssl3_write, \
- dtls1_shutdown, \
- ssl3_renegotiate, \
- ssl3_renegotiate_check, \
- dtls1_read_bytes, \
- dtls1_write_app_data_bytes, \
- dtls1_dispatch_alert, \
- dtls1_ctrl, \
- ssl3_ctx_ctrl, \
- ssl3_get_cipher_by_char, \
- ssl3_put_cipher_by_char, \
- ssl3_pending, \
- ssl3_num_ciphers, \
- ssl3_get_cipher, \
- dtls1_default_timeout, \
- &enc_data, \
- ssl_undefined_void_function, \
- ssl3_callback_ctrl, \
- ssl3_ctx_callback_ctrl, \
- }; \
- return &func_name##_data; \
- }
-
-struct openssl_ssl_test_functions {
- int (*p_ssl_init_wbio_buffer) (SSL *s);
- int (*p_ssl3_setup_buffers) (SSL *s);
-};
-
-const char *ssl_protocol_to_string(int version);
-
-/* Returns true if certificate and private key for 'idx' are present */
-static ossl_inline int ssl_has_cert(const SSL *s, int idx)
-{
- if (idx < 0 || idx >= SSL_PKEY_NUM)
- return 0;
- return s->cert->pkeys[idx].x509 != NULL
- && s->cert->pkeys[idx].privatekey != NULL;
-}
-
-static ossl_inline void tls1_get_peer_groups(SSL *s, const uint16_t **pgroups,
- size_t *pgroupslen)
-{
- *pgroups = s->ext.peer_supportedgroups;
- *pgroupslen = s->ext.peer_supportedgroups_len;
-}
-
-# ifndef OPENSSL_UNIT_TEST
-
-__owur int ssl_read_internal(SSL *s, void *buf, size_t num, size_t *readbytes);
-__owur int ssl_write_internal(SSL *s, const void *buf, size_t num, size_t *written);
-void ssl_clear_cipher_ctx(SSL *s);
-int ssl_clear_bad_session(SSL *s);
-__owur CERT *ssl_cert_new(void);
-__owur CERT *ssl_cert_dup(CERT *cert);
-void ssl_cert_clear_certs(CERT *c);
-void ssl_cert_free(CERT *c);
-__owur int ssl_generate_session_id(SSL *s, SSL_SESSION *ss);
-__owur int ssl_get_new_session(SSL *s, int session);
-__owur SSL_SESSION *lookup_sess_in_cache(SSL *s, const unsigned char *sess_id,
- size_t sess_id_len);
-__owur int ssl_get_prev_session(SSL *s, CLIENTHELLO_MSG *hello);
-__owur SSL_SESSION *ssl_session_dup(const SSL_SESSION *src, int ticket);
-__owur int ssl_cipher_id_cmp(const SSL_CIPHER *a, const SSL_CIPHER *b);
-DECLARE_OBJ_BSEARCH_GLOBAL_CMP_FN(SSL_CIPHER, SSL_CIPHER, ssl_cipher_id);
-__owur int ssl_cipher_ptr_id_cmp(const SSL_CIPHER *const *ap,
- const SSL_CIPHER *const *bp);
-__owur STACK_OF(SSL_CIPHER) *ssl_create_cipher_list(const SSL_METHOD *ssl_method,
- STACK_OF(SSL_CIPHER) *tls13_ciphersuites,
- STACK_OF(SSL_CIPHER) **cipher_list,
- STACK_OF(SSL_CIPHER) **cipher_list_by_id,
- const char *rule_str,
- CERT *c);
-__owur int ssl_cache_cipherlist(SSL *s, PACKET *cipher_suites, int sslv2format);
-__owur int bytes_to_cipher_list(SSL *s, PACKET *cipher_suites,
- STACK_OF(SSL_CIPHER) **skp,
- STACK_OF(SSL_CIPHER) **scsvs, int sslv2format,
- int fatal);
-void ssl_update_cache(SSL *s, int mode);
-__owur int ssl_cipher_get_evp(const SSL_SESSION *s, const EVP_CIPHER **enc,
- const EVP_MD **md, int *mac_pkey_type,
- size_t *mac_secret_size, SSL_COMP **comp,
- int use_etm);
-__owur int ssl_cipher_get_overhead(const SSL_CIPHER *c, size_t *mac_overhead,
- size_t *int_overhead, size_t *blocksize,
- size_t *ext_overhead);
-__owur int ssl_cert_is_disabled(size_t idx);
-__owur const SSL_CIPHER *ssl_get_cipher_by_char(SSL *ssl,
- const unsigned char *ptr,
- int all);
-__owur int ssl_cert_set0_chain(SSL *s, SSL_CTX *ctx, STACK_OF(X509) *chain);
-__owur int ssl_cert_set1_chain(SSL *s, SSL_CTX *ctx, STACK_OF(X509) *chain);
-__owur int ssl_cert_add0_chain_cert(SSL *s, SSL_CTX *ctx, X509 *x);
-__owur int ssl_cert_add1_chain_cert(SSL *s, SSL_CTX *ctx, X509 *x);
-__owur int ssl_cert_select_current(CERT *c, X509 *x);
-__owur int ssl_cert_set_current(CERT *c, long arg);
-void ssl_cert_set_cert_cb(CERT *c, int (*cb) (SSL *ssl, void *arg), void *arg);
-
-__owur int ssl_verify_cert_chain(SSL *s, STACK_OF(X509) *sk);
-__owur int ssl_build_cert_chain(SSL *s, SSL_CTX *ctx, int flags);
-__owur int ssl_cert_set_cert_store(CERT *c, X509_STORE *store, int chain,
- int ref);
-
-__owur int ssl_security(const SSL *s, int op, int bits, int nid, void *other);
-__owur int ssl_ctx_security(const SSL_CTX *ctx, int op, int bits, int nid,
- void *other);
-
-__owur int ssl_cert_lookup_by_nid(int nid, size_t *pidx);
-__owur const SSL_CERT_LOOKUP *ssl_cert_lookup_by_pkey(const EVP_PKEY *pk,
- size_t *pidx);
-__owur const SSL_CERT_LOOKUP *ssl_cert_lookup_by_idx(size_t idx);
-
-int ssl_undefined_function(SSL *s);
-__owur int ssl_undefined_void_function(void);
-__owur int ssl_undefined_const_function(const SSL *s);
-__owur int ssl_get_server_cert_serverinfo(SSL *s,
- const unsigned char **serverinfo,
- size_t *serverinfo_length);
-void ssl_set_masks(SSL *s);
-__owur STACK_OF(SSL_CIPHER) *ssl_get_ciphers_by_id(SSL *s);
-__owur int ssl_x509err2alert(int type);
-void ssl_sort_cipher_list(void);
-int ssl_load_ciphers(void);
-__owur int ssl_fill_hello_random(SSL *s, int server, unsigned char *field,
- size_t len, DOWNGRADE dgrd);
-__owur int ssl_generate_master_secret(SSL *s, unsigned char *pms, size_t pmslen,
- int free_pms);
-__owur EVP_PKEY *ssl_generate_pkey(EVP_PKEY *pm);
-__owur int ssl_derive(SSL *s, EVP_PKEY *privkey, EVP_PKEY *pubkey,
- int genmaster);
-__owur EVP_PKEY *ssl_dh_to_pkey(DH *dh);
-__owur unsigned int ssl_get_max_send_fragment(const SSL *ssl);
-__owur unsigned int ssl_get_split_send_fragment(const SSL *ssl);
-
-__owur const SSL_CIPHER *ssl3_get_cipher_by_id(uint32_t id);
-__owur const SSL_CIPHER *ssl3_get_cipher_by_std_name(const char *stdname);
-__owur const SSL_CIPHER *ssl3_get_cipher_by_char(const unsigned char *p);
-__owur int ssl3_put_cipher_by_char(const SSL_CIPHER *c, WPACKET *pkt,
- size_t *len);
-int ssl3_init_finished_mac(SSL *s);
-__owur int ssl3_setup_key_block(SSL *s);
-__owur int ssl3_change_cipher_state(SSL *s, int which);
-void ssl3_cleanup_key_block(SSL *s);
-__owur int ssl3_do_write(SSL *s, int type);
-int ssl3_send_alert(SSL *s, int level, int desc);
-__owur int ssl3_generate_master_secret(SSL *s, unsigned char *out,
- unsigned char *p, size_t len,
- size_t *secret_size);
-__owur int ssl3_get_req_cert_type(SSL *s, WPACKET *pkt);
-__owur int ssl3_num_ciphers(void);
-__owur const SSL_CIPHER *ssl3_get_cipher(unsigned int u);
-int ssl3_renegotiate(SSL *ssl);
-int ssl3_renegotiate_check(SSL *ssl, int initok);
-void ssl3_digest_master_key_set_params(const SSL_SESSION *session,
- OSSL_PARAM params[]);
-__owur int ssl3_dispatch_alert(SSL *s);
-__owur size_t ssl3_final_finish_mac(SSL *s, const char *sender, size_t slen,
- unsigned char *p);
-__owur int ssl3_finish_mac(SSL *s, const unsigned char *buf, size_t len);
-void ssl3_free_digest_list(SSL *s);
-__owur unsigned long ssl3_output_cert_chain(SSL *s, WPACKET *pkt,
- CERT_PKEY *cpk);
-__owur const SSL_CIPHER *ssl3_choose_cipher(SSL *ssl,
- STACK_OF(SSL_CIPHER) *clnt,
- STACK_OF(SSL_CIPHER) *srvr);
-__owur int ssl3_digest_cached_records(SSL *s, int keep);
-__owur int ssl3_new(SSL *s);
-void ssl3_free(SSL *s);
-__owur int ssl3_read(SSL *s, void *buf, size_t len, size_t *readbytes);
-__owur int ssl3_peek(SSL *s, void *buf, size_t len, size_t *readbytes);
-__owur int ssl3_write(SSL *s, const void *buf, size_t len, size_t *written);
-__owur int ssl3_shutdown(SSL *s);
-int ssl3_clear(SSL *s);
-__owur long ssl3_ctrl(SSL *s, int cmd, long larg, void *parg);
-__owur long ssl3_ctx_ctrl(SSL_CTX *s, int cmd, long larg, void *parg);
-__owur long ssl3_callback_ctrl(SSL *s, int cmd, void (*fp) (void));
-__owur long ssl3_ctx_callback_ctrl(SSL_CTX *s, int cmd, void (*fp) (void));
-
-__owur int ssl3_do_change_cipher_spec(SSL *ssl);
-__owur long ssl3_default_timeout(void);
-
-__owur int ssl3_set_handshake_header(SSL *s, WPACKET *pkt, int htype);
-__owur int tls_close_construct_packet(SSL *s, WPACKET *pkt, int htype);
-__owur int tls_setup_handshake(SSL *s);
-__owur int dtls1_set_handshake_header(SSL *s, WPACKET *pkt, int htype);
-__owur int dtls1_close_construct_packet(SSL *s, WPACKET *pkt, int htype);
-__owur int ssl3_handshake_write(SSL *s);
-
-__owur int ssl_allow_compression(SSL *s);
-
-__owur int ssl_version_supported(const SSL *s, int version,
- const SSL_METHOD **meth);
-
-__owur int ssl_set_client_hello_version(SSL *s);
-__owur int ssl_check_version_downgrade(SSL *s);
-__owur int ssl_set_version_bound(int method_version, int version, int *bound);
-__owur int ssl_choose_server_version(SSL *s, CLIENTHELLO_MSG *hello,
- DOWNGRADE *dgrd);
-__owur int ssl_choose_client_version(SSL *s, int version,
- RAW_EXTENSION *extensions);
-__owur int ssl_get_min_max_version(const SSL *s, int *min_version,
- int *max_version, int *real_max);
-
-__owur long tls1_default_timeout(void);
-__owur int dtls1_do_write(SSL *s, int type);
-void dtls1_set_message_header(SSL *s,
- unsigned char mt,
- size_t len,
- size_t frag_off, size_t frag_len);
-
-int dtls1_write_app_data_bytes(SSL *s, int type, const void *buf_, size_t len,
- size_t *written);
-
-__owur int dtls1_read_failed(SSL *s, int code);
-__owur int dtls1_buffer_message(SSL *s, int ccs);
-__owur int dtls1_retransmit_message(SSL *s, unsigned short seq, int *found);
-__owur int dtls1_get_queue_priority(unsigned short seq, int is_ccs);
-int dtls1_retransmit_buffered_messages(SSL *s);
-void dtls1_clear_received_buffer(SSL *s);
-void dtls1_clear_sent_buffer(SSL *s);
-void dtls1_get_message_header(unsigned char *data,
- struct hm_header_st *msg_hdr);
-__owur long dtls1_default_timeout(void);
-__owur struct timeval *dtls1_get_timeout(SSL *s, struct timeval *timeleft);
-__owur int dtls1_check_timeout_num(SSL *s);
-__owur int dtls1_handle_timeout(SSL *s);
-void dtls1_start_timer(SSL *s);
-void dtls1_stop_timer(SSL *s);
-__owur int dtls1_is_timer_expired(SSL *s);
-void dtls1_double_timeout(SSL *s);
-__owur int dtls_raw_hello_verify_request(WPACKET *pkt, unsigned char *cookie,
- size_t cookie_len);
-__owur size_t dtls1_min_mtu(SSL *s);
-void dtls1_hm_fragment_free(hm_fragment *frag);
-__owur int dtls1_query_mtu(SSL *s);
-
-__owur int tls1_new(SSL *s);
-void tls1_free(SSL *s);
-int tls1_clear(SSL *s);
-
-__owur int dtls1_new(SSL *s);
-void dtls1_free(SSL *s);
-int dtls1_clear(SSL *s);
-long dtls1_ctrl(SSL *s, int cmd, long larg, void *parg);
-__owur int dtls1_shutdown(SSL *s);
-
-__owur int dtls1_dispatch_alert(SSL *s);
-
-__owur int ssl_init_wbio_buffer(SSL *s);
-int ssl_free_wbio_buffer(SSL *s);
-
-__owur int tls1_change_cipher_state(SSL *s, int which);
-__owur int tls1_setup_key_block(SSL *s);
-__owur size_t tls1_final_finish_mac(SSL *s, const char *str, size_t slen,
- unsigned char *p);
-__owur int tls1_generate_master_secret(SSL *s, unsigned char *out,
- unsigned char *p, size_t len,
- size_t *secret_size);
-__owur int tls13_setup_key_block(SSL *s);
-__owur size_t tls13_final_finish_mac(SSL *s, const char *str, size_t slen,
- unsigned char *p);
-__owur int tls13_change_cipher_state(SSL *s, int which);
-__owur int tls13_update_key(SSL *s, int send);
-__owur int tls13_hkdf_expand(SSL *s, const EVP_MD *md,
- const unsigned char *secret,
- const unsigned char *label, size_t labellen,
- const unsigned char *data, size_t datalen,
- unsigned char *out, size_t outlen, int fatal);
-__owur int tls13_derive_key(SSL *s, const EVP_MD *md,
- const unsigned char *secret, unsigned char *key,
- size_t keylen);
-__owur int tls13_derive_iv(SSL *s, const EVP_MD *md,
- const unsigned char *secret, unsigned char *iv,
- size_t ivlen);
-__owur int tls13_derive_finishedkey(SSL *s, const EVP_MD *md,
- const unsigned char *secret,
- unsigned char *fin, size_t finlen);
-int tls13_generate_secret(SSL *s, const EVP_MD *md,
- const unsigned char *prevsecret,
- const unsigned char *insecret,
- size_t insecretlen,
- unsigned char *outsecret);
-__owur int tls13_generate_handshake_secret(SSL *s,
- const unsigned char *insecret,
- size_t insecretlen);
-__owur int tls13_generate_master_secret(SSL *s, unsigned char *out,
- unsigned char *prev, size_t prevlen,
- size_t *secret_size);
-__owur int tls1_export_keying_material(SSL *s, unsigned char *out, size_t olen,
- const char *label, size_t llen,
- const unsigned char *p, size_t plen,
- int use_context);
-__owur int tls13_export_keying_material(SSL *s, unsigned char *out, size_t olen,
- const char *label, size_t llen,
- const unsigned char *context,
- size_t contextlen, int use_context);
-__owur int tls13_export_keying_material_early(SSL *s, unsigned char *out,
- size_t olen, const char *label,
- size_t llen,
- const unsigned char *context,
- size_t contextlen);
-__owur int tls1_alert_code(int code);
-__owur int tls13_alert_code(int code);
-__owur int ssl3_alert_code(int code);
-
-# ifndef OPENSSL_NO_EC
-__owur int ssl_check_srvr_ecc_cert_and_alg(X509 *x, SSL *s);
-# endif
-
-SSL_COMP *ssl3_comp_find(STACK_OF(SSL_COMP) *sk, int n);
-
-__owur const TLS_GROUP_INFO *tls1_group_id_lookup(uint16_t curve_id);
-__owur int tls1_group_id2nid(uint16_t group_id);
-__owur int tls1_check_group_id(SSL *s, uint16_t group_id, int check_own_curves);
-__owur uint16_t tls1_shared_group(SSL *s, int nmatch);
-__owur int tls1_set_groups(uint16_t **pext, size_t *pextlen,
- int *curves, size_t ncurves);
-__owur int tls1_set_groups_list(uint16_t **pext, size_t *pextlen,
- const char *str);
-__owur EVP_PKEY *ssl_generate_pkey_group(SSL *s, uint16_t id);
-__owur int tls_valid_group(SSL *s, uint16_t group_id, int version);
-__owur EVP_PKEY *ssl_generate_param_group(uint16_t id);
-# ifndef OPENSSL_NO_EC
-void tls1_get_formatlist(SSL *s, const unsigned char **pformats,
- size_t *num_formats);
-__owur int tls1_check_ec_tmp_key(SSL *s, unsigned long id);
-# endif /* OPENSSL_NO_EC */
-
-__owur int tls_group_allowed(SSL *s, uint16_t curve, int op);
-void tls1_get_supported_groups(SSL *s, const uint16_t **pgroups,
- size_t *pgroupslen);
-
-__owur int tls1_set_server_sigalgs(SSL *s);
-
-__owur SSL_TICKET_STATUS tls_get_ticket_from_client(SSL *s, CLIENTHELLO_MSG *hello,
- SSL_SESSION **ret);
-__owur SSL_TICKET_STATUS tls_decrypt_ticket(SSL *s, const unsigned char *etick,
- size_t eticklen,
- const unsigned char *sess_id,
- size_t sesslen, SSL_SESSION **psess);
-
-__owur int tls_use_ticket(SSL *s);
-
-void ssl_set_sig_mask(uint32_t *pmask_a, SSL *s, int op);
-
-__owur int tls1_set_sigalgs_list(CERT *c, const char *str, int client);
-__owur int tls1_set_raw_sigalgs(CERT *c, const uint16_t *psigs, size_t salglen,
- int client);
-__owur int tls1_set_sigalgs(CERT *c, const int *salg, size_t salglen,
- int client);
-int tls1_check_chain(SSL *s, X509 *x, EVP_PKEY *pk, STACK_OF(X509) *chain,
- int idx);
-void tls1_set_cert_validity(SSL *s);
-
-# ifndef OPENSSL_NO_CT
-__owur int ssl_validate_ct(SSL *s);
-# endif
-
-# ifndef OPENSSL_NO_DH
-__owur DH *ssl_get_auto_dh(SSL *s);
-# endif
-
-__owur int ssl_security_cert(SSL *s, SSL_CTX *ctx, X509 *x, int vfy, int is_ee);
-__owur int ssl_security_cert_chain(SSL *s, STACK_OF(X509) *sk, X509 *ex,
- int vfy);
-
-int tls_choose_sigalg(SSL *s, int fatalerrs);
-
-__owur EVP_MD_CTX *ssl_replace_hash(EVP_MD_CTX **hash, const EVP_MD *md);
-void ssl_clear_hash_ctx(EVP_MD_CTX **hash);
-__owur long ssl_get_algorithm2(SSL *s);
-__owur int tls12_copy_sigalgs(SSL *s, WPACKET *pkt,
- const uint16_t *psig, size_t psiglen);
-__owur int tls1_save_u16(PACKET *pkt, uint16_t **pdest, size_t *pdestlen);
-__owur int tls1_save_sigalgs(SSL *s, PACKET *pkt, int cert);
-__owur int tls1_process_sigalgs(SSL *s);
-__owur int tls1_set_peer_legacy_sigalg(SSL *s, const EVP_PKEY *pkey);
-__owur int tls1_lookup_md(const SIGALG_LOOKUP *lu, const EVP_MD **pmd);
-__owur size_t tls12_get_psigalgs(SSL *s, int sent, const uint16_t **psigs);
-# ifndef OPENSSL_NO_EC
-__owur int tls_check_sigalg_curve(const SSL *s, int curve);
-# endif
-__owur int tls12_check_peer_sigalg(SSL *s, uint16_t, EVP_PKEY *pkey);
-__owur int ssl_set_client_disabled(SSL *s);
-__owur int ssl_cipher_disabled(SSL *s, const SSL_CIPHER *c, int op, int echde);
-
-__owur int ssl_handshake_hash(SSL *s, unsigned char *out, size_t outlen,
- size_t *hashlen);
-__owur const EVP_MD *ssl_md(int idx);
-__owur const EVP_MD *ssl_handshake_md(SSL *s);
-__owur const EVP_MD *ssl_prf_md(SSL *s);
-
-/*
- * ssl_log_rsa_client_key_exchange logs |premaster| to the SSL_CTX associated
- * with |ssl|, if logging is enabled. It returns one on success and zero on
- * failure. The entry is identified by the first 8 bytes of
- * |encrypted_premaster|.
- */
-__owur int ssl_log_rsa_client_key_exchange(SSL *ssl,
- const uint8_t *encrypted_premaster,
- size_t encrypted_premaster_len,
- const uint8_t *premaster,
- size_t premaster_len);
-
-/*
- * ssl_log_secret logs |secret| to the SSL_CTX associated with |ssl|, if
- * logging is available. It returns one on success and zero on failure. It tags
- * the entry with |label|.
- */
-__owur int ssl_log_secret(SSL *ssl, const char *label,
- const uint8_t *secret, size_t secret_len);
-
-#define MASTER_SECRET_LABEL "CLIENT_RANDOM"
-#define CLIENT_EARLY_LABEL "CLIENT_EARLY_TRAFFIC_SECRET"
-#define CLIENT_HANDSHAKE_LABEL "CLIENT_HANDSHAKE_TRAFFIC_SECRET"
-#define SERVER_HANDSHAKE_LABEL "SERVER_HANDSHAKE_TRAFFIC_SECRET"
-#define CLIENT_APPLICATION_LABEL "CLIENT_TRAFFIC_SECRET_0"
-#define SERVER_APPLICATION_LABEL "SERVER_TRAFFIC_SECRET_0"
-#define EARLY_EXPORTER_SECRET_LABEL "EARLY_EXPORTER_SECRET"
-#define EXPORTER_SECRET_LABEL "EXPORTER_SECRET"
-
-/* s3_cbc.c */
-__owur char ssl3_cbc_record_digest_supported(const EVP_MD_CTX *ctx);
-__owur int ssl3_cbc_digest_record(const EVP_MD_CTX *ctx,
- unsigned char *md_out,
- size_t *md_out_size,
- const unsigned char header[13],
- const unsigned char *data,
- size_t data_plus_mac_size,
- size_t data_plus_mac_plus_padding_size,
- const unsigned char *mac_secret,
- size_t mac_secret_length, char is_sslv3);
-
-__owur int srp_generate_server_master_secret(SSL *s);
-__owur int srp_generate_client_master_secret(SSL *s);
-__owur int srp_verify_server_param(SSL *s);
-
-/* statem/statem_srvr.c */
-
-__owur int send_certificate_request(SSL *s);
-
-/* statem/extensions_cust.c */
-
-custom_ext_method *custom_ext_find(const custom_ext_methods *exts,
- ENDPOINT role, unsigned int ext_type,
- size_t *idx);
-
-void custom_ext_init(custom_ext_methods *meths);
-
-__owur int custom_ext_parse(SSL *s, unsigned int context, unsigned int ext_type,
- const unsigned char *ext_data, size_t ext_size,
- X509 *x, size_t chainidx);
-__owur int custom_ext_add(SSL *s, int context, WPACKET *pkt, X509 *x,
- size_t chainidx, int maxversion);
-
-__owur int custom_exts_copy(custom_ext_methods *dst,
- const custom_ext_methods *src);
-__owur int custom_exts_copy_flags(custom_ext_methods *dst,
- const custom_ext_methods *src);
-void custom_exts_free(custom_ext_methods *exts);
-
-void ssl_comp_free_compression_methods_int(void);
-
-/* ssl_mcnf.c */
-void ssl_ctx_system_config(SSL_CTX *ctx);
-
-# else /* OPENSSL_UNIT_TEST */
-
-# define ssl_init_wbio_buffer SSL_test_functions()->p_ssl_init_wbio_buffer
-# define ssl3_setup_buffers SSL_test_functions()->p_ssl3_setup_buffers
-
-# endif
-#endif
#include <stdio.h>
#include <openssl/conf.h>
#include <openssl/ssl.h>
-#include "ssl_locl.h"
+#include "ssl_local.h"
#include "internal/sslconf.h"
/* SSL library configuration module. */
*/
#include <stdio.h>
-#include "ssl_locl.h"
+#include "ssl_local.h"
#include "internal/packet.h"
#include <openssl/bio.h>
#include <openssl/objects.h>
#include <openssl/engine.h>
#include "internal/refcount.h"
#include "internal/cryptlib.h"
-#include "ssl_locl.h"
-#include "statem/statem_locl.h"
+#include "ssl_local.h"
+#include "statem/statem_local.h"
static void SSL_SESSION_list_remove(SSL_CTX *ctx, SSL_SESSION *s);
static void SSL_SESSION_list_add(SSL_CTX *ctx, SSL_SESSION *s);
*/
#include <stdio.h>
-#include "ssl_locl.h"
+#include "ssl_local.h"
const char *SSL_state_string_long(const SSL *s)
{
#include <stdio.h>
#include <openssl/buffer.h>
-#include "ssl_locl.h"
+#include "ssl_local.h"
#ifndef OPENSSL_NO_STDIO
int SSL_SESSION_print_fp(FILE *fp, const SSL_SESSION *x)
* https://www.openssl.org/source/license.html
*/
-#include "ssl_locl.h"
+#include "ssl_local.h"
#ifndef OPENSSL_NO_UNIT_TEST
| |
| Core state machine code |
|____________________________|
- statem_locl.h ^ ^
+ statem_local.h ^ ^
_________| |_______
| |
_____________|____________ _____________|____________
#include <string.h>
#include "internal/nelem.h"
#include "internal/cryptlib.h"
-#include "../ssl_locl.h"
-#include "statem_locl.h"
+#include "../ssl_local.h"
+#include "statem_local.h"
#include "internal/cryptlib.h"
static int final_renegotiate(SSL *s, unsigned int context, int sent);
/*
* Definitions of all built-in extensions. NOTE: Changes in the number or order
* of these extensions should be mirrored with equivalent changes to the
- * indexes ( TLSEXT_IDX_* ) defined in ssl_locl.h.
+ * indexes ( TLSEXT_IDX_* ) defined in ssl_local.h.
* Each extension has an initialiser, a client and
* server side parser and a finaliser. The initialiser is called (if the
* extension is relevant to the given context) even if we did not see the
*/
#include <openssl/ocsp.h>
-#include "../ssl_locl.h"
+#include "../ssl_local.h"
#include "internal/cryptlib.h"
-#include "statem_locl.h"
+#include "statem_local.h"
EXT_RETURN tls_construct_ctos_renegotiate(SSL *s, WPACKET *pkt,
unsigned int context, X509 *x,
/* Custom extension utility functions */
#include <openssl/ct.h>
-#include "../ssl_locl.h"
+#include "../ssl_local.h"
#include "internal/cryptlib.h"
-#include "statem_locl.h"
+#include "statem_local.h"
typedef struct {
void *add_arg;
*/
#include <openssl/ocsp.h>
-#include "../ssl_locl.h"
-#include "statem_locl.h"
+#include "../ssl_local.h"
+#include "statem_local.h"
#include "internal/cryptlib.h"
#define COOKIE_STATE_FORMAT_VERSION 0
#include "internal/cryptlib.h"
#include <openssl/rand.h>
-#include "../ssl_locl.h"
-#include "statem_locl.h"
+#include "../ssl_local.h"
+#include "statem_local.h"
#include <assert.h>
/*
#include <stdio.h>
#include <time.h>
#include <assert.h>
-#include "../ssl_locl.h"
-#include "statem_locl.h"
+#include "../ssl_local.h"
+#include "statem_local.h"
#include <openssl/buffer.h>
#include <openssl/rand.h>
#include <openssl/objects.h>
#include <limits.h>
#include <string.h>
#include <stdio.h>
-#include "../ssl_locl.h"
-#include "statem_locl.h"
+#include "../ssl_local.h"
+#include "statem_local.h"
#include "internal/cryptlib.h"
#include <openssl/buffer.h>
#include <openssl/objects.h>
#include <limits.h>
#include <string.h>
#include <stdio.h>
-#include "../ssl_locl.h"
-#include "statem_locl.h"
+#include "../ssl_local.h"
+#include "statem_local.h"
#include "internal/cryptlib.h"
#include <openssl/buffer.h>
#include <openssl/objects.h>
--- /dev/null
+/*
+ * Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+/*****************************************************************************
+ * *
+ * The following definitions are PRIVATE to the state machine. They should *
+ * NOT be used outside of the state machine. *
+ * *
+ *****************************************************************************/
+
+/* Max message length definitions */
+
+/* The spec allows for a longer length than this, but we limit it */
+#define HELLO_VERIFY_REQUEST_MAX_LENGTH 258
+#define END_OF_EARLY_DATA_MAX_LENGTH 0
+#define SERVER_HELLO_MAX_LENGTH 20000
+#define HELLO_RETRY_REQUEST_MAX_LENGTH 20000
+#define ENCRYPTED_EXTENSIONS_MAX_LENGTH 20000
+#define SERVER_KEY_EXCH_MAX_LENGTH 102400
+#define SERVER_HELLO_DONE_MAX_LENGTH 0
+#define KEY_UPDATE_MAX_LENGTH 1
+#define CCS_MAX_LENGTH 1
+/* Max should actually be 36 but we are generous */
+#define FINISHED_MAX_LENGTH 64
+
+/* Dummy message type */
+#define SSL3_MT_DUMMY -1
+
+extern const unsigned char hrrrandom[];
+
+/* Message processing return codes */
+typedef enum {
+ /* Something bad happened */
+ MSG_PROCESS_ERROR,
+ /* We've finished reading - swap to writing */
+ MSG_PROCESS_FINISHED_READING,
+ /*
+ * We've completed the main processing of this message but there is some
+ * post processing to be done.
+ */
+ MSG_PROCESS_CONTINUE_PROCESSING,
+ /* We've finished this message - read the next message */
+ MSG_PROCESS_CONTINUE_READING
+} MSG_PROCESS_RETURN;
+
+typedef int (*confunc_f) (SSL *s, WPACKET *pkt);
+
+int ssl3_take_mac(SSL *s);
+int check_in_list(SSL *s, uint16_t group_id, const uint16_t *groups,
+ size_t num_groups, int checkallow);
+int create_synthetic_message_hash(SSL *s, const unsigned char *hashval,
+ size_t hashlen, const unsigned char *hrr,
+ size_t hrrlen);
+int parse_ca_names(SSL *s, PACKET *pkt);
+const STACK_OF(X509_NAME) *get_ca_names(SSL *s);
+int construct_ca_names(SSL *s, const STACK_OF(X509_NAME) *ca_sk, WPACKET *pkt);
+size_t construct_key_exchange_tbs(SSL *s, unsigned char **ptbs,
+ const void *param, size_t paramlen);
+
+/*
+ * TLS/DTLS client state machine functions
+ */
+int ossl_statem_client_read_transition(SSL *s, int mt);
+WRITE_TRAN ossl_statem_client_write_transition(SSL *s);
+WORK_STATE ossl_statem_client_pre_work(SSL *s, WORK_STATE wst);
+WORK_STATE ossl_statem_client_post_work(SSL *s, WORK_STATE wst);
+int ossl_statem_client_construct_message(SSL *s, WPACKET *pkt,
+ confunc_f *confunc, int *mt);
+size_t ossl_statem_client_max_message_size(SSL *s);
+MSG_PROCESS_RETURN ossl_statem_client_process_message(SSL *s, PACKET *pkt);
+WORK_STATE ossl_statem_client_post_process_message(SSL *s, WORK_STATE wst);
+
+/*
+ * TLS/DTLS server state machine functions
+ */
+int ossl_statem_server_read_transition(SSL *s, int mt);
+WRITE_TRAN ossl_statem_server_write_transition(SSL *s);
+WORK_STATE ossl_statem_server_pre_work(SSL *s, WORK_STATE wst);
+WORK_STATE ossl_statem_server_post_work(SSL *s, WORK_STATE wst);
+int ossl_statem_server_construct_message(SSL *s, WPACKET *pkt,
+ confunc_f *confunc,int *mt);
+size_t ossl_statem_server_max_message_size(SSL *s);
+MSG_PROCESS_RETURN ossl_statem_server_process_message(SSL *s, PACKET *pkt);
+WORK_STATE ossl_statem_server_post_process_message(SSL *s, WORK_STATE wst);
+
+/* Functions for getting new message data */
+__owur int tls_get_message_header(SSL *s, int *mt);
+__owur int tls_get_message_body(SSL *s, size_t *len);
+__owur int dtls_get_message(SSL *s, int *mt, size_t *len);
+
+/* Message construction and processing functions */
+__owur int tls_process_initial_server_flight(SSL *s);
+__owur MSG_PROCESS_RETURN tls_process_change_cipher_spec(SSL *s, PACKET *pkt);
+__owur MSG_PROCESS_RETURN tls_process_finished(SSL *s, PACKET *pkt);
+__owur int tls_construct_change_cipher_spec(SSL *s, WPACKET *pkt);
+__owur int dtls_construct_change_cipher_spec(SSL *s, WPACKET *pkt);
+
+__owur int tls_construct_finished(SSL *s, WPACKET *pkt);
+__owur int tls_construct_key_update(SSL *s, WPACKET *pkt);
+__owur MSG_PROCESS_RETURN tls_process_key_update(SSL *s, PACKET *pkt);
+__owur WORK_STATE tls_finish_handshake(SSL *s, WORK_STATE wst, int clearbufs,
+ int stop);
+__owur WORK_STATE dtls_wait_for_dry(SSL *s);
+
+/* some client-only functions */
+__owur int tls_construct_client_hello(SSL *s, WPACKET *pkt);
+__owur MSG_PROCESS_RETURN tls_process_server_hello(SSL *s, PACKET *pkt);
+__owur MSG_PROCESS_RETURN tls_process_certificate_request(SSL *s, PACKET *pkt);
+__owur MSG_PROCESS_RETURN tls_process_new_session_ticket(SSL *s, PACKET *pkt);
+__owur int tls_process_cert_status_body(SSL *s, PACKET *pkt);
+__owur MSG_PROCESS_RETURN tls_process_cert_status(SSL *s, PACKET *pkt);
+__owur MSG_PROCESS_RETURN tls_process_server_done(SSL *s, PACKET *pkt);
+__owur int tls_construct_cert_verify(SSL *s, WPACKET *pkt);
+__owur WORK_STATE tls_prepare_client_certificate(SSL *s, WORK_STATE wst);
+__owur int tls_construct_client_certificate(SSL *s, WPACKET *pkt);
+__owur int ssl_do_client_cert_cb(SSL *s, X509 **px509, EVP_PKEY **ppkey);
+__owur int tls_construct_client_key_exchange(SSL *s, WPACKET *pkt);
+__owur int tls_client_key_exchange_post_work(SSL *s);
+__owur int tls_construct_cert_status_body(SSL *s, WPACKET *pkt);
+__owur int tls_construct_cert_status(SSL *s, WPACKET *pkt);
+__owur MSG_PROCESS_RETURN tls_process_key_exchange(SSL *s, PACKET *pkt);
+__owur MSG_PROCESS_RETURN tls_process_server_certificate(SSL *s, PACKET *pkt);
+__owur int ssl3_check_cert_and_algorithm(SSL *s);
+#ifndef OPENSSL_NO_NEXTPROTONEG
+__owur int tls_construct_next_proto(SSL *s, WPACKET *pkt);
+#endif
+__owur MSG_PROCESS_RETURN tls_process_hello_req(SSL *s, PACKET *pkt);
+__owur MSG_PROCESS_RETURN dtls_process_hello_verify(SSL *s, PACKET *pkt);
+__owur int tls_construct_end_of_early_data(SSL *s, WPACKET *pkt);
+
+/* some server-only functions */
+__owur MSG_PROCESS_RETURN tls_process_client_hello(SSL *s, PACKET *pkt);
+__owur WORK_STATE tls_post_process_client_hello(SSL *s, WORK_STATE wst);
+__owur int tls_construct_server_hello(SSL *s, WPACKET *pkt);
+__owur int dtls_construct_hello_verify_request(SSL *s, WPACKET *pkt);
+__owur int tls_construct_server_certificate(SSL *s, WPACKET *pkt);
+__owur int tls_construct_server_key_exchange(SSL *s, WPACKET *pkt);
+__owur int tls_construct_certificate_request(SSL *s, WPACKET *pkt);
+__owur int tls_construct_server_done(SSL *s, WPACKET *pkt);
+__owur MSG_PROCESS_RETURN tls_process_client_certificate(SSL *s, PACKET *pkt);
+__owur MSG_PROCESS_RETURN tls_process_client_key_exchange(SSL *s, PACKET *pkt);
+__owur WORK_STATE tls_post_process_client_key_exchange(SSL *s, WORK_STATE wst);
+__owur MSG_PROCESS_RETURN tls_process_cert_verify(SSL *s, PACKET *pkt);
+#ifndef OPENSSL_NO_NEXTPROTONEG
+__owur MSG_PROCESS_RETURN tls_process_next_proto(SSL *s, PACKET *pkt);
+#endif
+__owur int tls_construct_new_session_ticket(SSL *s, WPACKET *pkt);
+MSG_PROCESS_RETURN tls_process_end_of_early_data(SSL *s, PACKET *pkt);
+
+
+/* Extension processing */
+
+typedef enum ext_return_en {
+ EXT_RETURN_FAIL,
+ EXT_RETURN_SENT,
+ EXT_RETURN_NOT_SENT
+} EXT_RETURN;
+
+__owur int tls_validate_all_contexts(SSL *s, unsigned int thisctx,
+ RAW_EXTENSION *exts);
+__owur int extension_is_relevant(SSL *s, unsigned int extctx,
+ unsigned int thisctx);
+__owur int tls_collect_extensions(SSL *s, PACKET *packet, unsigned int context,
+ RAW_EXTENSION **res, size_t *len, int init);
+__owur int tls_parse_extension(SSL *s, TLSEXT_INDEX idx, int context,
+ RAW_EXTENSION *exts, X509 *x, size_t chainidx);
+__owur int tls_parse_all_extensions(SSL *s, int context, RAW_EXTENSION *exts,
+ X509 *x, size_t chainidx, int fin);
+__owur int should_add_extension(SSL *s, unsigned int extctx,
+ unsigned int thisctx, int max_version);
+__owur int tls_construct_extensions(SSL *s, WPACKET *pkt, unsigned int context,
+ X509 *x, size_t chainidx);
+
+__owur int tls_psk_do_binder(SSL *s, const EVP_MD *md,
+ const unsigned char *msgstart,
+ size_t binderoffset, const unsigned char *binderin,
+ unsigned char *binderout,
+ SSL_SESSION *sess, int sign, int external);
+
+/* Server Extension processing */
+int tls_parse_ctos_renegotiate(SSL *s, PACKET *pkt, unsigned int context,
+ X509 *x, size_t chainidx);
+int tls_parse_ctos_server_name(SSL *s, PACKET *pkt, unsigned int context,
+ X509 *x, size_t chainidx);
+int tls_parse_ctos_maxfragmentlen(SSL *s, PACKET *pkt, unsigned int context,
+ X509 *x, size_t chainidx);
+#ifndef OPENSSL_NO_SRP
+int tls_parse_ctos_srp(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
+ size_t chainidx);
+#endif
+int tls_parse_ctos_early_data(SSL *s, PACKET *pkt, unsigned int context,
+ X509 *x, size_t chainidx);
+#ifndef OPENSSL_NO_EC
+int tls_parse_ctos_ec_pt_formats(SSL *s, PACKET *pkt, unsigned int context,
+ X509 *x, size_t chainidx);
+#endif
+int tls_parse_ctos_supported_groups(SSL *s, PACKET *pkt, unsigned int context,
+ X509 *x, size_t chainidxl);
+int tls_parse_ctos_session_ticket(SSL *s, PACKET *pkt, unsigned int context,
+ X509 *x, size_t chainidx);
+int tls_parse_ctos_sig_algs_cert(SSL *s, PACKET *pkt, unsigned int context,
+ X509 *x, size_t chainidx);
+int tls_parse_ctos_sig_algs(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
+ size_t chainidx);
+#ifndef OPENSSL_NO_OCSP
+int tls_parse_ctos_status_request(SSL *s, PACKET *pkt, unsigned int context,
+ X509 *x, size_t chainidx);
+#endif
+#ifndef OPENSSL_NO_NEXTPROTONEG
+int tls_parse_ctos_npn(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
+ size_t chainidx);
+#endif
+int tls_parse_ctos_alpn(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
+ size_t chainidx);
+#ifndef OPENSSL_NO_SRTP
+int tls_parse_ctos_use_srtp(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
+ size_t chainidx);
+#endif
+int tls_parse_ctos_etm(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
+ size_t chainidx);
+int tls_parse_ctos_key_share(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
+ size_t chainidx);
+int tls_parse_ctos_cookie(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
+ size_t chainidx);
+int tls_parse_ctos_ems(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
+ size_t chainidx);
+int tls_parse_ctos_psk_kex_modes(SSL *s, PACKET *pkt, unsigned int context,
+ X509 *x, size_t chainidx);
+int tls_parse_ctos_psk(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
+ size_t chainidx);
+int tls_parse_ctos_post_handshake_auth(SSL *, PACKET *pkt, unsigned int context,
+ X509 *x, size_t chainidx);
+
+EXT_RETURN tls_construct_stoc_renegotiate(SSL *s, WPACKET *pkt,
+ unsigned int context, X509 *x,
+ size_t chainidx);
+EXT_RETURN tls_construct_stoc_server_name(SSL *s, WPACKET *pkt,
+ unsigned int context, X509 *x,
+ size_t chainidx);
+EXT_RETURN tls_construct_stoc_early_data(SSL *s, WPACKET *pkt,
+ unsigned int context, X509 *x,
+ size_t chainidx);
+EXT_RETURN tls_construct_stoc_maxfragmentlen(SSL *s, WPACKET *pkt,
+ unsigned int context, X509 *x,
+ size_t chainidx);
+#ifndef OPENSSL_NO_EC
+EXT_RETURN tls_construct_stoc_ec_pt_formats(SSL *s, WPACKET *pkt,
+ unsigned int context, X509 *x,
+ size_t chainidx);
+#endif
+EXT_RETURN tls_construct_stoc_supported_groups(SSL *s, WPACKET *pkt,
+ unsigned int context, X509 *x,
+ size_t chainidx);
+EXT_RETURN tls_construct_stoc_session_ticket(SSL *s, WPACKET *pkt,
+ unsigned int context, X509 *x,
+ size_t chainidx);
+#ifndef OPENSSL_NO_OCSP
+EXT_RETURN tls_construct_stoc_status_request(SSL *s, WPACKET *pkt,
+ unsigned int context, X509 *x,
+ size_t chainidx);
+#endif
+#ifndef OPENSSL_NO_NEXTPROTONEG
+EXT_RETURN tls_construct_stoc_next_proto_neg(SSL *s, WPACKET *pkt,
+ unsigned int context, X509 *x,
+ size_t chainidx);
+#endif
+EXT_RETURN tls_construct_stoc_alpn(SSL *s, WPACKET *pkt, unsigned int context,
+ X509 *x, size_t chainidx);
+#ifndef OPENSSL_NO_SRTP
+EXT_RETURN tls_construct_stoc_use_srtp(SSL *s, WPACKET *pkt, unsigned int context,
+ X509 *x, size_t chainidx);
+#endif
+EXT_RETURN tls_construct_stoc_etm(SSL *s, WPACKET *pkt, unsigned int context,
+ X509 *x, size_t chainidx);
+EXT_RETURN tls_construct_stoc_ems(SSL *s, WPACKET *pkt, unsigned int context,
+ X509 *x, size_t chainidx);
+EXT_RETURN tls_construct_stoc_supported_versions(SSL *s, WPACKET *pkt,
+ unsigned int context, X509 *x,
+ size_t chainidx);
+EXT_RETURN tls_construct_stoc_key_share(SSL *s, WPACKET *pkt,
+ unsigned int context, X509 *x,
+ size_t chainidx);
+EXT_RETURN tls_construct_stoc_cookie(SSL *s, WPACKET *pkt, unsigned int context,
+ X509 *x, size_t chainidx);
+/*
+ * Not in public headers as this is not an official extension. Only used when
+ * SSL_OP_CRYPTOPRO_TLSEXT_BUG is set.
+ */
+#define TLSEXT_TYPE_cryptopro_bug 0xfde8
+EXT_RETURN tls_construct_stoc_cryptopro_bug(SSL *s, WPACKET *pkt,
+ unsigned int context, X509 *x,
+ size_t chainidx);
+EXT_RETURN tls_construct_stoc_psk(SSL *s, WPACKET *pkt, unsigned int context,
+ X509 *x, size_t chainidx);
+
+/* Client Extension processing */
+EXT_RETURN tls_construct_ctos_renegotiate(SSL *s, WPACKET *pkt, unsigned int context,
+ X509 *x, size_t chainidx);
+EXT_RETURN tls_construct_ctos_server_name(SSL *s, WPACKET *pkt, unsigned int context,
+ X509 *x, size_t chainidx);
+EXT_RETURN tls_construct_ctos_maxfragmentlen(SSL *s, WPACKET *pkt, unsigned int context,
+ X509 *x, size_t chainidx);
+#ifndef OPENSSL_NO_SRP
+EXT_RETURN tls_construct_ctos_srp(SSL *s, WPACKET *pkt, unsigned int context, X509 *x,
+ size_t chainidx);
+#endif
+#ifndef OPENSSL_NO_EC
+EXT_RETURN tls_construct_ctos_ec_pt_formats(SSL *s, WPACKET *pkt,
+ unsigned int context, X509 *x,
+ size_t chainidx);
+#endif
+EXT_RETURN tls_construct_ctos_supported_groups(SSL *s, WPACKET *pkt,
+ unsigned int context, X509 *x,
+ size_t chainidx);
+
+EXT_RETURN tls_construct_ctos_early_data(SSL *s, WPACKET *pkt,
+ unsigned int context, X509 *x,
+ size_t chainidx);
+EXT_RETURN tls_construct_ctos_session_ticket(SSL *s, WPACKET *pkt,
+ unsigned int context, X509 *x,
+ size_t chainidx);
+EXT_RETURN tls_construct_ctos_sig_algs(SSL *s, WPACKET *pkt,
+ unsigned int context, X509 *x,
+ size_t chainidx);
+#ifndef OPENSSL_NO_OCSP
+EXT_RETURN tls_construct_ctos_status_request(SSL *s, WPACKET *pkt,
+ unsigned int context, X509 *x,
+ size_t chainidx);
+#endif
+#ifndef OPENSSL_NO_NEXTPROTONEG
+EXT_RETURN tls_construct_ctos_npn(SSL *s, WPACKET *pkt, unsigned int context,
+ X509 *x, size_t chainidx);
+#endif
+EXT_RETURN tls_construct_ctos_alpn(SSL *s, WPACKET *pkt, unsigned int context,
+ X509 *x, size_t chainidx);
+#ifndef OPENSSL_NO_SRTP
+EXT_RETURN tls_construct_ctos_use_srtp(SSL *s, WPACKET *pkt, unsigned int context,
+ X509 *x, size_t chainidx);
+#endif
+EXT_RETURN tls_construct_ctos_etm(SSL *s, WPACKET *pkt, unsigned int context,
+ X509 *x, size_t chainidx);
+#ifndef OPENSSL_NO_CT
+EXT_RETURN tls_construct_ctos_sct(SSL *s, WPACKET *pkt, unsigned int context,
+ X509 *x, size_t chainidx);
+#endif
+EXT_RETURN tls_construct_ctos_ems(SSL *s, WPACKET *pkt, unsigned int context,
+ X509 *x, size_t chainidx);
+EXT_RETURN tls_construct_ctos_supported_versions(SSL *s, WPACKET *pkt,
+ unsigned int context, X509 *x,
+ size_t chainidx);
+EXT_RETURN tls_construct_ctos_key_share(SSL *s, WPACKET *pkt,
+ unsigned int context, X509 *x,
+ size_t chainidx);
+EXT_RETURN tls_construct_ctos_psk_kex_modes(SSL *s, WPACKET *pkt,
+ unsigned int context, X509 *x,
+ size_t chainidx);
+EXT_RETURN tls_construct_ctos_cookie(SSL *s, WPACKET *pkt, unsigned int context,
+ X509 *x, size_t chainidx);
+EXT_RETURN tls_construct_ctos_padding(SSL *s, WPACKET *pkt,
+ unsigned int context, X509 *x,
+ size_t chainidx);
+EXT_RETURN tls_construct_ctos_psk(SSL *s, WPACKET *pkt, unsigned int context,
+ X509 *x, size_t chainidx);
+EXT_RETURN tls_construct_ctos_post_handshake_auth(SSL *s, WPACKET *pkt, unsigned int context,
+ X509 *x, size_t chainidx);
+
+int tls_parse_stoc_renegotiate(SSL *s, PACKET *pkt, unsigned int context,
+ X509 *x, size_t chainidx);
+int tls_parse_stoc_server_name(SSL *s, PACKET *pkt, unsigned int context,
+ X509 *x, size_t chainidx);
+int tls_parse_stoc_early_data(SSL *s, PACKET *pkt, unsigned int context,
+ X509 *x, size_t chainidx);
+int tls_parse_stoc_maxfragmentlen(SSL *s, PACKET *pkt, unsigned int context,
+ X509 *x, size_t chainidx);
+#ifndef OPENSSL_NO_EC
+int tls_parse_stoc_ec_pt_formats(SSL *s, PACKET *pkt, unsigned int context,
+ X509 *x, size_t chainidx);
+#endif
+int tls_parse_stoc_session_ticket(SSL *s, PACKET *pkt, unsigned int context,
+ X509 *x, size_t chainidx);
+#ifndef OPENSSL_NO_OCSP
+int tls_parse_stoc_status_request(SSL *s, PACKET *pkt, unsigned int context,
+ X509 *x, size_t chainidx);
+#endif
+#ifndef OPENSSL_NO_CT
+int tls_parse_stoc_sct(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
+ size_t chainidx);
+#endif
+#ifndef OPENSSL_NO_NEXTPROTONEG
+int tls_parse_stoc_npn(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
+ size_t chainidx);
+#endif
+int tls_parse_stoc_alpn(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
+ size_t chainidx);
+#ifndef OPENSSL_NO_SRTP
+int tls_parse_stoc_use_srtp(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
+ size_t chainidx);
+#endif
+int tls_parse_stoc_etm(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
+ size_t chainidx);
+int tls_parse_stoc_ems(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
+ size_t chainidx);
+int tls_parse_stoc_supported_versions(SSL *s, PACKET *pkt, unsigned int context,
+ X509 *x, size_t chainidx);
+int tls_parse_stoc_key_share(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
+ size_t chainidx);
+int tls_parse_stoc_cookie(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
+ size_t chainidx);
+int tls_parse_stoc_psk(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
+ size_t chainidx);
+
+int tls_handle_alpn(SSL *s);
+
+int tls13_save_handshake_digest_for_pha(SSL *s);
+int tls13_restore_handshake_digest_for_pha(SSL *s);
+++ /dev/null
-/*
- * Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-/*****************************************************************************
- * *
- * The following definitions are PRIVATE to the state machine. They should *
- * NOT be used outside of the state machine. *
- * *
- *****************************************************************************/
-
-/* Max message length definitions */
-
-/* The spec allows for a longer length than this, but we limit it */
-#define HELLO_VERIFY_REQUEST_MAX_LENGTH 258
-#define END_OF_EARLY_DATA_MAX_LENGTH 0
-#define SERVER_HELLO_MAX_LENGTH 20000
-#define HELLO_RETRY_REQUEST_MAX_LENGTH 20000
-#define ENCRYPTED_EXTENSIONS_MAX_LENGTH 20000
-#define SERVER_KEY_EXCH_MAX_LENGTH 102400
-#define SERVER_HELLO_DONE_MAX_LENGTH 0
-#define KEY_UPDATE_MAX_LENGTH 1
-#define CCS_MAX_LENGTH 1
-/* Max should actually be 36 but we are generous */
-#define FINISHED_MAX_LENGTH 64
-
-/* Dummy message type */
-#define SSL3_MT_DUMMY -1
-
-extern const unsigned char hrrrandom[];
-
-/* Message processing return codes */
-typedef enum {
- /* Something bad happened */
- MSG_PROCESS_ERROR,
- /* We've finished reading - swap to writing */
- MSG_PROCESS_FINISHED_READING,
- /*
- * We've completed the main processing of this message but there is some
- * post processing to be done.
- */
- MSG_PROCESS_CONTINUE_PROCESSING,
- /* We've finished this message - read the next message */
- MSG_PROCESS_CONTINUE_READING
-} MSG_PROCESS_RETURN;
-
-typedef int (*confunc_f) (SSL *s, WPACKET *pkt);
-
-int ssl3_take_mac(SSL *s);
-int check_in_list(SSL *s, uint16_t group_id, const uint16_t *groups,
- size_t num_groups, int checkallow);
-int create_synthetic_message_hash(SSL *s, const unsigned char *hashval,
- size_t hashlen, const unsigned char *hrr,
- size_t hrrlen);
-int parse_ca_names(SSL *s, PACKET *pkt);
-const STACK_OF(X509_NAME) *get_ca_names(SSL *s);
-int construct_ca_names(SSL *s, const STACK_OF(X509_NAME) *ca_sk, WPACKET *pkt);
-size_t construct_key_exchange_tbs(SSL *s, unsigned char **ptbs,
- const void *param, size_t paramlen);
-
-/*
- * TLS/DTLS client state machine functions
- */
-int ossl_statem_client_read_transition(SSL *s, int mt);
-WRITE_TRAN ossl_statem_client_write_transition(SSL *s);
-WORK_STATE ossl_statem_client_pre_work(SSL *s, WORK_STATE wst);
-WORK_STATE ossl_statem_client_post_work(SSL *s, WORK_STATE wst);
-int ossl_statem_client_construct_message(SSL *s, WPACKET *pkt,
- confunc_f *confunc, int *mt);
-size_t ossl_statem_client_max_message_size(SSL *s);
-MSG_PROCESS_RETURN ossl_statem_client_process_message(SSL *s, PACKET *pkt);
-WORK_STATE ossl_statem_client_post_process_message(SSL *s, WORK_STATE wst);
-
-/*
- * TLS/DTLS server state machine functions
- */
-int ossl_statem_server_read_transition(SSL *s, int mt);
-WRITE_TRAN ossl_statem_server_write_transition(SSL *s);
-WORK_STATE ossl_statem_server_pre_work(SSL *s, WORK_STATE wst);
-WORK_STATE ossl_statem_server_post_work(SSL *s, WORK_STATE wst);
-int ossl_statem_server_construct_message(SSL *s, WPACKET *pkt,
- confunc_f *confunc,int *mt);
-size_t ossl_statem_server_max_message_size(SSL *s);
-MSG_PROCESS_RETURN ossl_statem_server_process_message(SSL *s, PACKET *pkt);
-WORK_STATE ossl_statem_server_post_process_message(SSL *s, WORK_STATE wst);
-
-/* Functions for getting new message data */
-__owur int tls_get_message_header(SSL *s, int *mt);
-__owur int tls_get_message_body(SSL *s, size_t *len);
-__owur int dtls_get_message(SSL *s, int *mt, size_t *len);
-
-/* Message construction and processing functions */
-__owur int tls_process_initial_server_flight(SSL *s);
-__owur MSG_PROCESS_RETURN tls_process_change_cipher_spec(SSL *s, PACKET *pkt);
-__owur MSG_PROCESS_RETURN tls_process_finished(SSL *s, PACKET *pkt);
-__owur int tls_construct_change_cipher_spec(SSL *s, WPACKET *pkt);
-__owur int dtls_construct_change_cipher_spec(SSL *s, WPACKET *pkt);
-
-__owur int tls_construct_finished(SSL *s, WPACKET *pkt);
-__owur int tls_construct_key_update(SSL *s, WPACKET *pkt);
-__owur MSG_PROCESS_RETURN tls_process_key_update(SSL *s, PACKET *pkt);
-__owur WORK_STATE tls_finish_handshake(SSL *s, WORK_STATE wst, int clearbufs,
- int stop);
-__owur WORK_STATE dtls_wait_for_dry(SSL *s);
-
-/* some client-only functions */
-__owur int tls_construct_client_hello(SSL *s, WPACKET *pkt);
-__owur MSG_PROCESS_RETURN tls_process_server_hello(SSL *s, PACKET *pkt);
-__owur MSG_PROCESS_RETURN tls_process_certificate_request(SSL *s, PACKET *pkt);
-__owur MSG_PROCESS_RETURN tls_process_new_session_ticket(SSL *s, PACKET *pkt);
-__owur int tls_process_cert_status_body(SSL *s, PACKET *pkt);
-__owur MSG_PROCESS_RETURN tls_process_cert_status(SSL *s, PACKET *pkt);
-__owur MSG_PROCESS_RETURN tls_process_server_done(SSL *s, PACKET *pkt);
-__owur int tls_construct_cert_verify(SSL *s, WPACKET *pkt);
-__owur WORK_STATE tls_prepare_client_certificate(SSL *s, WORK_STATE wst);
-__owur int tls_construct_client_certificate(SSL *s, WPACKET *pkt);
-__owur int ssl_do_client_cert_cb(SSL *s, X509 **px509, EVP_PKEY **ppkey);
-__owur int tls_construct_client_key_exchange(SSL *s, WPACKET *pkt);
-__owur int tls_client_key_exchange_post_work(SSL *s);
-__owur int tls_construct_cert_status_body(SSL *s, WPACKET *pkt);
-__owur int tls_construct_cert_status(SSL *s, WPACKET *pkt);
-__owur MSG_PROCESS_RETURN tls_process_key_exchange(SSL *s, PACKET *pkt);
-__owur MSG_PROCESS_RETURN tls_process_server_certificate(SSL *s, PACKET *pkt);
-__owur int ssl3_check_cert_and_algorithm(SSL *s);
-#ifndef OPENSSL_NO_NEXTPROTONEG
-__owur int tls_construct_next_proto(SSL *s, WPACKET *pkt);
-#endif
-__owur MSG_PROCESS_RETURN tls_process_hello_req(SSL *s, PACKET *pkt);
-__owur MSG_PROCESS_RETURN dtls_process_hello_verify(SSL *s, PACKET *pkt);
-__owur int tls_construct_end_of_early_data(SSL *s, WPACKET *pkt);
-
-/* some server-only functions */
-__owur MSG_PROCESS_RETURN tls_process_client_hello(SSL *s, PACKET *pkt);
-__owur WORK_STATE tls_post_process_client_hello(SSL *s, WORK_STATE wst);
-__owur int tls_construct_server_hello(SSL *s, WPACKET *pkt);
-__owur int dtls_construct_hello_verify_request(SSL *s, WPACKET *pkt);
-__owur int tls_construct_server_certificate(SSL *s, WPACKET *pkt);
-__owur int tls_construct_server_key_exchange(SSL *s, WPACKET *pkt);
-__owur int tls_construct_certificate_request(SSL *s, WPACKET *pkt);
-__owur int tls_construct_server_done(SSL *s, WPACKET *pkt);
-__owur MSG_PROCESS_RETURN tls_process_client_certificate(SSL *s, PACKET *pkt);
-__owur MSG_PROCESS_RETURN tls_process_client_key_exchange(SSL *s, PACKET *pkt);
-__owur WORK_STATE tls_post_process_client_key_exchange(SSL *s, WORK_STATE wst);
-__owur MSG_PROCESS_RETURN tls_process_cert_verify(SSL *s, PACKET *pkt);
-#ifndef OPENSSL_NO_NEXTPROTONEG
-__owur MSG_PROCESS_RETURN tls_process_next_proto(SSL *s, PACKET *pkt);
-#endif
-__owur int tls_construct_new_session_ticket(SSL *s, WPACKET *pkt);
-MSG_PROCESS_RETURN tls_process_end_of_early_data(SSL *s, PACKET *pkt);
-
-
-/* Extension processing */
-
-typedef enum ext_return_en {
- EXT_RETURN_FAIL,
- EXT_RETURN_SENT,
- EXT_RETURN_NOT_SENT
-} EXT_RETURN;
-
-__owur int tls_validate_all_contexts(SSL *s, unsigned int thisctx,
- RAW_EXTENSION *exts);
-__owur int extension_is_relevant(SSL *s, unsigned int extctx,
- unsigned int thisctx);
-__owur int tls_collect_extensions(SSL *s, PACKET *packet, unsigned int context,
- RAW_EXTENSION **res, size_t *len, int init);
-__owur int tls_parse_extension(SSL *s, TLSEXT_INDEX idx, int context,
- RAW_EXTENSION *exts, X509 *x, size_t chainidx);
-__owur int tls_parse_all_extensions(SSL *s, int context, RAW_EXTENSION *exts,
- X509 *x, size_t chainidx, int fin);
-__owur int should_add_extension(SSL *s, unsigned int extctx,
- unsigned int thisctx, int max_version);
-__owur int tls_construct_extensions(SSL *s, WPACKET *pkt, unsigned int context,
- X509 *x, size_t chainidx);
-
-__owur int tls_psk_do_binder(SSL *s, const EVP_MD *md,
- const unsigned char *msgstart,
- size_t binderoffset, const unsigned char *binderin,
- unsigned char *binderout,
- SSL_SESSION *sess, int sign, int external);
-
-/* Server Extension processing */
-int tls_parse_ctos_renegotiate(SSL *s, PACKET *pkt, unsigned int context,
- X509 *x, size_t chainidx);
-int tls_parse_ctos_server_name(SSL *s, PACKET *pkt, unsigned int context,
- X509 *x, size_t chainidx);
-int tls_parse_ctos_maxfragmentlen(SSL *s, PACKET *pkt, unsigned int context,
- X509 *x, size_t chainidx);
-#ifndef OPENSSL_NO_SRP
-int tls_parse_ctos_srp(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
- size_t chainidx);
-#endif
-int tls_parse_ctos_early_data(SSL *s, PACKET *pkt, unsigned int context,
- X509 *x, size_t chainidx);
-#ifndef OPENSSL_NO_EC
-int tls_parse_ctos_ec_pt_formats(SSL *s, PACKET *pkt, unsigned int context,
- X509 *x, size_t chainidx);
-#endif
-int tls_parse_ctos_supported_groups(SSL *s, PACKET *pkt, unsigned int context,
- X509 *x, size_t chainidxl);
-int tls_parse_ctos_session_ticket(SSL *s, PACKET *pkt, unsigned int context,
- X509 *x, size_t chainidx);
-int tls_parse_ctos_sig_algs_cert(SSL *s, PACKET *pkt, unsigned int context,
- X509 *x, size_t chainidx);
-int tls_parse_ctos_sig_algs(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
- size_t chainidx);
-#ifndef OPENSSL_NO_OCSP
-int tls_parse_ctos_status_request(SSL *s, PACKET *pkt, unsigned int context,
- X509 *x, size_t chainidx);
-#endif
-#ifndef OPENSSL_NO_NEXTPROTONEG
-int tls_parse_ctos_npn(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
- size_t chainidx);
-#endif
-int tls_parse_ctos_alpn(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
- size_t chainidx);
-#ifndef OPENSSL_NO_SRTP
-int tls_parse_ctos_use_srtp(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
- size_t chainidx);
-#endif
-int tls_parse_ctos_etm(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
- size_t chainidx);
-int tls_parse_ctos_key_share(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
- size_t chainidx);
-int tls_parse_ctos_cookie(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
- size_t chainidx);
-int tls_parse_ctos_ems(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
- size_t chainidx);
-int tls_parse_ctos_psk_kex_modes(SSL *s, PACKET *pkt, unsigned int context,
- X509 *x, size_t chainidx);
-int tls_parse_ctos_psk(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
- size_t chainidx);
-int tls_parse_ctos_post_handshake_auth(SSL *, PACKET *pkt, unsigned int context,
- X509 *x, size_t chainidx);
-
-EXT_RETURN tls_construct_stoc_renegotiate(SSL *s, WPACKET *pkt,
- unsigned int context, X509 *x,
- size_t chainidx);
-EXT_RETURN tls_construct_stoc_server_name(SSL *s, WPACKET *pkt,
- unsigned int context, X509 *x,
- size_t chainidx);
-EXT_RETURN tls_construct_stoc_early_data(SSL *s, WPACKET *pkt,
- unsigned int context, X509 *x,
- size_t chainidx);
-EXT_RETURN tls_construct_stoc_maxfragmentlen(SSL *s, WPACKET *pkt,
- unsigned int context, X509 *x,
- size_t chainidx);
-#ifndef OPENSSL_NO_EC
-EXT_RETURN tls_construct_stoc_ec_pt_formats(SSL *s, WPACKET *pkt,
- unsigned int context, X509 *x,
- size_t chainidx);
-#endif
-EXT_RETURN tls_construct_stoc_supported_groups(SSL *s, WPACKET *pkt,
- unsigned int context, X509 *x,
- size_t chainidx);
-EXT_RETURN tls_construct_stoc_session_ticket(SSL *s, WPACKET *pkt,
- unsigned int context, X509 *x,
- size_t chainidx);
-#ifndef OPENSSL_NO_OCSP
-EXT_RETURN tls_construct_stoc_status_request(SSL *s, WPACKET *pkt,
- unsigned int context, X509 *x,
- size_t chainidx);
-#endif
-#ifndef OPENSSL_NO_NEXTPROTONEG
-EXT_RETURN tls_construct_stoc_next_proto_neg(SSL *s, WPACKET *pkt,
- unsigned int context, X509 *x,
- size_t chainidx);
-#endif
-EXT_RETURN tls_construct_stoc_alpn(SSL *s, WPACKET *pkt, unsigned int context,
- X509 *x, size_t chainidx);
-#ifndef OPENSSL_NO_SRTP
-EXT_RETURN tls_construct_stoc_use_srtp(SSL *s, WPACKET *pkt, unsigned int context,
- X509 *x, size_t chainidx);
-#endif
-EXT_RETURN tls_construct_stoc_etm(SSL *s, WPACKET *pkt, unsigned int context,
- X509 *x, size_t chainidx);
-EXT_RETURN tls_construct_stoc_ems(SSL *s, WPACKET *pkt, unsigned int context,
- X509 *x, size_t chainidx);
-EXT_RETURN tls_construct_stoc_supported_versions(SSL *s, WPACKET *pkt,
- unsigned int context, X509 *x,
- size_t chainidx);
-EXT_RETURN tls_construct_stoc_key_share(SSL *s, WPACKET *pkt,
- unsigned int context, X509 *x,
- size_t chainidx);
-EXT_RETURN tls_construct_stoc_cookie(SSL *s, WPACKET *pkt, unsigned int context,
- X509 *x, size_t chainidx);
-/*
- * Not in public headers as this is not an official extension. Only used when
- * SSL_OP_CRYPTOPRO_TLSEXT_BUG is set.
- */
-#define TLSEXT_TYPE_cryptopro_bug 0xfde8
-EXT_RETURN tls_construct_stoc_cryptopro_bug(SSL *s, WPACKET *pkt,
- unsigned int context, X509 *x,
- size_t chainidx);
-EXT_RETURN tls_construct_stoc_psk(SSL *s, WPACKET *pkt, unsigned int context,
- X509 *x, size_t chainidx);
-
-/* Client Extension processing */
-EXT_RETURN tls_construct_ctos_renegotiate(SSL *s, WPACKET *pkt, unsigned int context,
- X509 *x, size_t chainidx);
-EXT_RETURN tls_construct_ctos_server_name(SSL *s, WPACKET *pkt, unsigned int context,
- X509 *x, size_t chainidx);
-EXT_RETURN tls_construct_ctos_maxfragmentlen(SSL *s, WPACKET *pkt, unsigned int context,
- X509 *x, size_t chainidx);
-#ifndef OPENSSL_NO_SRP
-EXT_RETURN tls_construct_ctos_srp(SSL *s, WPACKET *pkt, unsigned int context, X509 *x,
- size_t chainidx);
-#endif
-#ifndef OPENSSL_NO_EC
-EXT_RETURN tls_construct_ctos_ec_pt_formats(SSL *s, WPACKET *pkt,
- unsigned int context, X509 *x,
- size_t chainidx);
-#endif
-EXT_RETURN tls_construct_ctos_supported_groups(SSL *s, WPACKET *pkt,
- unsigned int context, X509 *x,
- size_t chainidx);
-
-EXT_RETURN tls_construct_ctos_early_data(SSL *s, WPACKET *pkt,
- unsigned int context, X509 *x,
- size_t chainidx);
-EXT_RETURN tls_construct_ctos_session_ticket(SSL *s, WPACKET *pkt,
- unsigned int context, X509 *x,
- size_t chainidx);
-EXT_RETURN tls_construct_ctos_sig_algs(SSL *s, WPACKET *pkt,
- unsigned int context, X509 *x,
- size_t chainidx);
-#ifndef OPENSSL_NO_OCSP
-EXT_RETURN tls_construct_ctos_status_request(SSL *s, WPACKET *pkt,
- unsigned int context, X509 *x,
- size_t chainidx);
-#endif
-#ifndef OPENSSL_NO_NEXTPROTONEG
-EXT_RETURN tls_construct_ctos_npn(SSL *s, WPACKET *pkt, unsigned int context,
- X509 *x, size_t chainidx);
-#endif
-EXT_RETURN tls_construct_ctos_alpn(SSL *s, WPACKET *pkt, unsigned int context,
- X509 *x, size_t chainidx);
-#ifndef OPENSSL_NO_SRTP
-EXT_RETURN tls_construct_ctos_use_srtp(SSL *s, WPACKET *pkt, unsigned int context,
- X509 *x, size_t chainidx);
-#endif
-EXT_RETURN tls_construct_ctos_etm(SSL *s, WPACKET *pkt, unsigned int context,
- X509 *x, size_t chainidx);
-#ifndef OPENSSL_NO_CT
-EXT_RETURN tls_construct_ctos_sct(SSL *s, WPACKET *pkt, unsigned int context,
- X509 *x, size_t chainidx);
-#endif
-EXT_RETURN tls_construct_ctos_ems(SSL *s, WPACKET *pkt, unsigned int context,
- X509 *x, size_t chainidx);
-EXT_RETURN tls_construct_ctos_supported_versions(SSL *s, WPACKET *pkt,
- unsigned int context, X509 *x,
- size_t chainidx);
-EXT_RETURN tls_construct_ctos_key_share(SSL *s, WPACKET *pkt,
- unsigned int context, X509 *x,
- size_t chainidx);
-EXT_RETURN tls_construct_ctos_psk_kex_modes(SSL *s, WPACKET *pkt,
- unsigned int context, X509 *x,
- size_t chainidx);
-EXT_RETURN tls_construct_ctos_cookie(SSL *s, WPACKET *pkt, unsigned int context,
- X509 *x, size_t chainidx);
-EXT_RETURN tls_construct_ctos_padding(SSL *s, WPACKET *pkt,
- unsigned int context, X509 *x,
- size_t chainidx);
-EXT_RETURN tls_construct_ctos_psk(SSL *s, WPACKET *pkt, unsigned int context,
- X509 *x, size_t chainidx);
-EXT_RETURN tls_construct_ctos_post_handshake_auth(SSL *s, WPACKET *pkt, unsigned int context,
- X509 *x, size_t chainidx);
-
-int tls_parse_stoc_renegotiate(SSL *s, PACKET *pkt, unsigned int context,
- X509 *x, size_t chainidx);
-int tls_parse_stoc_server_name(SSL *s, PACKET *pkt, unsigned int context,
- X509 *x, size_t chainidx);
-int tls_parse_stoc_early_data(SSL *s, PACKET *pkt, unsigned int context,
- X509 *x, size_t chainidx);
-int tls_parse_stoc_maxfragmentlen(SSL *s, PACKET *pkt, unsigned int context,
- X509 *x, size_t chainidx);
-#ifndef OPENSSL_NO_EC
-int tls_parse_stoc_ec_pt_formats(SSL *s, PACKET *pkt, unsigned int context,
- X509 *x, size_t chainidx);
-#endif
-int tls_parse_stoc_session_ticket(SSL *s, PACKET *pkt, unsigned int context,
- X509 *x, size_t chainidx);
-#ifndef OPENSSL_NO_OCSP
-int tls_parse_stoc_status_request(SSL *s, PACKET *pkt, unsigned int context,
- X509 *x, size_t chainidx);
-#endif
-#ifndef OPENSSL_NO_CT
-int tls_parse_stoc_sct(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
- size_t chainidx);
-#endif
-#ifndef OPENSSL_NO_NEXTPROTONEG
-int tls_parse_stoc_npn(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
- size_t chainidx);
-#endif
-int tls_parse_stoc_alpn(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
- size_t chainidx);
-#ifndef OPENSSL_NO_SRTP
-int tls_parse_stoc_use_srtp(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
- size_t chainidx);
-#endif
-int tls_parse_stoc_etm(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
- size_t chainidx);
-int tls_parse_stoc_ems(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
- size_t chainidx);
-int tls_parse_stoc_supported_versions(SSL *s, PACKET *pkt, unsigned int context,
- X509 *x, size_t chainidx);
-int tls_parse_stoc_key_share(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
- size_t chainidx);
-int tls_parse_stoc_cookie(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
- size_t chainidx);
-int tls_parse_stoc_psk(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
- size_t chainidx);
-
-int tls_handle_alpn(SSL *s);
-
-int tls13_save_handshake_digest_for_pha(SSL *s);
-int tls13_restore_handshake_digest_for_pha(SSL *s);
*/
#include <stdio.h>
-#include "../ssl_locl.h"
-#include "statem_locl.h"
-#include "internal/constant_time_locl.h"
+#include "../ssl_local.h"
+#include "statem_local.h"
+#include "internal/constant_time.h"
#include "internal/cryptlib.h"
#include <openssl/buffer.h>
#include <openssl/rand.h>
*/
#include <stdio.h>
-#include "ssl_locl.h"
-#include "record/record_locl.h"
+#include "ssl_local.h"
+#include "record/record_local.h"
#include "internal/ktls.h"
#include "internal/cryptlib.h"
#include <openssl/comp.h>
#include <openssl/dh.h>
#include <openssl/bn.h>
#include "internal/nelem.h"
-#include "ssl_locl.h"
+#include "ssl_local.h"
#include <openssl/ct.h>
static const SIGALG_LOOKUP *find_sig_alg(SSL *s, X509 *x, EVP_PKEY *pkey);
* https://www.openssl.org/source/license.html
*/
-#include "ssl_locl.h"
+#include "ssl_local.h"
#ifndef OPENSSL_NO_SSL_TRACE
*/
#include <stdlib.h>
-#include "ssl_locl.h"
+#include "ssl_local.h"
#include "internal/cryptlib.h"
#include <openssl/evp.h>
#include <openssl/kdf.h>
#include <openssl/crypto.h>
#include <openssl/rand.h>
#include <openssl/err.h>
-#include "ssl_locl.h"
+#include "ssl_local.h"
#ifndef OPENSSL_NO_SRP
# include <openssl/srp.h>
#include "internal/nelem.h"
#include "testutil.h"
-#include "../ssl/ssl_locl.h"
+#include "../ssl/ssl_local.h"
static int cipher_overhead(void)
{
# include <openssl/pem.h>
# include <openssl/rand.h>
-#include "../crypto/cmp/cmp_int.h"
+#include "../crypto/cmp/cmp_local.h"
# include "testutil.h"
#include <stdlib.h>
#include "internal/nelem.h"
-#include "internal/constant_time_locl.h"
+#include "internal/constant_time.h"
#include "testutil.h"
#include "internal/numbers.h"
#include <string.h>
#include <openssl/e_os2.h>
#include <openssl/evp.h>
-#include "curve448_lcl.h"
+#include "curve448_local.h"
#include "testutil.h"
static unsigned int max = 1000;
#include <openssl/obj_mac.h>
#include <openssl/evp.h>
#include <openssl/aes.h>
-#include "../crypto/rand/rand_lcl.h"
+#include "../crypto/rand/rand_local.h"
#include "testutil.h"
#include "drbg_cavs_data.h"
#include <openssl/obj_mac.h>
#include <openssl/evp.h>
#include <openssl/aes.h>
-#include "../crypto/rand/rand_lcl.h"
+#include "../crypto/rand/rand_local.h"
#include "../include/crypto/rand.h"
#if defined(_WIN32)
#include "testutil.h"
/* for SSL_READ_ETM() */
-#include "../ssl/ssl_locl.h"
+#include "../ssl/ssl_local.h"
static int debug = 0;
#include "internal/nelem.h"
#include "testutil.h"
#include <openssl/ec.h>
-#include "ec_lcl.h"
+#include "ec_local.h"
#include <openssl/objects.h>
static size_t crv_len = 0;
#include <openssl/srp.h>
#endif
-#include "../ssl/ssl_locl.h"
+#include "../ssl/ssl_local.h"
#include "internal/sockets.h"
#include "internal/nelem.h"
#include "handshake_helper.h"
#include "testutil.h"
#include "internal/nelem.h"
#include "internal/property.h"
-#include "../crypto/property/property_lcl.h"
+#include "../crypto/property/property_local.h"
static int add_property_names(const char *n, ...)
{
return 1;
}
#else
-# include "rsa_locl.h"
+# include "rsa_local.h"
# include <openssl/rsa.h>
/* taken from RSA2 cavs data */
#include <openssl/ssl.h>
#include "testutil.h"
#include "internal/nelem.h"
-#include "../ssl/ssl_locl.h"
+#include "../ssl/ssl_local.h"
#include "../ssl/ssl_cert_table.h"
#define test_cert_table(nid, amask, idx) \
#include "testutil/output.h"
#include "internal/nelem.h"
#include "internal/ktls.h"
-#include "../ssl/ssl_locl.h"
+#include "../ssl/ssl_local.h"
#ifndef OPENSSL_NO_TLS1_3
#include <openssl/ssl.h>
#include <openssl/evp.h>
-#include "../ssl/ssl_locl.h"
-#include "../ssl/record/record_locl.h"
+#include "../ssl/ssl_local.h"
+#include "../ssl/record/record_local.h"
#include "internal/nelem.h"
#include "testutil.h"
#include <openssl/ssl.h>
#include <openssl/evp.h>
-#include "../ssl/ssl_locl.h"
+#include "../ssl/ssl_local.h"
#include "testutil.h"
#define IVLEN 12