Merge pull request #27 from pandamicro/master
Sync 1.5 and Upgrade to Spidermonkey v52
This commit is contained in:
commit
7483966da7
|
|
@ -69,6 +69,21 @@ endif
|
|||
|
||||
include $(PREBUILT_STATIC_LIBRARY)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := cocos_crypto_static
|
||||
LOCAL_MODULE_FILENAME := crypto
|
||||
LOCAL_SRC_FILES := $(TARGET_ARCH_ABI)/libcrypto.a
|
||||
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/$(TARGET_ARCH_ABI)/include
|
||||
include $(PREBUILT_STATIC_LIBRARY)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := cocos_ssl_static
|
||||
LOCAL_MODULE_FILENAME := ssl
|
||||
LOCAL_SRC_FILES := $(TARGET_ARCH_ABI)/libssl.a
|
||||
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/$(TARGET_ARCH_ABI)/include
|
||||
include $(PREBUILT_STATIC_LIBRARY)
|
||||
|
||||
#======================================
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,92 @@
|
|||
/*
|
||||
* Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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_H
|
||||
# define HEADER_AES_H
|
||||
|
||||
# include <openssl/opensslconf.h>
|
||||
|
||||
# include <stddef.h>
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
# endif
|
||||
|
||||
# define AES_ENCRYPT 1
|
||||
# define AES_DECRYPT 0
|
||||
|
||||
/*
|
||||
* Because array size can't be a const in C, the following two are macros.
|
||||
* Both sizes are in bytes.
|
||||
*/
|
||||
# define AES_MAXNR 14
|
||||
# define AES_BLOCK_SIZE 16
|
||||
|
||||
/* This should be a hidden type, but EVP requires that the size be known */
|
||||
struct aes_key_st {
|
||||
# ifdef AES_LONG
|
||||
unsigned long rd_key[4 * (AES_MAXNR + 1)];
|
||||
# else
|
||||
unsigned int rd_key[4 * (AES_MAXNR + 1)];
|
||||
# endif
|
||||
int rounds;
|
||||
};
|
||||
typedef struct aes_key_st AES_KEY;
|
||||
|
||||
const char *AES_options(void);
|
||||
|
||||
int AES_set_encrypt_key(const unsigned char *userKey, const int bits,
|
||||
AES_KEY *key);
|
||||
int AES_set_decrypt_key(const unsigned char *userKey, const int bits,
|
||||
AES_KEY *key);
|
||||
|
||||
void AES_encrypt(const unsigned char *in, unsigned char *out,
|
||||
const AES_KEY *key);
|
||||
void AES_decrypt(const unsigned char *in, unsigned char *out,
|
||||
const AES_KEY *key);
|
||||
|
||||
void AES_ecb_encrypt(const unsigned char *in, unsigned char *out,
|
||||
const AES_KEY *key, const int enc);
|
||||
void AES_cbc_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t length, const AES_KEY *key,
|
||||
unsigned char *ivec, const int enc);
|
||||
void AES_cfb128_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t length, const AES_KEY *key,
|
||||
unsigned char *ivec, int *num, const int enc);
|
||||
void AES_cfb1_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t length, const AES_KEY *key,
|
||||
unsigned char *ivec, int *num, const int enc);
|
||||
void AES_cfb8_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t length, const AES_KEY *key,
|
||||
unsigned char *ivec, int *num, const int enc);
|
||||
void AES_ofb128_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t length, const AES_KEY *key,
|
||||
unsigned char *ivec, int *num);
|
||||
/* NB: the IV is _two_ blocks long */
|
||||
void AES_ige_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t length, const AES_KEY *key,
|
||||
unsigned char *ivec, const int enc);
|
||||
/* NB: the IV is _four_ blocks long */
|
||||
void AES_bi_ige_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t length, const AES_KEY *key,
|
||||
const AES_KEY *key2, const unsigned char *ivec,
|
||||
const int enc);
|
||||
|
||||
int AES_wrap_key(AES_KEY *key, const unsigned char *iv,
|
||||
unsigned char *out,
|
||||
const unsigned char *in, unsigned int inlen);
|
||||
int AES_unwrap_key(AES_KEY *key, const unsigned char *iv,
|
||||
unsigned char *out,
|
||||
const unsigned char *in, unsigned int inlen);
|
||||
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,10 @@
|
|||
/*
|
||||
* Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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
|
||||
*/
|
||||
|
||||
#error "This file is obsolete; please update your software."
|
||||
|
|
@ -0,0 +1,924 @@
|
|||
/*
|
||||
* Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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_ASN1T_H
|
||||
# define HEADER_ASN1T_H
|
||||
|
||||
# include <stddef.h>
|
||||
# include <openssl/e_os2.h>
|
||||
# include <openssl/asn1.h>
|
||||
|
||||
# ifdef OPENSSL_BUILD_SHLIBCRYPTO
|
||||
# undef OPENSSL_EXTERN
|
||||
# define OPENSSL_EXTERN OPENSSL_EXPORT
|
||||
# endif
|
||||
|
||||
/* ASN1 template defines, structures and functions */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION
|
||||
|
||||
/* Macro to obtain ASN1_ADB pointer from a type (only used internally) */
|
||||
# define ASN1_ADB_ptr(iptr) ((const ASN1_ADB *)(iptr))
|
||||
|
||||
/* Macros for start and end of ASN1_ITEM definition */
|
||||
|
||||
# define ASN1_ITEM_start(itname) \
|
||||
OPENSSL_GLOBAL const ASN1_ITEM itname##_it = {
|
||||
|
||||
# define static_ASN1_ITEM_start(itname) \
|
||||
static const ASN1_ITEM itname##_it = {
|
||||
|
||||
# define ASN1_ITEM_end(itname) \
|
||||
};
|
||||
|
||||
# else
|
||||
|
||||
/* Macro to obtain ASN1_ADB pointer from a type (only used internally) */
|
||||
# define ASN1_ADB_ptr(iptr) ((const ASN1_ADB *)(iptr()))
|
||||
|
||||
/* Macros for start and end of ASN1_ITEM definition */
|
||||
|
||||
# define ASN1_ITEM_start(itname) \
|
||||
const ASN1_ITEM * itname##_it(void) \
|
||||
{ \
|
||||
static const ASN1_ITEM local_it = {
|
||||
|
||||
# define static_ASN1_ITEM_start(itname) \
|
||||
static ASN1_ITEM_start(itname)
|
||||
|
||||
# define ASN1_ITEM_end(itname) \
|
||||
}; \
|
||||
return &local_it; \
|
||||
}
|
||||
|
||||
# endif
|
||||
|
||||
/* Macros to aid ASN1 template writing */
|
||||
|
||||
# define ASN1_ITEM_TEMPLATE(tname) \
|
||||
static const ASN1_TEMPLATE tname##_item_tt
|
||||
|
||||
# define ASN1_ITEM_TEMPLATE_END(tname) \
|
||||
;\
|
||||
ASN1_ITEM_start(tname) \
|
||||
ASN1_ITYPE_PRIMITIVE,\
|
||||
-1,\
|
||||
&tname##_item_tt,\
|
||||
0,\
|
||||
NULL,\
|
||||
0,\
|
||||
#tname \
|
||||
ASN1_ITEM_end(tname)
|
||||
# define static_ASN1_ITEM_TEMPLATE_END(tname) \
|
||||
;\
|
||||
static_ASN1_ITEM_start(tname) \
|
||||
ASN1_ITYPE_PRIMITIVE,\
|
||||
-1,\
|
||||
&tname##_item_tt,\
|
||||
0,\
|
||||
NULL,\
|
||||
0,\
|
||||
#tname \
|
||||
ASN1_ITEM_end(tname)
|
||||
|
||||
/* This is a ASN1 type which just embeds a template */
|
||||
|
||||
/*-
|
||||
* This pair helps declare a SEQUENCE. We can do:
|
||||
*
|
||||
* ASN1_SEQUENCE(stname) = {
|
||||
* ... SEQUENCE components ...
|
||||
* } ASN1_SEQUENCE_END(stname)
|
||||
*
|
||||
* This will produce an ASN1_ITEM called stname_it
|
||||
* for a structure called stname.
|
||||
*
|
||||
* If you want the same structure but a different
|
||||
* name then use:
|
||||
*
|
||||
* ASN1_SEQUENCE(itname) = {
|
||||
* ... SEQUENCE components ...
|
||||
* } ASN1_SEQUENCE_END_name(stname, itname)
|
||||
*
|
||||
* This will create an item called itname_it using
|
||||
* a structure called stname.
|
||||
*/
|
||||
|
||||
# define ASN1_SEQUENCE(tname) \
|
||||
static const ASN1_TEMPLATE tname##_seq_tt[]
|
||||
|
||||
# define ASN1_SEQUENCE_END(stname) ASN1_SEQUENCE_END_name(stname, stname)
|
||||
|
||||
# define static_ASN1_SEQUENCE_END(stname) static_ASN1_SEQUENCE_END_name(stname, stname)
|
||||
|
||||
# define ASN1_SEQUENCE_END_name(stname, tname) \
|
||||
;\
|
||||
ASN1_ITEM_start(tname) \
|
||||
ASN1_ITYPE_SEQUENCE,\
|
||||
V_ASN1_SEQUENCE,\
|
||||
tname##_seq_tt,\
|
||||
sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
|
||||
NULL,\
|
||||
sizeof(stname),\
|
||||
#stname \
|
||||
ASN1_ITEM_end(tname)
|
||||
|
||||
# define static_ASN1_SEQUENCE_END_name(stname, tname) \
|
||||
;\
|
||||
static_ASN1_ITEM_start(tname) \
|
||||
ASN1_ITYPE_SEQUENCE,\
|
||||
V_ASN1_SEQUENCE,\
|
||||
tname##_seq_tt,\
|
||||
sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
|
||||
NULL,\
|
||||
sizeof(stname),\
|
||||
#stname \
|
||||
ASN1_ITEM_end(tname)
|
||||
|
||||
# define ASN1_NDEF_SEQUENCE(tname) \
|
||||
ASN1_SEQUENCE(tname)
|
||||
|
||||
# define ASN1_NDEF_SEQUENCE_cb(tname, cb) \
|
||||
ASN1_SEQUENCE_cb(tname, cb)
|
||||
|
||||
# define ASN1_SEQUENCE_cb(tname, cb) \
|
||||
static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0}; \
|
||||
ASN1_SEQUENCE(tname)
|
||||
|
||||
# define ASN1_BROKEN_SEQUENCE(tname) \
|
||||
static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_BROKEN, 0, 0, 0, 0}; \
|
||||
ASN1_SEQUENCE(tname)
|
||||
|
||||
# define ASN1_SEQUENCE_ref(tname, cb) \
|
||||
static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_REFCOUNT, offsetof(tname, references), offsetof(tname, lock), cb, 0}; \
|
||||
ASN1_SEQUENCE(tname)
|
||||
|
||||
# define ASN1_SEQUENCE_enc(tname, enc, cb) \
|
||||
static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_ENCODING, 0, 0, cb, offsetof(tname, enc)}; \
|
||||
ASN1_SEQUENCE(tname)
|
||||
|
||||
# define ASN1_NDEF_SEQUENCE_END(tname) \
|
||||
;\
|
||||
ASN1_ITEM_start(tname) \
|
||||
ASN1_ITYPE_NDEF_SEQUENCE,\
|
||||
V_ASN1_SEQUENCE,\
|
||||
tname##_seq_tt,\
|
||||
sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
|
||||
NULL,\
|
||||
sizeof(tname),\
|
||||
#tname \
|
||||
ASN1_ITEM_end(tname)
|
||||
# define static_ASN1_NDEF_SEQUENCE_END(tname) \
|
||||
;\
|
||||
static_ASN1_ITEM_start(tname) \
|
||||
ASN1_ITYPE_NDEF_SEQUENCE,\
|
||||
V_ASN1_SEQUENCE,\
|
||||
tname##_seq_tt,\
|
||||
sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
|
||||
NULL,\
|
||||
sizeof(tname),\
|
||||
#tname \
|
||||
ASN1_ITEM_end(tname)
|
||||
|
||||
# define ASN1_BROKEN_SEQUENCE_END(stname) ASN1_SEQUENCE_END_ref(stname, stname)
|
||||
# define static_ASN1_BROKEN_SEQUENCE_END(stname) \
|
||||
static_ASN1_SEQUENCE_END_ref(stname, stname)
|
||||
|
||||
# define ASN1_SEQUENCE_END_enc(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname)
|
||||
|
||||
# define ASN1_SEQUENCE_END_cb(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname)
|
||||
# define static_ASN1_SEQUENCE_END_cb(stname, tname) static_ASN1_SEQUENCE_END_ref(stname, tname)
|
||||
|
||||
# define ASN1_SEQUENCE_END_ref(stname, tname) \
|
||||
;\
|
||||
ASN1_ITEM_start(tname) \
|
||||
ASN1_ITYPE_SEQUENCE,\
|
||||
V_ASN1_SEQUENCE,\
|
||||
tname##_seq_tt,\
|
||||
sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
|
||||
&tname##_aux,\
|
||||
sizeof(stname),\
|
||||
#stname \
|
||||
ASN1_ITEM_end(tname)
|
||||
# define static_ASN1_SEQUENCE_END_ref(stname, tname) \
|
||||
;\
|
||||
static_ASN1_ITEM_start(tname) \
|
||||
ASN1_ITYPE_SEQUENCE,\
|
||||
V_ASN1_SEQUENCE,\
|
||||
tname##_seq_tt,\
|
||||
sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
|
||||
&tname##_aux,\
|
||||
sizeof(stname),\
|
||||
#stname \
|
||||
ASN1_ITEM_end(tname)
|
||||
|
||||
# define ASN1_NDEF_SEQUENCE_END_cb(stname, tname) \
|
||||
;\
|
||||
ASN1_ITEM_start(tname) \
|
||||
ASN1_ITYPE_NDEF_SEQUENCE,\
|
||||
V_ASN1_SEQUENCE,\
|
||||
tname##_seq_tt,\
|
||||
sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
|
||||
&tname##_aux,\
|
||||
sizeof(stname),\
|
||||
#stname \
|
||||
ASN1_ITEM_end(tname)
|
||||
|
||||
/*-
|
||||
* This pair helps declare a CHOICE type. We can do:
|
||||
*
|
||||
* ASN1_CHOICE(chname) = {
|
||||
* ... CHOICE options ...
|
||||
* ASN1_CHOICE_END(chname)
|
||||
*
|
||||
* This will produce an ASN1_ITEM called chname_it
|
||||
* for a structure called chname. The structure
|
||||
* definition must look like this:
|
||||
* typedef struct {
|
||||
* int type;
|
||||
* union {
|
||||
* ASN1_SOMETHING *opt1;
|
||||
* ASN1_SOMEOTHER *opt2;
|
||||
* } value;
|
||||
* } chname;
|
||||
*
|
||||
* the name of the selector must be 'type'.
|
||||
* to use an alternative selector name use the
|
||||
* ASN1_CHOICE_END_selector() version.
|
||||
*/
|
||||
|
||||
# define ASN1_CHOICE(tname) \
|
||||
static const ASN1_TEMPLATE tname##_ch_tt[]
|
||||
|
||||
# define ASN1_CHOICE_cb(tname, cb) \
|
||||
static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0}; \
|
||||
ASN1_CHOICE(tname)
|
||||
|
||||
# define ASN1_CHOICE_END(stname) ASN1_CHOICE_END_name(stname, stname)
|
||||
|
||||
# define static_ASN1_CHOICE_END(stname) static_ASN1_CHOICE_END_name(stname, stname)
|
||||
|
||||
# define ASN1_CHOICE_END_name(stname, tname) ASN1_CHOICE_END_selector(stname, tname, type)
|
||||
|
||||
# define static_ASN1_CHOICE_END_name(stname, tname) static_ASN1_CHOICE_END_selector(stname, tname, type)
|
||||
|
||||
# define ASN1_CHOICE_END_selector(stname, tname, selname) \
|
||||
;\
|
||||
ASN1_ITEM_start(tname) \
|
||||
ASN1_ITYPE_CHOICE,\
|
||||
offsetof(stname,selname) ,\
|
||||
tname##_ch_tt,\
|
||||
sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\
|
||||
NULL,\
|
||||
sizeof(stname),\
|
||||
#stname \
|
||||
ASN1_ITEM_end(tname)
|
||||
|
||||
# define static_ASN1_CHOICE_END_selector(stname, tname, selname) \
|
||||
;\
|
||||
static_ASN1_ITEM_start(tname) \
|
||||
ASN1_ITYPE_CHOICE,\
|
||||
offsetof(stname,selname) ,\
|
||||
tname##_ch_tt,\
|
||||
sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\
|
||||
NULL,\
|
||||
sizeof(stname),\
|
||||
#stname \
|
||||
ASN1_ITEM_end(tname)
|
||||
|
||||
# define ASN1_CHOICE_END_cb(stname, tname, selname) \
|
||||
;\
|
||||
ASN1_ITEM_start(tname) \
|
||||
ASN1_ITYPE_CHOICE,\
|
||||
offsetof(stname,selname) ,\
|
||||
tname##_ch_tt,\
|
||||
sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\
|
||||
&tname##_aux,\
|
||||
sizeof(stname),\
|
||||
#stname \
|
||||
ASN1_ITEM_end(tname)
|
||||
|
||||
/* This helps with the template wrapper form of ASN1_ITEM */
|
||||
|
||||
# define ASN1_EX_TEMPLATE_TYPE(flags, tag, name, type) { \
|
||||
(flags), (tag), 0,\
|
||||
#name, ASN1_ITEM_ref(type) }
|
||||
|
||||
/* These help with SEQUENCE or CHOICE components */
|
||||
|
||||
/* used to declare other types */
|
||||
|
||||
# define ASN1_EX_TYPE(flags, tag, stname, field, type) { \
|
||||
(flags), (tag), offsetof(stname, field),\
|
||||
#field, ASN1_ITEM_ref(type) }
|
||||
|
||||
/* implicit and explicit helper macros */
|
||||
|
||||
# define ASN1_IMP_EX(stname, field, type, tag, ex) \
|
||||
ASN1_EX_TYPE(ASN1_TFLG_IMPLICIT | ex, tag, stname, field, type)
|
||||
|
||||
# define ASN1_EXP_EX(stname, field, type, tag, ex) \
|
||||
ASN1_EX_TYPE(ASN1_TFLG_EXPLICIT | ex, tag, stname, field, type)
|
||||
|
||||
/* Any defined by macros: the field used is in the table itself */
|
||||
|
||||
# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION
|
||||
# define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) }
|
||||
# define ASN1_ADB_INTEGER(tblname) { ASN1_TFLG_ADB_INT, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) }
|
||||
# else
|
||||
# define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, tblname##_adb }
|
||||
# define ASN1_ADB_INTEGER(tblname) { ASN1_TFLG_ADB_INT, -1, 0, #tblname, tblname##_adb }
|
||||
# endif
|
||||
/* Plain simple type */
|
||||
# define ASN1_SIMPLE(stname, field, type) ASN1_EX_TYPE(0,0, stname, field, type)
|
||||
/* Embedded simple type */
|
||||
# define ASN1_EMBED(stname, field, type) ASN1_EX_TYPE(ASN1_TFLG_EMBED,0, stname, field, type)
|
||||
|
||||
/* OPTIONAL simple type */
|
||||
# define ASN1_OPT(stname, field, type) ASN1_EX_TYPE(ASN1_TFLG_OPTIONAL, 0, stname, field, type)
|
||||
|
||||
/* IMPLICIT tagged simple type */
|
||||
# define ASN1_IMP(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, 0)
|
||||
|
||||
/* IMPLICIT tagged OPTIONAL simple type */
|
||||
# define ASN1_IMP_OPT(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL)
|
||||
|
||||
/* Same as above but EXPLICIT */
|
||||
|
||||
# define ASN1_EXP(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, 0)
|
||||
# define ASN1_EXP_OPT(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL)
|
||||
|
||||
/* SEQUENCE OF type */
|
||||
# define ASN1_SEQUENCE_OF(stname, field, type) \
|
||||
ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, stname, field, type)
|
||||
|
||||
/* OPTIONAL SEQUENCE OF */
|
||||
# define ASN1_SEQUENCE_OF_OPT(stname, field, type) \
|
||||
ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type)
|
||||
|
||||
/* Same as above but for SET OF */
|
||||
|
||||
# define ASN1_SET_OF(stname, field, type) \
|
||||
ASN1_EX_TYPE(ASN1_TFLG_SET_OF, 0, stname, field, type)
|
||||
|
||||
# define ASN1_SET_OF_OPT(stname, field, type) \
|
||||
ASN1_EX_TYPE(ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type)
|
||||
|
||||
/* Finally compound types of SEQUENCE, SET, IMPLICIT, EXPLICIT and OPTIONAL */
|
||||
|
||||
# define ASN1_IMP_SET_OF(stname, field, type, tag) \
|
||||
ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF)
|
||||
|
||||
# define ASN1_EXP_SET_OF(stname, field, type, tag) \
|
||||
ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF)
|
||||
|
||||
# define ASN1_IMP_SET_OF_OPT(stname, field, type, tag) \
|
||||
ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL)
|
||||
|
||||
# define ASN1_EXP_SET_OF_OPT(stname, field, type, tag) \
|
||||
ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL)
|
||||
|
||||
# define ASN1_IMP_SEQUENCE_OF(stname, field, type, tag) \
|
||||
ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF)
|
||||
|
||||
# define ASN1_IMP_SEQUENCE_OF_OPT(stname, field, type, tag) \
|
||||
ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL)
|
||||
|
||||
# define ASN1_EXP_SEQUENCE_OF(stname, field, type, tag) \
|
||||
ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF)
|
||||
|
||||
# define ASN1_EXP_SEQUENCE_OF_OPT(stname, field, type, tag) \
|
||||
ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL)
|
||||
|
||||
/* EXPLICIT using indefinite length constructed form */
|
||||
# define ASN1_NDEF_EXP(stname, field, type, tag) \
|
||||
ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_NDEF)
|
||||
|
||||
/* EXPLICIT OPTIONAL using indefinite length constructed form */
|
||||
# define ASN1_NDEF_EXP_OPT(stname, field, type, tag) \
|
||||
ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL|ASN1_TFLG_NDEF)
|
||||
|
||||
/* Macros for the ASN1_ADB structure */
|
||||
|
||||
# define ASN1_ADB(name) \
|
||||
static const ASN1_ADB_TABLE name##_adbtbl[]
|
||||
|
||||
# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION
|
||||
|
||||
# define ASN1_ADB_END(name, flags, field, adb_cb, def, none) \
|
||||
;\
|
||||
static const ASN1_ADB name##_adb = {\
|
||||
flags,\
|
||||
offsetof(name, field),\
|
||||
adb_cb,\
|
||||
name##_adbtbl,\
|
||||
sizeof(name##_adbtbl) / sizeof(ASN1_ADB_TABLE),\
|
||||
def,\
|
||||
none\
|
||||
}
|
||||
|
||||
# else
|
||||
|
||||
# define ASN1_ADB_END(name, flags, field, adb_cb, def, none) \
|
||||
;\
|
||||
static const ASN1_ITEM *name##_adb(void) \
|
||||
{ \
|
||||
static const ASN1_ADB internal_adb = \
|
||||
{\
|
||||
flags,\
|
||||
offsetof(name, field),\
|
||||
adb_cb,\
|
||||
name##_adbtbl,\
|
||||
sizeof(name##_adbtbl) / sizeof(ASN1_ADB_TABLE),\
|
||||
def,\
|
||||
none\
|
||||
}; \
|
||||
return (const ASN1_ITEM *) &internal_adb; \
|
||||
} \
|
||||
void dummy_function(void)
|
||||
|
||||
# endif
|
||||
|
||||
# define ADB_ENTRY(val, template) {val, template}
|
||||
|
||||
# define ASN1_ADB_TEMPLATE(name) \
|
||||
static const ASN1_TEMPLATE name##_tt
|
||||
|
||||
/*
|
||||
* This is the ASN1 template structure that defines a wrapper round the
|
||||
* actual type. It determines the actual position of the field in the value
|
||||
* structure, various flags such as OPTIONAL and the field name.
|
||||
*/
|
||||
|
||||
struct ASN1_TEMPLATE_st {
|
||||
unsigned long flags; /* Various flags */
|
||||
long tag; /* tag, not used if no tagging */
|
||||
unsigned long offset; /* Offset of this field in structure */
|
||||
const char *field_name; /* Field name */
|
||||
ASN1_ITEM_EXP *item; /* Relevant ASN1_ITEM or ASN1_ADB */
|
||||
};
|
||||
|
||||
/* Macro to extract ASN1_ITEM and ASN1_ADB pointer from ASN1_TEMPLATE */
|
||||
|
||||
# define ASN1_TEMPLATE_item(t) (t->item_ptr)
|
||||
# define ASN1_TEMPLATE_adb(t) (t->item_ptr)
|
||||
|
||||
typedef struct ASN1_ADB_TABLE_st ASN1_ADB_TABLE;
|
||||
typedef struct ASN1_ADB_st ASN1_ADB;
|
||||
|
||||
struct ASN1_ADB_st {
|
||||
unsigned long flags; /* Various flags */
|
||||
unsigned long offset; /* Offset of selector field */
|
||||
int (*adb_cb)(long *psel); /* Application callback */
|
||||
const ASN1_ADB_TABLE *tbl; /* Table of possible types */
|
||||
long tblcount; /* Number of entries in tbl */
|
||||
const ASN1_TEMPLATE *default_tt; /* Type to use if no match */
|
||||
const ASN1_TEMPLATE *null_tt; /* Type to use if selector is NULL */
|
||||
};
|
||||
|
||||
struct ASN1_ADB_TABLE_st {
|
||||
long value; /* NID for an object or value for an int */
|
||||
const ASN1_TEMPLATE tt; /* item for this value */
|
||||
};
|
||||
|
||||
/* template flags */
|
||||
|
||||
/* Field is optional */
|
||||
# define ASN1_TFLG_OPTIONAL (0x1)
|
||||
|
||||
/* Field is a SET OF */
|
||||
# define ASN1_TFLG_SET_OF (0x1 << 1)
|
||||
|
||||
/* Field is a SEQUENCE OF */
|
||||
# define ASN1_TFLG_SEQUENCE_OF (0x2 << 1)
|
||||
|
||||
/*
|
||||
* Special case: this refers to a SET OF that will be sorted into DER order
|
||||
* when encoded *and* the corresponding STACK will be modified to match the
|
||||
* new order.
|
||||
*/
|
||||
# define ASN1_TFLG_SET_ORDER (0x3 << 1)
|
||||
|
||||
/* Mask for SET OF or SEQUENCE OF */
|
||||
# define ASN1_TFLG_SK_MASK (0x3 << 1)
|
||||
|
||||
/*
|
||||
* These flags mean the tag should be taken from the tag field. If EXPLICIT
|
||||
* then the underlying type is used for the inner tag.
|
||||
*/
|
||||
|
||||
/* IMPLICIT tagging */
|
||||
# define ASN1_TFLG_IMPTAG (0x1 << 3)
|
||||
|
||||
/* EXPLICIT tagging, inner tag from underlying type */
|
||||
# define ASN1_TFLG_EXPTAG (0x2 << 3)
|
||||
|
||||
# define ASN1_TFLG_TAG_MASK (0x3 << 3)
|
||||
|
||||
/* context specific IMPLICIT */
|
||||
# define ASN1_TFLG_IMPLICIT ASN1_TFLG_IMPTAG|ASN1_TFLG_CONTEXT
|
||||
|
||||
/* context specific EXPLICIT */
|
||||
# define ASN1_TFLG_EXPLICIT ASN1_TFLG_EXPTAG|ASN1_TFLG_CONTEXT
|
||||
|
||||
/*
|
||||
* If tagging is in force these determine the type of tag to use. Otherwise
|
||||
* the tag is determined by the underlying type. These values reflect the
|
||||
* actual octet format.
|
||||
*/
|
||||
|
||||
/* Universal tag */
|
||||
# define ASN1_TFLG_UNIVERSAL (0x0<<6)
|
||||
/* Application tag */
|
||||
# define ASN1_TFLG_APPLICATION (0x1<<6)
|
||||
/* Context specific tag */
|
||||
# define ASN1_TFLG_CONTEXT (0x2<<6)
|
||||
/* Private tag */
|
||||
# define ASN1_TFLG_PRIVATE (0x3<<6)
|
||||
|
||||
# define ASN1_TFLG_TAG_CLASS (0x3<<6)
|
||||
|
||||
/*
|
||||
* These are for ANY DEFINED BY type. In this case the 'item' field points to
|
||||
* an ASN1_ADB structure which contains a table of values to decode the
|
||||
* relevant type
|
||||
*/
|
||||
|
||||
# define ASN1_TFLG_ADB_MASK (0x3<<8)
|
||||
|
||||
# define ASN1_TFLG_ADB_OID (0x1<<8)
|
||||
|
||||
# define ASN1_TFLG_ADB_INT (0x1<<9)
|
||||
|
||||
/*
|
||||
* This flag when present in a SEQUENCE OF, SET OF or EXPLICIT causes
|
||||
* indefinite length constructed encoding to be used if required.
|
||||
*/
|
||||
|
||||
# define ASN1_TFLG_NDEF (0x1<<11)
|
||||
|
||||
/* Field is embedded and not a pointer */
|
||||
# define ASN1_TFLG_EMBED (0x1 << 12)
|
||||
|
||||
/* This is the actual ASN1 item itself */
|
||||
|
||||
struct ASN1_ITEM_st {
|
||||
char itype; /* The item type, primitive, SEQUENCE, CHOICE
|
||||
* or extern */
|
||||
long utype; /* underlying type */
|
||||
const ASN1_TEMPLATE *templates; /* If SEQUENCE or CHOICE this contains
|
||||
* the contents */
|
||||
long tcount; /* Number of templates if SEQUENCE or CHOICE */
|
||||
const void *funcs; /* functions that handle this type */
|
||||
long size; /* Structure size (usually) */
|
||||
const char *sname; /* Structure name */
|
||||
};
|
||||
|
||||
/*-
|
||||
* These are values for the itype field and
|
||||
* determine how the type is interpreted.
|
||||
*
|
||||
* For PRIMITIVE types the underlying type
|
||||
* determines the behaviour if items is NULL.
|
||||
*
|
||||
* Otherwise templates must contain a single
|
||||
* template and the type is treated in the
|
||||
* same way as the type specified in the template.
|
||||
*
|
||||
* For SEQUENCE types the templates field points
|
||||
* to the members, the size field is the
|
||||
* structure size.
|
||||
*
|
||||
* For CHOICE types the templates field points
|
||||
* to each possible member (typically a union)
|
||||
* and the 'size' field is the offset of the
|
||||
* selector.
|
||||
*
|
||||
* The 'funcs' field is used for application
|
||||
* specific functions.
|
||||
*
|
||||
* The EXTERN type uses a new style d2i/i2d.
|
||||
* The new style should be used where possible
|
||||
* because it avoids things like the d2i IMPLICIT
|
||||
* hack.
|
||||
*
|
||||
* MSTRING is a multiple string type, it is used
|
||||
* for a CHOICE of character strings where the
|
||||
* actual strings all occupy an ASN1_STRING
|
||||
* structure. In this case the 'utype' field
|
||||
* has a special meaning, it is used as a mask
|
||||
* of acceptable types using the B_ASN1 constants.
|
||||
*
|
||||
* NDEF_SEQUENCE is the same as SEQUENCE except
|
||||
* that it will use indefinite length constructed
|
||||
* encoding if requested.
|
||||
*
|
||||
*/
|
||||
|
||||
# define ASN1_ITYPE_PRIMITIVE 0x0
|
||||
|
||||
# define ASN1_ITYPE_SEQUENCE 0x1
|
||||
|
||||
# define ASN1_ITYPE_CHOICE 0x2
|
||||
|
||||
# define ASN1_ITYPE_EXTERN 0x4
|
||||
|
||||
# define ASN1_ITYPE_MSTRING 0x5
|
||||
|
||||
# define ASN1_ITYPE_NDEF_SEQUENCE 0x6
|
||||
|
||||
/*
|
||||
* Cache for ASN1 tag and length, so we don't keep re-reading it for things
|
||||
* like CHOICE
|
||||
*/
|
||||
|
||||
struct ASN1_TLC_st {
|
||||
char valid; /* Values below are valid */
|
||||
int ret; /* return value */
|
||||
long plen; /* length */
|
||||
int ptag; /* class value */
|
||||
int pclass; /* class value */
|
||||
int hdrlen; /* header length */
|
||||
};
|
||||
|
||||
/* Typedefs for ASN1 function pointers */
|
||||
typedef int ASN1_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,
|
||||
const ASN1_ITEM *it, int tag, int aclass, char opt,
|
||||
ASN1_TLC *ctx);
|
||||
|
||||
typedef int ASN1_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
|
||||
const ASN1_ITEM *it, int tag, int aclass);
|
||||
typedef int ASN1_ex_new_func(ASN1_VALUE **pval, const ASN1_ITEM *it);
|
||||
typedef void ASN1_ex_free_func(ASN1_VALUE **pval, const ASN1_ITEM *it);
|
||||
|
||||
typedef int ASN1_ex_print_func(BIO *out, ASN1_VALUE **pval,
|
||||
int indent, const char *fname,
|
||||
const ASN1_PCTX *pctx);
|
||||
|
||||
typedef int ASN1_primitive_i2c(ASN1_VALUE **pval, unsigned char *cont,
|
||||
int *putype, const ASN1_ITEM *it);
|
||||
typedef int ASN1_primitive_c2i(ASN1_VALUE **pval, const unsigned char *cont,
|
||||
int len, int utype, char *free_cont,
|
||||
const ASN1_ITEM *it);
|
||||
typedef int ASN1_primitive_print(BIO *out, ASN1_VALUE **pval,
|
||||
const ASN1_ITEM *it, int indent,
|
||||
const ASN1_PCTX *pctx);
|
||||
|
||||
typedef struct ASN1_EXTERN_FUNCS_st {
|
||||
void *app_data;
|
||||
ASN1_ex_new_func *asn1_ex_new;
|
||||
ASN1_ex_free_func *asn1_ex_free;
|
||||
ASN1_ex_free_func *asn1_ex_clear;
|
||||
ASN1_ex_d2i *asn1_ex_d2i;
|
||||
ASN1_ex_i2d *asn1_ex_i2d;
|
||||
ASN1_ex_print_func *asn1_ex_print;
|
||||
} ASN1_EXTERN_FUNCS;
|
||||
|
||||
typedef struct ASN1_PRIMITIVE_FUNCS_st {
|
||||
void *app_data;
|
||||
unsigned long flags;
|
||||
ASN1_ex_new_func *prim_new;
|
||||
ASN1_ex_free_func *prim_free;
|
||||
ASN1_ex_free_func *prim_clear;
|
||||
ASN1_primitive_c2i *prim_c2i;
|
||||
ASN1_primitive_i2c *prim_i2c;
|
||||
ASN1_primitive_print *prim_print;
|
||||
} ASN1_PRIMITIVE_FUNCS;
|
||||
|
||||
/*
|
||||
* This is the ASN1_AUX structure: it handles various miscellaneous
|
||||
* requirements. For example the use of reference counts and an informational
|
||||
* callback. The "informational callback" is called at various points during
|
||||
* the ASN1 encoding and decoding. It can be used to provide minor
|
||||
* customisation of the structures used. This is most useful where the
|
||||
* supplied routines *almost* do the right thing but need some extra help at
|
||||
* a few points. If the callback returns zero then it is assumed a fatal
|
||||
* error has occurred and the main operation should be abandoned. If major
|
||||
* changes in the default behaviour are required then an external type is
|
||||
* more appropriate.
|
||||
*/
|
||||
|
||||
typedef int ASN1_aux_cb(int operation, ASN1_VALUE **in, const ASN1_ITEM *it,
|
||||
void *exarg);
|
||||
|
||||
typedef struct ASN1_AUX_st {
|
||||
void *app_data;
|
||||
int flags;
|
||||
int ref_offset; /* Offset of reference value */
|
||||
int ref_lock; /* Lock type to use */
|
||||
ASN1_aux_cb *asn1_cb;
|
||||
int enc_offset; /* Offset of ASN1_ENCODING structure */
|
||||
} ASN1_AUX;
|
||||
|
||||
/* For print related callbacks exarg points to this structure */
|
||||
typedef struct ASN1_PRINT_ARG_st {
|
||||
BIO *out;
|
||||
int indent;
|
||||
const ASN1_PCTX *pctx;
|
||||
} ASN1_PRINT_ARG;
|
||||
|
||||
/* For streaming related callbacks exarg points to this structure */
|
||||
typedef struct ASN1_STREAM_ARG_st {
|
||||
/* BIO to stream through */
|
||||
BIO *out;
|
||||
/* BIO with filters appended */
|
||||
BIO *ndef_bio;
|
||||
/* Streaming I/O boundary */
|
||||
unsigned char **boundary;
|
||||
} ASN1_STREAM_ARG;
|
||||
|
||||
/* Flags in ASN1_AUX */
|
||||
|
||||
/* Use a reference count */
|
||||
# define ASN1_AFLG_REFCOUNT 1
|
||||
/* Save the encoding of structure (useful for signatures) */
|
||||
# define ASN1_AFLG_ENCODING 2
|
||||
/* The Sequence length is invalid */
|
||||
# define ASN1_AFLG_BROKEN 4
|
||||
|
||||
/* operation values for asn1_cb */
|
||||
|
||||
# define ASN1_OP_NEW_PRE 0
|
||||
# define ASN1_OP_NEW_POST 1
|
||||
# define ASN1_OP_FREE_PRE 2
|
||||
# define ASN1_OP_FREE_POST 3
|
||||
# define ASN1_OP_D2I_PRE 4
|
||||
# define ASN1_OP_D2I_POST 5
|
||||
# define ASN1_OP_I2D_PRE 6
|
||||
# define ASN1_OP_I2D_POST 7
|
||||
# define ASN1_OP_PRINT_PRE 8
|
||||
# define ASN1_OP_PRINT_POST 9
|
||||
# define ASN1_OP_STREAM_PRE 10
|
||||
# define ASN1_OP_STREAM_POST 11
|
||||
# define ASN1_OP_DETACHED_PRE 12
|
||||
# define ASN1_OP_DETACHED_POST 13
|
||||
|
||||
/* Macro to implement a primitive type */
|
||||
# define IMPLEMENT_ASN1_TYPE(stname) IMPLEMENT_ASN1_TYPE_ex(stname, stname, 0)
|
||||
# define IMPLEMENT_ASN1_TYPE_ex(itname, vname, ex) \
|
||||
ASN1_ITEM_start(itname) \
|
||||
ASN1_ITYPE_PRIMITIVE, V_##vname, NULL, 0, NULL, ex, #itname \
|
||||
ASN1_ITEM_end(itname)
|
||||
|
||||
/* Macro to implement a multi string type */
|
||||
# define IMPLEMENT_ASN1_MSTRING(itname, mask) \
|
||||
ASN1_ITEM_start(itname) \
|
||||
ASN1_ITYPE_MSTRING, mask, NULL, 0, NULL, sizeof(ASN1_STRING), #itname \
|
||||
ASN1_ITEM_end(itname)
|
||||
|
||||
# define IMPLEMENT_EXTERN_ASN1(sname, tag, fptrs) \
|
||||
ASN1_ITEM_start(sname) \
|
||||
ASN1_ITYPE_EXTERN, \
|
||||
tag, \
|
||||
NULL, \
|
||||
0, \
|
||||
&fptrs, \
|
||||
0, \
|
||||
#sname \
|
||||
ASN1_ITEM_end(sname)
|
||||
|
||||
/* Macro to implement standard functions in terms of ASN1_ITEM structures */
|
||||
|
||||
# define IMPLEMENT_ASN1_FUNCTIONS(stname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, stname, stname)
|
||||
|
||||
# define IMPLEMENT_ASN1_FUNCTIONS_name(stname, itname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, itname)
|
||||
|
||||
# define IMPLEMENT_ASN1_FUNCTIONS_ENCODE_name(stname, itname) \
|
||||
IMPLEMENT_ASN1_FUNCTIONS_ENCODE_fname(stname, itname, itname)
|
||||
|
||||
# define IMPLEMENT_STATIC_ASN1_ALLOC_FUNCTIONS(stname) \
|
||||
IMPLEMENT_ASN1_ALLOC_FUNCTIONS_pfname(static, stname, stname, stname)
|
||||
|
||||
# define IMPLEMENT_ASN1_ALLOC_FUNCTIONS(stname) \
|
||||
IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, stname, stname)
|
||||
|
||||
# define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_pfname(pre, stname, itname, fname) \
|
||||
pre stname *fname##_new(void) \
|
||||
{ \
|
||||
return (stname *)ASN1_item_new(ASN1_ITEM_rptr(itname)); \
|
||||
} \
|
||||
pre void fname##_free(stname *a) \
|
||||
{ \
|
||||
ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \
|
||||
}
|
||||
|
||||
# define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) \
|
||||
stname *fname##_new(void) \
|
||||
{ \
|
||||
return (stname *)ASN1_item_new(ASN1_ITEM_rptr(itname)); \
|
||||
} \
|
||||
void fname##_free(stname *a) \
|
||||
{ \
|
||||
ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \
|
||||
}
|
||||
|
||||
# define IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, fname) \
|
||||
IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \
|
||||
IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname)
|
||||
|
||||
# define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \
|
||||
stname *d2i_##fname(stname **a, const unsigned char **in, long len) \
|
||||
{ \
|
||||
return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(itname));\
|
||||
} \
|
||||
int i2d_##fname(stname *a, unsigned char **out) \
|
||||
{ \
|
||||
return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\
|
||||
}
|
||||
|
||||
# define IMPLEMENT_ASN1_NDEF_FUNCTION(stname) \
|
||||
int i2d_##stname##_NDEF(stname *a, unsigned char **out) \
|
||||
{ \
|
||||
return ASN1_item_ndef_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(stname));\
|
||||
}
|
||||
|
||||
# define IMPLEMENT_STATIC_ASN1_ENCODE_FUNCTIONS(stname) \
|
||||
static stname *d2i_##stname(stname **a, \
|
||||
const unsigned char **in, long len) \
|
||||
{ \
|
||||
return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, \
|
||||
ASN1_ITEM_rptr(stname)); \
|
||||
} \
|
||||
static int i2d_##stname(stname *a, unsigned char **out) \
|
||||
{ \
|
||||
return ASN1_item_i2d((ASN1_VALUE *)a, out, \
|
||||
ASN1_ITEM_rptr(stname)); \
|
||||
}
|
||||
|
||||
/*
|
||||
* This includes evil casts to remove const: they will go away when full ASN1
|
||||
* constification is done.
|
||||
*/
|
||||
# define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \
|
||||
stname *d2i_##fname(stname **a, const unsigned char **in, long len) \
|
||||
{ \
|
||||
return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(itname));\
|
||||
} \
|
||||
int i2d_##fname(const stname *a, unsigned char **out) \
|
||||
{ \
|
||||
return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\
|
||||
}
|
||||
|
||||
# define IMPLEMENT_ASN1_DUP_FUNCTION(stname) \
|
||||
stname * stname##_dup(stname *x) \
|
||||
{ \
|
||||
return ASN1_item_dup(ASN1_ITEM_rptr(stname), x); \
|
||||
}
|
||||
|
||||
# define IMPLEMENT_ASN1_PRINT_FUNCTION(stname) \
|
||||
IMPLEMENT_ASN1_PRINT_FUNCTION_fname(stname, stname, stname)
|
||||
|
||||
# define IMPLEMENT_ASN1_PRINT_FUNCTION_fname(stname, itname, fname) \
|
||||
int fname##_print_ctx(BIO *out, stname *x, int indent, \
|
||||
const ASN1_PCTX *pctx) \
|
||||
{ \
|
||||
return ASN1_item_print(out, (ASN1_VALUE *)x, indent, \
|
||||
ASN1_ITEM_rptr(itname), pctx); \
|
||||
}
|
||||
|
||||
# define IMPLEMENT_ASN1_FUNCTIONS_const(name) \
|
||||
IMPLEMENT_ASN1_FUNCTIONS_const_fname(name, name, name)
|
||||
|
||||
# define IMPLEMENT_ASN1_FUNCTIONS_const_fname(stname, itname, fname) \
|
||||
IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \
|
||||
IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname)
|
||||
|
||||
/* external definitions for primitive types */
|
||||
|
||||
DECLARE_ASN1_ITEM(ASN1_BOOLEAN)
|
||||
DECLARE_ASN1_ITEM(ASN1_TBOOLEAN)
|
||||
DECLARE_ASN1_ITEM(ASN1_FBOOLEAN)
|
||||
DECLARE_ASN1_ITEM(ASN1_SEQUENCE)
|
||||
DECLARE_ASN1_ITEM(CBIGNUM)
|
||||
DECLARE_ASN1_ITEM(BIGNUM)
|
||||
DECLARE_ASN1_ITEM(LONG)
|
||||
DECLARE_ASN1_ITEM(ZLONG)
|
||||
|
||||
DEFINE_STACK_OF(ASN1_VALUE)
|
||||
|
||||
/* Functions used internally by the ASN1 code */
|
||||
|
||||
int ASN1_item_ex_new(ASN1_VALUE **pval, const ASN1_ITEM *it);
|
||||
void ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it);
|
||||
|
||||
int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,
|
||||
const ASN1_ITEM *it, int tag, int aclass, char opt,
|
||||
ASN1_TLC *ctx);
|
||||
|
||||
int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
|
||||
const ASN1_ITEM *it, int tag, int aclass);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -0,0 +1,98 @@
|
|||
/*
|
||||
* Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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>
|
||||
|
||||
#ifndef HEADER_ASYNC_H
|
||||
# define HEADER_ASYNC_H
|
||||
|
||||
#if defined(_WIN32)
|
||||
# if defined(BASETYPES) || defined(_WINDEF_H)
|
||||
/* application has to include <windows.h> to use this */
|
||||
#define OSSL_ASYNC_FD HANDLE
|
||||
#define OSSL_BAD_ASYNC_FD INVALID_HANDLE_VALUE
|
||||
# endif
|
||||
#else
|
||||
#define OSSL_ASYNC_FD int
|
||||
#define OSSL_BAD_ASYNC_FD -1
|
||||
#endif
|
||||
|
||||
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
# endif
|
||||
|
||||
typedef struct async_job_st ASYNC_JOB;
|
||||
typedef struct async_wait_ctx_st ASYNC_WAIT_CTX;
|
||||
|
||||
#define ASYNC_ERR 0
|
||||
#define ASYNC_NO_JOBS 1
|
||||
#define ASYNC_PAUSE 2
|
||||
#define ASYNC_FINISH 3
|
||||
|
||||
int ASYNC_init_thread(size_t max_size, size_t init_size);
|
||||
void ASYNC_cleanup_thread(void);
|
||||
|
||||
#ifdef OSSL_ASYNC_FD
|
||||
ASYNC_WAIT_CTX *ASYNC_WAIT_CTX_new(void);
|
||||
void ASYNC_WAIT_CTX_free(ASYNC_WAIT_CTX *ctx);
|
||||
int ASYNC_WAIT_CTX_set_wait_fd(ASYNC_WAIT_CTX *ctx, const void *key,
|
||||
OSSL_ASYNC_FD fd,
|
||||
void *custom_data,
|
||||
void (*cleanup)(ASYNC_WAIT_CTX *, const void *,
|
||||
OSSL_ASYNC_FD, void *));
|
||||
int ASYNC_WAIT_CTX_get_fd(ASYNC_WAIT_CTX *ctx, const void *key,
|
||||
OSSL_ASYNC_FD *fd, void **custom_data);
|
||||
int ASYNC_WAIT_CTX_get_all_fds(ASYNC_WAIT_CTX *ctx, OSSL_ASYNC_FD *fd,
|
||||
size_t *numfds);
|
||||
int ASYNC_WAIT_CTX_get_changed_fds(ASYNC_WAIT_CTX *ctx, OSSL_ASYNC_FD *addfd,
|
||||
size_t *numaddfds, OSSL_ASYNC_FD *delfd,
|
||||
size_t *numdelfds);
|
||||
int ASYNC_WAIT_CTX_clear_fd(ASYNC_WAIT_CTX *ctx, const void *key);
|
||||
#endif
|
||||
|
||||
int ASYNC_is_capable(void);
|
||||
|
||||
int ASYNC_start_job(ASYNC_JOB **job, ASYNC_WAIT_CTX *ctx, int *ret,
|
||||
int (*func)(void *), void *args, size_t size);
|
||||
int ASYNC_pause_job(void);
|
||||
|
||||
ASYNC_JOB *ASYNC_get_current_job(void);
|
||||
ASYNC_WAIT_CTX *ASYNC_get_wait_ctx(ASYNC_JOB *job);
|
||||
void ASYNC_block_pause(void);
|
||||
void ASYNC_unblock_pause(void);
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
/*
|
||||
* The following lines are auto generated by the script mkerr.pl. Any changes
|
||||
* made after this point may be overwritten when the script is next run.
|
||||
*/
|
||||
|
||||
int ERR_load_ASYNC_strings(void);
|
||||
|
||||
/* Error codes for the ASYNC functions. */
|
||||
|
||||
/* Function codes. */
|
||||
# define ASYNC_F_ASYNC_CTX_NEW 100
|
||||
# define ASYNC_F_ASYNC_INIT_THREAD 101
|
||||
# define ASYNC_F_ASYNC_JOB_NEW 102
|
||||
# define ASYNC_F_ASYNC_PAUSE_JOB 103
|
||||
# define ASYNC_F_ASYNC_START_FUNC 104
|
||||
# define ASYNC_F_ASYNC_START_JOB 105
|
||||
|
||||
/* Reason codes. */
|
||||
# define ASYNC_R_FAILED_TO_SET_POOL 101
|
||||
# define ASYNC_R_FAILED_TO_SWAP_CONTEXT 102
|
||||
# define ASYNC_R_INIT_FAILED 105
|
||||
# define ASYNC_R_INVALID_POOL_SIZE 103
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
|
@ -0,0 +1,854 @@
|
|||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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_BIO_H
|
||||
# define HEADER_BIO_H
|
||||
|
||||
# include <openssl/e_os2.h>
|
||||
|
||||
# ifndef OPENSSL_NO_STDIO
|
||||
# include <stdio.h>
|
||||
# endif
|
||||
# include <stdarg.h>
|
||||
|
||||
# include <openssl/crypto.h>
|
||||
|
||||
# ifndef OPENSSL_NO_SCTP
|
||||
# ifndef OPENSSL_SYS_VMS
|
||||
# include <stdint.h>
|
||||
# else
|
||||
# include <inttypes.h>
|
||||
# endif
|
||||
# endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* There are the classes of BIOs */
|
||||
# define BIO_TYPE_DESCRIPTOR 0x0100 /* socket, fd, connect or accept */
|
||||
# define BIO_TYPE_FILTER 0x0200
|
||||
# define BIO_TYPE_SOURCE_SINK 0x0400
|
||||
|
||||
/* These are the 'types' of BIOs */
|
||||
# define BIO_TYPE_NONE 0
|
||||
# define BIO_TYPE_MEM ( 1|BIO_TYPE_SOURCE_SINK)
|
||||
# define BIO_TYPE_FILE ( 2|BIO_TYPE_SOURCE_SINK)
|
||||
|
||||
# define BIO_TYPE_FD ( 4|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR)
|
||||
# define BIO_TYPE_SOCKET ( 5|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR)
|
||||
# define BIO_TYPE_NULL ( 6|BIO_TYPE_SOURCE_SINK)
|
||||
# define BIO_TYPE_SSL ( 7|BIO_TYPE_FILTER)
|
||||
# define BIO_TYPE_MD ( 8|BIO_TYPE_FILTER)
|
||||
# define BIO_TYPE_BUFFER ( 9|BIO_TYPE_FILTER)
|
||||
# define BIO_TYPE_CIPHER (10|BIO_TYPE_FILTER)
|
||||
# define BIO_TYPE_BASE64 (11|BIO_TYPE_FILTER)
|
||||
# define BIO_TYPE_CONNECT (12|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR)
|
||||
# define BIO_TYPE_ACCEPT (13|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR)
|
||||
|
||||
# define BIO_TYPE_NBIO_TEST (16|BIO_TYPE_FILTER)/* server proxy BIO */
|
||||
# define BIO_TYPE_NULL_FILTER (17|BIO_TYPE_FILTER)
|
||||
# define BIO_TYPE_BIO (19|BIO_TYPE_SOURCE_SINK)/* half a BIO pair */
|
||||
# define BIO_TYPE_LINEBUFFER (20|BIO_TYPE_FILTER)
|
||||
# define BIO_TYPE_DGRAM (21|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR)
|
||||
# define BIO_TYPE_ASN1 (22|BIO_TYPE_FILTER)
|
||||
# define BIO_TYPE_COMP (23|BIO_TYPE_FILTER)
|
||||
# ifndef OPENSSL_NO_SCTP
|
||||
# define BIO_TYPE_DGRAM_SCTP (24|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR)
|
||||
# endif
|
||||
|
||||
#define BIO_TYPE_START 128
|
||||
|
||||
/*
|
||||
* BIO_FILENAME_READ|BIO_CLOSE to open or close on free.
|
||||
* BIO_set_fp(in,stdin,BIO_NOCLOSE);
|
||||
*/
|
||||
# define BIO_NOCLOSE 0x00
|
||||
# define BIO_CLOSE 0x01
|
||||
|
||||
/*
|
||||
* These are used in the following macros and are passed to BIO_ctrl()
|
||||
*/
|
||||
# define BIO_CTRL_RESET 1/* opt - rewind/zero etc */
|
||||
# define BIO_CTRL_EOF 2/* opt - are we at the eof */
|
||||
# define BIO_CTRL_INFO 3/* opt - extra tit-bits */
|
||||
# define BIO_CTRL_SET 4/* man - set the 'IO' type */
|
||||
# define BIO_CTRL_GET 5/* man - get the 'IO' type */
|
||||
# define BIO_CTRL_PUSH 6/* opt - internal, used to signify change */
|
||||
# define BIO_CTRL_POP 7/* opt - internal, used to signify change */
|
||||
# define BIO_CTRL_GET_CLOSE 8/* man - set the 'close' on free */
|
||||
# define BIO_CTRL_SET_CLOSE 9/* man - set the 'close' on free */
|
||||
# define BIO_CTRL_PENDING 10/* opt - is their more data buffered */
|
||||
# define BIO_CTRL_FLUSH 11/* opt - 'flush' buffered output */
|
||||
# define BIO_CTRL_DUP 12/* man - extra stuff for 'duped' BIO */
|
||||
# define BIO_CTRL_WPENDING 13/* opt - number of bytes still to write */
|
||||
# define BIO_CTRL_SET_CALLBACK 14/* opt - set callback function */
|
||||
# define BIO_CTRL_GET_CALLBACK 15/* opt - set callback function */
|
||||
|
||||
# define BIO_CTRL_SET_FILENAME 30/* BIO_s_file special */
|
||||
|
||||
/* dgram BIO stuff */
|
||||
# define BIO_CTRL_DGRAM_CONNECT 31/* BIO dgram special */
|
||||
# define BIO_CTRL_DGRAM_SET_CONNECTED 32/* allow for an externally connected
|
||||
* socket to be passed in */
|
||||
# define BIO_CTRL_DGRAM_SET_RECV_TIMEOUT 33/* setsockopt, essentially */
|
||||
# define BIO_CTRL_DGRAM_GET_RECV_TIMEOUT 34/* getsockopt, essentially */
|
||||
# define BIO_CTRL_DGRAM_SET_SEND_TIMEOUT 35/* setsockopt, essentially */
|
||||
# define BIO_CTRL_DGRAM_GET_SEND_TIMEOUT 36/* getsockopt, essentially */
|
||||
|
||||
# define BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP 37/* flag whether the last */
|
||||
# define BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP 38/* I/O operation tiemd out */
|
||||
|
||||
/* #ifdef IP_MTU_DISCOVER */
|
||||
# define BIO_CTRL_DGRAM_MTU_DISCOVER 39/* set DF bit on egress packets */
|
||||
/* #endif */
|
||||
|
||||
# define BIO_CTRL_DGRAM_QUERY_MTU 40/* as kernel for current MTU */
|
||||
# define BIO_CTRL_DGRAM_GET_FALLBACK_MTU 47
|
||||
# define BIO_CTRL_DGRAM_GET_MTU 41/* get cached value for MTU */
|
||||
# define BIO_CTRL_DGRAM_SET_MTU 42/* set cached value for MTU.
|
||||
* want to use this if asking
|
||||
* the kernel fails */
|
||||
|
||||
# define BIO_CTRL_DGRAM_MTU_EXCEEDED 43/* check whether the MTU was
|
||||
* exceed in the previous write
|
||||
* operation */
|
||||
|
||||
# define BIO_CTRL_DGRAM_GET_PEER 46
|
||||
# define BIO_CTRL_DGRAM_SET_PEER 44/* Destination for the data */
|
||||
|
||||
# define BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT 45/* Next DTLS handshake timeout
|
||||
* to adjust socket timeouts */
|
||||
# define BIO_CTRL_DGRAM_SET_DONT_FRAG 48
|
||||
|
||||
# define BIO_CTRL_DGRAM_GET_MTU_OVERHEAD 49
|
||||
|
||||
# define BIO_CTRL_DGRAM_SET_PEEK_MODE 50
|
||||
|
||||
# ifndef OPENSSL_NO_SCTP
|
||||
/* SCTP stuff */
|
||||
# define BIO_CTRL_DGRAM_SCTP_SET_IN_HANDSHAKE 50
|
||||
# define BIO_CTRL_DGRAM_SCTP_ADD_AUTH_KEY 51
|
||||
# define BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY 52
|
||||
# define BIO_CTRL_DGRAM_SCTP_AUTH_CCS_RCVD 53
|
||||
# define BIO_CTRL_DGRAM_SCTP_GET_SNDINFO 60
|
||||
# define BIO_CTRL_DGRAM_SCTP_SET_SNDINFO 61
|
||||
# define BIO_CTRL_DGRAM_SCTP_GET_RCVINFO 62
|
||||
# define BIO_CTRL_DGRAM_SCTP_SET_RCVINFO 63
|
||||
# define BIO_CTRL_DGRAM_SCTP_GET_PRINFO 64
|
||||
# define BIO_CTRL_DGRAM_SCTP_SET_PRINFO 65
|
||||
# define BIO_CTRL_DGRAM_SCTP_SAVE_SHUTDOWN 70
|
||||
# endif
|
||||
|
||||
/* modifiers */
|
||||
# define BIO_FP_READ 0x02
|
||||
# define BIO_FP_WRITE 0x04
|
||||
# define BIO_FP_APPEND 0x08
|
||||
# define BIO_FP_TEXT 0x10
|
||||
|
||||
# define BIO_FLAGS_READ 0x01
|
||||
# define BIO_FLAGS_WRITE 0x02
|
||||
# define BIO_FLAGS_IO_SPECIAL 0x04
|
||||
# define BIO_FLAGS_RWS (BIO_FLAGS_READ|BIO_FLAGS_WRITE|BIO_FLAGS_IO_SPECIAL)
|
||||
# define BIO_FLAGS_SHOULD_RETRY 0x08
|
||||
# ifndef BIO_FLAGS_UPLINK
|
||||
/*
|
||||
* "UPLINK" flag denotes file descriptors provided by application. It
|
||||
* defaults to 0, as most platforms don't require UPLINK interface.
|
||||
*/
|
||||
# define BIO_FLAGS_UPLINK 0
|
||||
# endif
|
||||
|
||||
# define BIO_FLAGS_BASE64_NO_NL 0x100
|
||||
|
||||
/*
|
||||
* This is used with memory BIOs:
|
||||
* BIO_FLAGS_MEM_RDONLY means we shouldn't free up or change the data in any way;
|
||||
* BIO_FLAGS_NONCLEAR_RST means we should't clear data on reset.
|
||||
*/
|
||||
# define BIO_FLAGS_MEM_RDONLY 0x200
|
||||
# define BIO_FLAGS_NONCLEAR_RST 0x400
|
||||
|
||||
typedef union bio_addr_st BIO_ADDR;
|
||||
typedef struct bio_addrinfo_st BIO_ADDRINFO;
|
||||
|
||||
int BIO_get_new_index(void);
|
||||
void BIO_set_flags(BIO *b, int flags);
|
||||
int BIO_test_flags(const BIO *b, int flags);
|
||||
void BIO_clear_flags(BIO *b, int flags);
|
||||
|
||||
# define BIO_get_flags(b) BIO_test_flags(b, ~(0x0))
|
||||
# define BIO_set_retry_special(b) \
|
||||
BIO_set_flags(b, (BIO_FLAGS_IO_SPECIAL|BIO_FLAGS_SHOULD_RETRY))
|
||||
# define BIO_set_retry_read(b) \
|
||||
BIO_set_flags(b, (BIO_FLAGS_READ|BIO_FLAGS_SHOULD_RETRY))
|
||||
# define BIO_set_retry_write(b) \
|
||||
BIO_set_flags(b, (BIO_FLAGS_WRITE|BIO_FLAGS_SHOULD_RETRY))
|
||||
|
||||
/* These are normally used internally in BIOs */
|
||||
# define BIO_clear_retry_flags(b) \
|
||||
BIO_clear_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY))
|
||||
# define BIO_get_retry_flags(b) \
|
||||
BIO_test_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY))
|
||||
|
||||
/* These should be used by the application to tell why we should retry */
|
||||
# define BIO_should_read(a) BIO_test_flags(a, BIO_FLAGS_READ)
|
||||
# define BIO_should_write(a) BIO_test_flags(a, BIO_FLAGS_WRITE)
|
||||
# define BIO_should_io_special(a) BIO_test_flags(a, BIO_FLAGS_IO_SPECIAL)
|
||||
# define BIO_retry_type(a) BIO_test_flags(a, BIO_FLAGS_RWS)
|
||||
# define BIO_should_retry(a) BIO_test_flags(a, BIO_FLAGS_SHOULD_RETRY)
|
||||
|
||||
/*
|
||||
* The next three are used in conjunction with the BIO_should_io_special()
|
||||
* condition. After this returns true, BIO *BIO_get_retry_BIO(BIO *bio, int
|
||||
* *reason); will walk the BIO stack and return the 'reason' for the special
|
||||
* and the offending BIO. Given a BIO, BIO_get_retry_reason(bio) will return
|
||||
* the code.
|
||||
*/
|
||||
/*
|
||||
* Returned from the SSL bio when the certificate retrieval code had an error
|
||||
*/
|
||||
# define BIO_RR_SSL_X509_LOOKUP 0x01
|
||||
/* Returned from the connect BIO when a connect would have blocked */
|
||||
# define BIO_RR_CONNECT 0x02
|
||||
/* Returned from the accept BIO when an accept would have blocked */
|
||||
# define BIO_RR_ACCEPT 0x03
|
||||
|
||||
/* These are passed by the BIO callback */
|
||||
# define BIO_CB_FREE 0x01
|
||||
# define BIO_CB_READ 0x02
|
||||
# define BIO_CB_WRITE 0x03
|
||||
# define BIO_CB_PUTS 0x04
|
||||
# define BIO_CB_GETS 0x05
|
||||
# define BIO_CB_CTRL 0x06
|
||||
|
||||
/*
|
||||
* The callback is called before and after the underling operation, The
|
||||
* BIO_CB_RETURN flag indicates if it is after the call
|
||||
*/
|
||||
# define BIO_CB_RETURN 0x80
|
||||
# define BIO_CB_return(a) ((a)|BIO_CB_RETURN)
|
||||
# define BIO_cb_pre(a) (!((a)&BIO_CB_RETURN))
|
||||
# define BIO_cb_post(a) ((a)&BIO_CB_RETURN)
|
||||
|
||||
typedef long (*BIO_callback_fn)(BIO *b, int oper, const char *argp, int argi,
|
||||
long argl, long ret);
|
||||
BIO_callback_fn BIO_get_callback(const BIO *b);
|
||||
void BIO_set_callback(BIO *b, BIO_callback_fn callback);
|
||||
char *BIO_get_callback_arg(const BIO *b);
|
||||
void BIO_set_callback_arg(BIO *b, char *arg);
|
||||
|
||||
typedef struct bio_method_st BIO_METHOD;
|
||||
|
||||
const char *BIO_method_name(const BIO *b);
|
||||
int BIO_method_type(const BIO *b);
|
||||
|
||||
typedef void bio_info_cb(BIO *, int, const char *, int, long, long);
|
||||
|
||||
DEFINE_STACK_OF(BIO)
|
||||
|
||||
/* Prefix and suffix callback in ASN1 BIO */
|
||||
typedef int asn1_ps_func (BIO *b, unsigned char **pbuf, int *plen,
|
||||
void *parg);
|
||||
|
||||
# ifndef OPENSSL_NO_SCTP
|
||||
/* SCTP parameter structs */
|
||||
struct bio_dgram_sctp_sndinfo {
|
||||
uint16_t snd_sid;
|
||||
uint16_t snd_flags;
|
||||
uint32_t snd_ppid;
|
||||
uint32_t snd_context;
|
||||
};
|
||||
|
||||
struct bio_dgram_sctp_rcvinfo {
|
||||
uint16_t rcv_sid;
|
||||
uint16_t rcv_ssn;
|
||||
uint16_t rcv_flags;
|
||||
uint32_t rcv_ppid;
|
||||
uint32_t rcv_tsn;
|
||||
uint32_t rcv_cumtsn;
|
||||
uint32_t rcv_context;
|
||||
};
|
||||
|
||||
struct bio_dgram_sctp_prinfo {
|
||||
uint16_t pr_policy;
|
||||
uint32_t pr_value;
|
||||
};
|
||||
# endif
|
||||
|
||||
/*
|
||||
* #define BIO_CONN_get_param_hostname BIO_ctrl
|
||||
*/
|
||||
|
||||
# define BIO_C_SET_CONNECT 100
|
||||
# define BIO_C_DO_STATE_MACHINE 101
|
||||
# define BIO_C_SET_NBIO 102
|
||||
/* # define BIO_C_SET_PROXY_PARAM 103 */
|
||||
# define BIO_C_SET_FD 104
|
||||
# define BIO_C_GET_FD 105
|
||||
# define BIO_C_SET_FILE_PTR 106
|
||||
# define BIO_C_GET_FILE_PTR 107
|
||||
# define BIO_C_SET_FILENAME 108
|
||||
# define BIO_C_SET_SSL 109
|
||||
# define BIO_C_GET_SSL 110
|
||||
# define BIO_C_SET_MD 111
|
||||
# define BIO_C_GET_MD 112
|
||||
# define BIO_C_GET_CIPHER_STATUS 113
|
||||
# define BIO_C_SET_BUF_MEM 114
|
||||
# define BIO_C_GET_BUF_MEM_PTR 115
|
||||
# define BIO_C_GET_BUFF_NUM_LINES 116
|
||||
# define BIO_C_SET_BUFF_SIZE 117
|
||||
# define BIO_C_SET_ACCEPT 118
|
||||
# define BIO_C_SSL_MODE 119
|
||||
# define BIO_C_GET_MD_CTX 120
|
||||
/* # define BIO_C_GET_PROXY_PARAM 121 */
|
||||
# define BIO_C_SET_BUFF_READ_DATA 122/* data to read first */
|
||||
# define BIO_C_GET_CONNECT 123
|
||||
# define BIO_C_GET_ACCEPT 124
|
||||
# define BIO_C_SET_SSL_RENEGOTIATE_BYTES 125
|
||||
# define BIO_C_GET_SSL_NUM_RENEGOTIATES 126
|
||||
# define BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT 127
|
||||
# define BIO_C_FILE_SEEK 128
|
||||
# define BIO_C_GET_CIPHER_CTX 129
|
||||
# define BIO_C_SET_BUF_MEM_EOF_RETURN 130/* return end of input
|
||||
* value */
|
||||
# define BIO_C_SET_BIND_MODE 131
|
||||
# define BIO_C_GET_BIND_MODE 132
|
||||
# define BIO_C_FILE_TELL 133
|
||||
# define BIO_C_GET_SOCKS 134
|
||||
# define BIO_C_SET_SOCKS 135
|
||||
|
||||
# define BIO_C_SET_WRITE_BUF_SIZE 136/* for BIO_s_bio */
|
||||
# define BIO_C_GET_WRITE_BUF_SIZE 137
|
||||
# define BIO_C_MAKE_BIO_PAIR 138
|
||||
# define BIO_C_DESTROY_BIO_PAIR 139
|
||||
# define BIO_C_GET_WRITE_GUARANTEE 140
|
||||
# define BIO_C_GET_READ_REQUEST 141
|
||||
# define BIO_C_SHUTDOWN_WR 142
|
||||
# define BIO_C_NREAD0 143
|
||||
# define BIO_C_NREAD 144
|
||||
# define BIO_C_NWRITE0 145
|
||||
# define BIO_C_NWRITE 146
|
||||
# define BIO_C_RESET_READ_REQUEST 147
|
||||
# define BIO_C_SET_MD_CTX 148
|
||||
|
||||
# define BIO_C_SET_PREFIX 149
|
||||
# define BIO_C_GET_PREFIX 150
|
||||
# define BIO_C_SET_SUFFIX 151
|
||||
# define BIO_C_GET_SUFFIX 152
|
||||
|
||||
# define BIO_C_SET_EX_ARG 153
|
||||
# define BIO_C_GET_EX_ARG 154
|
||||
|
||||
# define BIO_C_SET_CONNECT_MODE 155
|
||||
|
||||
# define BIO_set_app_data(s,arg) BIO_set_ex_data(s,0,arg)
|
||||
# define BIO_get_app_data(s) BIO_get_ex_data(s,0)
|
||||
|
||||
# define BIO_set_nbio(b,n) BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL)
|
||||
|
||||
# ifndef OPENSSL_NO_SOCK
|
||||
/* IP families we support, for BIO_s_connect() and BIO_s_accept() */
|
||||
/* Note: the underlying operating system may not support some of them */
|
||||
# define BIO_FAMILY_IPV4 4
|
||||
# define BIO_FAMILY_IPV6 6
|
||||
# define BIO_FAMILY_IPANY 256
|
||||
|
||||
/* BIO_s_connect() */
|
||||
# define BIO_set_conn_hostname(b,name) BIO_ctrl(b,BIO_C_SET_CONNECT,0,(char *)name)
|
||||
# define BIO_set_conn_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,1,(char *)port)
|
||||
# define BIO_set_conn_address(b,addr) BIO_ctrl(b,BIO_C_SET_CONNECT,2,(char *)addr)
|
||||
# define BIO_set_conn_ip_family(b,f) BIO_int_ctrl(b,BIO_C_SET_CONNECT,3,f)
|
||||
# define BIO_get_conn_hostname(b) ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,0))
|
||||
# define BIO_get_conn_port(b) ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,1))
|
||||
# define BIO_get_conn_address(b) ((const BIO_ADDR *)BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,2))
|
||||
# define BIO_get_conn_ip_family(b) BIO_ctrl(b,BIO_C_GET_CONNECT,3,NULL)
|
||||
# define BIO_set_conn_mode(b,n) BIO_ctrl(b,BIO_C_SET_CONNECT_MODE,(n),NULL)
|
||||
|
||||
/* BIO_s_accept() */
|
||||
# define BIO_set_accept_name(b,name) BIO_ctrl(b,BIO_C_SET_ACCEPT,0,(char *)name)
|
||||
# define BIO_set_accept_port(b,port) BIO_ctrl(b,BIO_C_SET_ACCEPT,1,(char *)port)
|
||||
# define BIO_get_accept_name(b) ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,0))
|
||||
# define BIO_get_accept_port(b) ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,1))
|
||||
# define BIO_get_peer_name(b) ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,2))
|
||||
# define BIO_get_peer_port(b) ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,3))
|
||||
/* #define BIO_set_nbio(b,n) BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL) */
|
||||
# define BIO_set_nbio_accept(b,n) BIO_ctrl(b,BIO_C_SET_ACCEPT,2,(n)?(void *)"a":NULL)
|
||||
# define BIO_set_accept_bios(b,bio) BIO_ctrl(b,BIO_C_SET_ACCEPT,3,(char *)bio)
|
||||
# define BIO_set_accept_ip_family(b,f) BIO_int_ctrl(b,BIO_C_SET_ACCEPT,4,f)
|
||||
# define BIO_get_accept_ip_family(b) BIO_ctrl(b,BIO_C_GET_ACCEPT,4,NULL)
|
||||
|
||||
/* Aliases kept for backward compatibility */
|
||||
# define BIO_BIND_NORMAL 0
|
||||
# define BIO_BIND_REUSEADDR BIO_SOCK_REUSEADDR
|
||||
# define BIO_BIND_REUSEADDR_IF_UNUSED BIO_SOCK_REUSEADDR
|
||||
# define BIO_set_bind_mode(b,mode) BIO_ctrl(b,BIO_C_SET_BIND_MODE,mode,NULL)
|
||||
# define BIO_get_bind_mode(b) BIO_ctrl(b,BIO_C_GET_BIND_MODE,0,NULL)
|
||||
|
||||
/* BIO_s_accept() and BIO_s_connect() */
|
||||
# define BIO_do_connect(b) BIO_do_handshake(b)
|
||||
# define BIO_do_accept(b) BIO_do_handshake(b)
|
||||
# endif /* OPENSSL_NO_SOCK */
|
||||
|
||||
# define BIO_do_handshake(b) BIO_ctrl(b,BIO_C_DO_STATE_MACHINE,0,NULL)
|
||||
|
||||
/* BIO_s_datagram(), BIO_s_fd(), BIO_s_socket(), BIO_s_accept() and BIO_s_connect() */
|
||||
# define BIO_set_fd(b,fd,c) BIO_int_ctrl(b,BIO_C_SET_FD,c,fd)
|
||||
# define BIO_get_fd(b,c) BIO_ctrl(b,BIO_C_GET_FD,0,(char *)c)
|
||||
|
||||
/* BIO_s_file() */
|
||||
# define BIO_set_fp(b,fp,c) BIO_ctrl(b,BIO_C_SET_FILE_PTR,c,(char *)fp)
|
||||
# define BIO_get_fp(b,fpp) BIO_ctrl(b,BIO_C_GET_FILE_PTR,0,(char *)fpp)
|
||||
|
||||
/* BIO_s_fd() and BIO_s_file() */
|
||||
# define BIO_seek(b,ofs) (int)BIO_ctrl(b,BIO_C_FILE_SEEK,ofs,NULL)
|
||||
# define BIO_tell(b) (int)BIO_ctrl(b,BIO_C_FILE_TELL,0,NULL)
|
||||
|
||||
/*
|
||||
* name is cast to lose const, but might be better to route through a
|
||||
* function so we can do it safely
|
||||
*/
|
||||
# ifdef CONST_STRICT
|
||||
/*
|
||||
* If you are wondering why this isn't defined, its because CONST_STRICT is
|
||||
* purely a compile-time kludge to allow const to be checked.
|
||||
*/
|
||||
int BIO_read_filename(BIO *b, const char *name);
|
||||
# else
|
||||
# define BIO_read_filename(b,name) (int)BIO_ctrl(b,BIO_C_SET_FILENAME, \
|
||||
BIO_CLOSE|BIO_FP_READ,(char *)name)
|
||||
# endif
|
||||
# define BIO_write_filename(b,name) (int)BIO_ctrl(b,BIO_C_SET_FILENAME, \
|
||||
BIO_CLOSE|BIO_FP_WRITE,name)
|
||||
# define BIO_append_filename(b,name) (int)BIO_ctrl(b,BIO_C_SET_FILENAME, \
|
||||
BIO_CLOSE|BIO_FP_APPEND,name)
|
||||
# define BIO_rw_filename(b,name) (int)BIO_ctrl(b,BIO_C_SET_FILENAME, \
|
||||
BIO_CLOSE|BIO_FP_READ|BIO_FP_WRITE,name)
|
||||
|
||||
/*
|
||||
* WARNING WARNING, this ups the reference count on the read bio of the SSL
|
||||
* structure. This is because the ssl read BIO is now pointed to by the
|
||||
* next_bio field in the bio. So when you free the BIO, make sure you are
|
||||
* doing a BIO_free_all() to catch the underlying BIO.
|
||||
*/
|
||||
# define BIO_set_ssl(b,ssl,c) BIO_ctrl(b,BIO_C_SET_SSL,c,(char *)ssl)
|
||||
# define BIO_get_ssl(b,sslp) BIO_ctrl(b,BIO_C_GET_SSL,0,(char *)sslp)
|
||||
# define BIO_set_ssl_mode(b,client) BIO_ctrl(b,BIO_C_SSL_MODE,client,NULL)
|
||||
# define BIO_set_ssl_renegotiate_bytes(b,num) \
|
||||
BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_BYTES,num,NULL)
|
||||
# define BIO_get_num_renegotiates(b) \
|
||||
BIO_ctrl(b,BIO_C_GET_SSL_NUM_RENEGOTIATES,0,NULL)
|
||||
# define BIO_set_ssl_renegotiate_timeout(b,seconds) \
|
||||
BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT,seconds,NULL)
|
||||
|
||||
/* defined in evp.h */
|
||||
/* #define BIO_set_md(b,md) BIO_ctrl(b,BIO_C_SET_MD,1,(char *)md) */
|
||||
|
||||
# define BIO_get_mem_data(b,pp) BIO_ctrl(b,BIO_CTRL_INFO,0,(char *)pp)
|
||||
# define BIO_set_mem_buf(b,bm,c) BIO_ctrl(b,BIO_C_SET_BUF_MEM,c,(char *)bm)
|
||||
# define BIO_get_mem_ptr(b,pp) BIO_ctrl(b,BIO_C_GET_BUF_MEM_PTR,0,(char *)pp)
|
||||
# define BIO_set_mem_eof_return(b,v) \
|
||||
BIO_ctrl(b,BIO_C_SET_BUF_MEM_EOF_RETURN,v,NULL)
|
||||
|
||||
/* For the BIO_f_buffer() type */
|
||||
# define BIO_get_buffer_num_lines(b) BIO_ctrl(b,BIO_C_GET_BUFF_NUM_LINES,0,NULL)
|
||||
# define BIO_set_buffer_size(b,size) BIO_ctrl(b,BIO_C_SET_BUFF_SIZE,size,NULL)
|
||||
# define BIO_set_read_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,0)
|
||||
# define BIO_set_write_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,1)
|
||||
# define BIO_set_buffer_read_data(b,buf,num) BIO_ctrl(b,BIO_C_SET_BUFF_READ_DATA,num,buf)
|
||||
|
||||
/* Don't use the next one unless you know what you are doing :-) */
|
||||
# define BIO_dup_state(b,ret) BIO_ctrl(b,BIO_CTRL_DUP,0,(char *)(ret))
|
||||
|
||||
# define BIO_reset(b) (int)BIO_ctrl(b,BIO_CTRL_RESET,0,NULL)
|
||||
# define BIO_eof(b) (int)BIO_ctrl(b,BIO_CTRL_EOF,0,NULL)
|
||||
# define BIO_set_close(b,c) (int)BIO_ctrl(b,BIO_CTRL_SET_CLOSE,(c),NULL)
|
||||
# define BIO_get_close(b) (int)BIO_ctrl(b,BIO_CTRL_GET_CLOSE,0,NULL)
|
||||
# define BIO_pending(b) (int)BIO_ctrl(b,BIO_CTRL_PENDING,0,NULL)
|
||||
# define BIO_wpending(b) (int)BIO_ctrl(b,BIO_CTRL_WPENDING,0,NULL)
|
||||
/* ...pending macros have inappropriate return type */
|
||||
size_t BIO_ctrl_pending(BIO *b);
|
||||
size_t BIO_ctrl_wpending(BIO *b);
|
||||
# define BIO_flush(b) (int)BIO_ctrl(b,BIO_CTRL_FLUSH,0,NULL)
|
||||
# define BIO_get_info_callback(b,cbp) (int)BIO_ctrl(b,BIO_CTRL_GET_CALLBACK,0, \
|
||||
cbp)
|
||||
# define BIO_set_info_callback(b,cb) (int)BIO_callback_ctrl(b,BIO_CTRL_SET_CALLBACK,cb)
|
||||
|
||||
/* For the BIO_f_buffer() type */
|
||||
# define BIO_buffer_get_num_lines(b) BIO_ctrl(b,BIO_CTRL_GET,0,NULL)
|
||||
|
||||
/* For BIO_s_bio() */
|
||||
# define BIO_set_write_buf_size(b,size) (int)BIO_ctrl(b,BIO_C_SET_WRITE_BUF_SIZE,size,NULL)
|
||||
# define BIO_get_write_buf_size(b,size) (size_t)BIO_ctrl(b,BIO_C_GET_WRITE_BUF_SIZE,size,NULL)
|
||||
# define BIO_make_bio_pair(b1,b2) (int)BIO_ctrl(b1,BIO_C_MAKE_BIO_PAIR,0,b2)
|
||||
# define BIO_destroy_bio_pair(b) (int)BIO_ctrl(b,BIO_C_DESTROY_BIO_PAIR,0,NULL)
|
||||
# define BIO_shutdown_wr(b) (int)BIO_ctrl(b, BIO_C_SHUTDOWN_WR, 0, NULL)
|
||||
/* macros with inappropriate type -- but ...pending macros use int too: */
|
||||
# define BIO_get_write_guarantee(b) (int)BIO_ctrl(b,BIO_C_GET_WRITE_GUARANTEE,0,NULL)
|
||||
# define BIO_get_read_request(b) (int)BIO_ctrl(b,BIO_C_GET_READ_REQUEST,0,NULL)
|
||||
size_t BIO_ctrl_get_write_guarantee(BIO *b);
|
||||
size_t BIO_ctrl_get_read_request(BIO *b);
|
||||
int BIO_ctrl_reset_read_request(BIO *b);
|
||||
|
||||
/* ctrl macros for dgram */
|
||||
# define BIO_ctrl_dgram_connect(b,peer) \
|
||||
(int)BIO_ctrl(b,BIO_CTRL_DGRAM_CONNECT,0, (char *)peer)
|
||||
# define BIO_ctrl_set_connected(b,peer) \
|
||||
(int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_CONNECTED, 0, (char *)peer)
|
||||
# define BIO_dgram_recv_timedout(b) \
|
||||
(int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP, 0, NULL)
|
||||
# define BIO_dgram_send_timedout(b) \
|
||||
(int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP, 0, NULL)
|
||||
# define BIO_dgram_get_peer(b,peer) \
|
||||
(int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_PEER, 0, (char *)peer)
|
||||
# define BIO_dgram_set_peer(b,peer) \
|
||||
(int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_PEER, 0, (char *)peer)
|
||||
# define BIO_dgram_get_mtu_overhead(b) \
|
||||
(unsigned int)BIO_ctrl((b), BIO_CTRL_DGRAM_GET_MTU_OVERHEAD, 0, NULL)
|
||||
|
||||
#define BIO_get_ex_new_index(l, p, newf, dupf, freef) \
|
||||
CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_BIO, l, p, newf, dupf, freef)
|
||||
int BIO_set_ex_data(BIO *bio, int idx, void *data);
|
||||
void *BIO_get_ex_data(BIO *bio, int idx);
|
||||
uint64_t BIO_number_read(BIO *bio);
|
||||
uint64_t BIO_number_written(BIO *bio);
|
||||
|
||||
/* For BIO_f_asn1() */
|
||||
int BIO_asn1_set_prefix(BIO *b, asn1_ps_func *prefix,
|
||||
asn1_ps_func *prefix_free);
|
||||
int BIO_asn1_get_prefix(BIO *b, asn1_ps_func **pprefix,
|
||||
asn1_ps_func **pprefix_free);
|
||||
int BIO_asn1_set_suffix(BIO *b, asn1_ps_func *suffix,
|
||||
asn1_ps_func *suffix_free);
|
||||
int BIO_asn1_get_suffix(BIO *b, asn1_ps_func **psuffix,
|
||||
asn1_ps_func **psuffix_free);
|
||||
|
||||
const BIO_METHOD *BIO_s_file(void);
|
||||
BIO *BIO_new_file(const char *filename, const char *mode);
|
||||
# ifndef OPENSSL_NO_STDIO
|
||||
BIO *BIO_new_fp(FILE *stream, int close_flag);
|
||||
# endif
|
||||
BIO *BIO_new(const BIO_METHOD *type);
|
||||
int BIO_free(BIO *a);
|
||||
void BIO_set_data(BIO *a, void *ptr);
|
||||
void *BIO_get_data(BIO *a);
|
||||
void BIO_set_init(BIO *a, int init);
|
||||
int BIO_get_init(BIO *a);
|
||||
void BIO_set_shutdown(BIO *a, int shut);
|
||||
int BIO_get_shutdown(BIO *a);
|
||||
void BIO_vfree(BIO *a);
|
||||
int BIO_up_ref(BIO *a);
|
||||
int BIO_read(BIO *b, void *data, int len);
|
||||
int BIO_gets(BIO *bp, char *buf, int size);
|
||||
int BIO_write(BIO *b, const void *data, int len);
|
||||
int BIO_puts(BIO *bp, const char *buf);
|
||||
int BIO_indent(BIO *b, int indent, int max);
|
||||
long BIO_ctrl(BIO *bp, int cmd, long larg, void *parg);
|
||||
long BIO_callback_ctrl(BIO *b, int cmd,
|
||||
void (*fp) (BIO *, int, const char *, int, long, long));
|
||||
void *BIO_ptr_ctrl(BIO *bp, int cmd, long larg);
|
||||
long BIO_int_ctrl(BIO *bp, int cmd, long larg, int iarg);
|
||||
BIO *BIO_push(BIO *b, BIO *append);
|
||||
BIO *BIO_pop(BIO *b);
|
||||
void BIO_free_all(BIO *a);
|
||||
BIO *BIO_find_type(BIO *b, int bio_type);
|
||||
BIO *BIO_next(BIO *b);
|
||||
void BIO_set_next(BIO *b, BIO *next);
|
||||
BIO *BIO_get_retry_BIO(BIO *bio, int *reason);
|
||||
int BIO_get_retry_reason(BIO *bio);
|
||||
void BIO_set_retry_reason(BIO *bio, int reason);
|
||||
BIO *BIO_dup_chain(BIO *in);
|
||||
|
||||
int BIO_nread0(BIO *bio, char **buf);
|
||||
int BIO_nread(BIO *bio, char **buf, int num);
|
||||
int BIO_nwrite0(BIO *bio, char **buf);
|
||||
int BIO_nwrite(BIO *bio, char **buf, int num);
|
||||
|
||||
long BIO_debug_callback(BIO *bio, int cmd, const char *argp, int argi,
|
||||
long argl, long ret);
|
||||
|
||||
const BIO_METHOD *BIO_s_mem(void);
|
||||
const BIO_METHOD *BIO_s_secmem(void);
|
||||
BIO *BIO_new_mem_buf(const void *buf, int len);
|
||||
# ifndef OPENSSL_NO_SOCK
|
||||
const BIO_METHOD *BIO_s_socket(void);
|
||||
const BIO_METHOD *BIO_s_connect(void);
|
||||
const BIO_METHOD *BIO_s_accept(void);
|
||||
# endif
|
||||
const BIO_METHOD *BIO_s_fd(void);
|
||||
const BIO_METHOD *BIO_s_log(void);
|
||||
const BIO_METHOD *BIO_s_bio(void);
|
||||
const BIO_METHOD *BIO_s_null(void);
|
||||
const BIO_METHOD *BIO_f_null(void);
|
||||
const BIO_METHOD *BIO_f_buffer(void);
|
||||
const BIO_METHOD *BIO_f_linebuffer(void);
|
||||
const BIO_METHOD *BIO_f_nbio_test(void);
|
||||
# ifndef OPENSSL_NO_DGRAM
|
||||
const BIO_METHOD *BIO_s_datagram(void);
|
||||
int BIO_dgram_non_fatal_error(int error);
|
||||
BIO *BIO_new_dgram(int fd, int close_flag);
|
||||
# ifndef OPENSSL_NO_SCTP
|
||||
const BIO_METHOD *BIO_s_datagram_sctp(void);
|
||||
BIO *BIO_new_dgram_sctp(int fd, int close_flag);
|
||||
int BIO_dgram_is_sctp(BIO *bio);
|
||||
int BIO_dgram_sctp_notification_cb(BIO *b,
|
||||
void (*handle_notifications) (BIO *bio,
|
||||
void *context,
|
||||
void *buf),
|
||||
void *context);
|
||||
int BIO_dgram_sctp_wait_for_dry(BIO *b);
|
||||
int BIO_dgram_sctp_msg_waiting(BIO *b);
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifndef OPENSSL_NO_SOCK
|
||||
int BIO_sock_should_retry(int i);
|
||||
int BIO_sock_non_fatal_error(int error);
|
||||
# endif
|
||||
|
||||
int BIO_fd_should_retry(int i);
|
||||
int BIO_fd_non_fatal_error(int error);
|
||||
int BIO_dump_cb(int (*cb) (const void *data, size_t len, void *u),
|
||||
void *u, const char *s, int len);
|
||||
int BIO_dump_indent_cb(int (*cb) (const void *data, size_t len, void *u),
|
||||
void *u, const char *s, int len, int indent);
|
||||
int BIO_dump(BIO *b, const char *bytes, int len);
|
||||
int BIO_dump_indent(BIO *b, const char *bytes, int len, int indent);
|
||||
# ifndef OPENSSL_NO_STDIO
|
||||
int BIO_dump_fp(FILE *fp, const char *s, int len);
|
||||
int BIO_dump_indent_fp(FILE *fp, const char *s, int len, int indent);
|
||||
# endif
|
||||
int BIO_hex_string(BIO *out, int indent, int width, unsigned char *data,
|
||||
int datalen);
|
||||
|
||||
# ifndef OPENSSL_NO_SOCK
|
||||
BIO_ADDR *BIO_ADDR_new(void);
|
||||
int BIO_ADDR_rawmake(BIO_ADDR *ap, int family,
|
||||
const void *where, size_t wherelen, unsigned short port);
|
||||
void BIO_ADDR_free(BIO_ADDR *);
|
||||
void BIO_ADDR_clear(BIO_ADDR *ap);
|
||||
int BIO_ADDR_family(const BIO_ADDR *ap);
|
||||
int BIO_ADDR_rawaddress(const BIO_ADDR *ap, void *p, size_t *l);
|
||||
unsigned short BIO_ADDR_rawport(const BIO_ADDR *ap);
|
||||
char *BIO_ADDR_hostname_string(const BIO_ADDR *ap, int numeric);
|
||||
char *BIO_ADDR_service_string(const BIO_ADDR *ap, int numeric);
|
||||
char *BIO_ADDR_path_string(const BIO_ADDR *ap);
|
||||
|
||||
const BIO_ADDRINFO *BIO_ADDRINFO_next(const BIO_ADDRINFO *bai);
|
||||
int BIO_ADDRINFO_family(const BIO_ADDRINFO *bai);
|
||||
int BIO_ADDRINFO_socktype(const BIO_ADDRINFO *bai);
|
||||
int BIO_ADDRINFO_protocol(const BIO_ADDRINFO *bai);
|
||||
const BIO_ADDR *BIO_ADDRINFO_address(const BIO_ADDRINFO *bai);
|
||||
void BIO_ADDRINFO_free(BIO_ADDRINFO *bai);
|
||||
|
||||
enum BIO_hostserv_priorities {
|
||||
BIO_PARSE_PRIO_HOST, BIO_PARSE_PRIO_SERV
|
||||
};
|
||||
int BIO_parse_hostserv(const char *hostserv, char **host, char **service,
|
||||
enum BIO_hostserv_priorities hostserv_prio);
|
||||
enum BIO_lookup_type {
|
||||
BIO_LOOKUP_CLIENT, BIO_LOOKUP_SERVER
|
||||
};
|
||||
int BIO_lookup(const char *host, const char *service,
|
||||
enum BIO_lookup_type lookup_type,
|
||||
int family, int socktype, BIO_ADDRINFO **res);
|
||||
int BIO_sock_error(int sock);
|
||||
int BIO_socket_ioctl(int fd, long type, void *arg);
|
||||
int BIO_socket_nbio(int fd, int mode);
|
||||
int BIO_sock_init(void);
|
||||
# if OPENSSL_API_COMPAT < 0x10100000L
|
||||
# define BIO_sock_cleanup() while(0) continue
|
||||
# endif
|
||||
int BIO_set_tcp_ndelay(int sock, int turn_on);
|
||||
|
||||
DEPRECATEDIN_1_1_0(struct hostent *BIO_gethostbyname(const char *name))
|
||||
DEPRECATEDIN_1_1_0(int BIO_get_port(const char *str, unsigned short *port_ptr))
|
||||
DEPRECATEDIN_1_1_0(int BIO_get_host_ip(const char *str, unsigned char *ip))
|
||||
DEPRECATEDIN_1_1_0(int BIO_get_accept_socket(char *host_port, int mode))
|
||||
DEPRECATEDIN_1_1_0(int BIO_accept(int sock, char **ip_port))
|
||||
|
||||
union BIO_sock_info_u {
|
||||
BIO_ADDR *addr;
|
||||
};
|
||||
enum BIO_sock_info_type {
|
||||
BIO_SOCK_INFO_ADDRESS
|
||||
};
|
||||
int BIO_sock_info(int sock,
|
||||
enum BIO_sock_info_type type, union BIO_sock_info_u *info);
|
||||
|
||||
# define BIO_SOCK_REUSEADDR 0x01
|
||||
# define BIO_SOCK_V6_ONLY 0x02
|
||||
# define BIO_SOCK_KEEPALIVE 0x04
|
||||
# define BIO_SOCK_NONBLOCK 0x08
|
||||
# define BIO_SOCK_NODELAY 0x10
|
||||
|
||||
int BIO_socket(int domain, int socktype, int protocol, int options);
|
||||
int BIO_connect(int sock, const BIO_ADDR *addr, int options);
|
||||
int BIO_listen(int sock, const BIO_ADDR *addr, int options);
|
||||
int BIO_accept_ex(int accept_sock, BIO_ADDR *addr, int options);
|
||||
int BIO_closesocket(int sock);
|
||||
|
||||
BIO *BIO_new_socket(int sock, int close_flag);
|
||||
BIO *BIO_new_connect(const char *host_port);
|
||||
BIO *BIO_new_accept(const char *host_port);
|
||||
# endif /* OPENSSL_NO_SOCK*/
|
||||
|
||||
BIO *BIO_new_fd(int fd, int close_flag);
|
||||
|
||||
int BIO_new_bio_pair(BIO **bio1, size_t writebuf1,
|
||||
BIO **bio2, size_t writebuf2);
|
||||
/*
|
||||
* If successful, returns 1 and in *bio1, *bio2 two BIO pair endpoints.
|
||||
* Otherwise returns 0 and sets *bio1 and *bio2 to NULL. Size 0 uses default
|
||||
* value.
|
||||
*/
|
||||
|
||||
void BIO_copy_next_retry(BIO *b);
|
||||
|
||||
/*
|
||||
* long BIO_ghbn_ctrl(int cmd,int iarg,char *parg);
|
||||
*/
|
||||
|
||||
# ifdef __GNUC__
|
||||
# define __bio_h__attr__ __attribute__
|
||||
# else
|
||||
# define __bio_h__attr__(x)
|
||||
# endif
|
||||
int BIO_printf(BIO *bio, const char *format, ...)
|
||||
__bio_h__attr__((__format__(__printf__, 2, 3)));
|
||||
int BIO_vprintf(BIO *bio, const char *format, va_list args)
|
||||
__bio_h__attr__((__format__(__printf__, 2, 0)));
|
||||
int BIO_snprintf(char *buf, size_t n, const char *format, ...)
|
||||
__bio_h__attr__((__format__(__printf__, 3, 4)));
|
||||
int BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args)
|
||||
__bio_h__attr__((__format__(__printf__, 3, 0)));
|
||||
# undef __bio_h__attr__
|
||||
|
||||
|
||||
BIO_METHOD *BIO_meth_new(int type, const char *name);
|
||||
void BIO_meth_free(BIO_METHOD *biom);
|
||||
int (*BIO_meth_get_write(BIO_METHOD *biom)) (BIO *, const char *, int);
|
||||
int BIO_meth_set_write(BIO_METHOD *biom,
|
||||
int (*write) (BIO *, const char *, int));
|
||||
int (*BIO_meth_get_read(BIO_METHOD *biom)) (BIO *, char *, int);
|
||||
int BIO_meth_set_read(BIO_METHOD *biom,
|
||||
int (*read) (BIO *, char *, int));
|
||||
int (*BIO_meth_get_puts(BIO_METHOD *biom)) (BIO *, const char *);
|
||||
int BIO_meth_set_puts(BIO_METHOD *biom,
|
||||
int (*puts) (BIO *, const char *));
|
||||
int (*BIO_meth_get_gets(BIO_METHOD *biom)) (BIO *, char *, int);
|
||||
int BIO_meth_set_gets(BIO_METHOD *biom,
|
||||
int (*gets) (BIO *, char *, int));
|
||||
long (*BIO_meth_get_ctrl(BIO_METHOD *biom)) (BIO *, int, long, void *);
|
||||
int BIO_meth_set_ctrl(BIO_METHOD *biom,
|
||||
long (*ctrl) (BIO *, int, long, void *));
|
||||
int (*BIO_meth_get_create(BIO_METHOD *bion)) (BIO *);
|
||||
int BIO_meth_set_create(BIO_METHOD *biom, int (*create) (BIO *));
|
||||
int (*BIO_meth_get_destroy(BIO_METHOD *biom)) (BIO *);
|
||||
int BIO_meth_set_destroy(BIO_METHOD *biom, int (*destroy) (BIO *));
|
||||
long (*BIO_meth_get_callback_ctrl(BIO_METHOD *biom))
|
||||
(BIO *, int, bio_info_cb *);
|
||||
int BIO_meth_set_callback_ctrl(BIO_METHOD *biom,
|
||||
long (*callback_ctrl) (BIO *, int,
|
||||
bio_info_cb *));
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
/*
|
||||
* The following lines are auto generated by the script mkerr.pl. Any changes
|
||||
* made after this point may be overwritten when the script is next run.
|
||||
*/
|
||||
|
||||
int ERR_load_BIO_strings(void);
|
||||
|
||||
/* Error codes for the BIO functions. */
|
||||
|
||||
/* Function codes. */
|
||||
# define BIO_F_ACPT_STATE 100
|
||||
# define BIO_F_ADDR_STRINGS 134
|
||||
# define BIO_F_BIO_ACCEPT 101
|
||||
# define BIO_F_BIO_ACCEPT_EX 137
|
||||
# define BIO_F_BIO_ADDR_NEW 144
|
||||
# define BIO_F_BIO_CALLBACK_CTRL 131
|
||||
# define BIO_F_BIO_CONNECT 138
|
||||
# define BIO_F_BIO_CTRL 103
|
||||
# define BIO_F_BIO_GETS 104
|
||||
# define BIO_F_BIO_GET_HOST_IP 106
|
||||
# define BIO_F_BIO_GET_NEW_INDEX 102
|
||||
# define BIO_F_BIO_GET_PORT 107
|
||||
# define BIO_F_BIO_LISTEN 139
|
||||
# define BIO_F_BIO_LOOKUP 135
|
||||
# define BIO_F_BIO_MAKE_PAIR 121
|
||||
# define BIO_F_BIO_NEW 108
|
||||
# define BIO_F_BIO_NEW_FILE 109
|
||||
# define BIO_F_BIO_NEW_MEM_BUF 126
|
||||
# define BIO_F_BIO_NREAD 123
|
||||
# define BIO_F_BIO_NREAD0 124
|
||||
# define BIO_F_BIO_NWRITE 125
|
||||
# define BIO_F_BIO_NWRITE0 122
|
||||
# define BIO_F_BIO_PARSE_HOSTSERV 136
|
||||
# define BIO_F_BIO_PUTS 110
|
||||
# define BIO_F_BIO_READ 111
|
||||
# define BIO_F_BIO_SOCKET 140
|
||||
# define BIO_F_BIO_SOCKET_NBIO 142
|
||||
# define BIO_F_BIO_SOCK_INFO 141
|
||||
# define BIO_F_BIO_SOCK_INIT 112
|
||||
# define BIO_F_BIO_WRITE 113
|
||||
# define BIO_F_BUFFER_CTRL 114
|
||||
# define BIO_F_CONN_CTRL 127
|
||||
# define BIO_F_CONN_STATE 115
|
||||
# define BIO_F_DGRAM_SCTP_READ 132
|
||||
# define BIO_F_DGRAM_SCTP_WRITE 133
|
||||
# define BIO_F_FILE_CTRL 116
|
||||
# define BIO_F_FILE_READ 130
|
||||
# define BIO_F_LINEBUFFER_CTRL 129
|
||||
# define BIO_F_MEM_WRITE 117
|
||||
# define BIO_F_SSL_NEW 118
|
||||
|
||||
/* Reason codes. */
|
||||
# define BIO_R_ACCEPT_ERROR 100
|
||||
# define BIO_R_ADDRINFO_ADDR_IS_NOT_AF_INET 141
|
||||
# define BIO_R_AMBIGUOUS_HOST_OR_SERVICE 129
|
||||
# define BIO_R_BAD_FOPEN_MODE 101
|
||||
# define BIO_R_BROKEN_PIPE 124
|
||||
# define BIO_R_CONNECT_ERROR 103
|
||||
# define BIO_R_GETHOSTBYNAME_ADDR_IS_NOT_AF_INET 107
|
||||
# define BIO_R_GETSOCKNAME_ERROR 132
|
||||
# define BIO_R_GETSOCKNAME_TRUNCATED_ADDRESS 133
|
||||
# define BIO_R_GETTING_SOCKTYPE 134
|
||||
# define BIO_R_INVALID_ARGUMENT 125
|
||||
# define BIO_R_INVALID_SOCKET 135
|
||||
# define BIO_R_IN_USE 123
|
||||
# define BIO_R_LISTEN_V6_ONLY 136
|
||||
# define BIO_R_LOOKUP_RETURNED_NOTHING 142
|
||||
# define BIO_R_MALFORMED_HOST_OR_SERVICE 130
|
||||
# define BIO_R_NBIO_CONNECT_ERROR 110
|
||||
# define BIO_R_NO_ACCEPT_ADDR_OR_SERVICE_SPECIFIED 143
|
||||
# define BIO_R_NO_HOSTNAME_OR_SERVICE_SPECIFIED 144
|
||||
# define BIO_R_NO_PORT_DEFINED 113
|
||||
# define BIO_R_NO_SUCH_FILE 128
|
||||
# define BIO_R_NULL_PARAMETER 115
|
||||
# define BIO_R_UNABLE_TO_BIND_SOCKET 117
|
||||
# define BIO_R_UNABLE_TO_CREATE_SOCKET 118
|
||||
# define BIO_R_UNABLE_TO_KEEPALIVE 137
|
||||
# define BIO_R_UNABLE_TO_LISTEN_SOCKET 119
|
||||
# define BIO_R_UNABLE_TO_NODELAY 138
|
||||
# define BIO_R_UNABLE_TO_REUSEADDR 139
|
||||
# define BIO_R_UNAVAILABLE_IP_FAMILY 145
|
||||
# define BIO_R_UNINITIALIZED 120
|
||||
# define BIO_R_UNKNOWN_INFO_TYPE 140
|
||||
# define BIO_R_UNSUPPORTED_IP_FAMILY 146
|
||||
# define BIO_R_UNSUPPORTED_METHOD 121
|
||||
# define BIO_R_UNSUPPORTED_PROTOCOL_FAMILY 131
|
||||
# define BIO_R_WRITE_TO_READ_ONLY_BIO 126
|
||||
# define BIO_R_WSASTARTUP 122
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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_BLOWFISH_H
|
||||
# define HEADER_BLOWFISH_H
|
||||
|
||||
# include <openssl/opensslconf.h>
|
||||
|
||||
# ifndef OPENSSL_NO_BF
|
||||
# include <openssl/e_os2.h>
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
# endif
|
||||
|
||||
# define BF_ENCRYPT 1
|
||||
# define BF_DECRYPT 0
|
||||
|
||||
/*-
|
||||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
* ! BF_LONG has to be at least 32 bits wide. !
|
||||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
*/
|
||||
# define BF_LONG unsigned int
|
||||
|
||||
# define BF_ROUNDS 16
|
||||
# define BF_BLOCK 8
|
||||
|
||||
typedef struct bf_key_st {
|
||||
BF_LONG P[BF_ROUNDS + 2];
|
||||
BF_LONG S[4 * 256];
|
||||
} BF_KEY;
|
||||
|
||||
void BF_set_key(BF_KEY *key, int len, const unsigned char *data);
|
||||
|
||||
void BF_encrypt(BF_LONG *data, const BF_KEY *key);
|
||||
void BF_decrypt(BF_LONG *data, const BF_KEY *key);
|
||||
|
||||
void BF_ecb_encrypt(const unsigned char *in, unsigned char *out,
|
||||
const BF_KEY *key, int enc);
|
||||
void BF_cbc_encrypt(const unsigned char *in, unsigned char *out, long length,
|
||||
const BF_KEY *schedule, unsigned char *ivec, int enc);
|
||||
void BF_cfb64_encrypt(const unsigned char *in, unsigned char *out,
|
||||
long length, const BF_KEY *schedule,
|
||||
unsigned char *ivec, int *num, int enc);
|
||||
void BF_ofb64_encrypt(const unsigned char *in, unsigned char *out,
|
||||
long length, const BF_KEY *schedule,
|
||||
unsigned char *ivec, int *num);
|
||||
const char *BF_options(void);
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,575 @@
|
|||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
|
||||
*
|
||||
* Portions of the attached software ("Contribution") are developed by
|
||||
* SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project.
|
||||
*
|
||||
* The Contribution is licensed pursuant to the Eric Young open source
|
||||
* license provided above.
|
||||
*
|
||||
* The binary polynomial arithmetic software is originally written by
|
||||
* Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HEADER_BN_H
|
||||
# define HEADER_BN_H
|
||||
|
||||
# include <openssl/e_os2.h>
|
||||
# ifndef OPENSSL_NO_STDIO
|
||||
# include <stdio.h>
|
||||
# endif
|
||||
# include <openssl/opensslconf.h>
|
||||
# include <openssl/ossl_typ.h>
|
||||
# include <openssl/crypto.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 64-bit processor with LP64 ABI
|
||||
*/
|
||||
# ifdef SIXTY_FOUR_BIT_LONG
|
||||
# define BN_ULONG unsigned long
|
||||
# define BN_BYTES 8
|
||||
# endif
|
||||
|
||||
/*
|
||||
* 64-bit processor other than LP64 ABI
|
||||
*/
|
||||
# ifdef SIXTY_FOUR_BIT
|
||||
# define BN_ULONG unsigned long long
|
||||
# define BN_BYTES 8
|
||||
# endif
|
||||
|
||||
# ifdef THIRTY_TWO_BIT
|
||||
# define BN_ULONG unsigned int
|
||||
# define BN_BYTES 4
|
||||
# endif
|
||||
|
||||
# define BN_BITS2 (BN_BYTES * 8)
|
||||
# define BN_BITS (BN_BITS2 * 2)
|
||||
# define BN_TBIT ((BN_ULONG)1 << (BN_BITS2 - 1))
|
||||
|
||||
# define BN_FLG_MALLOCED 0x01
|
||||
# define BN_FLG_STATIC_DATA 0x02
|
||||
|
||||
/*
|
||||
* avoid leaking exponent information through timing,
|
||||
* BN_mod_exp_mont() will call BN_mod_exp_mont_consttime,
|
||||
* BN_div() will call BN_div_no_branch,
|
||||
* BN_mod_inverse() will call BN_mod_inverse_no_branch.
|
||||
*/
|
||||
# define BN_FLG_CONSTTIME 0x04
|
||||
# define BN_FLG_SECURE 0x08
|
||||
|
||||
# if OPENSSL_API_COMPAT < 0x00908000L
|
||||
/* deprecated name for the flag */
|
||||
# define BN_FLG_EXP_CONSTTIME BN_FLG_CONSTTIME
|
||||
# define BN_FLG_FREE 0x8000 /* used for debugging */
|
||||
# endif
|
||||
|
||||
void BN_set_flags(BIGNUM *b, int n);
|
||||
int BN_get_flags(const BIGNUM *b, int n);
|
||||
|
||||
/* Values for |top| in BN_rand() */
|
||||
#define BN_RAND_TOP_ANY -1
|
||||
#define BN_RAND_TOP_ONE 0
|
||||
#define BN_RAND_TOP_TWO 1
|
||||
|
||||
/* Values for |bottom| in BN_rand() */
|
||||
#define BN_RAND_BOTTOM_ANY 0
|
||||
#define BN_RAND_BOTTOM_ODD 1
|
||||
|
||||
/*
|
||||
* get a clone of a BIGNUM with changed flags, for *temporary* use only (the
|
||||
* two BIGNUMs cannot be used in parallel!). Also only for *read only* use. The
|
||||
* value |dest| should be a newly allocated BIGNUM obtained via BN_new() that
|
||||
* has not been otherwise initialised or used.
|
||||
*/
|
||||
void BN_with_flags(BIGNUM *dest, const BIGNUM *b, int flags);
|
||||
|
||||
/* Wrapper function to make using BN_GENCB easier */
|
||||
int BN_GENCB_call(BN_GENCB *cb, int a, int b);
|
||||
|
||||
BN_GENCB *BN_GENCB_new(void);
|
||||
void BN_GENCB_free(BN_GENCB *cb);
|
||||
|
||||
/* Populate a BN_GENCB structure with an "old"-style callback */
|
||||
void BN_GENCB_set_old(BN_GENCB *gencb, void (*callback) (int, int, void *),
|
||||
void *cb_arg);
|
||||
|
||||
/* Populate a BN_GENCB structure with a "new"-style callback */
|
||||
void BN_GENCB_set(BN_GENCB *gencb, int (*callback) (int, int, BN_GENCB *),
|
||||
void *cb_arg);
|
||||
|
||||
void *BN_GENCB_get_arg(BN_GENCB *cb);
|
||||
|
||||
# define BN_prime_checks 0 /* default: select number of iterations based
|
||||
* on the size of the number */
|
||||
|
||||
/*
|
||||
* number of Miller-Rabin iterations for an error rate of less than 2^-80 for
|
||||
* random 'b'-bit input, b >= 100 (taken from table 4.4 in the Handbook of
|
||||
* Applied Cryptography [Menezes, van Oorschot, Vanstone; CRC Press 1996];
|
||||
* original paper: Damgaard, Landrock, Pomerance: Average case error
|
||||
* estimates for the strong probable prime test. -- Math. Comp. 61 (1993)
|
||||
* 177-194)
|
||||
*/
|
||||
# define BN_prime_checks_for_size(b) ((b) >= 1300 ? 2 : \
|
||||
(b) >= 850 ? 3 : \
|
||||
(b) >= 650 ? 4 : \
|
||||
(b) >= 550 ? 5 : \
|
||||
(b) >= 450 ? 6 : \
|
||||
(b) >= 400 ? 7 : \
|
||||
(b) >= 350 ? 8 : \
|
||||
(b) >= 300 ? 9 : \
|
||||
(b) >= 250 ? 12 : \
|
||||
(b) >= 200 ? 15 : \
|
||||
(b) >= 150 ? 18 : \
|
||||
/* b >= 100 */ 27)
|
||||
|
||||
# define BN_num_bytes(a) ((BN_num_bits(a)+7)/8)
|
||||
|
||||
int BN_abs_is_word(const BIGNUM *a, const BN_ULONG w);
|
||||
int BN_is_zero(const BIGNUM *a);
|
||||
int BN_is_one(const BIGNUM *a);
|
||||
int BN_is_word(const BIGNUM *a, const BN_ULONG w);
|
||||
int BN_is_odd(const BIGNUM *a);
|
||||
|
||||
# define BN_one(a) (BN_set_word((a),1))
|
||||
|
||||
void BN_zero_ex(BIGNUM *a);
|
||||
|
||||
# if OPENSSL_API_COMPAT >= 0x00908000L
|
||||
# define BN_zero(a) BN_zero_ex(a)
|
||||
# else
|
||||
# define BN_zero(a) (BN_set_word((a),0))
|
||||
# endif
|
||||
|
||||
const BIGNUM *BN_value_one(void);
|
||||
char *BN_options(void);
|
||||
BN_CTX *BN_CTX_new(void);
|
||||
BN_CTX *BN_CTX_secure_new(void);
|
||||
void BN_CTX_free(BN_CTX *c);
|
||||
void BN_CTX_start(BN_CTX *ctx);
|
||||
BIGNUM *BN_CTX_get(BN_CTX *ctx);
|
||||
void BN_CTX_end(BN_CTX *ctx);
|
||||
int BN_rand(BIGNUM *rnd, int bits, int top, int bottom);
|
||||
int BN_pseudo_rand(BIGNUM *rnd, int bits, int top, int bottom);
|
||||
int BN_rand_range(BIGNUM *rnd, const BIGNUM *range);
|
||||
int BN_pseudo_rand_range(BIGNUM *rnd, const BIGNUM *range);
|
||||
int BN_num_bits(const BIGNUM *a);
|
||||
int BN_num_bits_word(BN_ULONG l);
|
||||
int BN_security_bits(int L, int N);
|
||||
BIGNUM *BN_new(void);
|
||||
BIGNUM *BN_secure_new(void);
|
||||
void BN_clear_free(BIGNUM *a);
|
||||
BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b);
|
||||
void BN_swap(BIGNUM *a, BIGNUM *b);
|
||||
BIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret);
|
||||
int BN_bn2bin(const BIGNUM *a, unsigned char *to);
|
||||
int BN_bn2binpad(const BIGNUM *a, unsigned char *to, int tolen);
|
||||
BIGNUM *BN_lebin2bn(const unsigned char *s, int len, BIGNUM *ret);
|
||||
int BN_bn2lebinpad(const BIGNUM *a, unsigned char *to, int tolen);
|
||||
BIGNUM *BN_mpi2bn(const unsigned char *s, int len, BIGNUM *ret);
|
||||
int BN_bn2mpi(const BIGNUM *a, unsigned char *to);
|
||||
int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
|
||||
int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
|
||||
int BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
|
||||
int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
|
||||
int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
|
||||
int BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx);
|
||||
/** BN_set_negative sets sign of a BIGNUM
|
||||
* \param b pointer to the BIGNUM object
|
||||
* \param n 0 if the BIGNUM b should be positive and a value != 0 otherwise
|
||||
*/
|
||||
void BN_set_negative(BIGNUM *b, int n);
|
||||
/** BN_is_negative returns 1 if the BIGNUM is negative
|
||||
* \param a pointer to the BIGNUM object
|
||||
* \return 1 if a < 0 and 0 otherwise
|
||||
*/
|
||||
int BN_is_negative(const BIGNUM *b);
|
||||
|
||||
int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d,
|
||||
BN_CTX *ctx);
|
||||
# define BN_mod(rem,m,d,ctx) BN_div(NULL,(rem),(m),(d),(ctx))
|
||||
int BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx);
|
||||
int BN_mod_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,
|
||||
BN_CTX *ctx);
|
||||
int BN_mod_add_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||
const BIGNUM *m);
|
||||
int BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,
|
||||
BN_CTX *ctx);
|
||||
int BN_mod_sub_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||
const BIGNUM *m);
|
||||
int BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,
|
||||
BN_CTX *ctx);
|
||||
int BN_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);
|
||||
int BN_mod_lshift1(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);
|
||||
int BN_mod_lshift1_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *m);
|
||||
int BN_mod_lshift(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m,
|
||||
BN_CTX *ctx);
|
||||
int BN_mod_lshift_quick(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m);
|
||||
|
||||
BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w);
|
||||
BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w);
|
||||
int BN_mul_word(BIGNUM *a, BN_ULONG w);
|
||||
int BN_add_word(BIGNUM *a, BN_ULONG w);
|
||||
int BN_sub_word(BIGNUM *a, BN_ULONG w);
|
||||
int BN_set_word(BIGNUM *a, BN_ULONG w);
|
||||
BN_ULONG BN_get_word(const BIGNUM *a);
|
||||
|
||||
int BN_cmp(const BIGNUM *a, const BIGNUM *b);
|
||||
void BN_free(BIGNUM *a);
|
||||
int BN_is_bit_set(const BIGNUM *a, int n);
|
||||
int BN_lshift(BIGNUM *r, const BIGNUM *a, int n);
|
||||
int BN_lshift1(BIGNUM *r, const BIGNUM *a);
|
||||
int BN_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
|
||||
|
||||
int BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
|
||||
const BIGNUM *m, BN_CTX *ctx);
|
||||
int BN_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
|
||||
const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
|
||||
int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
|
||||
const BIGNUM *m, BN_CTX *ctx,
|
||||
BN_MONT_CTX *in_mont);
|
||||
int BN_mod_exp_mont_word(BIGNUM *r, BN_ULONG a, const BIGNUM *p,
|
||||
const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
|
||||
int BN_mod_exp2_mont(BIGNUM *r, const BIGNUM *a1, const BIGNUM *p1,
|
||||
const BIGNUM *a2, const BIGNUM *p2, const BIGNUM *m,
|
||||
BN_CTX *ctx, BN_MONT_CTX *m_ctx);
|
||||
int BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
|
||||
const BIGNUM *m, BN_CTX *ctx);
|
||||
|
||||
int BN_mask_bits(BIGNUM *a, int n);
|
||||
# ifndef OPENSSL_NO_STDIO
|
||||
int BN_print_fp(FILE *fp, const BIGNUM *a);
|
||||
# endif
|
||||
int BN_print(BIO *bio, const BIGNUM *a);
|
||||
int BN_reciprocal(BIGNUM *r, const BIGNUM *m, int len, BN_CTX *ctx);
|
||||
int BN_rshift(BIGNUM *r, const BIGNUM *a, int n);
|
||||
int BN_rshift1(BIGNUM *r, const BIGNUM *a);
|
||||
void BN_clear(BIGNUM *a);
|
||||
BIGNUM *BN_dup(const BIGNUM *a);
|
||||
int BN_ucmp(const BIGNUM *a, const BIGNUM *b);
|
||||
int BN_set_bit(BIGNUM *a, int n);
|
||||
int BN_clear_bit(BIGNUM *a, int n);
|
||||
char *BN_bn2hex(const BIGNUM *a);
|
||||
char *BN_bn2dec(const BIGNUM *a);
|
||||
int BN_hex2bn(BIGNUM **a, const char *str);
|
||||
int BN_dec2bn(BIGNUM **a, const char *str);
|
||||
int BN_asc2bn(BIGNUM **a, const char *str);
|
||||
int BN_gcd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
|
||||
int BN_kronecker(const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); /* returns
|
||||
* -2 for
|
||||
* error */
|
||||
BIGNUM *BN_mod_inverse(BIGNUM *ret,
|
||||
const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx);
|
||||
BIGNUM *BN_mod_sqrt(BIGNUM *ret,
|
||||
const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx);
|
||||
|
||||
void BN_consttime_swap(BN_ULONG swap, BIGNUM *a, BIGNUM *b, int nwords);
|
||||
|
||||
/* Deprecated versions */
|
||||
DEPRECATEDIN_0_9_8(BIGNUM *BN_generate_prime(BIGNUM *ret, int bits, int safe,
|
||||
const BIGNUM *add,
|
||||
const BIGNUM *rem,
|
||||
void (*callback) (int, int,
|
||||
void *),
|
||||
void *cb_arg))
|
||||
DEPRECATEDIN_0_9_8(int
|
||||
BN_is_prime(const BIGNUM *p, int nchecks,
|
||||
void (*callback) (int, int, void *),
|
||||
BN_CTX *ctx, void *cb_arg))
|
||||
DEPRECATEDIN_0_9_8(int
|
||||
BN_is_prime_fasttest(const BIGNUM *p, int nchecks,
|
||||
void (*callback) (int, int, void *),
|
||||
BN_CTX *ctx, void *cb_arg,
|
||||
int do_trial_division))
|
||||
|
||||
/* Newer versions */
|
||||
int BN_generate_prime_ex(BIGNUM *ret, int bits, int safe, const BIGNUM *add,
|
||||
const BIGNUM *rem, BN_GENCB *cb);
|
||||
int BN_is_prime_ex(const BIGNUM *p, int nchecks, BN_CTX *ctx, BN_GENCB *cb);
|
||||
int BN_is_prime_fasttest_ex(const BIGNUM *p, int nchecks, BN_CTX *ctx,
|
||||
int do_trial_division, BN_GENCB *cb);
|
||||
|
||||
int BN_X931_generate_Xpq(BIGNUM *Xp, BIGNUM *Xq, int nbits, BN_CTX *ctx);
|
||||
|
||||
int BN_X931_derive_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2,
|
||||
const BIGNUM *Xp, const BIGNUM *Xp1,
|
||||
const BIGNUM *Xp2, const BIGNUM *e, BN_CTX *ctx,
|
||||
BN_GENCB *cb);
|
||||
int BN_X931_generate_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2, BIGNUM *Xp1,
|
||||
BIGNUM *Xp2, const BIGNUM *Xp, const BIGNUM *e,
|
||||
BN_CTX *ctx, BN_GENCB *cb);
|
||||
|
||||
BN_MONT_CTX *BN_MONT_CTX_new(void);
|
||||
int BN_mod_mul_montgomery(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||
BN_MONT_CTX *mont, BN_CTX *ctx);
|
||||
int BN_to_montgomery(BIGNUM *r, const BIGNUM *a, BN_MONT_CTX *mont,
|
||||
BN_CTX *ctx);
|
||||
int BN_from_montgomery(BIGNUM *r, const BIGNUM *a, BN_MONT_CTX *mont,
|
||||
BN_CTX *ctx);
|
||||
void BN_MONT_CTX_free(BN_MONT_CTX *mont);
|
||||
int BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx);
|
||||
BN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to, BN_MONT_CTX *from);
|
||||
BN_MONT_CTX *BN_MONT_CTX_set_locked(BN_MONT_CTX **pmont, CRYPTO_RWLOCK *lock,
|
||||
const BIGNUM *mod, BN_CTX *ctx);
|
||||
|
||||
/* BN_BLINDING flags */
|
||||
# define BN_BLINDING_NO_UPDATE 0x00000001
|
||||
# define BN_BLINDING_NO_RECREATE 0x00000002
|
||||
|
||||
BN_BLINDING *BN_BLINDING_new(const BIGNUM *A, const BIGNUM *Ai, BIGNUM *mod);
|
||||
void BN_BLINDING_free(BN_BLINDING *b);
|
||||
int BN_BLINDING_update(BN_BLINDING *b, BN_CTX *ctx);
|
||||
int BN_BLINDING_convert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx);
|
||||
int BN_BLINDING_invert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx);
|
||||
int BN_BLINDING_convert_ex(BIGNUM *n, BIGNUM *r, BN_BLINDING *b, BN_CTX *);
|
||||
int BN_BLINDING_invert_ex(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b,
|
||||
BN_CTX *);
|
||||
|
||||
int BN_BLINDING_is_current_thread(BN_BLINDING *b);
|
||||
void BN_BLINDING_set_current_thread(BN_BLINDING *b);
|
||||
int BN_BLINDING_lock(BN_BLINDING *b);
|
||||
int BN_BLINDING_unlock(BN_BLINDING *b);
|
||||
|
||||
unsigned long BN_BLINDING_get_flags(const BN_BLINDING *);
|
||||
void BN_BLINDING_set_flags(BN_BLINDING *, unsigned long);
|
||||
BN_BLINDING *BN_BLINDING_create_param(BN_BLINDING *b,
|
||||
const BIGNUM *e, BIGNUM *m, BN_CTX *ctx,
|
||||
int (*bn_mod_exp) (BIGNUM *r,
|
||||
const BIGNUM *a,
|
||||
const BIGNUM *p,
|
||||
const BIGNUM *m,
|
||||
BN_CTX *ctx,
|
||||
BN_MONT_CTX *m_ctx),
|
||||
BN_MONT_CTX *m_ctx);
|
||||
|
||||
DEPRECATEDIN_0_9_8(void BN_set_params(int mul, int high, int low, int mont))
|
||||
DEPRECATEDIN_0_9_8(int BN_get_params(int which)) /* 0, mul, 1 high, 2 low, 3
|
||||
* mont */
|
||||
|
||||
BN_RECP_CTX *BN_RECP_CTX_new(void);
|
||||
void BN_RECP_CTX_free(BN_RECP_CTX *recp);
|
||||
int BN_RECP_CTX_set(BN_RECP_CTX *recp, const BIGNUM *rdiv, BN_CTX *ctx);
|
||||
int BN_mod_mul_reciprocal(BIGNUM *r, const BIGNUM *x, const BIGNUM *y,
|
||||
BN_RECP_CTX *recp, BN_CTX *ctx);
|
||||
int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
|
||||
const BIGNUM *m, BN_CTX *ctx);
|
||||
int BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m,
|
||||
BN_RECP_CTX *recp, BN_CTX *ctx);
|
||||
|
||||
# ifndef OPENSSL_NO_EC2M
|
||||
|
||||
/*
|
||||
* Functions for arithmetic over binary polynomials represented by BIGNUMs.
|
||||
* The BIGNUM::neg property of BIGNUMs representing binary polynomials is
|
||||
* ignored. Note that input arguments are not const so that their bit arrays
|
||||
* can be expanded to the appropriate size if needed.
|
||||
*/
|
||||
|
||||
/*
|
||||
* r = a + b
|
||||
*/
|
||||
int BN_GF2m_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
|
||||
# define BN_GF2m_sub(r, a, b) BN_GF2m_add(r, a, b)
|
||||
/*
|
||||
* r=a mod p
|
||||
*/
|
||||
int BN_GF2m_mod(BIGNUM *r, const BIGNUM *a, const BIGNUM *p);
|
||||
/* r = (a * b) mod p */
|
||||
int BN_GF2m_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||
const BIGNUM *p, BN_CTX *ctx);
|
||||
/* r = (a * a) mod p */
|
||||
int BN_GF2m_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
|
||||
/* r = (1 / b) mod p */
|
||||
int BN_GF2m_mod_inv(BIGNUM *r, const BIGNUM *b, const BIGNUM *p, BN_CTX *ctx);
|
||||
/* r = (a / b) mod p */
|
||||
int BN_GF2m_mod_div(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||
const BIGNUM *p, BN_CTX *ctx);
|
||||
/* r = (a ^ b) mod p */
|
||||
int BN_GF2m_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||
const BIGNUM *p, BN_CTX *ctx);
|
||||
/* r = sqrt(a) mod p */
|
||||
int BN_GF2m_mod_sqrt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
|
||||
BN_CTX *ctx);
|
||||
/* r^2 + r = a mod p */
|
||||
int BN_GF2m_mod_solve_quad(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
|
||||
BN_CTX *ctx);
|
||||
# define BN_GF2m_cmp(a, b) BN_ucmp((a), (b))
|
||||
/*-
|
||||
* Some functions allow for representation of the irreducible polynomials
|
||||
* as an unsigned int[], say p. The irreducible f(t) is then of the form:
|
||||
* t^p[0] + t^p[1] + ... + t^p[k]
|
||||
* where m = p[0] > p[1] > ... > p[k] = 0.
|
||||
*/
|
||||
/* r = a mod p */
|
||||
int BN_GF2m_mod_arr(BIGNUM *r, const BIGNUM *a, const int p[]);
|
||||
/* r = (a * b) mod p */
|
||||
int BN_GF2m_mod_mul_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||
const int p[], BN_CTX *ctx);
|
||||
/* r = (a * a) mod p */
|
||||
int BN_GF2m_mod_sqr_arr(BIGNUM *r, const BIGNUM *a, const int p[],
|
||||
BN_CTX *ctx);
|
||||
/* r = (1 / b) mod p */
|
||||
int BN_GF2m_mod_inv_arr(BIGNUM *r, const BIGNUM *b, const int p[],
|
||||
BN_CTX *ctx);
|
||||
/* r = (a / b) mod p */
|
||||
int BN_GF2m_mod_div_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||
const int p[], BN_CTX *ctx);
|
||||
/* r = (a ^ b) mod p */
|
||||
int BN_GF2m_mod_exp_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||
const int p[], BN_CTX *ctx);
|
||||
/* r = sqrt(a) mod p */
|
||||
int BN_GF2m_mod_sqrt_arr(BIGNUM *r, const BIGNUM *a,
|
||||
const int p[], BN_CTX *ctx);
|
||||
/* r^2 + r = a mod p */
|
||||
int BN_GF2m_mod_solve_quad_arr(BIGNUM *r, const BIGNUM *a,
|
||||
const int p[], BN_CTX *ctx);
|
||||
int BN_GF2m_poly2arr(const BIGNUM *a, int p[], int max);
|
||||
int BN_GF2m_arr2poly(const int p[], BIGNUM *a);
|
||||
|
||||
# endif
|
||||
|
||||
/*
|
||||
* faster mod functions for the 'NIST primes' 0 <= a < p^2
|
||||
*/
|
||||
int BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
|
||||
int BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
|
||||
int BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
|
||||
int BN_nist_mod_384(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
|
||||
int BN_nist_mod_521(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
|
||||
|
||||
const BIGNUM *BN_get0_nist_prime_192(void);
|
||||
const BIGNUM *BN_get0_nist_prime_224(void);
|
||||
const BIGNUM *BN_get0_nist_prime_256(void);
|
||||
const BIGNUM *BN_get0_nist_prime_384(void);
|
||||
const BIGNUM *BN_get0_nist_prime_521(void);
|
||||
|
||||
int (*BN_nist_mod_func(const BIGNUM *p)) (BIGNUM *r, const BIGNUM *a,
|
||||
const BIGNUM *field, BN_CTX *ctx);
|
||||
|
||||
int BN_generate_dsa_nonce(BIGNUM *out, const BIGNUM *range,
|
||||
const BIGNUM *priv, const unsigned char *message,
|
||||
size_t message_len, BN_CTX *ctx);
|
||||
|
||||
/* Primes from RFC 2409 */
|
||||
BIGNUM *BN_get_rfc2409_prime_768(BIGNUM *bn);
|
||||
BIGNUM *BN_get_rfc2409_prime_1024(BIGNUM *bn);
|
||||
|
||||
/* Primes from RFC 3526 */
|
||||
BIGNUM *BN_get_rfc3526_prime_1536(BIGNUM *bn);
|
||||
BIGNUM *BN_get_rfc3526_prime_2048(BIGNUM *bn);
|
||||
BIGNUM *BN_get_rfc3526_prime_3072(BIGNUM *bn);
|
||||
BIGNUM *BN_get_rfc3526_prime_4096(BIGNUM *bn);
|
||||
BIGNUM *BN_get_rfc3526_prime_6144(BIGNUM *bn);
|
||||
BIGNUM *BN_get_rfc3526_prime_8192(BIGNUM *bn);
|
||||
|
||||
# if OPENSSL_API_COMPAT < 0x10100000L
|
||||
# define get_rfc2409_prime_768 BN_get_rfc2409_prime_768
|
||||
# define get_rfc2409_prime_1024 BN_get_rfc2409_prime_1024
|
||||
# define get_rfc3526_prime_1536 BN_get_rfc3526_prime_1536
|
||||
# define get_rfc3526_prime_2048 BN_get_rfc3526_prime_2048
|
||||
# define get_rfc3526_prime_3072 BN_get_rfc3526_prime_3072
|
||||
# define get_rfc3526_prime_4096 BN_get_rfc3526_prime_4096
|
||||
# define get_rfc3526_prime_6144 BN_get_rfc3526_prime_6144
|
||||
# define get_rfc3526_prime_8192 BN_get_rfc3526_prime_8192
|
||||
# endif
|
||||
|
||||
int BN_bntest_rand(BIGNUM *rnd, int bits, int top, int bottom);
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
/*
|
||||
* The following lines are auto generated by the script mkerr.pl. Any changes
|
||||
* made after this point may be overwritten when the script is next run.
|
||||
*/
|
||||
|
||||
int ERR_load_BN_strings(void);
|
||||
|
||||
/* Error codes for the BN functions. */
|
||||
|
||||
/* Function codes. */
|
||||
# define BN_F_BNRAND 127
|
||||
# define BN_F_BN_BLINDING_CONVERT_EX 100
|
||||
# define BN_F_BN_BLINDING_CREATE_PARAM 128
|
||||
# define BN_F_BN_BLINDING_INVERT_EX 101
|
||||
# define BN_F_BN_BLINDING_NEW 102
|
||||
# define BN_F_BN_BLINDING_UPDATE 103
|
||||
# define BN_F_BN_BN2DEC 104
|
||||
# define BN_F_BN_BN2HEX 105
|
||||
# define BN_F_BN_COMPUTE_WNAF 142
|
||||
# define BN_F_BN_CTX_GET 116
|
||||
# define BN_F_BN_CTX_NEW 106
|
||||
# define BN_F_BN_CTX_START 129
|
||||
# define BN_F_BN_DIV 107
|
||||
# define BN_F_BN_DIV_RECP 130
|
||||
# define BN_F_BN_EXP 123
|
||||
# define BN_F_BN_EXPAND_INTERNAL 120
|
||||
# define BN_F_BN_GENCB_NEW 143
|
||||
# define BN_F_BN_GENERATE_DSA_NONCE 140
|
||||
# define BN_F_BN_GENERATE_PRIME_EX 141
|
||||
# define BN_F_BN_GF2M_MOD 131
|
||||
# define BN_F_BN_GF2M_MOD_EXP 132
|
||||
# define BN_F_BN_GF2M_MOD_MUL 133
|
||||
# define BN_F_BN_GF2M_MOD_SOLVE_QUAD 134
|
||||
# define BN_F_BN_GF2M_MOD_SOLVE_QUAD_ARR 135
|
||||
# define BN_F_BN_GF2M_MOD_SQR 136
|
||||
# define BN_F_BN_GF2M_MOD_SQRT 137
|
||||
# define BN_F_BN_LSHIFT 145
|
||||
# define BN_F_BN_MOD_EXP2_MONT 118
|
||||
# define BN_F_BN_MOD_EXP_MONT 109
|
||||
# define BN_F_BN_MOD_EXP_MONT_CONSTTIME 124
|
||||
# define BN_F_BN_MOD_EXP_MONT_WORD 117
|
||||
# define BN_F_BN_MOD_EXP_RECP 125
|
||||
# define BN_F_BN_MOD_EXP_SIMPLE 126
|
||||
# define BN_F_BN_MOD_INVERSE 110
|
||||
# define BN_F_BN_MOD_INVERSE_NO_BRANCH 139
|
||||
# define BN_F_BN_MOD_LSHIFT_QUICK 119
|
||||
# define BN_F_BN_MOD_SQRT 121
|
||||
# define BN_F_BN_MPI2BN 112
|
||||
# define BN_F_BN_NEW 113
|
||||
# define BN_F_BN_RAND 114
|
||||
# define BN_F_BN_RAND_RANGE 122
|
||||
# define BN_F_BN_RSHIFT 146
|
||||
# define BN_F_BN_SET_WORDS 144
|
||||
# define BN_F_BN_USUB 115
|
||||
|
||||
/* Reason codes. */
|
||||
# define BN_R_ARG2_LT_ARG3 100
|
||||
# define BN_R_BAD_RECIPROCAL 101
|
||||
# define BN_R_BIGNUM_TOO_LONG 114
|
||||
# define BN_R_BITS_TOO_SMALL 118
|
||||
# define BN_R_CALLED_WITH_EVEN_MODULUS 102
|
||||
# define BN_R_DIV_BY_ZERO 103
|
||||
# define BN_R_ENCODING_ERROR 104
|
||||
# define BN_R_EXPAND_ON_STATIC_BIGNUM_DATA 105
|
||||
# define BN_R_INPUT_NOT_REDUCED 110
|
||||
# define BN_R_INVALID_LENGTH 106
|
||||
# define BN_R_INVALID_RANGE 115
|
||||
# define BN_R_INVALID_SHIFT 119
|
||||
# define BN_R_NOT_A_SQUARE 111
|
||||
# define BN_R_NOT_INITIALIZED 107
|
||||
# define BN_R_NO_INVERSE 108
|
||||
# define BN_R_NO_SOLUTION 116
|
||||
# define BN_R_PRIVATE_KEY_TOO_LARGE 117
|
||||
# define BN_R_P_IS_NOT_PRIME 112
|
||||
# define BN_R_TOO_MANY_ITERATIONS 113
|
||||
# define BN_R_TOO_MANY_TEMPORARY_VARIABLES 109
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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_BUFFER_H
|
||||
# define HEADER_BUFFER_H
|
||||
|
||||
# include <openssl/ossl_typ.h>
|
||||
# ifndef HEADER_CRYPTO_H
|
||||
# include <openssl/crypto.h>
|
||||
# endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
# include <stddef.h>
|
||||
|
||||
# if !defined(NO_SYS_TYPES_H)
|
||||
# include <sys/types.h>
|
||||
# endif
|
||||
|
||||
/*
|
||||
* These names are outdated as of OpenSSL 1.1; a future release
|
||||
* will move them to be deprecated.
|
||||
*/
|
||||
# define BUF_strdup(s) OPENSSL_strdup(s)
|
||||
# define BUF_strndup(s, size) OPENSSL_strndup(s, size)
|
||||
# define BUF_memdup(data, size) OPENSSL_memdup(data, size)
|
||||
# define BUF_strlcpy(dst, src, size) OPENSSL_strlcpy(dst, src, size)
|
||||
# define BUF_strlcat(dst, src, size) OPENSSL_strlcat(dst, src, size)
|
||||
# define BUF_strnlen(str, maxlen) OPENSSL_strnlen(str, maxlen)
|
||||
|
||||
struct buf_mem_st {
|
||||
size_t length; /* current number of bytes */
|
||||
char *data;
|
||||
size_t max; /* size of buffer */
|
||||
unsigned long flags;
|
||||
};
|
||||
|
||||
# define BUF_MEM_FLAG_SECURE 0x01
|
||||
|
||||
BUF_MEM *BUF_MEM_new(void);
|
||||
BUF_MEM *BUF_MEM_new_ex(unsigned long flags);
|
||||
void BUF_MEM_free(BUF_MEM *a);
|
||||
size_t BUF_MEM_grow(BUF_MEM *str, size_t len);
|
||||
size_t BUF_MEM_grow_clean(BUF_MEM *str, size_t len);
|
||||
void BUF_reverse(unsigned char *out, const unsigned char *in, size_t siz);
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
/*
|
||||
* The following lines are auto generated by the script mkerr.pl. Any changes
|
||||
* made after this point may be overwritten when the script is next run.
|
||||
*/
|
||||
|
||||
int ERR_load_BUF_strings(void);
|
||||
|
||||
/* Error codes for the BUF functions. */
|
||||
|
||||
/* Function codes. */
|
||||
# define BUF_F_BUF_MEM_GROW 100
|
||||
# define BUF_F_BUF_MEM_GROW_CLEAN 105
|
||||
# define BUF_F_BUF_MEM_NEW 101
|
||||
|
||||
/* Reason codes. */
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
* Copyright 2006-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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_CAMELLIA_H
|
||||
# define HEADER_CAMELLIA_H
|
||||
|
||||
# include <openssl/opensslconf.h>
|
||||
|
||||
# ifndef OPENSSL_NO_CAMELLIA
|
||||
# include <stddef.h>
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
# define CAMELLIA_ENCRYPT 1
|
||||
# define CAMELLIA_DECRYPT 0
|
||||
|
||||
/*
|
||||
* Because array size can't be a const in C, the following two are macros.
|
||||
* Both sizes are in bytes.
|
||||
*/
|
||||
|
||||
/* This should be a hidden type, but EVP requires that the size be known */
|
||||
|
||||
# define CAMELLIA_BLOCK_SIZE 16
|
||||
# define CAMELLIA_TABLE_BYTE_LEN 272
|
||||
# define CAMELLIA_TABLE_WORD_LEN (CAMELLIA_TABLE_BYTE_LEN / 4)
|
||||
|
||||
typedef unsigned int KEY_TABLE_TYPE[CAMELLIA_TABLE_WORD_LEN]; /* to match
|
||||
* with WORD */
|
||||
|
||||
struct camellia_key_st {
|
||||
union {
|
||||
double d; /* ensures 64-bit align */
|
||||
KEY_TABLE_TYPE rd_key;
|
||||
} u;
|
||||
int grand_rounds;
|
||||
};
|
||||
typedef struct camellia_key_st CAMELLIA_KEY;
|
||||
|
||||
int Camellia_set_key(const unsigned char *userKey, const int bits,
|
||||
CAMELLIA_KEY *key);
|
||||
|
||||
void Camellia_encrypt(const unsigned char *in, unsigned char *out,
|
||||
const CAMELLIA_KEY *key);
|
||||
void Camellia_decrypt(const unsigned char *in, unsigned char *out,
|
||||
const CAMELLIA_KEY *key);
|
||||
|
||||
void Camellia_ecb_encrypt(const unsigned char *in, unsigned char *out,
|
||||
const CAMELLIA_KEY *key, const int enc);
|
||||
void Camellia_cbc_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t length, const CAMELLIA_KEY *key,
|
||||
unsigned char *ivec, const int enc);
|
||||
void Camellia_cfb128_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t length, const CAMELLIA_KEY *key,
|
||||
unsigned char *ivec, int *num, const int enc);
|
||||
void Camellia_cfb1_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t length, const CAMELLIA_KEY *key,
|
||||
unsigned char *ivec, int *num, const int enc);
|
||||
void Camellia_cfb8_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t length, const CAMELLIA_KEY *key,
|
||||
unsigned char *ivec, int *num, const int enc);
|
||||
void Camellia_ofb128_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t length, const CAMELLIA_KEY *key,
|
||||
unsigned char *ivec, int *num);
|
||||
void Camellia_ctr128_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t length, const CAMELLIA_KEY *key,
|
||||
unsigned char ivec[CAMELLIA_BLOCK_SIZE],
|
||||
unsigned char ecount_buf[CAMELLIA_BLOCK_SIZE],
|
||||
unsigned int *num);
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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_CAST_H
|
||||
# define HEADER_CAST_H
|
||||
|
||||
# include <openssl/opensslconf.h>
|
||||
|
||||
# ifndef OPENSSL_NO_CAST
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
# endif
|
||||
|
||||
# define CAST_ENCRYPT 1
|
||||
# define CAST_DECRYPT 0
|
||||
|
||||
# define CAST_LONG unsigned int
|
||||
|
||||
# define CAST_BLOCK 8
|
||||
# define CAST_KEY_LENGTH 16
|
||||
|
||||
typedef struct cast_key_st {
|
||||
CAST_LONG data[32];
|
||||
int short_key; /* Use reduced rounds for short key */
|
||||
} CAST_KEY;
|
||||
|
||||
void CAST_set_key(CAST_KEY *key, int len, const unsigned char *data);
|
||||
void CAST_ecb_encrypt(const unsigned char *in, unsigned char *out,
|
||||
const CAST_KEY *key, int enc);
|
||||
void CAST_encrypt(CAST_LONG *data, const CAST_KEY *key);
|
||||
void CAST_decrypt(CAST_LONG *data, const CAST_KEY *key);
|
||||
void CAST_cbc_encrypt(const unsigned char *in, unsigned char *out,
|
||||
long length, const CAST_KEY *ks, unsigned char *iv,
|
||||
int enc);
|
||||
void CAST_cfb64_encrypt(const unsigned char *in, unsigned char *out,
|
||||
long length, const CAST_KEY *schedule,
|
||||
unsigned char *ivec, int *num, int enc);
|
||||
void CAST_ofb64_encrypt(const unsigned char *in, unsigned char *out,
|
||||
long length, const CAST_KEY *schedule,
|
||||
unsigned char *ivec, int *num);
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Copyright 2010-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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_CMAC_H
|
||||
# define HEADER_CMAC_H
|
||||
|
||||
# ifndef OPENSSL_NO_CMAC
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
# include <openssl/evp.h>
|
||||
|
||||
/* Opaque */
|
||||
typedef struct CMAC_CTX_st CMAC_CTX;
|
||||
|
||||
CMAC_CTX *CMAC_CTX_new(void);
|
||||
void CMAC_CTX_cleanup(CMAC_CTX *ctx);
|
||||
void CMAC_CTX_free(CMAC_CTX *ctx);
|
||||
EVP_CIPHER_CTX *CMAC_CTX_get0_cipher_ctx(CMAC_CTX *ctx);
|
||||
int CMAC_CTX_copy(CMAC_CTX *out, const CMAC_CTX *in);
|
||||
|
||||
int CMAC_Init(CMAC_CTX *ctx, const void *key, size_t keylen,
|
||||
const EVP_CIPHER *cipher, ENGINE *impl);
|
||||
int CMAC_Update(CMAC_CTX *ctx, const void *data, size_t dlen);
|
||||
int CMAC_Final(CMAC_CTX *ctx, unsigned char *out, size_t *poutlen);
|
||||
int CMAC_resume(CMAC_CTX *ctx);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
# endif
|
||||
#endif
|
||||
|
|
@ -0,0 +1,512 @@
|
|||
/*
|
||||
* Copyright 2008-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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_H
|
||||
# define HEADER_CMS_H
|
||||
|
||||
# include <openssl/opensslconf.h>
|
||||
|
||||
# ifndef OPENSSL_NO_CMS
|
||||
# include <openssl/x509.h>
|
||||
# include <openssl/x509v3.h>
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
# endif
|
||||
|
||||
typedef struct CMS_ContentInfo_st CMS_ContentInfo;
|
||||
typedef struct CMS_SignerInfo_st CMS_SignerInfo;
|
||||
typedef struct CMS_CertificateChoices CMS_CertificateChoices;
|
||||
typedef struct CMS_RevocationInfoChoice_st CMS_RevocationInfoChoice;
|
||||
typedef struct CMS_RecipientInfo_st CMS_RecipientInfo;
|
||||
typedef struct CMS_ReceiptRequest_st CMS_ReceiptRequest;
|
||||
typedef struct CMS_Receipt_st CMS_Receipt;
|
||||
typedef struct CMS_RecipientEncryptedKey_st CMS_RecipientEncryptedKey;
|
||||
typedef struct CMS_OtherKeyAttribute_st CMS_OtherKeyAttribute;
|
||||
|
||||
DEFINE_STACK_OF(CMS_SignerInfo)
|
||||
DEFINE_STACK_OF(CMS_RecipientEncryptedKey)
|
||||
DEFINE_STACK_OF(CMS_RecipientInfo)
|
||||
DEFINE_STACK_OF(CMS_RevocationInfoChoice)
|
||||
DECLARE_ASN1_FUNCTIONS(CMS_ContentInfo)
|
||||
DECLARE_ASN1_FUNCTIONS(CMS_ReceiptRequest)
|
||||
DECLARE_ASN1_PRINT_FUNCTION(CMS_ContentInfo)
|
||||
|
||||
# define CMS_SIGNERINFO_ISSUER_SERIAL 0
|
||||
# define CMS_SIGNERINFO_KEYIDENTIFIER 1
|
||||
|
||||
# define CMS_RECIPINFO_NONE -1
|
||||
# define CMS_RECIPINFO_TRANS 0
|
||||
# define CMS_RECIPINFO_AGREE 1
|
||||
# define CMS_RECIPINFO_KEK 2
|
||||
# define CMS_RECIPINFO_PASS 3
|
||||
# define CMS_RECIPINFO_OTHER 4
|
||||
|
||||
/* S/MIME related flags */
|
||||
|
||||
# define CMS_TEXT 0x1
|
||||
# define CMS_NOCERTS 0x2
|
||||
# define CMS_NO_CONTENT_VERIFY 0x4
|
||||
# define CMS_NO_ATTR_VERIFY 0x8
|
||||
# define CMS_NOSIGS \
|
||||
(CMS_NO_CONTENT_VERIFY|CMS_NO_ATTR_VERIFY)
|
||||
# define CMS_NOINTERN 0x10
|
||||
# define CMS_NO_SIGNER_CERT_VERIFY 0x20
|
||||
# define CMS_NOVERIFY 0x20
|
||||
# define CMS_DETACHED 0x40
|
||||
# define CMS_BINARY 0x80
|
||||
# define CMS_NOATTR 0x100
|
||||
# define CMS_NOSMIMECAP 0x200
|
||||
# define CMS_NOOLDMIMETYPE 0x400
|
||||
# define CMS_CRLFEOL 0x800
|
||||
# define CMS_STREAM 0x1000
|
||||
# define CMS_NOCRL 0x2000
|
||||
# define CMS_PARTIAL 0x4000
|
||||
# define CMS_REUSE_DIGEST 0x8000
|
||||
# define CMS_USE_KEYID 0x10000
|
||||
# define CMS_DEBUG_DECRYPT 0x20000
|
||||
# define CMS_KEY_PARAM 0x40000
|
||||
# define CMS_ASCIICRLF 0x80000
|
||||
|
||||
const ASN1_OBJECT *CMS_get0_type(const CMS_ContentInfo *cms);
|
||||
|
||||
BIO *CMS_dataInit(CMS_ContentInfo *cms, BIO *icont);
|
||||
int CMS_dataFinal(CMS_ContentInfo *cms, BIO *bio);
|
||||
|
||||
ASN1_OCTET_STRING **CMS_get0_content(CMS_ContentInfo *cms);
|
||||
int CMS_is_detached(CMS_ContentInfo *cms);
|
||||
int CMS_set_detached(CMS_ContentInfo *cms, int detached);
|
||||
|
||||
# ifdef HEADER_PEM_H
|
||||
DECLARE_PEM_rw_const(CMS, CMS_ContentInfo)
|
||||
# endif
|
||||
int CMS_stream(unsigned char ***boundary, CMS_ContentInfo *cms);
|
||||
CMS_ContentInfo *d2i_CMS_bio(BIO *bp, CMS_ContentInfo **cms);
|
||||
int i2d_CMS_bio(BIO *bp, CMS_ContentInfo *cms);
|
||||
|
||||
BIO *BIO_new_CMS(BIO *out, CMS_ContentInfo *cms);
|
||||
int i2d_CMS_bio_stream(BIO *out, CMS_ContentInfo *cms, BIO *in, int flags);
|
||||
int PEM_write_bio_CMS_stream(BIO *out, CMS_ContentInfo *cms, BIO *in,
|
||||
int flags);
|
||||
CMS_ContentInfo *SMIME_read_CMS(BIO *bio, BIO **bcont);
|
||||
int SMIME_write_CMS(BIO *bio, CMS_ContentInfo *cms, BIO *data, int flags);
|
||||
|
||||
int CMS_final(CMS_ContentInfo *cms, BIO *data, BIO *dcont,
|
||||
unsigned int flags);
|
||||
|
||||
CMS_ContentInfo *CMS_sign(X509 *signcert, EVP_PKEY *pkey,
|
||||
STACK_OF(X509) *certs, BIO *data,
|
||||
unsigned int flags);
|
||||
|
||||
CMS_ContentInfo *CMS_sign_receipt(CMS_SignerInfo *si,
|
||||
X509 *signcert, EVP_PKEY *pkey,
|
||||
STACK_OF(X509) *certs, unsigned int flags);
|
||||
|
||||
int CMS_data(CMS_ContentInfo *cms, BIO *out, unsigned int flags);
|
||||
CMS_ContentInfo *CMS_data_create(BIO *in, unsigned int flags);
|
||||
|
||||
int CMS_digest_verify(CMS_ContentInfo *cms, BIO *dcont, BIO *out,
|
||||
unsigned int flags);
|
||||
CMS_ContentInfo *CMS_digest_create(BIO *in, const EVP_MD *md,
|
||||
unsigned int flags);
|
||||
|
||||
int CMS_EncryptedData_decrypt(CMS_ContentInfo *cms,
|
||||
const unsigned char *key, size_t keylen,
|
||||
BIO *dcont, BIO *out, unsigned int flags);
|
||||
|
||||
CMS_ContentInfo *CMS_EncryptedData_encrypt(BIO *in, const EVP_CIPHER *cipher,
|
||||
const unsigned char *key,
|
||||
size_t keylen, unsigned int flags);
|
||||
|
||||
int CMS_EncryptedData_set1_key(CMS_ContentInfo *cms, const EVP_CIPHER *ciph,
|
||||
const unsigned char *key, size_t keylen);
|
||||
|
||||
int CMS_verify(CMS_ContentInfo *cms, STACK_OF(X509) *certs,
|
||||
X509_STORE *store, BIO *dcont, BIO *out, unsigned int flags);
|
||||
|
||||
int CMS_verify_receipt(CMS_ContentInfo *rcms, CMS_ContentInfo *ocms,
|
||||
STACK_OF(X509) *certs,
|
||||
X509_STORE *store, unsigned int flags);
|
||||
|
||||
STACK_OF(X509) *CMS_get0_signers(CMS_ContentInfo *cms);
|
||||
|
||||
CMS_ContentInfo *CMS_encrypt(STACK_OF(X509) *certs, BIO *in,
|
||||
const EVP_CIPHER *cipher, unsigned int flags);
|
||||
|
||||
int CMS_decrypt(CMS_ContentInfo *cms, EVP_PKEY *pkey, X509 *cert,
|
||||
BIO *dcont, BIO *out, unsigned int flags);
|
||||
|
||||
int CMS_decrypt_set1_pkey(CMS_ContentInfo *cms, EVP_PKEY *pk, X509 *cert);
|
||||
int CMS_decrypt_set1_key(CMS_ContentInfo *cms,
|
||||
unsigned char *key, size_t keylen,
|
||||
const unsigned char *id, size_t idlen);
|
||||
int CMS_decrypt_set1_password(CMS_ContentInfo *cms,
|
||||
unsigned char *pass, ossl_ssize_t passlen);
|
||||
|
||||
STACK_OF(CMS_RecipientInfo) *CMS_get0_RecipientInfos(CMS_ContentInfo *cms);
|
||||
int CMS_RecipientInfo_type(CMS_RecipientInfo *ri);
|
||||
EVP_PKEY_CTX *CMS_RecipientInfo_get0_pkey_ctx(CMS_RecipientInfo *ri);
|
||||
CMS_ContentInfo *CMS_EnvelopedData_create(const EVP_CIPHER *cipher);
|
||||
CMS_RecipientInfo *CMS_add1_recipient_cert(CMS_ContentInfo *cms,
|
||||
X509 *recip, unsigned int flags);
|
||||
int CMS_RecipientInfo_set0_pkey(CMS_RecipientInfo *ri, EVP_PKEY *pkey);
|
||||
int CMS_RecipientInfo_ktri_cert_cmp(CMS_RecipientInfo *ri, X509 *cert);
|
||||
int CMS_RecipientInfo_ktri_get0_algs(CMS_RecipientInfo *ri,
|
||||
EVP_PKEY **pk, X509 **recip,
|
||||
X509_ALGOR **palg);
|
||||
int CMS_RecipientInfo_ktri_get0_signer_id(CMS_RecipientInfo *ri,
|
||||
ASN1_OCTET_STRING **keyid,
|
||||
X509_NAME **issuer,
|
||||
ASN1_INTEGER **sno);
|
||||
|
||||
CMS_RecipientInfo *CMS_add0_recipient_key(CMS_ContentInfo *cms, int nid,
|
||||
unsigned char *key, size_t keylen,
|
||||
unsigned char *id, size_t idlen,
|
||||
ASN1_GENERALIZEDTIME *date,
|
||||
ASN1_OBJECT *otherTypeId,
|
||||
ASN1_TYPE *otherType);
|
||||
|
||||
int CMS_RecipientInfo_kekri_get0_id(CMS_RecipientInfo *ri,
|
||||
X509_ALGOR **palg,
|
||||
ASN1_OCTET_STRING **pid,
|
||||
ASN1_GENERALIZEDTIME **pdate,
|
||||
ASN1_OBJECT **potherid,
|
||||
ASN1_TYPE **pothertype);
|
||||
|
||||
int CMS_RecipientInfo_set0_key(CMS_RecipientInfo *ri,
|
||||
unsigned char *key, size_t keylen);
|
||||
|
||||
int CMS_RecipientInfo_kekri_id_cmp(CMS_RecipientInfo *ri,
|
||||
const unsigned char *id, size_t idlen);
|
||||
|
||||
int CMS_RecipientInfo_set0_password(CMS_RecipientInfo *ri,
|
||||
unsigned char *pass,
|
||||
ossl_ssize_t passlen);
|
||||
|
||||
CMS_RecipientInfo *CMS_add0_recipient_password(CMS_ContentInfo *cms,
|
||||
int iter, int wrap_nid,
|
||||
int pbe_nid,
|
||||
unsigned char *pass,
|
||||
ossl_ssize_t passlen,
|
||||
const EVP_CIPHER *kekciph);
|
||||
|
||||
int CMS_RecipientInfo_decrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri);
|
||||
int CMS_RecipientInfo_encrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri);
|
||||
|
||||
int CMS_uncompress(CMS_ContentInfo *cms, BIO *dcont, BIO *out,
|
||||
unsigned int flags);
|
||||
CMS_ContentInfo *CMS_compress(BIO *in, int comp_nid, unsigned int flags);
|
||||
|
||||
int CMS_set1_eContentType(CMS_ContentInfo *cms, const ASN1_OBJECT *oid);
|
||||
const ASN1_OBJECT *CMS_get0_eContentType(CMS_ContentInfo *cms);
|
||||
|
||||
CMS_CertificateChoices *CMS_add0_CertificateChoices(CMS_ContentInfo *cms);
|
||||
int CMS_add0_cert(CMS_ContentInfo *cms, X509 *cert);
|
||||
int CMS_add1_cert(CMS_ContentInfo *cms, X509 *cert);
|
||||
STACK_OF(X509) *CMS_get1_certs(CMS_ContentInfo *cms);
|
||||
|
||||
CMS_RevocationInfoChoice *CMS_add0_RevocationInfoChoice(CMS_ContentInfo *cms);
|
||||
int CMS_add0_crl(CMS_ContentInfo *cms, X509_CRL *crl);
|
||||
int CMS_add1_crl(CMS_ContentInfo *cms, X509_CRL *crl);
|
||||
STACK_OF(X509_CRL) *CMS_get1_crls(CMS_ContentInfo *cms);
|
||||
|
||||
int CMS_SignedData_init(CMS_ContentInfo *cms);
|
||||
CMS_SignerInfo *CMS_add1_signer(CMS_ContentInfo *cms,
|
||||
X509 *signer, EVP_PKEY *pk, const EVP_MD *md,
|
||||
unsigned int flags);
|
||||
EVP_PKEY_CTX *CMS_SignerInfo_get0_pkey_ctx(CMS_SignerInfo *si);
|
||||
EVP_MD_CTX *CMS_SignerInfo_get0_md_ctx(CMS_SignerInfo *si);
|
||||
STACK_OF(CMS_SignerInfo) *CMS_get0_SignerInfos(CMS_ContentInfo *cms);
|
||||
|
||||
void CMS_SignerInfo_set1_signer_cert(CMS_SignerInfo *si, X509 *signer);
|
||||
int CMS_SignerInfo_get0_signer_id(CMS_SignerInfo *si,
|
||||
ASN1_OCTET_STRING **keyid,
|
||||
X509_NAME **issuer, ASN1_INTEGER **sno);
|
||||
int CMS_SignerInfo_cert_cmp(CMS_SignerInfo *si, X509 *cert);
|
||||
int CMS_set1_signers_certs(CMS_ContentInfo *cms, STACK_OF(X509) *certs,
|
||||
unsigned int flags);
|
||||
void CMS_SignerInfo_get0_algs(CMS_SignerInfo *si, EVP_PKEY **pk,
|
||||
X509 **signer, X509_ALGOR **pdig,
|
||||
X509_ALGOR **psig);
|
||||
ASN1_OCTET_STRING *CMS_SignerInfo_get0_signature(CMS_SignerInfo *si);
|
||||
int CMS_SignerInfo_sign(CMS_SignerInfo *si);
|
||||
int CMS_SignerInfo_verify(CMS_SignerInfo *si);
|
||||
int CMS_SignerInfo_verify_content(CMS_SignerInfo *si, BIO *chain);
|
||||
|
||||
int CMS_add_smimecap(CMS_SignerInfo *si, STACK_OF(X509_ALGOR) *algs);
|
||||
int CMS_add_simple_smimecap(STACK_OF(X509_ALGOR) **algs,
|
||||
int algnid, int keysize);
|
||||
int CMS_add_standard_smimecap(STACK_OF(X509_ALGOR) **smcap);
|
||||
|
||||
int CMS_signed_get_attr_count(const CMS_SignerInfo *si);
|
||||
int CMS_signed_get_attr_by_NID(const CMS_SignerInfo *si, int nid,
|
||||
int lastpos);
|
||||
int CMS_signed_get_attr_by_OBJ(const CMS_SignerInfo *si, const ASN1_OBJECT *obj,
|
||||
int lastpos);
|
||||
X509_ATTRIBUTE *CMS_signed_get_attr(const CMS_SignerInfo *si, int loc);
|
||||
X509_ATTRIBUTE *CMS_signed_delete_attr(CMS_SignerInfo *si, int loc);
|
||||
int CMS_signed_add1_attr(CMS_SignerInfo *si, X509_ATTRIBUTE *attr);
|
||||
int CMS_signed_add1_attr_by_OBJ(CMS_SignerInfo *si,
|
||||
const ASN1_OBJECT *obj, int type,
|
||||
const void *bytes, int len);
|
||||
int CMS_signed_add1_attr_by_NID(CMS_SignerInfo *si,
|
||||
int nid, int type,
|
||||
const void *bytes, int len);
|
||||
int CMS_signed_add1_attr_by_txt(CMS_SignerInfo *si,
|
||||
const char *attrname, int type,
|
||||
const void *bytes, int len);
|
||||
void *CMS_signed_get0_data_by_OBJ(CMS_SignerInfo *si, const ASN1_OBJECT *oid,
|
||||
int lastpos, int type);
|
||||
|
||||
int CMS_unsigned_get_attr_count(const CMS_SignerInfo *si);
|
||||
int CMS_unsigned_get_attr_by_NID(const CMS_SignerInfo *si, int nid,
|
||||
int lastpos);
|
||||
int CMS_unsigned_get_attr_by_OBJ(const CMS_SignerInfo *si,
|
||||
const ASN1_OBJECT *obj, int lastpos);
|
||||
X509_ATTRIBUTE *CMS_unsigned_get_attr(const CMS_SignerInfo *si, int loc);
|
||||
X509_ATTRIBUTE *CMS_unsigned_delete_attr(CMS_SignerInfo *si, int loc);
|
||||
int CMS_unsigned_add1_attr(CMS_SignerInfo *si, X509_ATTRIBUTE *attr);
|
||||
int CMS_unsigned_add1_attr_by_OBJ(CMS_SignerInfo *si,
|
||||
const ASN1_OBJECT *obj, int type,
|
||||
const void *bytes, int len);
|
||||
int CMS_unsigned_add1_attr_by_NID(CMS_SignerInfo *si,
|
||||
int nid, int type,
|
||||
const void *bytes, int len);
|
||||
int CMS_unsigned_add1_attr_by_txt(CMS_SignerInfo *si,
|
||||
const char *attrname, int type,
|
||||
const void *bytes, int len);
|
||||
void *CMS_unsigned_get0_data_by_OBJ(CMS_SignerInfo *si, ASN1_OBJECT *oid,
|
||||
int lastpos, int type);
|
||||
|
||||
# ifdef HEADER_X509V3_H
|
||||
|
||||
int CMS_get1_ReceiptRequest(CMS_SignerInfo *si, CMS_ReceiptRequest **prr);
|
||||
CMS_ReceiptRequest *CMS_ReceiptRequest_create0(unsigned char *id, int idlen,
|
||||
int allorfirst,
|
||||
STACK_OF(GENERAL_NAMES)
|
||||
*receiptList, STACK_OF(GENERAL_NAMES)
|
||||
*receiptsTo);
|
||||
int CMS_add1_ReceiptRequest(CMS_SignerInfo *si, CMS_ReceiptRequest *rr);
|
||||
void CMS_ReceiptRequest_get0_values(CMS_ReceiptRequest *rr,
|
||||
ASN1_STRING **pcid,
|
||||
int *pallorfirst,
|
||||
STACK_OF(GENERAL_NAMES) **plist,
|
||||
STACK_OF(GENERAL_NAMES) **prto);
|
||||
# endif
|
||||
int CMS_RecipientInfo_kari_get0_alg(CMS_RecipientInfo *ri,
|
||||
X509_ALGOR **palg,
|
||||
ASN1_OCTET_STRING **pukm);
|
||||
STACK_OF(CMS_RecipientEncryptedKey)
|
||||
*CMS_RecipientInfo_kari_get0_reks(CMS_RecipientInfo *ri);
|
||||
|
||||
int CMS_RecipientInfo_kari_get0_orig_id(CMS_RecipientInfo *ri,
|
||||
X509_ALGOR **pubalg,
|
||||
ASN1_BIT_STRING **pubkey,
|
||||
ASN1_OCTET_STRING **keyid,
|
||||
X509_NAME **issuer,
|
||||
ASN1_INTEGER **sno);
|
||||
|
||||
int CMS_RecipientInfo_kari_orig_id_cmp(CMS_RecipientInfo *ri, X509 *cert);
|
||||
|
||||
int CMS_RecipientEncryptedKey_get0_id(CMS_RecipientEncryptedKey *rek,
|
||||
ASN1_OCTET_STRING **keyid,
|
||||
ASN1_GENERALIZEDTIME **tm,
|
||||
CMS_OtherKeyAttribute **other,
|
||||
X509_NAME **issuer, ASN1_INTEGER **sno);
|
||||
int CMS_RecipientEncryptedKey_cert_cmp(CMS_RecipientEncryptedKey *rek,
|
||||
X509 *cert);
|
||||
int CMS_RecipientInfo_kari_set0_pkey(CMS_RecipientInfo *ri, EVP_PKEY *pk);
|
||||
EVP_CIPHER_CTX *CMS_RecipientInfo_kari_get0_ctx(CMS_RecipientInfo *ri);
|
||||
int CMS_RecipientInfo_kari_decrypt(CMS_ContentInfo *cms,
|
||||
CMS_RecipientInfo *ri,
|
||||
CMS_RecipientEncryptedKey *rek);
|
||||
|
||||
int CMS_SharedInfo_encode(unsigned char **pder, X509_ALGOR *kekalg,
|
||||
ASN1_OCTET_STRING *ukm, int keylen);
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
/*
|
||||
* The following lines are auto generated by the script mkerr.pl. Any changes
|
||||
* made after this point may be overwritten when the script is next run.
|
||||
*/
|
||||
|
||||
int ERR_load_CMS_strings(void);
|
||||
|
||||
/* Error codes for the CMS functions. */
|
||||
|
||||
/* Function codes. */
|
||||
# define CMS_F_CHECK_CONTENT 99
|
||||
# define CMS_F_CMS_ADD0_CERT 164
|
||||
# define CMS_F_CMS_ADD0_RECIPIENT_KEY 100
|
||||
# define CMS_F_CMS_ADD0_RECIPIENT_PASSWORD 165
|
||||
# define CMS_F_CMS_ADD1_RECEIPTREQUEST 158
|
||||
# define CMS_F_CMS_ADD1_RECIPIENT_CERT 101
|
||||
# define CMS_F_CMS_ADD1_SIGNER 102
|
||||
# define CMS_F_CMS_ADD1_SIGNINGTIME 103
|
||||
# define CMS_F_CMS_COMPRESS 104
|
||||
# define CMS_F_CMS_COMPRESSEDDATA_CREATE 105
|
||||
# define CMS_F_CMS_COMPRESSEDDATA_INIT_BIO 106
|
||||
# define CMS_F_CMS_COPY_CONTENT 107
|
||||
# define CMS_F_CMS_COPY_MESSAGEDIGEST 108
|
||||
# define CMS_F_CMS_DATA 109
|
||||
# define CMS_F_CMS_DATAFINAL 110
|
||||
# define CMS_F_CMS_DATAINIT 111
|
||||
# define CMS_F_CMS_DECRYPT 112
|
||||
# define CMS_F_CMS_DECRYPT_SET1_KEY 113
|
||||
# define CMS_F_CMS_DECRYPT_SET1_PASSWORD 166
|
||||
# define CMS_F_CMS_DECRYPT_SET1_PKEY 114
|
||||
# define CMS_F_CMS_DIGESTALGORITHM_FIND_CTX 115
|
||||
# define CMS_F_CMS_DIGESTALGORITHM_INIT_BIO 116
|
||||
# define CMS_F_CMS_DIGESTEDDATA_DO_FINAL 117
|
||||
# define CMS_F_CMS_DIGEST_VERIFY 118
|
||||
# define CMS_F_CMS_ENCODE_RECEIPT 161
|
||||
# define CMS_F_CMS_ENCRYPT 119
|
||||
# define CMS_F_CMS_ENCRYPTEDCONTENT_INIT_BIO 120
|
||||
# define CMS_F_CMS_ENCRYPTEDDATA_DECRYPT 121
|
||||
# define CMS_F_CMS_ENCRYPTEDDATA_ENCRYPT 122
|
||||
# define CMS_F_CMS_ENCRYPTEDDATA_SET1_KEY 123
|
||||
# define CMS_F_CMS_ENVELOPEDDATA_CREATE 124
|
||||
# define CMS_F_CMS_ENVELOPEDDATA_INIT_BIO 125
|
||||
# define CMS_F_CMS_ENVELOPED_DATA_INIT 126
|
||||
# define CMS_F_CMS_ENV_ASN1_CTRL 171
|
||||
# define CMS_F_CMS_FINAL 127
|
||||
# define CMS_F_CMS_GET0_CERTIFICATE_CHOICES 128
|
||||
# define CMS_F_CMS_GET0_CONTENT 129
|
||||
# define CMS_F_CMS_GET0_ECONTENT_TYPE 130
|
||||
# define CMS_F_CMS_GET0_ENVELOPED 131
|
||||
# define CMS_F_CMS_GET0_REVOCATION_CHOICES 132
|
||||
# define CMS_F_CMS_GET0_SIGNED 133
|
||||
# define CMS_F_CMS_MSGSIGDIGEST_ADD1 162
|
||||
# define CMS_F_CMS_RECEIPTREQUEST_CREATE0 159
|
||||
# define CMS_F_CMS_RECEIPT_VERIFY 160
|
||||
# define CMS_F_CMS_RECIPIENTINFO_DECRYPT 134
|
||||
# define CMS_F_CMS_RECIPIENTINFO_ENCRYPT 169
|
||||
# define CMS_F_CMS_RECIPIENTINFO_KARI_ENCRYPT 178
|
||||
# define CMS_F_CMS_RECIPIENTINFO_KARI_GET0_ALG 175
|
||||
# define CMS_F_CMS_RECIPIENTINFO_KARI_GET0_ORIG_ID 173
|
||||
# define CMS_F_CMS_RECIPIENTINFO_KARI_GET0_REKS 172
|
||||
# define CMS_F_CMS_RECIPIENTINFO_KARI_ORIG_ID_CMP 174
|
||||
# define CMS_F_CMS_RECIPIENTINFO_KEKRI_DECRYPT 135
|
||||
# define CMS_F_CMS_RECIPIENTINFO_KEKRI_ENCRYPT 136
|
||||
# define CMS_F_CMS_RECIPIENTINFO_KEKRI_GET0_ID 137
|
||||
# define CMS_F_CMS_RECIPIENTINFO_KEKRI_ID_CMP 138
|
||||
# define CMS_F_CMS_RECIPIENTINFO_KTRI_CERT_CMP 139
|
||||
# define CMS_F_CMS_RECIPIENTINFO_KTRI_DECRYPT 140
|
||||
# define CMS_F_CMS_RECIPIENTINFO_KTRI_ENCRYPT 141
|
||||
# define CMS_F_CMS_RECIPIENTINFO_KTRI_GET0_ALGS 142
|
||||
# define CMS_F_CMS_RECIPIENTINFO_KTRI_GET0_SIGNER_ID 143
|
||||
# define CMS_F_CMS_RECIPIENTINFO_PWRI_CRYPT 167
|
||||
# define CMS_F_CMS_RECIPIENTINFO_SET0_KEY 144
|
||||
# define CMS_F_CMS_RECIPIENTINFO_SET0_PASSWORD 168
|
||||
# define CMS_F_CMS_RECIPIENTINFO_SET0_PKEY 145
|
||||
# define CMS_F_CMS_SD_ASN1_CTRL 170
|
||||
# define CMS_F_CMS_SET1_IAS 176
|
||||
# define CMS_F_CMS_SET1_KEYID 177
|
||||
# define CMS_F_CMS_SET1_SIGNERIDENTIFIER 146
|
||||
# define CMS_F_CMS_SET_DETACHED 147
|
||||
# define CMS_F_CMS_SIGN 148
|
||||
# define CMS_F_CMS_SIGNED_DATA_INIT 149
|
||||
# define CMS_F_CMS_SIGNERINFO_CONTENT_SIGN 150
|
||||
# define CMS_F_CMS_SIGNERINFO_SIGN 151
|
||||
# define CMS_F_CMS_SIGNERINFO_VERIFY 152
|
||||
# define CMS_F_CMS_SIGNERINFO_VERIFY_CERT 153
|
||||
# define CMS_F_CMS_SIGNERINFO_VERIFY_CONTENT 154
|
||||
# define CMS_F_CMS_SIGN_RECEIPT 163
|
||||
# define CMS_F_CMS_STREAM 155
|
||||
# define CMS_F_CMS_UNCOMPRESS 156
|
||||
# define CMS_F_CMS_VERIFY 157
|
||||
|
||||
/* Reason codes. */
|
||||
# define CMS_R_ADD_SIGNER_ERROR 99
|
||||
# define CMS_R_CERTIFICATE_ALREADY_PRESENT 175
|
||||
# define CMS_R_CERTIFICATE_HAS_NO_KEYID 160
|
||||
# define CMS_R_CERTIFICATE_VERIFY_ERROR 100
|
||||
# define CMS_R_CIPHER_INITIALISATION_ERROR 101
|
||||
# define CMS_R_CIPHER_PARAMETER_INITIALISATION_ERROR 102
|
||||
# define CMS_R_CMS_DATAFINAL_ERROR 103
|
||||
# define CMS_R_CMS_LIB 104
|
||||
# define CMS_R_CONTENTIDENTIFIER_MISMATCH 170
|
||||
# define CMS_R_CONTENT_NOT_FOUND 105
|
||||
# define CMS_R_CONTENT_TYPE_MISMATCH 171
|
||||
# define CMS_R_CONTENT_TYPE_NOT_COMPRESSED_DATA 106
|
||||
# define CMS_R_CONTENT_TYPE_NOT_ENVELOPED_DATA 107
|
||||
# define CMS_R_CONTENT_TYPE_NOT_SIGNED_DATA 108
|
||||
# define CMS_R_CONTENT_VERIFY_ERROR 109
|
||||
# define CMS_R_CTRL_ERROR 110
|
||||
# define CMS_R_CTRL_FAILURE 111
|
||||
# define CMS_R_DECRYPT_ERROR 112
|
||||
# define CMS_R_ERROR_GETTING_PUBLIC_KEY 113
|
||||
# define CMS_R_ERROR_READING_MESSAGEDIGEST_ATTRIBUTE 114
|
||||
# define CMS_R_ERROR_SETTING_KEY 115
|
||||
# define CMS_R_ERROR_SETTING_RECIPIENTINFO 116
|
||||
# define CMS_R_INVALID_ENCRYPTED_KEY_LENGTH 117
|
||||
# define CMS_R_INVALID_KEY_ENCRYPTION_PARAMETER 176
|
||||
# define CMS_R_INVALID_KEY_LENGTH 118
|
||||
# define CMS_R_MD_BIO_INIT_ERROR 119
|
||||
# define CMS_R_MESSAGEDIGEST_ATTRIBUTE_WRONG_LENGTH 120
|
||||
# define CMS_R_MESSAGEDIGEST_WRONG_LENGTH 121
|
||||
# define CMS_R_MSGSIGDIGEST_ERROR 172
|
||||
# define CMS_R_MSGSIGDIGEST_VERIFICATION_FAILURE 162
|
||||
# define CMS_R_MSGSIGDIGEST_WRONG_LENGTH 163
|
||||
# define CMS_R_NEED_ONE_SIGNER 164
|
||||
# define CMS_R_NOT_A_SIGNED_RECEIPT 165
|
||||
# define CMS_R_NOT_ENCRYPTED_DATA 122
|
||||
# define CMS_R_NOT_KEK 123
|
||||
# define CMS_R_NOT_KEY_AGREEMENT 181
|
||||
# define CMS_R_NOT_KEY_TRANSPORT 124
|
||||
# define CMS_R_NOT_PWRI 177
|
||||
# define CMS_R_NOT_SUPPORTED_FOR_THIS_KEY_TYPE 125
|
||||
# define CMS_R_NO_CIPHER 126
|
||||
# define CMS_R_NO_CONTENT 127
|
||||
# define CMS_R_NO_CONTENT_TYPE 173
|
||||
# define CMS_R_NO_DEFAULT_DIGEST 128
|
||||
# define CMS_R_NO_DIGEST_SET 129
|
||||
# define CMS_R_NO_KEY 130
|
||||
# define CMS_R_NO_KEY_OR_CERT 174
|
||||
# define CMS_R_NO_MATCHING_DIGEST 131
|
||||
# define CMS_R_NO_MATCHING_RECIPIENT 132
|
||||
# define CMS_R_NO_MATCHING_SIGNATURE 166
|
||||
# define CMS_R_NO_MSGSIGDIGEST 167
|
||||
# define CMS_R_NO_PASSWORD 178
|
||||
# define CMS_R_NO_PRIVATE_KEY 133
|
||||
# define CMS_R_NO_PUBLIC_KEY 134
|
||||
# define CMS_R_NO_RECEIPT_REQUEST 168
|
||||
# define CMS_R_NO_SIGNERS 135
|
||||
# define CMS_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE 136
|
||||
# define CMS_R_RECEIPT_DECODE_ERROR 169
|
||||
# define CMS_R_RECIPIENT_ERROR 137
|
||||
# define CMS_R_SIGNER_CERTIFICATE_NOT_FOUND 138
|
||||
# define CMS_R_SIGNFINAL_ERROR 139
|
||||
# define CMS_R_SMIME_TEXT_ERROR 140
|
||||
# define CMS_R_STORE_INIT_ERROR 141
|
||||
# define CMS_R_TYPE_NOT_COMPRESSED_DATA 142
|
||||
# define CMS_R_TYPE_NOT_DATA 143
|
||||
# define CMS_R_TYPE_NOT_DIGESTED_DATA 144
|
||||
# define CMS_R_TYPE_NOT_ENCRYPTED_DATA 145
|
||||
# define CMS_R_TYPE_NOT_ENVELOPED_DATA 146
|
||||
# define CMS_R_UNABLE_TO_FINALIZE_CONTEXT 147
|
||||
# define CMS_R_UNKNOWN_CIPHER 148
|
||||
# define CMS_R_UNKNOWN_DIGEST_ALGORIHM 149
|
||||
# define CMS_R_UNKNOWN_ID 150
|
||||
# define CMS_R_UNSUPPORTED_COMPRESSION_ALGORITHM 151
|
||||
# define CMS_R_UNSUPPORTED_CONTENT_TYPE 152
|
||||
# define CMS_R_UNSUPPORTED_KEK_ALGORITHM 153
|
||||
# define CMS_R_UNSUPPORTED_KEY_ENCRYPTION_ALGORITHM 179
|
||||
# define CMS_R_UNSUPPORTED_RECIPIENT_TYPE 154
|
||||
# define CMS_R_UNSUPPORTED_RECPIENTINFO_TYPE 155
|
||||
# define CMS_R_UNSUPPORTED_TYPE 156
|
||||
# define CMS_R_UNWRAP_ERROR 157
|
||||
# define CMS_R_UNWRAP_FAILURE 180
|
||||
# define CMS_R_VERIFICATION_FAILURE 158
|
||||
# define CMS_R_WRAP_ERROR 159
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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_COMP_H
|
||||
# define HEADER_COMP_H
|
||||
|
||||
# include <openssl/opensslconf.h>
|
||||
|
||||
# ifndef OPENSSL_NO_COMP
|
||||
# include <openssl/crypto.h>
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
# endif
|
||||
|
||||
|
||||
|
||||
COMP_CTX *COMP_CTX_new(COMP_METHOD *meth);
|
||||
const COMP_METHOD *COMP_CTX_get_method(const COMP_CTX *ctx);
|
||||
int COMP_CTX_get_type(const COMP_CTX* comp);
|
||||
int COMP_get_type(const COMP_METHOD *meth);
|
||||
const char *COMP_get_name(const COMP_METHOD *meth);
|
||||
void COMP_CTX_free(COMP_CTX *ctx);
|
||||
|
||||
int COMP_compress_block(COMP_CTX *ctx, unsigned char *out, int olen,
|
||||
unsigned char *in, int ilen);
|
||||
int COMP_expand_block(COMP_CTX *ctx, unsigned char *out, int olen,
|
||||
unsigned char *in, int ilen);
|
||||
|
||||
COMP_METHOD *COMP_zlib(void);
|
||||
|
||||
#if OPENSSL_API_COMPAT < 0x10100000L
|
||||
#define COMP_zlib_cleanup() while(0) continue
|
||||
#endif
|
||||
|
||||
# ifdef HEADER_BIO_H
|
||||
# ifdef ZLIB
|
||||
const BIO_METHOD *BIO_f_zlib(void);
|
||||
# endif
|
||||
# endif
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
/*
|
||||
* The following lines are auto generated by the script mkerr.pl. Any changes
|
||||
* made after this point may be overwritten when the script is next run.
|
||||
*/
|
||||
|
||||
int ERR_load_COMP_strings(void);
|
||||
|
||||
/* Error codes for the COMP functions. */
|
||||
|
||||
/* Function codes. */
|
||||
# define COMP_F_BIO_ZLIB_FLUSH 99
|
||||
# define COMP_F_BIO_ZLIB_NEW 100
|
||||
# define COMP_F_BIO_ZLIB_READ 101
|
||||
# define COMP_F_BIO_ZLIB_WRITE 102
|
||||
|
||||
/* Reason codes. */
|
||||
# define COMP_R_ZLIB_DEFLATE_ERROR 99
|
||||
# define COMP_R_ZLIB_INFLATE_ERROR 100
|
||||
# define COMP_R_ZLIB_NOT_SUPPORTED 101
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
|
@ -0,0 +1,216 @@
|
|||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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_CONF_H
|
||||
# define HEADER_CONF_H
|
||||
|
||||
# include <openssl/bio.h>
|
||||
# include <openssl/lhash.h>
|
||||
# include <openssl/stack.h>
|
||||
# include <openssl/safestack.h>
|
||||
# include <openssl/e_os2.h>
|
||||
|
||||
# include <openssl/ossl_typ.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
char *section;
|
||||
char *name;
|
||||
char *value;
|
||||
} CONF_VALUE;
|
||||
|
||||
DEFINE_STACK_OF(CONF_VALUE)
|
||||
DEFINE_LHASH_OF(CONF_VALUE);
|
||||
|
||||
struct conf_st;
|
||||
struct conf_method_st;
|
||||
typedef struct conf_method_st CONF_METHOD;
|
||||
|
||||
struct conf_method_st {
|
||||
const char *name;
|
||||
CONF *(*create) (CONF_METHOD *meth);
|
||||
int (*init) (CONF *conf);
|
||||
int (*destroy) (CONF *conf);
|
||||
int (*destroy_data) (CONF *conf);
|
||||
int (*load_bio) (CONF *conf, BIO *bp, long *eline);
|
||||
int (*dump) (const CONF *conf, BIO *bp);
|
||||
int (*is_number) (const CONF *conf, char c);
|
||||
int (*to_int) (const CONF *conf, char c);
|
||||
int (*load) (CONF *conf, const char *name, long *eline);
|
||||
};
|
||||
|
||||
/* Module definitions */
|
||||
|
||||
typedef struct conf_imodule_st CONF_IMODULE;
|
||||
typedef struct conf_module_st CONF_MODULE;
|
||||
|
||||
DEFINE_STACK_OF(CONF_MODULE)
|
||||
DEFINE_STACK_OF(CONF_IMODULE)
|
||||
|
||||
/* DSO module function typedefs */
|
||||
typedef int conf_init_func (CONF_IMODULE *md, const CONF *cnf);
|
||||
typedef void conf_finish_func (CONF_IMODULE *md);
|
||||
|
||||
# define CONF_MFLAGS_IGNORE_ERRORS 0x1
|
||||
# define CONF_MFLAGS_IGNORE_RETURN_CODES 0x2
|
||||
# define CONF_MFLAGS_SILENT 0x4
|
||||
# define CONF_MFLAGS_NO_DSO 0x8
|
||||
# define CONF_MFLAGS_IGNORE_MISSING_FILE 0x10
|
||||
# define CONF_MFLAGS_DEFAULT_SECTION 0x20
|
||||
|
||||
int CONF_set_default_method(CONF_METHOD *meth);
|
||||
void CONF_set_nconf(CONF *conf, LHASH_OF(CONF_VALUE) *hash);
|
||||
LHASH_OF(CONF_VALUE) *CONF_load(LHASH_OF(CONF_VALUE) *conf, const char *file,
|
||||
long *eline);
|
||||
# ifndef OPENSSL_NO_STDIO
|
||||
LHASH_OF(CONF_VALUE) *CONF_load_fp(LHASH_OF(CONF_VALUE) *conf, FILE *fp,
|
||||
long *eline);
|
||||
# endif
|
||||
LHASH_OF(CONF_VALUE) *CONF_load_bio(LHASH_OF(CONF_VALUE) *conf, BIO *bp,
|
||||
long *eline);
|
||||
STACK_OF(CONF_VALUE) *CONF_get_section(LHASH_OF(CONF_VALUE) *conf,
|
||||
const char *section);
|
||||
char *CONF_get_string(LHASH_OF(CONF_VALUE) *conf, const char *group,
|
||||
const char *name);
|
||||
long CONF_get_number(LHASH_OF(CONF_VALUE) *conf, const char *group,
|
||||
const char *name);
|
||||
void CONF_free(LHASH_OF(CONF_VALUE) *conf);
|
||||
#ifndef OPENSSL_NO_STDIO
|
||||
int CONF_dump_fp(LHASH_OF(CONF_VALUE) *conf, FILE *out);
|
||||
#endif
|
||||
int CONF_dump_bio(LHASH_OF(CONF_VALUE) *conf, BIO *out);
|
||||
|
||||
DEPRECATEDIN_1_1_0(void OPENSSL_config(const char *config_name))
|
||||
|
||||
#if OPENSSL_API_COMPAT < 0x10100000L
|
||||
# define OPENSSL_no_config() \
|
||||
OPENSSL_init_crypto(OPENSSL_INIT_NO_LOAD_CONFIG, NULL)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* New conf code. The semantics are different from the functions above. If
|
||||
* that wasn't the case, the above functions would have been replaced
|
||||
*/
|
||||
|
||||
struct conf_st {
|
||||
CONF_METHOD *meth;
|
||||
void *meth_data;
|
||||
LHASH_OF(CONF_VALUE) *data;
|
||||
};
|
||||
|
||||
CONF *NCONF_new(CONF_METHOD *meth);
|
||||
CONF_METHOD *NCONF_default(void);
|
||||
CONF_METHOD *NCONF_WIN32(void);
|
||||
void NCONF_free(CONF *conf);
|
||||
void NCONF_free_data(CONF *conf);
|
||||
|
||||
int NCONF_load(CONF *conf, const char *file, long *eline);
|
||||
# ifndef OPENSSL_NO_STDIO
|
||||
int NCONF_load_fp(CONF *conf, FILE *fp, long *eline);
|
||||
# endif
|
||||
int NCONF_load_bio(CONF *conf, BIO *bp, long *eline);
|
||||
STACK_OF(CONF_VALUE) *NCONF_get_section(const CONF *conf,
|
||||
const char *section);
|
||||
char *NCONF_get_string(const CONF *conf, const char *group, const char *name);
|
||||
int NCONF_get_number_e(const CONF *conf, const char *group, const char *name,
|
||||
long *result);
|
||||
#ifndef OPENSSL_NO_STDIO
|
||||
int NCONF_dump_fp(const CONF *conf, FILE *out);
|
||||
#endif
|
||||
int NCONF_dump_bio(const CONF *conf, BIO *out);
|
||||
|
||||
#define NCONF_get_number(c,g,n,r) NCONF_get_number_e(c,g,n,r)
|
||||
|
||||
/* Module functions */
|
||||
|
||||
int CONF_modules_load(const CONF *cnf, const char *appname,
|
||||
unsigned long flags);
|
||||
int CONF_modules_load_file(const char *filename, const char *appname,
|
||||
unsigned long flags);
|
||||
void CONF_modules_unload(int all);
|
||||
void CONF_modules_finish(void);
|
||||
#if OPENSSL_API_COMPAT < 0x10100000L
|
||||
# define CONF_modules_free() while(0) continue
|
||||
#endif
|
||||
int CONF_module_add(const char *name, conf_init_func *ifunc,
|
||||
conf_finish_func *ffunc);
|
||||
|
||||
const char *CONF_imodule_get_name(const CONF_IMODULE *md);
|
||||
const char *CONF_imodule_get_value(const CONF_IMODULE *md);
|
||||
void *CONF_imodule_get_usr_data(const CONF_IMODULE *md);
|
||||
void CONF_imodule_set_usr_data(CONF_IMODULE *md, void *usr_data);
|
||||
CONF_MODULE *CONF_imodule_get_module(const CONF_IMODULE *md);
|
||||
unsigned long CONF_imodule_get_flags(const CONF_IMODULE *md);
|
||||
void CONF_imodule_set_flags(CONF_IMODULE *md, unsigned long flags);
|
||||
void *CONF_module_get_usr_data(CONF_MODULE *pmod);
|
||||
void CONF_module_set_usr_data(CONF_MODULE *pmod, void *usr_data);
|
||||
|
||||
char *CONF_get1_default_config_file(void);
|
||||
|
||||
int CONF_parse_list(const char *list, int sep, int nospc,
|
||||
int (*list_cb) (const char *elem, int len, void *usr),
|
||||
void *arg);
|
||||
|
||||
void OPENSSL_load_builtin_modules(void);
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
/*
|
||||
* The following lines are auto generated by the script mkerr.pl. Any changes
|
||||
* made after this point may be overwritten when the script is next run.
|
||||
*/
|
||||
|
||||
int ERR_load_CONF_strings(void);
|
||||
|
||||
/* Error codes for the CONF functions. */
|
||||
|
||||
/* Function codes. */
|
||||
# define CONF_F_CONF_DUMP_FP 104
|
||||
# define CONF_F_CONF_LOAD 100
|
||||
# define CONF_F_CONF_LOAD_FP 103
|
||||
# define CONF_F_CONF_PARSE_LIST 119
|
||||
# define CONF_F_DEF_LOAD 120
|
||||
# define CONF_F_DEF_LOAD_BIO 121
|
||||
# define CONF_F_MODULE_INIT 115
|
||||
# define CONF_F_MODULE_LOAD_DSO 117
|
||||
# define CONF_F_MODULE_RUN 118
|
||||
# define CONF_F_NCONF_DUMP_BIO 105
|
||||
# define CONF_F_NCONF_DUMP_FP 106
|
||||
# define CONF_F_NCONF_GET_NUMBER_E 112
|
||||
# define CONF_F_NCONF_GET_SECTION 108
|
||||
# define CONF_F_NCONF_GET_STRING 109
|
||||
# define CONF_F_NCONF_LOAD 113
|
||||
# define CONF_F_NCONF_LOAD_BIO 110
|
||||
# define CONF_F_NCONF_LOAD_FP 114
|
||||
# define CONF_F_NCONF_NEW 111
|
||||
# define CONF_F_STR_COPY 101
|
||||
|
||||
/* Reason codes. */
|
||||
# define CONF_R_ERROR_LOADING_DSO 110
|
||||
# define CONF_R_LIST_CANNOT_BE_NULL 115
|
||||
# define CONF_R_MISSING_CLOSE_SQUARE_BRACKET 100
|
||||
# define CONF_R_MISSING_EQUAL_SIGN 101
|
||||
# define CONF_R_MISSING_INIT_FUNCTION 112
|
||||
# define CONF_R_MODULE_INITIALIZATION_ERROR 109
|
||||
# define CONF_R_NO_CLOSE_BRACE 102
|
||||
# define CONF_R_NO_CONF 105
|
||||
# define CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE 106
|
||||
# define CONF_R_NO_SECTION 107
|
||||
# define CONF_R_NO_SUCH_FILE 114
|
||||
# define CONF_R_NO_VALUE 108
|
||||
# define CONF_R_UNABLE_TO_CREATE_NEW_SECTION 103
|
||||
# define CONF_R_UNKNOWN_MODULE_NAME 113
|
||||
# define CONF_R_VARIABLE_HAS_NO_VALUE 104
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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_CONF_API_H
|
||||
# define HEADER_CONF_API_H
|
||||
|
||||
# include <openssl/lhash.h>
|
||||
# include <openssl/conf.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Up until OpenSSL 0.9.5a, this was new_section */
|
||||
CONF_VALUE *_CONF_new_section(CONF *conf, const char *section);
|
||||
/* Up until OpenSSL 0.9.5a, this was get_section */
|
||||
CONF_VALUE *_CONF_get_section(const CONF *conf, const char *section);
|
||||
/* Up until OpenSSL 0.9.5a, this was CONF_get_section */
|
||||
STACK_OF(CONF_VALUE) *_CONF_get_section_values(const CONF *conf,
|
||||
const char *section);
|
||||
|
||||
int _CONF_add_string(CONF *conf, CONF_VALUE *section, CONF_VALUE *value);
|
||||
char *_CONF_get_string(const CONF *conf, const char *section,
|
||||
const char *name);
|
||||
long _CONF_get_number(const CONF *conf, const char *section,
|
||||
const char *name);
|
||||
|
||||
int _CONF_new_data(CONF *conf);
|
||||
void _CONF_free_data(CONF *conf);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -0,0 +1,463 @@
|
|||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
|
||||
* ECDH support in OpenSSL originally developed by
|
||||
* SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.
|
||||
*/
|
||||
|
||||
#ifndef HEADER_CRYPTO_H
|
||||
# define HEADER_CRYPTO_H
|
||||
|
||||
# include <stdlib.h>
|
||||
# include <time.h>
|
||||
|
||||
# include <openssl/e_os2.h>
|
||||
|
||||
# ifndef OPENSSL_NO_STDIO
|
||||
# include <stdio.h>
|
||||
# endif
|
||||
|
||||
# include <openssl/stack.h>
|
||||
# include <openssl/safestack.h>
|
||||
# include <openssl/opensslv.h>
|
||||
# include <openssl/ossl_typ.h>
|
||||
# include <openssl/opensslconf.h>
|
||||
|
||||
# ifdef CHARSET_EBCDIC
|
||||
# include <openssl/ebcdic.h>
|
||||
# endif
|
||||
|
||||
/*
|
||||
* Resolve problems on some operating systems with symbol names that clash
|
||||
* one way or another
|
||||
*/
|
||||
# include <openssl/symhacks.h>
|
||||
|
||||
# if OPENSSL_API_COMPAT < 0x10100000L
|
||||
# include <openssl/opensslv.h>
|
||||
# endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
# if OPENSSL_API_COMPAT < 0x10100000L
|
||||
# define SSLeay OpenSSL_version_num
|
||||
# define SSLeay_version OpenSSL_version
|
||||
# define SSLEAY_VERSION_NUMBER OPENSSL_VERSION_NUMBER
|
||||
# define SSLEAY_VERSION OPENSSL_VERSION
|
||||
# define SSLEAY_CFLAGS OPENSSL_CFLAGS
|
||||
# define SSLEAY_BUILT_ON OPENSSL_BUILT_ON
|
||||
# define SSLEAY_PLATFORM OPENSSL_PLATFORM
|
||||
# define SSLEAY_DIR OPENSSL_DIR
|
||||
|
||||
/*
|
||||
* Old type for allocating dynamic locks. No longer used. Use the new thread
|
||||
* API instead.
|
||||
*/
|
||||
typedef struct {
|
||||
int dummy;
|
||||
} CRYPTO_dynlock;
|
||||
|
||||
# endif /* OPENSSL_API_COMPAT */
|
||||
|
||||
typedef void CRYPTO_RWLOCK;
|
||||
|
||||
CRYPTO_RWLOCK *CRYPTO_THREAD_lock_new(void);
|
||||
int CRYPTO_THREAD_read_lock(CRYPTO_RWLOCK *lock);
|
||||
int CRYPTO_THREAD_write_lock(CRYPTO_RWLOCK *lock);
|
||||
int CRYPTO_THREAD_unlock(CRYPTO_RWLOCK *lock);
|
||||
void CRYPTO_THREAD_lock_free(CRYPTO_RWLOCK *lock);
|
||||
|
||||
int CRYPTO_atomic_add(int *val, int amount, int *ret, CRYPTO_RWLOCK *lock);
|
||||
|
||||
/*
|
||||
* The following can be used to detect memory leaks in the library. If
|
||||
* used, it turns on malloc checking
|
||||
*/
|
||||
# define CRYPTO_MEM_CHECK_OFF 0x0 /* Control only */
|
||||
# define CRYPTO_MEM_CHECK_ON 0x1 /* Control and mode bit */
|
||||
# define CRYPTO_MEM_CHECK_ENABLE 0x2 /* Control and mode bit */
|
||||
# define CRYPTO_MEM_CHECK_DISABLE 0x3 /* Control only */
|
||||
|
||||
struct crypto_ex_data_st {
|
||||
STACK_OF(void) *sk;
|
||||
};
|
||||
DEFINE_STACK_OF(void)
|
||||
|
||||
/*
|
||||
* Per class, we have a STACK of function pointers.
|
||||
*/
|
||||
# define CRYPTO_EX_INDEX_SSL 0
|
||||
# define CRYPTO_EX_INDEX_SSL_CTX 1
|
||||
# define CRYPTO_EX_INDEX_SSL_SESSION 2
|
||||
# define CRYPTO_EX_INDEX_X509 3
|
||||
# define CRYPTO_EX_INDEX_X509_STORE 4
|
||||
# define CRYPTO_EX_INDEX_X509_STORE_CTX 5
|
||||
# define CRYPTO_EX_INDEX_DH 6
|
||||
# define CRYPTO_EX_INDEX_DSA 7
|
||||
# define CRYPTO_EX_INDEX_EC_KEY 8
|
||||
# define CRYPTO_EX_INDEX_RSA 9
|
||||
# define CRYPTO_EX_INDEX_ENGINE 10
|
||||
# define CRYPTO_EX_INDEX_UI 11
|
||||
# define CRYPTO_EX_INDEX_BIO 12
|
||||
# define CRYPTO_EX_INDEX_APP 13
|
||||
# define CRYPTO_EX_INDEX__COUNT 14
|
||||
|
||||
/*
|
||||
* This is the default callbacks, but we can have others as well: this is
|
||||
* needed in Win32 where the application malloc and the library malloc may
|
||||
* not be the same.
|
||||
*/
|
||||
#define OPENSSL_malloc_init() \
|
||||
CRYPTO_set_mem_functions(CRYPTO_malloc, CRYPTO_realloc, CRYPTO_free)
|
||||
|
||||
int CRYPTO_mem_ctrl(int mode);
|
||||
|
||||
# define OPENSSL_malloc(num) \
|
||||
CRYPTO_malloc(num, OPENSSL_FILE, OPENSSL_LINE)
|
||||
# define OPENSSL_zalloc(num) \
|
||||
CRYPTO_zalloc(num, OPENSSL_FILE, OPENSSL_LINE)
|
||||
# define OPENSSL_realloc(addr, num) \
|
||||
CRYPTO_realloc(addr, num, OPENSSL_FILE, OPENSSL_LINE)
|
||||
# define OPENSSL_clear_realloc(addr, old_num, num) \
|
||||
CRYPTO_clear_realloc(addr, old_num, num, OPENSSL_FILE, OPENSSL_LINE)
|
||||
# define OPENSSL_clear_free(addr, num) \
|
||||
CRYPTO_clear_free(addr, num, OPENSSL_FILE, OPENSSL_LINE)
|
||||
# define OPENSSL_free(addr) \
|
||||
CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
|
||||
# define OPENSSL_memdup(str, s) \
|
||||
CRYPTO_memdup((str), s, OPENSSL_FILE, OPENSSL_LINE)
|
||||
# define OPENSSL_strdup(str) \
|
||||
CRYPTO_strdup(str, OPENSSL_FILE, OPENSSL_LINE)
|
||||
# define OPENSSL_strndup(str, n) \
|
||||
CRYPTO_strndup(str, n, OPENSSL_FILE, OPENSSL_LINE)
|
||||
# define OPENSSL_secure_malloc(num) \
|
||||
CRYPTO_secure_malloc(num, OPENSSL_FILE, OPENSSL_LINE)
|
||||
# define OPENSSL_secure_zalloc(num) \
|
||||
CRYPTO_secure_zalloc(num, OPENSSL_FILE, OPENSSL_LINE)
|
||||
# define OPENSSL_secure_free(addr) \
|
||||
CRYPTO_secure_free(addr, OPENSSL_FILE, OPENSSL_LINE)
|
||||
# define OPENSSL_secure_actual_size(ptr) \
|
||||
CRYPTO_secure_actual_size(ptr)
|
||||
|
||||
size_t OPENSSL_strlcpy(char *dst, const char *src, size_t siz);
|
||||
size_t OPENSSL_strlcat(char *dst, const char *src, size_t siz);
|
||||
size_t OPENSSL_strnlen(const char *str, size_t maxlen);
|
||||
char *OPENSSL_buf2hexstr(const unsigned char *buffer, long len);
|
||||
unsigned char *OPENSSL_hexstr2buf(const char *str, long *len);
|
||||
int OPENSSL_hexchar2int(unsigned char c);
|
||||
|
||||
# define OPENSSL_MALLOC_MAX_NELEMS(type) (((1U<<(sizeof(int)*8-1))-1)/sizeof(type))
|
||||
|
||||
unsigned long OpenSSL_version_num(void);
|
||||
const char *OpenSSL_version(int type);
|
||||
# define OPENSSL_VERSION 0
|
||||
# define OPENSSL_CFLAGS 1
|
||||
# define OPENSSL_BUILT_ON 2
|
||||
# define OPENSSL_PLATFORM 3
|
||||
# define OPENSSL_DIR 4
|
||||
# define OPENSSL_ENGINES_DIR 5
|
||||
|
||||
int OPENSSL_issetugid(void);
|
||||
|
||||
typedef void CRYPTO_EX_new (void *parent, void *ptr, CRYPTO_EX_DATA *ad,
|
||||
int idx, long argl, void *argp);
|
||||
typedef void CRYPTO_EX_free (void *parent, void *ptr, CRYPTO_EX_DATA *ad,
|
||||
int idx, long argl, void *argp);
|
||||
typedef int CRYPTO_EX_dup (CRYPTO_EX_DATA *to, const CRYPTO_EX_DATA *from,
|
||||
void *srcp, int idx, long argl, void *argp);
|
||||
__owur int CRYPTO_get_ex_new_index(int class_index, long argl, void *argp,
|
||||
CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,
|
||||
CRYPTO_EX_free *free_func);
|
||||
/* No longer use an index. */
|
||||
int CRYPTO_free_ex_index(int class_index, int idx);
|
||||
|
||||
/*
|
||||
* Initialise/duplicate/free CRYPTO_EX_DATA variables corresponding to a
|
||||
* given class (invokes whatever per-class callbacks are applicable)
|
||||
*/
|
||||
int CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad);
|
||||
int CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA *to,
|
||||
const CRYPTO_EX_DATA *from);
|
||||
|
||||
void CRYPTO_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad);
|
||||
|
||||
/*
|
||||
* Get/set data in a CRYPTO_EX_DATA variable corresponding to a particular
|
||||
* index (relative to the class type involved)
|
||||
*/
|
||||
int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val);
|
||||
void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx);
|
||||
|
||||
# if OPENSSL_API_COMPAT < 0x10100000L
|
||||
/*
|
||||
* This function cleans up all "ex_data" state. It mustn't be called under
|
||||
* potential race-conditions.
|
||||
*/
|
||||
# define CRYPTO_cleanup_all_ex_data() while(0) continue
|
||||
|
||||
/*
|
||||
* The old locking functions have been removed completely without compatibility
|
||||
* macros. This is because the old functions either could not properly report
|
||||
* errors, or the returned error values were not clearly documented.
|
||||
* Replacing the locking functions with with no-ops would cause race condition
|
||||
* issues in the affected applications. It is far better for them to fail at
|
||||
* compile time.
|
||||
* On the other hand, the locking callbacks are no longer used. Consequently,
|
||||
* the callback management functions can be safely replaced with no-op macros.
|
||||
*/
|
||||
# define CRYPTO_num_locks() (1)
|
||||
# define CRYPTO_set_locking_callback(func)
|
||||
# define CRYPTO_get_locking_callback() (NULL)
|
||||
# define CRYPTO_set_add_lock_callback(func)
|
||||
# define CRYPTO_get_add_lock_callback() (NULL)
|
||||
|
||||
/*
|
||||
* These defines where used in combination with the old locking callbacks,
|
||||
* they are not called anymore, but old code that's not called might still
|
||||
* use them.
|
||||
*/
|
||||
# define CRYPTO_LOCK 1
|
||||
# define CRYPTO_UNLOCK 2
|
||||
# define CRYPTO_READ 4
|
||||
# define CRYPTO_WRITE 8
|
||||
|
||||
/* This structure is no longer used */
|
||||
typedef struct crypto_threadid_st {
|
||||
int dummy;
|
||||
} CRYPTO_THREADID;
|
||||
/* Only use CRYPTO_THREADID_set_[numeric|pointer]() within callbacks */
|
||||
# define CRYPTO_THREADID_set_numeric(id, val)
|
||||
# define CRYPTO_THREADID_set_pointer(id, ptr)
|
||||
# define CRYPTO_THREADID_set_callback(threadid_func) (0)
|
||||
# define CRYPTO_THREADID_get_callback() (NULL)
|
||||
# define CRYPTO_THREADID_current(id)
|
||||
# define CRYPTO_THREADID_cmp(a, b) (-1)
|
||||
# define CRYPTO_THREADID_cpy(dest, src)
|
||||
# define CRYPTO_THREADID_hash(id) (0UL)
|
||||
|
||||
# if OPENSSL_API_COMPAT < 0x10000000L
|
||||
# define CRYPTO_set_id_callback(func)
|
||||
# define CRYPTO_get_id_callback() (NULL)
|
||||
# define CRYPTO_thread_id() (0UL)
|
||||
# endif /* OPENSSL_API_COMPAT < 0x10000000L */
|
||||
|
||||
# define CRYPTO_set_dynlock_create_callback(dyn_create_function)
|
||||
# define CRYPTO_set_dynlock_lock_callback(dyn_lock_function)
|
||||
# define CRYPTO_set_dynlock_destroy_callback(dyn_destroy_function)
|
||||
# define CRYPTO_get_dynlock_create_callback() (NULL)
|
||||
# define CRYPTO_get_dynlock_lock_callback() (NULL)
|
||||
# define CRYPTO_get_dynlock_destroy_callback() (NULL)
|
||||
# endif /* OPENSSL_API_COMPAT < 0x10100000L */
|
||||
|
||||
int CRYPTO_set_mem_functions(
|
||||
void *(*m) (size_t, const char *, int),
|
||||
void *(*r) (void *, size_t, const char *, int),
|
||||
void (*f) (void *, const char *, int));
|
||||
int CRYPTO_set_mem_debug(int flag);
|
||||
void CRYPTO_get_mem_functions(
|
||||
void *(**m) (size_t, const char *, int),
|
||||
void *(**r) (void *, size_t, const char *, int),
|
||||
void (**f) (void *, const char *, int));
|
||||
|
||||
void *CRYPTO_malloc(size_t num, const char *file, int line);
|
||||
void *CRYPTO_zalloc(size_t num, const char *file, int line);
|
||||
void *CRYPTO_memdup(const void *str, size_t siz, const char *file, int line);
|
||||
char *CRYPTO_strdup(const char *str, const char *file, int line);
|
||||
char *CRYPTO_strndup(const char *str, size_t s, const char *file, int line);
|
||||
void CRYPTO_free(void *ptr, const char *file, int line);
|
||||
void CRYPTO_clear_free(void *ptr, size_t num, const char *file, int line);
|
||||
void *CRYPTO_realloc(void *addr, size_t num, const char *file, int line);
|
||||
void *CRYPTO_clear_realloc(void *addr, size_t old_num, size_t num,
|
||||
const char *file, int line);
|
||||
|
||||
int CRYPTO_secure_malloc_init(size_t sz, int minsize);
|
||||
int CRYPTO_secure_malloc_done(void);
|
||||
void *CRYPTO_secure_malloc(size_t num, const char *file, int line);
|
||||
void *CRYPTO_secure_zalloc(size_t num, const char *file, int line);
|
||||
void CRYPTO_secure_free(void *ptr, const char *file, int line);
|
||||
int CRYPTO_secure_allocated(const void *ptr);
|
||||
int CRYPTO_secure_malloc_initialized(void);
|
||||
size_t CRYPTO_secure_actual_size(void *ptr);
|
||||
size_t CRYPTO_secure_used(void);
|
||||
|
||||
void OPENSSL_cleanse(void *ptr, size_t len);
|
||||
|
||||
# ifndef OPENSSL_NO_CRYPTO_MDEBUG
|
||||
# define OPENSSL_mem_debug_push(info) \
|
||||
CRYPTO_mem_debug_push(info, OPENSSL_FILE, OPENSSL_LINE)
|
||||
# define OPENSSL_mem_debug_pop() \
|
||||
CRYPTO_mem_debug_pop()
|
||||
int CRYPTO_mem_debug_push(const char *info, const char *file, int line);
|
||||
int CRYPTO_mem_debug_pop(void);
|
||||
|
||||
/*-
|
||||
* Debugging functions (enabled by CRYPTO_set_mem_debug(1))
|
||||
* The flag argument has the following significance:
|
||||
* 0: called before the actual memory allocation has taken place
|
||||
* 1: called after the actual memory allocation has taken place
|
||||
*/
|
||||
void CRYPTO_mem_debug_malloc(void *addr, size_t num, int flag,
|
||||
const char *file, int line);
|
||||
void CRYPTO_mem_debug_realloc(void *addr1, void *addr2, size_t num, int flag,
|
||||
const char *file, int line);
|
||||
void CRYPTO_mem_debug_free(void *addr, int flag,
|
||||
const char *file, int line);
|
||||
|
||||
# ifndef OPENSSL_NO_STDIO
|
||||
int CRYPTO_mem_leaks_fp(FILE *);
|
||||
# endif
|
||||
int CRYPTO_mem_leaks(BIO *bio);
|
||||
# endif
|
||||
|
||||
/* die if we have to */
|
||||
ossl_noreturn void OPENSSL_die(const char *assertion, const char *file, int line);
|
||||
# if OPENSSL_API_COMPAT < 0x10100000L
|
||||
# define OpenSSLDie(f,l,a) OPENSSL_die((a),(f),(l))
|
||||
# endif
|
||||
# define OPENSSL_assert(e) \
|
||||
(void)((e) ? 0 : (OPENSSL_die("assertion failed: " #e, OPENSSL_FILE, OPENSSL_LINE), 1))
|
||||
|
||||
int OPENSSL_isservice(void);
|
||||
|
||||
int FIPS_mode(void);
|
||||
int FIPS_mode_set(int r);
|
||||
|
||||
void OPENSSL_init(void);
|
||||
|
||||
struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result);
|
||||
int OPENSSL_gmtime_adj(struct tm *tm, int offset_day, long offset_sec);
|
||||
int OPENSSL_gmtime_diff(int *pday, int *psec,
|
||||
const struct tm *from, const struct tm *to);
|
||||
|
||||
/*
|
||||
* CRYPTO_memcmp returns zero iff the |len| bytes at |a| and |b| are equal.
|
||||
* It takes an amount of time dependent on |len|, but independent of the
|
||||
* contents of |a| and |b|. Unlike memcmp, it cannot be used to put elements
|
||||
* into a defined order as the return value when a != b is undefined, other
|
||||
* than to be non-zero.
|
||||
*/
|
||||
int CRYPTO_memcmp(const volatile void * volatile in_a,
|
||||
const volatile void * volatile in_b,
|
||||
size_t len);
|
||||
|
||||
/* Standard initialisation options */
|
||||
# define OPENSSL_INIT_NO_LOAD_CRYPTO_STRINGS 0x00000001L
|
||||
# define OPENSSL_INIT_LOAD_CRYPTO_STRINGS 0x00000002L
|
||||
# define OPENSSL_INIT_ADD_ALL_CIPHERS 0x00000004L
|
||||
# define OPENSSL_INIT_ADD_ALL_DIGESTS 0x00000008L
|
||||
# define OPENSSL_INIT_NO_ADD_ALL_CIPHERS 0x00000010L
|
||||
# define OPENSSL_INIT_NO_ADD_ALL_DIGESTS 0x00000020L
|
||||
# define OPENSSL_INIT_LOAD_CONFIG 0x00000040L
|
||||
# define OPENSSL_INIT_NO_LOAD_CONFIG 0x00000080L
|
||||
# define OPENSSL_INIT_ASYNC 0x00000100L
|
||||
# define OPENSSL_INIT_ENGINE_RDRAND 0x00000200L
|
||||
# define OPENSSL_INIT_ENGINE_DYNAMIC 0x00000400L
|
||||
# define OPENSSL_INIT_ENGINE_OPENSSL 0x00000800L
|
||||
# define OPENSSL_INIT_ENGINE_CRYPTODEV 0x00001000L
|
||||
# define OPENSSL_INIT_ENGINE_CAPI 0x00002000L
|
||||
# define OPENSSL_INIT_ENGINE_PADLOCK 0x00004000L
|
||||
# define OPENSSL_INIT_ENGINE_AFALG 0x00008000L
|
||||
/* OPENSSL_INIT flag 0x00010000 reserved for internal use */
|
||||
/* OPENSSL_INIT flag range 0xfff00000 reserved for OPENSSL_init_ssl() */
|
||||
/* Max OPENSSL_INIT flag value is 0x80000000 */
|
||||
|
||||
/* openssl and dasync not counted as builtin */
|
||||
# define OPENSSL_INIT_ENGINE_ALL_BUILTIN \
|
||||
(OPENSSL_INIT_ENGINE_RDRAND | OPENSSL_INIT_ENGINE_DYNAMIC \
|
||||
| OPENSSL_INIT_ENGINE_CRYPTODEV | OPENSSL_INIT_ENGINE_CAPI | \
|
||||
OPENSSL_INIT_ENGINE_PADLOCK)
|
||||
|
||||
|
||||
/* Library initialisation functions */
|
||||
void OPENSSL_cleanup(void);
|
||||
int OPENSSL_init_crypto(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings);
|
||||
int OPENSSL_atexit(void (*handler)(void));
|
||||
void OPENSSL_thread_stop(void);
|
||||
|
||||
/* Low-level control of initialization */
|
||||
OPENSSL_INIT_SETTINGS *OPENSSL_INIT_new(void);
|
||||
# ifndef OPENSSL_NO_STDIO
|
||||
int OPENSSL_INIT_set_config_appname(OPENSSL_INIT_SETTINGS *settings,
|
||||
const char *config_file);
|
||||
# endif
|
||||
void OPENSSL_INIT_free(OPENSSL_INIT_SETTINGS *settings);
|
||||
|
||||
# if defined(OPENSSL_THREADS) && !defined(CRYPTO_TDEBUG)
|
||||
# if defined(_WIN32)
|
||||
# if defined(BASETYPES) || defined(_WINDEF_H)
|
||||
/* application has to include <windows.h> in order to use this */
|
||||
typedef DWORD CRYPTO_THREAD_LOCAL;
|
||||
typedef DWORD CRYPTO_THREAD_ID;
|
||||
|
||||
typedef LONG CRYPTO_ONCE;
|
||||
# define CRYPTO_ONCE_STATIC_INIT 0
|
||||
# endif
|
||||
# else
|
||||
# include <pthread.h>
|
||||
typedef pthread_once_t CRYPTO_ONCE;
|
||||
typedef pthread_key_t CRYPTO_THREAD_LOCAL;
|
||||
typedef pthread_t CRYPTO_THREAD_ID;
|
||||
|
||||
# define CRYPTO_ONCE_STATIC_INIT PTHREAD_ONCE_INIT
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# if !defined(CRYPTO_ONCE_STATIC_INIT)
|
||||
typedef unsigned int CRYPTO_ONCE;
|
||||
typedef unsigned int CRYPTO_THREAD_LOCAL;
|
||||
typedef unsigned int CRYPTO_THREAD_ID;
|
||||
# define CRYPTO_ONCE_STATIC_INIT 0
|
||||
# endif
|
||||
|
||||
int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void));
|
||||
|
||||
int CRYPTO_THREAD_init_local(CRYPTO_THREAD_LOCAL *key, void (*cleanup)(void *));
|
||||
void *CRYPTO_THREAD_get_local(CRYPTO_THREAD_LOCAL *key);
|
||||
int CRYPTO_THREAD_set_local(CRYPTO_THREAD_LOCAL *key, void *val);
|
||||
int CRYPTO_THREAD_cleanup_local(CRYPTO_THREAD_LOCAL *key);
|
||||
|
||||
CRYPTO_THREAD_ID CRYPTO_THREAD_get_current_id(void);
|
||||
int CRYPTO_THREAD_compare_id(CRYPTO_THREAD_ID a, CRYPTO_THREAD_ID b);
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
/*
|
||||
* The following lines are auto generated by the script mkerr.pl. Any changes
|
||||
* made after this point may be overwritten when the script is next run.
|
||||
*/
|
||||
|
||||
int ERR_load_CRYPTO_strings(void);
|
||||
|
||||
/* Error codes for the CRYPTO functions. */
|
||||
|
||||
/* Function codes. */
|
||||
# define CRYPTO_F_CRYPTO_DUP_EX_DATA 110
|
||||
# define CRYPTO_F_CRYPTO_FREE_EX_DATA 111
|
||||
# define CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX 100
|
||||
# define CRYPTO_F_CRYPTO_MEMDUP 115
|
||||
# define CRYPTO_F_CRYPTO_NEW_EX_DATA 112
|
||||
# define CRYPTO_F_CRYPTO_SET_EX_DATA 102
|
||||
# define CRYPTO_F_FIPS_MODE_SET 109
|
||||
# define CRYPTO_F_GET_AND_LOCK 113
|
||||
# define CRYPTO_F_OPENSSL_BUF2HEXSTR 117
|
||||
# define CRYPTO_F_OPENSSL_HEXSTR2BUF 118
|
||||
# define CRYPTO_F_OPENSSL_INIT_CRYPTO 116
|
||||
|
||||
/* Reason codes. */
|
||||
# define CRYPTO_R_FIPS_MODE_NOT_SUPPORTED 101
|
||||
# define CRYPTO_R_ILLEGAL_HEX_DIGIT 102
|
||||
# define CRYPTO_R_ODD_NUMBER_OF_DIGITS 103
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
|
@ -0,0 +1,518 @@
|
|||
/*
|
||||
* Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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_CT_H
|
||||
# define HEADER_CT_H
|
||||
|
||||
# include <openssl/opensslconf.h>
|
||||
|
||||
# ifndef OPENSSL_NO_CT
|
||||
# include <openssl/ossl_typ.h>
|
||||
# include <openssl/safestack.h>
|
||||
# include <openssl/x509.h>
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
# endif
|
||||
|
||||
|
||||
/* Minimum RSA key size, from RFC6962 */
|
||||
# define SCT_MIN_RSA_BITS 2048
|
||||
|
||||
/* All hashes are SHA256 in v1 of Certificate Transparency */
|
||||
# define CT_V1_HASHLEN SHA256_DIGEST_LENGTH
|
||||
|
||||
typedef enum {
|
||||
CT_LOG_ENTRY_TYPE_NOT_SET = -1,
|
||||
CT_LOG_ENTRY_TYPE_X509 = 0,
|
||||
CT_LOG_ENTRY_TYPE_PRECERT = 1
|
||||
} ct_log_entry_type_t;
|
||||
|
||||
typedef enum {
|
||||
SCT_VERSION_NOT_SET = -1,
|
||||
SCT_VERSION_V1 = 0
|
||||
} sct_version_t;
|
||||
|
||||
typedef enum {
|
||||
SCT_SOURCE_UNKNOWN,
|
||||
SCT_SOURCE_TLS_EXTENSION,
|
||||
SCT_SOURCE_X509V3_EXTENSION,
|
||||
SCT_SOURCE_OCSP_STAPLED_RESPONSE
|
||||
} sct_source_t;
|
||||
|
||||
typedef enum {
|
||||
SCT_VALIDATION_STATUS_NOT_SET,
|
||||
SCT_VALIDATION_STATUS_UNKNOWN_LOG,
|
||||
SCT_VALIDATION_STATUS_VALID,
|
||||
SCT_VALIDATION_STATUS_INVALID,
|
||||
SCT_VALIDATION_STATUS_UNVERIFIED,
|
||||
SCT_VALIDATION_STATUS_UNKNOWN_VERSION
|
||||
} sct_validation_status_t;
|
||||
|
||||
DEFINE_STACK_OF(SCT)
|
||||
DEFINE_STACK_OF(CTLOG)
|
||||
|
||||
/******************************************
|
||||
* CT policy evaluation context functions *
|
||||
******************************************/
|
||||
|
||||
/*
|
||||
* Creates a new, empty policy evaluation context.
|
||||
* The caller is responsible for calling CT_POLICY_EVAL_CTX_free when finished
|
||||
* with the CT_POLICY_EVAL_CTX.
|
||||
*/
|
||||
CT_POLICY_EVAL_CTX *CT_POLICY_EVAL_CTX_new(void);
|
||||
|
||||
/* Deletes a policy evaluation context and anything it owns. */
|
||||
void CT_POLICY_EVAL_CTX_free(CT_POLICY_EVAL_CTX *ctx);
|
||||
|
||||
/* Gets the peer certificate that the SCTs are for */
|
||||
X509* CT_POLICY_EVAL_CTX_get0_cert(const CT_POLICY_EVAL_CTX *ctx);
|
||||
|
||||
/*
|
||||
* Sets the certificate associated with the received SCTs.
|
||||
* Increments the reference count of cert.
|
||||
* Returns 1 on success, 0 otherwise.
|
||||
*/
|
||||
int CT_POLICY_EVAL_CTX_set1_cert(CT_POLICY_EVAL_CTX *ctx, X509 *cert);
|
||||
|
||||
/* Gets the issuer of the aforementioned certificate */
|
||||
X509* CT_POLICY_EVAL_CTX_get0_issuer(const CT_POLICY_EVAL_CTX *ctx);
|
||||
|
||||
/*
|
||||
* Sets the issuer of the certificate associated with the received SCTs.
|
||||
* Increments the reference count of issuer.
|
||||
* Returns 1 on success, 0 otherwise.
|
||||
*/
|
||||
int CT_POLICY_EVAL_CTX_set1_issuer(CT_POLICY_EVAL_CTX *ctx, X509 *issuer);
|
||||
|
||||
/* Gets the CT logs that are trusted sources of SCTs */
|
||||
const CTLOG_STORE *CT_POLICY_EVAL_CTX_get0_log_store(const CT_POLICY_EVAL_CTX *ctx);
|
||||
|
||||
/* Sets the log store that is in use. It must outlive the CT_POLICY_EVAL_CTX. */
|
||||
void CT_POLICY_EVAL_CTX_set_shared_CTLOG_STORE(CT_POLICY_EVAL_CTX *ctx,
|
||||
CTLOG_STORE *log_store);
|
||||
|
||||
/*****************
|
||||
* SCT functions *
|
||||
*****************/
|
||||
|
||||
/*
|
||||
* Creates a new, blank SCT.
|
||||
* The caller is responsible for calling SCT_free when finished with the SCT.
|
||||
*/
|
||||
SCT *SCT_new(void);
|
||||
|
||||
/*
|
||||
* Creates a new SCT from some base64-encoded strings.
|
||||
* The caller is responsible for calling SCT_free when finished with the SCT.
|
||||
*/
|
||||
SCT *SCT_new_from_base64(unsigned char version,
|
||||
const char *logid_base64,
|
||||
ct_log_entry_type_t entry_type,
|
||||
uint64_t timestamp,
|
||||
const char *extensions_base64,
|
||||
const char *signature_base64);
|
||||
|
||||
/*
|
||||
* Frees the SCT and the underlying data structures.
|
||||
*/
|
||||
void SCT_free(SCT *sct);
|
||||
|
||||
/*
|
||||
* Free a stack of SCTs, and the underlying SCTs themselves.
|
||||
* Intended to be compatible with X509V3_EXT_FREE.
|
||||
*/
|
||||
void SCT_LIST_free(STACK_OF(SCT) *a);
|
||||
|
||||
/*
|
||||
* Returns the version of the SCT.
|
||||
*/
|
||||
sct_version_t SCT_get_version(const SCT *sct);
|
||||
|
||||
/*
|
||||
* Set the version of an SCT.
|
||||
* Returns 1 on success, 0 if the version is unrecognized.
|
||||
*/
|
||||
__owur int SCT_set_version(SCT *sct, sct_version_t version);
|
||||
|
||||
/*
|
||||
* Returns the log entry type of the SCT.
|
||||
*/
|
||||
ct_log_entry_type_t SCT_get_log_entry_type(const SCT *sct);
|
||||
|
||||
/*
|
||||
* Set the log entry type of an SCT.
|
||||
* Returns 1 on success, 0 otherwise.
|
||||
*/
|
||||
__owur int SCT_set_log_entry_type(SCT *sct, ct_log_entry_type_t entry_type);
|
||||
|
||||
/*
|
||||
* Gets the ID of the log that an SCT came from.
|
||||
* Ownership of the log ID remains with the SCT.
|
||||
* Returns the length of the log ID.
|
||||
*/
|
||||
size_t SCT_get0_log_id(const SCT *sct, unsigned char **log_id);
|
||||
|
||||
/*
|
||||
* Set the log ID of an SCT to point directly to the *log_id specified.
|
||||
* The SCT takes ownership of the specified pointer.
|
||||
* Returns 1 on success, 0 otherwise.
|
||||
*/
|
||||
__owur int SCT_set0_log_id(SCT *sct, unsigned char *log_id, size_t log_id_len);
|
||||
|
||||
/*
|
||||
* Set the log ID of an SCT.
|
||||
* This makes a copy of the log_id.
|
||||
* Returns 1 on success, 0 otherwise.
|
||||
*/
|
||||
__owur int SCT_set1_log_id(SCT *sct, const unsigned char *log_id,
|
||||
size_t log_id_len);
|
||||
|
||||
/*
|
||||
* Returns the timestamp for the SCT (epoch time in milliseconds).
|
||||
*/
|
||||
uint64_t SCT_get_timestamp(const SCT *sct);
|
||||
|
||||
/*
|
||||
* Set the timestamp of an SCT (epoch time in milliseconds).
|
||||
*/
|
||||
void SCT_set_timestamp(SCT *sct, uint64_t timestamp);
|
||||
|
||||
/*
|
||||
* Return the NID for the signature used by the SCT.
|
||||
* For CT v1, this will be either NID_sha256WithRSAEncryption or
|
||||
* NID_ecdsa_with_SHA256 (or NID_undef if incorrect/unset).
|
||||
*/
|
||||
int SCT_get_signature_nid(const SCT *sct);
|
||||
|
||||
/*
|
||||
* Set the signature type of an SCT
|
||||
* For CT v1, this should be either NID_sha256WithRSAEncryption or
|
||||
* NID_ecdsa_with_SHA256.
|
||||
* Returns 1 on success, 0 otherwise.
|
||||
*/
|
||||
__owur int SCT_set_signature_nid(SCT *sct, int nid);
|
||||
|
||||
/*
|
||||
* Set *ext to point to the extension data for the SCT. ext must not be NULL.
|
||||
* The SCT retains ownership of this pointer.
|
||||
* Returns length of the data pointed to.
|
||||
*/
|
||||
size_t SCT_get0_extensions(const SCT *sct, unsigned char **ext);
|
||||
|
||||
/*
|
||||
* Set the extensions of an SCT to point directly to the *ext specified.
|
||||
* The SCT takes ownership of the specified pointer.
|
||||
*/
|
||||
void SCT_set0_extensions(SCT *sct, unsigned char *ext, size_t ext_len);
|
||||
|
||||
/*
|
||||
* Set the extensions of an SCT.
|
||||
* This takes a copy of the ext.
|
||||
* Returns 1 on success, 0 otherwise.
|
||||
*/
|
||||
__owur int SCT_set1_extensions(SCT *sct, const unsigned char *ext,
|
||||
size_t ext_len);
|
||||
|
||||
/*
|
||||
* Set *sig to point to the signature for the SCT. sig must not be NULL.
|
||||
* The SCT retains ownership of this pointer.
|
||||
* Returns length of the data pointed to.
|
||||
*/
|
||||
size_t SCT_get0_signature(const SCT *sct, unsigned char **sig);
|
||||
|
||||
/*
|
||||
* Set the signature of an SCT to point directly to the *sig specified.
|
||||
* The SCT takes ownership of the specified pointer.
|
||||
*/
|
||||
void SCT_set0_signature(SCT *sct, unsigned char *sig, size_t sig_len);
|
||||
|
||||
/*
|
||||
* Set the signature of an SCT to be a copy of the *sig specified.
|
||||
* Returns 1 on success, 0 otherwise.
|
||||
*/
|
||||
__owur int SCT_set1_signature(SCT *sct, const unsigned char *sig,
|
||||
size_t sig_len);
|
||||
|
||||
/*
|
||||
* The origin of this SCT, e.g. TLS extension, OCSP response, etc.
|
||||
*/
|
||||
sct_source_t SCT_get_source(const SCT *sct);
|
||||
|
||||
/*
|
||||
* Set the origin of this SCT, e.g. TLS extension, OCSP response, etc.
|
||||
* Returns 1 on success, 0 otherwise.
|
||||
*/
|
||||
__owur int SCT_set_source(SCT *sct, sct_source_t source);
|
||||
|
||||
/*
|
||||
* Returns a text string describing the validation status of |sct|.
|
||||
*/
|
||||
const char *SCT_validation_status_string(const SCT *sct);
|
||||
|
||||
/*
|
||||
* Pretty-prints an |sct| to |out|.
|
||||
* It will be indented by the number of spaces specified by |indent|.
|
||||
* If |logs| is not NULL, it will be used to lookup the CT log that the SCT came
|
||||
* from, so that the log name can be printed.
|
||||
*/
|
||||
void SCT_print(const SCT *sct, BIO *out, int indent, const CTLOG_STORE *logs);
|
||||
|
||||
/*
|
||||
* Pretty-prints an |sct_list| to |out|.
|
||||
* It will be indented by the number of spaces specified by |indent|.
|
||||
* SCTs will be delimited by |separator|.
|
||||
* If |logs| is not NULL, it will be used to lookup the CT log that each SCT
|
||||
* came from, so that the log names can be printed.
|
||||
*/
|
||||
void SCT_LIST_print(const STACK_OF(SCT) *sct_list, BIO *out, int indent,
|
||||
const char *separator, const CTLOG_STORE *logs);
|
||||
|
||||
/*
|
||||
* Gets the last result of validating this SCT.
|
||||
* If it has not been validated yet, returns SCT_VALIDATION_STATUS_NOT_SET.
|
||||
*/
|
||||
sct_validation_status_t SCT_get_validation_status(const SCT *sct);
|
||||
|
||||
/*
|
||||
* Validates the given SCT with the provided context.
|
||||
* Sets the "validation_status" field of the SCT.
|
||||
* Returns 1 if the SCT is valid and the signature verifies.
|
||||
* Returns 0 if the SCT is invalid or could not be verified.
|
||||
* Returns -1 if an error occurs.
|
||||
*/
|
||||
__owur int SCT_validate(SCT *sct, const CT_POLICY_EVAL_CTX *ctx);
|
||||
|
||||
/*
|
||||
* Validates the given list of SCTs with the provided context.
|
||||
* Sets the "validation_status" field of each SCT.
|
||||
* Returns 1 if there are no invalid SCTs and all signatures verify.
|
||||
* Returns 0 if at least one SCT is invalid or could not be verified.
|
||||
* Returns a negative integer if an error occurs.
|
||||
*/
|
||||
__owur int SCT_LIST_validate(const STACK_OF(SCT) *scts,
|
||||
CT_POLICY_EVAL_CTX *ctx);
|
||||
|
||||
|
||||
/*********************************
|
||||
* SCT parsing and serialisation *
|
||||
*********************************/
|
||||
|
||||
/*
|
||||
* Serialize (to TLS format) a stack of SCTs and return the length.
|
||||
* "a" must not be NULL.
|
||||
* If "pp" is NULL, just return the length of what would have been serialized.
|
||||
* If "pp" is not NULL and "*pp" is null, function will allocate a new pointer
|
||||
* for data that caller is responsible for freeing (only if function returns
|
||||
* successfully).
|
||||
* If "pp" is NULL and "*pp" is not NULL, caller is responsible for ensuring
|
||||
* that "*pp" is large enough to accept all of the serialized data.
|
||||
* Returns < 0 on error, >= 0 indicating bytes written (or would have been)
|
||||
* on success.
|
||||
*/
|
||||
__owur int i2o_SCT_LIST(const STACK_OF(SCT) *a, unsigned char **pp);
|
||||
|
||||
/*
|
||||
* Convert TLS format SCT list to a stack of SCTs.
|
||||
* If "a" or "*a" is NULL, a new stack will be created that the caller is
|
||||
* responsible for freeing (by calling SCT_LIST_free).
|
||||
* "**pp" and "*pp" must not be NULL.
|
||||
* Upon success, "*pp" will point to after the last bytes read, and a stack
|
||||
* will be returned.
|
||||
* Upon failure, a NULL pointer will be returned, and the position of "*pp" is
|
||||
* not defined.
|
||||
*/
|
||||
STACK_OF(SCT) *o2i_SCT_LIST(STACK_OF(SCT) **a, const unsigned char **pp,
|
||||
size_t len);
|
||||
|
||||
/*
|
||||
* Serialize (to DER format) a stack of SCTs and return the length.
|
||||
* "a" must not be NULL.
|
||||
* If "pp" is NULL, just returns the length of what would have been serialized.
|
||||
* If "pp" is not NULL and "*pp" is null, function will allocate a new pointer
|
||||
* for data that caller is responsible for freeing (only if function returns
|
||||
* successfully).
|
||||
* If "pp" is NULL and "*pp" is not NULL, caller is responsible for ensuring
|
||||
* that "*pp" is large enough to accept all of the serialized data.
|
||||
* Returns < 0 on error, >= 0 indicating bytes written (or would have been)
|
||||
* on success.
|
||||
*/
|
||||
__owur int i2d_SCT_LIST(const STACK_OF(SCT) *a, unsigned char **pp);
|
||||
|
||||
/*
|
||||
* Parses an SCT list in DER format and returns it.
|
||||
* If "a" or "*a" is NULL, a new stack will be created that the caller is
|
||||
* responsible for freeing (by calling SCT_LIST_free).
|
||||
* "**pp" and "*pp" must not be NULL.
|
||||
* Upon success, "*pp" will point to after the last bytes read, and a stack
|
||||
* will be returned.
|
||||
* Upon failure, a NULL pointer will be returned, and the position of "*pp" is
|
||||
* not defined.
|
||||
*/
|
||||
STACK_OF(SCT) *d2i_SCT_LIST(STACK_OF(SCT) **a, const unsigned char **pp,
|
||||
long len);
|
||||
|
||||
/*
|
||||
* Serialize (to TLS format) an |sct| and write it to |out|.
|
||||
* If |out| is null, no SCT will be output but the length will still be returned.
|
||||
* If |out| points to a null pointer, a string will be allocated to hold the
|
||||
* TLS-format SCT. It is the responsibility of the caller to free it.
|
||||
* If |out| points to an allocated string, the TLS-format SCT will be written
|
||||
* to it.
|
||||
* The length of the SCT in TLS format will be returned.
|
||||
*/
|
||||
__owur int i2o_SCT(const SCT *sct, unsigned char **out);
|
||||
|
||||
/*
|
||||
* Parses an SCT in TLS format and returns it.
|
||||
* If |psct| is not null, it will end up pointing to the parsed SCT. If it
|
||||
* already points to a non-null pointer, the pointer will be free'd.
|
||||
* |in| should be a pointer to a string containing the TLS-format SCT.
|
||||
* |in| will be advanced to the end of the SCT if parsing succeeds.
|
||||
* |len| should be the length of the SCT in |in|.
|
||||
* Returns NULL if an error occurs.
|
||||
* If the SCT is an unsupported version, only the SCT's 'sct' and 'sct_len'
|
||||
* fields will be populated (with |in| and |len| respectively).
|
||||
*/
|
||||
SCT *o2i_SCT(SCT **psct, const unsigned char **in, size_t len);
|
||||
|
||||
/********************
|
||||
* CT log functions *
|
||||
********************/
|
||||
|
||||
/*
|
||||
* Creates a new CT log instance with the given |public_key| and |name|.
|
||||
* Takes ownership of |public_key| but copies |name|.
|
||||
* Returns NULL if malloc fails or if |public_key| cannot be converted to DER.
|
||||
* Should be deleted by the caller using CTLOG_free when no longer needed.
|
||||
*/
|
||||
CTLOG *CTLOG_new(EVP_PKEY *public_key, const char *name);
|
||||
|
||||
/*
|
||||
* Creates a new CTLOG instance with the base64-encoded SubjectPublicKeyInfo DER
|
||||
* in |pkey_base64|. The |name| is a string to help users identify this log.
|
||||
* Returns 1 on success, 0 on failure.
|
||||
* Should be deleted by the caller using CTLOG_free when no longer needed.
|
||||
*/
|
||||
int CTLOG_new_from_base64(CTLOG ** ct_log,
|
||||
const char *pkey_base64, const char *name);
|
||||
|
||||
/*
|
||||
* Deletes a CT log instance and its fields.
|
||||
*/
|
||||
void CTLOG_free(CTLOG *log);
|
||||
|
||||
/* Gets the name of the CT log */
|
||||
const char *CTLOG_get0_name(const CTLOG *log);
|
||||
/* Gets the ID of the CT log */
|
||||
void CTLOG_get0_log_id(const CTLOG *log, const uint8_t **log_id,
|
||||
size_t *log_id_len);
|
||||
/* Gets the public key of the CT log */
|
||||
EVP_PKEY *CTLOG_get0_public_key(const CTLOG *log);
|
||||
|
||||
/**************************
|
||||
* CT log store functions *
|
||||
**************************/
|
||||
|
||||
/*
|
||||
* Creates a new CT log store.
|
||||
* Should be deleted by the caller using CTLOG_STORE_free when no longer needed.
|
||||
*/
|
||||
CTLOG_STORE *CTLOG_STORE_new(void);
|
||||
|
||||
/*
|
||||
* Deletes a CT log store and all of the CT log instances held within.
|
||||
*/
|
||||
void CTLOG_STORE_free(CTLOG_STORE *store);
|
||||
|
||||
/*
|
||||
* Finds a CT log in the store based on its log ID.
|
||||
* Returns the CT log, or NULL if no match is found.
|
||||
*/
|
||||
const CTLOG *CTLOG_STORE_get0_log_by_id(const CTLOG_STORE *store,
|
||||
const uint8_t *log_id,
|
||||
size_t log_id_len);
|
||||
|
||||
/*
|
||||
* Loads a CT log list into a |store| from a |file|.
|
||||
* Returns 1 if loading is successful, or 0 otherwise.
|
||||
*/
|
||||
__owur int CTLOG_STORE_load_file(CTLOG_STORE *store, const char *file);
|
||||
|
||||
/*
|
||||
* Loads the default CT log list into a |store|.
|
||||
* See internal/cryptlib.h for the environment variable and file path that are
|
||||
* consulted to find the default file.
|
||||
* Returns 1 if loading is successful, or 0 otherwise.
|
||||
*/
|
||||
__owur int CTLOG_STORE_load_default_file(CTLOG_STORE *store);
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
/*
|
||||
* The following lines are auto generated by the script mkerr.pl. Any changes
|
||||
* made after this point may be overwritten when the script is next run.
|
||||
*/
|
||||
|
||||
int ERR_load_CT_strings(void);
|
||||
|
||||
/* Error codes for the CT functions. */
|
||||
|
||||
/* Function codes. */
|
||||
# define CT_F_CTLOG_NEW 117
|
||||
# define CT_F_CTLOG_NEW_FROM_BASE64 118
|
||||
# define CT_F_CTLOG_NEW_FROM_CONF 119
|
||||
# define CT_F_CTLOG_NEW_NULL 120
|
||||
# define CT_F_CTLOG_STORE_LOAD_CTX_NEW 122
|
||||
# define CT_F_CTLOG_STORE_LOAD_FILE 123
|
||||
# define CT_F_CTLOG_STORE_LOAD_LOG 130
|
||||
# define CT_F_CTLOG_STORE_NEW 131
|
||||
# define CT_F_CT_BASE64_DECODE 124
|
||||
# define CT_F_CT_POLICY_EVAL_CTX_NEW 133
|
||||
# define CT_F_CT_V1_LOG_ID_FROM_PKEY 125
|
||||
# define CT_F_I2O_SCT 107
|
||||
# define CT_F_I2O_SCT_LIST 108
|
||||
# define CT_F_I2O_SCT_SIGNATURE 109
|
||||
# define CT_F_O2I_SCT 110
|
||||
# define CT_F_O2I_SCT_LIST 111
|
||||
# define CT_F_O2I_SCT_SIGNATURE 112
|
||||
# define CT_F_SCT_CTX_NEW 126
|
||||
# define CT_F_SCT_NEW 100
|
||||
# define CT_F_SCT_NEW_FROM_BASE64 127
|
||||
# define CT_F_SCT_SET0_LOG_ID 101
|
||||
# define CT_F_SCT_SET1_EXTENSIONS 114
|
||||
# define CT_F_SCT_SET1_LOG_ID 115
|
||||
# define CT_F_SCT_SET1_SIGNATURE 116
|
||||
# define CT_F_SCT_SET_LOG_ENTRY_TYPE 102
|
||||
# define CT_F_SCT_SET_SIGNATURE_NID 103
|
||||
# define CT_F_SCT_SET_VERSION 104
|
||||
# define CT_F_SCT_CTX_VERIFY 128
|
||||
|
||||
/* Reason codes. */
|
||||
# define CT_R_BASE64_DECODE_ERROR 108
|
||||
# define CT_R_INVALID_LOG_ID_LENGTH 100
|
||||
# define CT_R_LOG_CONF_INVALID 109
|
||||
# define CT_R_LOG_CONF_INVALID_KEY 110
|
||||
# define CT_R_LOG_CONF_MISSING_DESCRIPTION 111
|
||||
# define CT_R_LOG_CONF_MISSING_KEY 112
|
||||
# define CT_R_LOG_KEY_INVALID 113
|
||||
# define CT_R_SCT_INVALID 104
|
||||
# define CT_R_SCT_INVALID_SIGNATURE 107
|
||||
# define CT_R_SCT_LIST_INVALID 105
|
||||
# define CT_R_SCT_LOG_ID_MISMATCH 114
|
||||
# define CT_R_SCT_NOT_SET 106
|
||||
# define CT_R_SCT_UNSUPPORTED_VERSION 115
|
||||
# define CT_R_UNRECOGNIZED_SIGNATURE_NID 101
|
||||
# define CT_R_UNSUPPORTED_ENTRY_TYPE 102
|
||||
# define CT_R_UNSUPPORTED_VERSION 103
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
|
@ -0,0 +1,174 @@
|
|||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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_H
|
||||
# define HEADER_DES_H
|
||||
|
||||
# include <openssl/opensslconf.h>
|
||||
|
||||
# ifndef OPENSSL_NO_DES
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
# endif
|
||||
# include <openssl/e_os2.h>
|
||||
|
||||
typedef unsigned int DES_LONG;
|
||||
|
||||
# ifdef OPENSSL_BUILD_SHLIBCRYPTO
|
||||
# undef OPENSSL_EXTERN
|
||||
# define OPENSSL_EXTERN OPENSSL_EXPORT
|
||||
# endif
|
||||
|
||||
typedef unsigned char DES_cblock[8];
|
||||
typedef /* const */ unsigned char const_DES_cblock[8];
|
||||
/*
|
||||
* With "const", gcc 2.8.1 on Solaris thinks that DES_cblock * and
|
||||
* const_DES_cblock * are incompatible pointer types.
|
||||
*/
|
||||
|
||||
typedef struct DES_ks {
|
||||
union {
|
||||
DES_cblock cblock;
|
||||
/*
|
||||
* make sure things are correct size on machines with 8 byte longs
|
||||
*/
|
||||
DES_LONG deslong[2];
|
||||
} ks[16];
|
||||
} DES_key_schedule;
|
||||
|
||||
# define DES_KEY_SZ (sizeof(DES_cblock))
|
||||
# define DES_SCHEDULE_SZ (sizeof(DES_key_schedule))
|
||||
|
||||
# define DES_ENCRYPT 1
|
||||
# define DES_DECRYPT 0
|
||||
|
||||
# define DES_CBC_MODE 0
|
||||
# define DES_PCBC_MODE 1
|
||||
|
||||
# define DES_ecb2_encrypt(i,o,k1,k2,e) \
|
||||
DES_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e))
|
||||
|
||||
# define DES_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \
|
||||
DES_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e))
|
||||
|
||||
# define DES_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \
|
||||
DES_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e))
|
||||
|
||||
# define DES_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \
|
||||
DES_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n))
|
||||
|
||||
OPENSSL_DECLARE_GLOBAL(int, DES_check_key); /* defaults to false */
|
||||
# define DES_check_key OPENSSL_GLOBAL_REF(DES_check_key)
|
||||
|
||||
const char *DES_options(void);
|
||||
void DES_ecb3_encrypt(const_DES_cblock *input, DES_cblock *output,
|
||||
DES_key_schedule *ks1, DES_key_schedule *ks2,
|
||||
DES_key_schedule *ks3, int enc);
|
||||
DES_LONG DES_cbc_cksum(const unsigned char *input, DES_cblock *output,
|
||||
long length, DES_key_schedule *schedule,
|
||||
const_DES_cblock *ivec);
|
||||
/* DES_cbc_encrypt does not update the IV! Use DES_ncbc_encrypt instead. */
|
||||
void DES_cbc_encrypt(const unsigned char *input, unsigned char *output,
|
||||
long length, DES_key_schedule *schedule,
|
||||
DES_cblock *ivec, int enc);
|
||||
void DES_ncbc_encrypt(const unsigned char *input, unsigned char *output,
|
||||
long length, DES_key_schedule *schedule,
|
||||
DES_cblock *ivec, int enc);
|
||||
void DES_xcbc_encrypt(const unsigned char *input, unsigned char *output,
|
||||
long length, DES_key_schedule *schedule,
|
||||
DES_cblock *ivec, const_DES_cblock *inw,
|
||||
const_DES_cblock *outw, int enc);
|
||||
void DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits,
|
||||
long length, DES_key_schedule *schedule,
|
||||
DES_cblock *ivec, int enc);
|
||||
void DES_ecb_encrypt(const_DES_cblock *input, DES_cblock *output,
|
||||
DES_key_schedule *ks, int enc);
|
||||
|
||||
/*
|
||||
* This is the DES encryption function that gets called by just about every
|
||||
* other DES routine in the library. You should not use this function except
|
||||
* to implement 'modes' of DES. I say this because the functions that call
|
||||
* this routine do the conversion from 'char *' to long, and this needs to be
|
||||
* done to make sure 'non-aligned' memory access do not occur. The
|
||||
* characters are loaded 'little endian'. Data is a pointer to 2 unsigned
|
||||
* long's and ks is the DES_key_schedule to use. enc, is non zero specifies
|
||||
* encryption, zero if decryption.
|
||||
*/
|
||||
void DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc);
|
||||
|
||||
/*
|
||||
* This functions is the same as DES_encrypt1() except that the DES initial
|
||||
* permutation (IP) and final permutation (FP) have been left out. As for
|
||||
* DES_encrypt1(), you should not use this function. It is used by the
|
||||
* routines in the library that implement triple DES. IP() DES_encrypt2()
|
||||
* DES_encrypt2() DES_encrypt2() FP() is the same as DES_encrypt1()
|
||||
* DES_encrypt1() DES_encrypt1() except faster :-).
|
||||
*/
|
||||
void DES_encrypt2(DES_LONG *data, DES_key_schedule *ks, int enc);
|
||||
|
||||
void DES_encrypt3(DES_LONG *data, DES_key_schedule *ks1,
|
||||
DES_key_schedule *ks2, DES_key_schedule *ks3);
|
||||
void DES_decrypt3(DES_LONG *data, DES_key_schedule *ks1,
|
||||
DES_key_schedule *ks2, DES_key_schedule *ks3);
|
||||
void DES_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output,
|
||||
long length,
|
||||
DES_key_schedule *ks1, DES_key_schedule *ks2,
|
||||
DES_key_schedule *ks3, DES_cblock *ivec, int enc);
|
||||
void DES_ede3_cfb64_encrypt(const unsigned char *in, unsigned char *out,
|
||||
long length, DES_key_schedule *ks1,
|
||||
DES_key_schedule *ks2, DES_key_schedule *ks3,
|
||||
DES_cblock *ivec, int *num, int enc);
|
||||
void DES_ede3_cfb_encrypt(const unsigned char *in, unsigned char *out,
|
||||
int numbits, long length, DES_key_schedule *ks1,
|
||||
DES_key_schedule *ks2, DES_key_schedule *ks3,
|
||||
DES_cblock *ivec, int enc);
|
||||
void DES_ede3_ofb64_encrypt(const unsigned char *in, unsigned char *out,
|
||||
long length, DES_key_schedule *ks1,
|
||||
DES_key_schedule *ks2, DES_key_schedule *ks3,
|
||||
DES_cblock *ivec, int *num);
|
||||
char *DES_fcrypt(const char *buf, const char *salt, char *ret);
|
||||
char *DES_crypt(const char *buf, const char *salt);
|
||||
void DES_ofb_encrypt(const unsigned char *in, unsigned char *out, int numbits,
|
||||
long length, DES_key_schedule *schedule,
|
||||
DES_cblock *ivec);
|
||||
void DES_pcbc_encrypt(const unsigned char *input, unsigned char *output,
|
||||
long length, DES_key_schedule *schedule,
|
||||
DES_cblock *ivec, int enc);
|
||||
DES_LONG DES_quad_cksum(const unsigned char *input, DES_cblock output[],
|
||||
long length, int out_count, DES_cblock *seed);
|
||||
int DES_random_key(DES_cblock *ret);
|
||||
void DES_set_odd_parity(DES_cblock *key);
|
||||
int DES_check_key_parity(const_DES_cblock *key);
|
||||
int DES_is_weak_key(const_DES_cblock *key);
|
||||
/*
|
||||
* DES_set_key (= set_key = DES_key_sched = key_sched) calls
|
||||
* DES_set_key_checked if global variable DES_check_key is set,
|
||||
* DES_set_key_unchecked otherwise.
|
||||
*/
|
||||
int DES_set_key(const_DES_cblock *key, DES_key_schedule *schedule);
|
||||
int DES_key_sched(const_DES_cblock *key, DES_key_schedule *schedule);
|
||||
int DES_set_key_checked(const_DES_cblock *key, DES_key_schedule *schedule);
|
||||
void DES_set_key_unchecked(const_DES_cblock *key, DES_key_schedule *schedule);
|
||||
void DES_string_to_key(const char *str, DES_cblock *key);
|
||||
void DES_string_to_2keys(const char *str, DES_cblock *key1, DES_cblock *key2);
|
||||
void DES_cfb64_encrypt(const unsigned char *in, unsigned char *out,
|
||||
long length, DES_key_schedule *schedule,
|
||||
DES_cblock *ivec, int *num, int enc);
|
||||
void DES_ofb64_encrypt(const unsigned char *in, unsigned char *out,
|
||||
long length, DES_key_schedule *schedule,
|
||||
DES_cblock *ivec, int *num);
|
||||
|
||||
# define DES_fixup_key_parity DES_set_odd_parity
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,343 @@
|
|||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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_DH_H
|
||||
# define HEADER_DH_H
|
||||
|
||||
# include <openssl/opensslconf.h>
|
||||
|
||||
# ifndef OPENSSL_NO_DH
|
||||
# include <openssl/e_os2.h>
|
||||
# include <openssl/bio.h>
|
||||
# include <openssl/asn1.h>
|
||||
# include <openssl/ossl_typ.h>
|
||||
# if OPENSSL_API_COMPAT < 0x10100000L
|
||||
# include <openssl/bn.h>
|
||||
# endif
|
||||
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
# endif
|
||||
|
||||
# ifndef OPENSSL_DH_MAX_MODULUS_BITS
|
||||
# define OPENSSL_DH_MAX_MODULUS_BITS 10000
|
||||
# endif
|
||||
|
||||
# define OPENSSL_DH_FIPS_MIN_MODULUS_BITS 1024
|
||||
|
||||
# define DH_FLAG_CACHE_MONT_P 0x01
|
||||
|
||||
# if OPENSSL_API_COMPAT < 0x10100000L
|
||||
/*
|
||||
* Does nothing. Previously this switched off constant time behaviour.
|
||||
*/
|
||||
# define DH_FLAG_NO_EXP_CONSTTIME 0x00
|
||||
# endif
|
||||
|
||||
/*
|
||||
* If this flag is set the DH method is FIPS compliant and can be used in
|
||||
* FIPS mode. This is set in the validated module method. If an application
|
||||
* sets this flag in its own methods it is its responsibility to ensure the
|
||||
* result is compliant.
|
||||
*/
|
||||
|
||||
# define DH_FLAG_FIPS_METHOD 0x0400
|
||||
|
||||
/*
|
||||
* If this flag is set the operations normally disabled in FIPS mode are
|
||||
* permitted it is then the applications responsibility to ensure that the
|
||||
* usage is compliant.
|
||||
*/
|
||||
|
||||
# define DH_FLAG_NON_FIPS_ALLOW 0x0400
|
||||
|
||||
/* Already defined in ossl_typ.h */
|
||||
/* typedef struct dh_st DH; */
|
||||
/* typedef struct dh_method DH_METHOD; */
|
||||
|
||||
DECLARE_ASN1_ITEM(DHparams)
|
||||
|
||||
# define DH_GENERATOR_2 2
|
||||
/* #define DH_GENERATOR_3 3 */
|
||||
# define DH_GENERATOR_5 5
|
||||
|
||||
/* DH_check error codes */
|
||||
# define DH_CHECK_P_NOT_PRIME 0x01
|
||||
# define DH_CHECK_P_NOT_SAFE_PRIME 0x02
|
||||
# define DH_UNABLE_TO_CHECK_GENERATOR 0x04
|
||||
# define DH_NOT_SUITABLE_GENERATOR 0x08
|
||||
# define DH_CHECK_Q_NOT_PRIME 0x10
|
||||
# define DH_CHECK_INVALID_Q_VALUE 0x20
|
||||
# define DH_CHECK_INVALID_J_VALUE 0x40
|
||||
|
||||
/* DH_check_pub_key error codes */
|
||||
# define DH_CHECK_PUBKEY_TOO_SMALL 0x01
|
||||
# define DH_CHECK_PUBKEY_TOO_LARGE 0x02
|
||||
# define DH_CHECK_PUBKEY_INVALID 0x04
|
||||
|
||||
/*
|
||||
* primes p where (p-1)/2 is prime too are called "safe"; we define this for
|
||||
* backward compatibility:
|
||||
*/
|
||||
# define DH_CHECK_P_NOT_STRONG_PRIME DH_CHECK_P_NOT_SAFE_PRIME
|
||||
|
||||
# define d2i_DHparams_fp(fp,x) (DH *)ASN1_d2i_fp((char *(*)())DH_new, \
|
||||
(char *(*)())d2i_DHparams,(fp),(unsigned char **)(x))
|
||||
# define i2d_DHparams_fp(fp,x) ASN1_i2d_fp(i2d_DHparams,(fp), \
|
||||
(unsigned char *)(x))
|
||||
# define d2i_DHparams_bio(bp,x) ASN1_d2i_bio_of(DH,DH_new,d2i_DHparams,bp,x)
|
||||
# define i2d_DHparams_bio(bp,x) ASN1_i2d_bio_of_const(DH,i2d_DHparams,bp,x)
|
||||
|
||||
DH *DHparams_dup(DH *);
|
||||
|
||||
const DH_METHOD *DH_OpenSSL(void);
|
||||
|
||||
void DH_set_default_method(const DH_METHOD *meth);
|
||||
const DH_METHOD *DH_get_default_method(void);
|
||||
int DH_set_method(DH *dh, const DH_METHOD *meth);
|
||||
DH *DH_new_method(ENGINE *engine);
|
||||
|
||||
DH *DH_new(void);
|
||||
void DH_free(DH *dh);
|
||||
int DH_up_ref(DH *dh);
|
||||
int DH_bits(const DH *dh);
|
||||
int DH_size(const DH *dh);
|
||||
int DH_security_bits(const DH *dh);
|
||||
#define DH_get_ex_new_index(l, p, newf, dupf, freef) \
|
||||
CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_DH, l, p, newf, dupf, freef)
|
||||
int DH_set_ex_data(DH *d, int idx, void *arg);
|
||||
void *DH_get_ex_data(DH *d, int idx);
|
||||
|
||||
/* Deprecated version */
|
||||
DEPRECATEDIN_0_9_8(DH *DH_generate_parameters(int prime_len, int generator,
|
||||
void (*callback) (int, int,
|
||||
void *),
|
||||
void *cb_arg))
|
||||
|
||||
/* New version */
|
||||
int DH_generate_parameters_ex(DH *dh, int prime_len, int generator,
|
||||
BN_GENCB *cb);
|
||||
|
||||
int DH_check(const DH *dh, int *codes);
|
||||
int DH_check_pub_key(const DH *dh, const BIGNUM *pub_key, int *codes);
|
||||
int DH_generate_key(DH *dh);
|
||||
int DH_compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh);
|
||||
int DH_compute_key_padded(unsigned char *key, const BIGNUM *pub_key, DH *dh);
|
||||
DH *d2i_DHparams(DH **a, const unsigned char **pp, long length);
|
||||
int i2d_DHparams(const DH *a, unsigned char **pp);
|
||||
DH *d2i_DHxparams(DH **a, const unsigned char **pp, long length);
|
||||
int i2d_DHxparams(const DH *a, unsigned char **pp);
|
||||
# ifndef OPENSSL_NO_STDIO
|
||||
int DHparams_print_fp(FILE *fp, const DH *x);
|
||||
# endif
|
||||
int DHparams_print(BIO *bp, const DH *x);
|
||||
|
||||
/* RFC 5114 parameters */
|
||||
DH *DH_get_1024_160(void);
|
||||
DH *DH_get_2048_224(void);
|
||||
DH *DH_get_2048_256(void);
|
||||
|
||||
# ifndef OPENSSL_NO_CMS
|
||||
/* RFC2631 KDF */
|
||||
int DH_KDF_X9_42(unsigned char *out, size_t outlen,
|
||||
const unsigned char *Z, size_t Zlen,
|
||||
ASN1_OBJECT *key_oid,
|
||||
const unsigned char *ukm, size_t ukmlen, const EVP_MD *md);
|
||||
# endif
|
||||
|
||||
void DH_get0_pqg(const DH *dh,
|
||||
const BIGNUM **p, const BIGNUM **q, const BIGNUM **g);
|
||||
int DH_set0_pqg(DH *dh, BIGNUM *p, BIGNUM *q, BIGNUM *g);
|
||||
void DH_get0_key(const DH *dh,
|
||||
const BIGNUM **pub_key, const BIGNUM **priv_key);
|
||||
int DH_set0_key(DH *dh, BIGNUM *pub_key, BIGNUM *priv_key);
|
||||
void DH_clear_flags(DH *dh, int flags);
|
||||
int DH_test_flags(const DH *dh, int flags);
|
||||
void DH_set_flags(DH *dh, int flags);
|
||||
ENGINE *DH_get0_engine(DH *d);
|
||||
long DH_get_length(const DH *dh);
|
||||
int DH_set_length(DH *dh, long length);
|
||||
|
||||
DH_METHOD *DH_meth_new(const char *name, int flags);
|
||||
void DH_meth_free(DH_METHOD *dhm);
|
||||
DH_METHOD *DH_meth_dup(const DH_METHOD *dhm);
|
||||
const char *DH_meth_get0_name(const DH_METHOD *dhm);
|
||||
int DH_meth_set1_name(DH_METHOD *dhm, const char *name);
|
||||
int DH_meth_get_flags(DH_METHOD *dhm);
|
||||
int DH_meth_set_flags(DH_METHOD *dhm, int flags);
|
||||
void *DH_meth_get0_app_data(const DH_METHOD *dhm);
|
||||
int DH_meth_set0_app_data(DH_METHOD *dhm, void *app_data);
|
||||
int (*DH_meth_get_generate_key(const DH_METHOD *dhm)) (DH *);
|
||||
int DH_meth_set_generate_key(DH_METHOD *dhm, int (*generate_key) (DH *));
|
||||
int (*DH_meth_get_compute_key(const DH_METHOD *dhm))
|
||||
(unsigned char *key, const BIGNUM *pub_key, DH *dh);
|
||||
int DH_meth_set_compute_key(DH_METHOD *dhm,
|
||||
int (*compute_key) (unsigned char *key, const BIGNUM *pub_key, DH *dh));
|
||||
int (*DH_meth_get_bn_mod_exp(const DH_METHOD *dhm))
|
||||
(const DH *, BIGNUM *, const BIGNUM *, const BIGNUM *, const BIGNUM *,
|
||||
BN_CTX *, BN_MONT_CTX *);
|
||||
int DH_meth_set_bn_mod_exp(DH_METHOD *dhm,
|
||||
int (*bn_mod_exp) (const DH *, BIGNUM *, const BIGNUM *, const BIGNUM *,
|
||||
const BIGNUM *, BN_CTX *, BN_MONT_CTX *));
|
||||
int (*DH_meth_get_init(const DH_METHOD *dhm))(DH *);
|
||||
int DH_meth_set_init(DH_METHOD *dhm, int (*init)(DH *));
|
||||
int (*DH_meth_get_finish(const DH_METHOD *dhm)) (DH *);
|
||||
int DH_meth_set_finish(DH_METHOD *dhm, int (*finish) (DH *));
|
||||
int (*DH_meth_get_generate_params(const DH_METHOD *dhm))
|
||||
(DH *, int, int, BN_GENCB *);
|
||||
int DH_meth_set_generate_params(DH_METHOD *dhm,
|
||||
int (*generate_params) (DH *, int, int, BN_GENCB *));
|
||||
|
||||
|
||||
# define EVP_PKEY_CTX_set_dh_paramgen_prime_len(ctx, len) \
|
||||
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \
|
||||
EVP_PKEY_CTRL_DH_PARAMGEN_PRIME_LEN, len, NULL)
|
||||
|
||||
# define EVP_PKEY_CTX_set_dh_paramgen_subprime_len(ctx, len) \
|
||||
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \
|
||||
EVP_PKEY_CTRL_DH_PARAMGEN_SUBPRIME_LEN, len, NULL)
|
||||
|
||||
# define EVP_PKEY_CTX_set_dh_paramgen_type(ctx, typ) \
|
||||
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \
|
||||
EVP_PKEY_CTRL_DH_PARAMGEN_TYPE, typ, NULL)
|
||||
|
||||
# define EVP_PKEY_CTX_set_dh_paramgen_generator(ctx, gen) \
|
||||
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \
|
||||
EVP_PKEY_CTRL_DH_PARAMGEN_GENERATOR, gen, NULL)
|
||||
|
||||
# define EVP_PKEY_CTX_set_dh_rfc5114(ctx, gen) \
|
||||
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, EVP_PKEY_OP_PARAMGEN, \
|
||||
EVP_PKEY_CTRL_DH_RFC5114, gen, NULL)
|
||||
|
||||
# define EVP_PKEY_CTX_set_dhx_rfc5114(ctx, gen) \
|
||||
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, EVP_PKEY_OP_PARAMGEN, \
|
||||
EVP_PKEY_CTRL_DH_RFC5114, gen, NULL)
|
||||
|
||||
# define EVP_PKEY_CTX_set_dh_kdf_type(ctx, kdf) \
|
||||
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \
|
||||
EVP_PKEY_OP_DERIVE, \
|
||||
EVP_PKEY_CTRL_DH_KDF_TYPE, kdf, NULL)
|
||||
|
||||
# define EVP_PKEY_CTX_get_dh_kdf_type(ctx) \
|
||||
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \
|
||||
EVP_PKEY_OP_DERIVE, \
|
||||
EVP_PKEY_CTRL_DH_KDF_TYPE, -2, NULL)
|
||||
|
||||
# define EVP_PKEY_CTX_set0_dh_kdf_oid(ctx, oid) \
|
||||
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \
|
||||
EVP_PKEY_OP_DERIVE, \
|
||||
EVP_PKEY_CTRL_DH_KDF_OID, 0, (void *)oid)
|
||||
|
||||
# define EVP_PKEY_CTX_get0_dh_kdf_oid(ctx, poid) \
|
||||
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \
|
||||
EVP_PKEY_OP_DERIVE, \
|
||||
EVP_PKEY_CTRL_GET_DH_KDF_OID, 0, (void *)poid)
|
||||
|
||||
# define EVP_PKEY_CTX_set_dh_kdf_md(ctx, md) \
|
||||
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \
|
||||
EVP_PKEY_OP_DERIVE, \
|
||||
EVP_PKEY_CTRL_DH_KDF_MD, 0, (void *)md)
|
||||
|
||||
# define EVP_PKEY_CTX_get_dh_kdf_md(ctx, pmd) \
|
||||
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \
|
||||
EVP_PKEY_OP_DERIVE, \
|
||||
EVP_PKEY_CTRL_GET_DH_KDF_MD, 0, (void *)pmd)
|
||||
|
||||
# define EVP_PKEY_CTX_set_dh_kdf_outlen(ctx, len) \
|
||||
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \
|
||||
EVP_PKEY_OP_DERIVE, \
|
||||
EVP_PKEY_CTRL_DH_KDF_OUTLEN, len, NULL)
|
||||
|
||||
# define EVP_PKEY_CTX_get_dh_kdf_outlen(ctx, plen) \
|
||||
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \
|
||||
EVP_PKEY_OP_DERIVE, \
|
||||
EVP_PKEY_CTRL_GET_DH_KDF_OUTLEN, 0, (void *)plen)
|
||||
|
||||
# define EVP_PKEY_CTX_set0_dh_kdf_ukm(ctx, p, plen) \
|
||||
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \
|
||||
EVP_PKEY_OP_DERIVE, \
|
||||
EVP_PKEY_CTRL_DH_KDF_UKM, plen, (void *)p)
|
||||
|
||||
# define EVP_PKEY_CTX_get0_dh_kdf_ukm(ctx, p) \
|
||||
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \
|
||||
EVP_PKEY_OP_DERIVE, \
|
||||
EVP_PKEY_CTRL_GET_DH_KDF_UKM, 0, (void *)p)
|
||||
|
||||
# define EVP_PKEY_CTRL_DH_PARAMGEN_PRIME_LEN (EVP_PKEY_ALG_CTRL + 1)
|
||||
# define EVP_PKEY_CTRL_DH_PARAMGEN_GENERATOR (EVP_PKEY_ALG_CTRL + 2)
|
||||
# define EVP_PKEY_CTRL_DH_RFC5114 (EVP_PKEY_ALG_CTRL + 3)
|
||||
# define EVP_PKEY_CTRL_DH_PARAMGEN_SUBPRIME_LEN (EVP_PKEY_ALG_CTRL + 4)
|
||||
# define EVP_PKEY_CTRL_DH_PARAMGEN_TYPE (EVP_PKEY_ALG_CTRL + 5)
|
||||
# define EVP_PKEY_CTRL_DH_KDF_TYPE (EVP_PKEY_ALG_CTRL + 6)
|
||||
# define EVP_PKEY_CTRL_DH_KDF_MD (EVP_PKEY_ALG_CTRL + 7)
|
||||
# define EVP_PKEY_CTRL_GET_DH_KDF_MD (EVP_PKEY_ALG_CTRL + 8)
|
||||
# define EVP_PKEY_CTRL_DH_KDF_OUTLEN (EVP_PKEY_ALG_CTRL + 9)
|
||||
# define EVP_PKEY_CTRL_GET_DH_KDF_OUTLEN (EVP_PKEY_ALG_CTRL + 10)
|
||||
# define EVP_PKEY_CTRL_DH_KDF_UKM (EVP_PKEY_ALG_CTRL + 11)
|
||||
# define EVP_PKEY_CTRL_GET_DH_KDF_UKM (EVP_PKEY_ALG_CTRL + 12)
|
||||
# define EVP_PKEY_CTRL_DH_KDF_OID (EVP_PKEY_ALG_CTRL + 13)
|
||||
# define EVP_PKEY_CTRL_GET_DH_KDF_OID (EVP_PKEY_ALG_CTRL + 14)
|
||||
|
||||
/* KDF types */
|
||||
# define EVP_PKEY_DH_KDF_NONE 1
|
||||
# ifndef OPENSSL_NO_CMS
|
||||
# define EVP_PKEY_DH_KDF_X9_42 2
|
||||
# endif
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
/*
|
||||
* The following lines are auto generated by the script mkerr.pl. Any changes
|
||||
* made after this point may be overwritten when the script is next run.
|
||||
*/
|
||||
|
||||
int ERR_load_DH_strings(void);
|
||||
|
||||
/* Error codes for the DH functions. */
|
||||
|
||||
/* Function codes. */
|
||||
# define DH_F_COMPUTE_KEY 102
|
||||
# define DH_F_DHPARAMS_PRINT_FP 101
|
||||
# define DH_F_DH_BUILTIN_GENPARAMS 106
|
||||
# define DH_F_DH_CMS_DECRYPT 114
|
||||
# define DH_F_DH_CMS_SET_PEERKEY 115
|
||||
# define DH_F_DH_CMS_SET_SHARED_INFO 116
|
||||
# define DH_F_DH_METH_DUP 117
|
||||
# define DH_F_DH_METH_NEW 118
|
||||
# define DH_F_DH_METH_SET1_NAME 119
|
||||
# define DH_F_DH_NEW_METHOD 105
|
||||
# define DH_F_DH_PARAM_DECODE 107
|
||||
# define DH_F_DH_PRIV_DECODE 110
|
||||
# define DH_F_DH_PRIV_ENCODE 111
|
||||
# define DH_F_DH_PUB_DECODE 108
|
||||
# define DH_F_DH_PUB_ENCODE 109
|
||||
# define DH_F_DO_DH_PRINT 100
|
||||
# define DH_F_GENERATE_KEY 103
|
||||
# define DH_F_PKEY_DH_DERIVE 112
|
||||
# define DH_F_PKEY_DH_KEYGEN 113
|
||||
|
||||
/* Reason codes. */
|
||||
# define DH_R_BAD_GENERATOR 101
|
||||
# define DH_R_BN_DECODE_ERROR 109
|
||||
# define DH_R_BN_ERROR 106
|
||||
# define DH_R_DECODE_ERROR 104
|
||||
# define DH_R_INVALID_PUBKEY 102
|
||||
# define DH_R_KDF_PARAMETER_ERROR 112
|
||||
# define DH_R_KEYS_NOT_SET 108
|
||||
# define DH_R_MODULUS_TOO_LARGE 103
|
||||
# define DH_R_NO_PARAMETERS_SET 107
|
||||
# define DH_R_NO_PRIVATE_VALUE 100
|
||||
# define DH_R_PARAMETER_ENCODING_ERROR 105
|
||||
# define DH_R_PEER_KEY_ERROR 111
|
||||
# define DH_R_SHARED_INFO_ERROR 113
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
|
@ -0,0 +1,282 @@
|
|||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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 DSS routines are based on patches supplied by
|
||||
* Steven Schoch <schoch@sheba.arc.nasa.gov>.
|
||||
*/
|
||||
|
||||
#ifndef HEADER_DSA_H
|
||||
# define HEADER_DSA_H
|
||||
|
||||
# include <openssl/opensslconf.h>
|
||||
|
||||
# ifndef OPENSSL_NO_DSA
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
# endif
|
||||
# include <openssl/e_os2.h>
|
||||
# include <openssl/bio.h>
|
||||
# include <openssl/crypto.h>
|
||||
# include <openssl/ossl_typ.h>
|
||||
# include <openssl/opensslconf.h>
|
||||
# include <openssl/bn.h>
|
||||
# if OPENSSL_API_COMPAT < 0x10100000L
|
||||
# include <openssl/dh.h>
|
||||
# endif
|
||||
|
||||
# ifndef OPENSSL_DSA_MAX_MODULUS_BITS
|
||||
# define OPENSSL_DSA_MAX_MODULUS_BITS 10000
|
||||
# endif
|
||||
|
||||
# define OPENSSL_DSA_FIPS_MIN_MODULUS_BITS 1024
|
||||
|
||||
# define DSA_FLAG_CACHE_MONT_P 0x01
|
||||
# if OPENSSL_API_COMPAT < 0x10100000L
|
||||
/*
|
||||
* Does nothing. Previously this switched off constant time behaviour.
|
||||
*/
|
||||
# define DSA_FLAG_NO_EXP_CONSTTIME 0x00
|
||||
# endif
|
||||
|
||||
/*
|
||||
* If this flag is set the DSA method is FIPS compliant and can be used in
|
||||
* FIPS mode. This is set in the validated module method. If an application
|
||||
* sets this flag in its own methods it is its responsibility to ensure the
|
||||
* result is compliant.
|
||||
*/
|
||||
|
||||
# define DSA_FLAG_FIPS_METHOD 0x0400
|
||||
|
||||
/*
|
||||
* If this flag is set the operations normally disabled in FIPS mode are
|
||||
* permitted it is then the applications responsibility to ensure that the
|
||||
* usage is compliant.
|
||||
*/
|
||||
|
||||
# define DSA_FLAG_NON_FIPS_ALLOW 0x0400
|
||||
# define DSA_FLAG_FIPS_CHECKED 0x0800
|
||||
|
||||
/* Already defined in ossl_typ.h */
|
||||
/* typedef struct dsa_st DSA; */
|
||||
/* typedef struct dsa_method DSA_METHOD; */
|
||||
|
||||
typedef struct DSA_SIG_st DSA_SIG;
|
||||
|
||||
# define d2i_DSAparams_fp(fp,x) (DSA *)ASN1_d2i_fp((char *(*)())DSA_new, \
|
||||
(char *(*)())d2i_DSAparams,(fp),(unsigned char **)(x))
|
||||
# define i2d_DSAparams_fp(fp,x) ASN1_i2d_fp(i2d_DSAparams,(fp), \
|
||||
(unsigned char *)(x))
|
||||
# define d2i_DSAparams_bio(bp,x) ASN1_d2i_bio_of(DSA,DSA_new,d2i_DSAparams,bp,x)
|
||||
# define i2d_DSAparams_bio(bp,x) ASN1_i2d_bio_of_const(DSA,i2d_DSAparams,bp,x)
|
||||
|
||||
DSA *DSAparams_dup(DSA *x);
|
||||
DSA_SIG *DSA_SIG_new(void);
|
||||
void DSA_SIG_free(DSA_SIG *a);
|
||||
int i2d_DSA_SIG(const DSA_SIG *a, unsigned char **pp);
|
||||
DSA_SIG *d2i_DSA_SIG(DSA_SIG **v, const unsigned char **pp, long length);
|
||||
void DSA_SIG_get0(const DSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps);
|
||||
int DSA_SIG_set0(DSA_SIG *sig, BIGNUM *r, BIGNUM *s);
|
||||
|
||||
DSA_SIG *DSA_do_sign(const unsigned char *dgst, int dlen, DSA *dsa);
|
||||
int DSA_do_verify(const unsigned char *dgst, int dgst_len,
|
||||
DSA_SIG *sig, DSA *dsa);
|
||||
|
||||
const DSA_METHOD *DSA_OpenSSL(void);
|
||||
|
||||
void DSA_set_default_method(const DSA_METHOD *);
|
||||
const DSA_METHOD *DSA_get_default_method(void);
|
||||
int DSA_set_method(DSA *dsa, const DSA_METHOD *);
|
||||
const DSA_METHOD *DSA_get_method(DSA *d);
|
||||
|
||||
DSA *DSA_new(void);
|
||||
DSA *DSA_new_method(ENGINE *engine);
|
||||
void DSA_free(DSA *r);
|
||||
/* "up" the DSA object's reference count */
|
||||
int DSA_up_ref(DSA *r);
|
||||
int DSA_size(const DSA *);
|
||||
int DSA_bits(const DSA *d);
|
||||
int DSA_security_bits(const DSA *d);
|
||||
/* next 4 return -1 on error */
|
||||
int DSA_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp);
|
||||
int DSA_sign(int type, const unsigned char *dgst, int dlen,
|
||||
unsigned char *sig, unsigned int *siglen, DSA *dsa);
|
||||
int DSA_verify(int type, const unsigned char *dgst, int dgst_len,
|
||||
const unsigned char *sigbuf, int siglen, DSA *dsa);
|
||||
#define DSA_get_ex_new_index(l, p, newf, dupf, freef) \
|
||||
CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_DSA, l, p, newf, dupf, freef)
|
||||
int DSA_set_ex_data(DSA *d, int idx, void *arg);
|
||||
void *DSA_get_ex_data(DSA *d, int idx);
|
||||
|
||||
DSA *d2i_DSAPublicKey(DSA **a, const unsigned char **pp, long length);
|
||||
DSA *d2i_DSAPrivateKey(DSA **a, const unsigned char **pp, long length);
|
||||
DSA *d2i_DSAparams(DSA **a, const unsigned char **pp, long length);
|
||||
|
||||
/* Deprecated version */
|
||||
DEPRECATEDIN_0_9_8(DSA *DSA_generate_parameters(int bits,
|
||||
unsigned char *seed,
|
||||
int seed_len,
|
||||
int *counter_ret,
|
||||
unsigned long *h_ret, void
|
||||
(*callback) (int, int,
|
||||
void *),
|
||||
void *cb_arg))
|
||||
|
||||
/* New version */
|
||||
int DSA_generate_parameters_ex(DSA *dsa, int bits,
|
||||
const unsigned char *seed, int seed_len,
|
||||
int *counter_ret, unsigned long *h_ret,
|
||||
BN_GENCB *cb);
|
||||
|
||||
int DSA_generate_key(DSA *a);
|
||||
int i2d_DSAPublicKey(const DSA *a, unsigned char **pp);
|
||||
int i2d_DSAPrivateKey(const DSA *a, unsigned char **pp);
|
||||
int i2d_DSAparams(const DSA *a, unsigned char **pp);
|
||||
|
||||
int DSAparams_print(BIO *bp, const DSA *x);
|
||||
int DSA_print(BIO *bp, const DSA *x, int off);
|
||||
# ifndef OPENSSL_NO_STDIO
|
||||
int DSAparams_print_fp(FILE *fp, const DSA *x);
|
||||
int DSA_print_fp(FILE *bp, const DSA *x, int off);
|
||||
# endif
|
||||
|
||||
# define DSS_prime_checks 50
|
||||
/*
|
||||
* Primality test according to FIPS PUB 186[-1], Appendix 2.1: 50 rounds of
|
||||
* Rabin-Miller
|
||||
*/
|
||||
# define DSA_is_prime(n, callback, cb_arg) \
|
||||
BN_is_prime(n, DSS_prime_checks, callback, NULL, cb_arg)
|
||||
|
||||
# ifndef OPENSSL_NO_DH
|
||||
/*
|
||||
* Convert DSA structure (key or just parameters) into DH structure (be
|
||||
* careful to avoid small subgroup attacks when using this!)
|
||||
*/
|
||||
DH *DSA_dup_DH(const DSA *r);
|
||||
# endif
|
||||
|
||||
# define EVP_PKEY_CTX_set_dsa_paramgen_bits(ctx, nbits) \
|
||||
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DSA, EVP_PKEY_OP_PARAMGEN, \
|
||||
EVP_PKEY_CTRL_DSA_PARAMGEN_BITS, nbits, NULL)
|
||||
|
||||
# define EVP_PKEY_CTRL_DSA_PARAMGEN_BITS (EVP_PKEY_ALG_CTRL + 1)
|
||||
# define EVP_PKEY_CTRL_DSA_PARAMGEN_Q_BITS (EVP_PKEY_ALG_CTRL + 2)
|
||||
# define EVP_PKEY_CTRL_DSA_PARAMGEN_MD (EVP_PKEY_ALG_CTRL + 3)
|
||||
|
||||
void DSA_get0_pqg(const DSA *d,
|
||||
const BIGNUM **p, const BIGNUM **q, const BIGNUM **g);
|
||||
int DSA_set0_pqg(DSA *d, BIGNUM *p, BIGNUM *q, BIGNUM *g);
|
||||
void DSA_get0_key(const DSA *d,
|
||||
const BIGNUM **pub_key, const BIGNUM **priv_key);
|
||||
int DSA_set0_key(DSA *d, BIGNUM *pub_key, BIGNUM *priv_key);
|
||||
void DSA_clear_flags(DSA *d, int flags);
|
||||
int DSA_test_flags(const DSA *d, int flags);
|
||||
void DSA_set_flags(DSA *d, int flags);
|
||||
ENGINE *DSA_get0_engine(DSA *d);
|
||||
|
||||
DSA_METHOD *DSA_meth_new(const char *name, int flags);
|
||||
void DSA_meth_free(DSA_METHOD *dsam);
|
||||
DSA_METHOD *DSA_meth_dup(const DSA_METHOD *dsam);
|
||||
const char *DSA_meth_get0_name(const DSA_METHOD *dsam);
|
||||
int DSA_meth_set1_name(DSA_METHOD *dsam, const char *name);
|
||||
int DSA_meth_get_flags(DSA_METHOD *dsam);
|
||||
int DSA_meth_set_flags(DSA_METHOD *dsam, int flags);
|
||||
void *DSA_meth_get0_app_data(const DSA_METHOD *dsam);
|
||||
int DSA_meth_set0_app_data(DSA_METHOD *dsam, void *app_data);
|
||||
DSA_SIG *(*DSA_meth_get_sign(const DSA_METHOD *dsam))
|
||||
(const unsigned char *, int, DSA *);
|
||||
int DSA_meth_set_sign(DSA_METHOD *dsam,
|
||||
DSA_SIG *(*sign) (const unsigned char *, int, DSA *));
|
||||
int (*DSA_meth_get_sign_setup(const DSA_METHOD *dsam))
|
||||
(DSA *, BN_CTX *, BIGNUM **, BIGNUM **);
|
||||
int DSA_meth_set_sign_setup(DSA_METHOD *dsam,
|
||||
int (*sign_setup) (DSA *, BN_CTX *, BIGNUM **, BIGNUM **));
|
||||
int (*DSA_meth_get_verify(const DSA_METHOD *dsam))
|
||||
(const unsigned char *, int , DSA_SIG *, DSA *);
|
||||
int DSA_meth_set_verify(DSA_METHOD *dsam,
|
||||
int (*verify) (const unsigned char *, int, DSA_SIG *, DSA *));
|
||||
int (*DSA_meth_get_mod_exp(const DSA_METHOD *dsam))
|
||||
(DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *, const BIGNUM *,
|
||||
const BIGNUM *, const BIGNUM *, BN_CTX *, BN_MONT_CTX *);
|
||||
int DSA_meth_set_mod_exp(DSA_METHOD *dsam,
|
||||
int (*mod_exp) (DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *,
|
||||
const BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *,
|
||||
BN_MONT_CTX *));
|
||||
int (*DSA_meth_get_bn_mod_exp(const DSA_METHOD *dsam))
|
||||
(DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *, const BIGNUM *,
|
||||
BN_CTX *, BN_MONT_CTX *);
|
||||
int DSA_meth_set_bn_mod_exp(DSA_METHOD *dsam,
|
||||
int (*bn_mod_exp) (DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *,
|
||||
const BIGNUM *, BN_CTX *, BN_MONT_CTX *));
|
||||
int (*DSA_meth_get_init(const DSA_METHOD *dsam))(DSA *);
|
||||
int DSA_meth_set_init(DSA_METHOD *dsam, int (*init)(DSA *));
|
||||
int (*DSA_meth_get_finish(const DSA_METHOD *dsam)) (DSA *);
|
||||
int DSA_meth_set_finish(DSA_METHOD *dsam, int (*finish) (DSA *));
|
||||
int (*DSA_meth_get_paramgen(const DSA_METHOD *dsam))
|
||||
(DSA *, int, const unsigned char *, int, int *, unsigned long *,
|
||||
BN_GENCB *);
|
||||
int DSA_meth_set_paramgen(DSA_METHOD *dsam,
|
||||
int (*paramgen) (DSA *, int, const unsigned char *, int, int *,
|
||||
unsigned long *, BN_GENCB *));
|
||||
int (*DSA_meth_get_keygen(const DSA_METHOD *dsam)) (DSA *);
|
||||
int DSA_meth_set_keygen(DSA_METHOD *dsam, int (*keygen) (DSA *));
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
/*
|
||||
* The following lines are auto generated by the script mkerr.pl. Any changes
|
||||
* made after this point may be overwritten when the script is next run.
|
||||
*/
|
||||
|
||||
int ERR_load_DSA_strings(void);
|
||||
|
||||
/* Error codes for the DSA functions. */
|
||||
|
||||
/* Function codes. */
|
||||
# define DSA_F_DSAPARAMS_PRINT 100
|
||||
# define DSA_F_DSAPARAMS_PRINT_FP 101
|
||||
# define DSA_F_DSA_BUILTIN_PARAMGEN 125
|
||||
# define DSA_F_DSA_BUILTIN_PARAMGEN2 126
|
||||
# define DSA_F_DSA_DO_SIGN 112
|
||||
# define DSA_F_DSA_DO_VERIFY 113
|
||||
# define DSA_F_DSA_METH_DUP 127
|
||||
# define DSA_F_DSA_METH_NEW 128
|
||||
# define DSA_F_DSA_METH_SET1_NAME 129
|
||||
# define DSA_F_DSA_NEW_METHOD 103
|
||||
# define DSA_F_DSA_PARAM_DECODE 119
|
||||
# define DSA_F_DSA_PRINT_FP 105
|
||||
# define DSA_F_DSA_PRIV_DECODE 115
|
||||
# define DSA_F_DSA_PRIV_ENCODE 116
|
||||
# define DSA_F_DSA_PUB_DECODE 117
|
||||
# define DSA_F_DSA_PUB_ENCODE 118
|
||||
# define DSA_F_DSA_SIGN 106
|
||||
# define DSA_F_DSA_SIGN_SETUP 107
|
||||
# define DSA_F_DSA_SIG_NEW 102
|
||||
# define DSA_F_OLD_DSA_PRIV_DECODE 122
|
||||
# define DSA_F_PKEY_DSA_CTRL 120
|
||||
# define DSA_F_PKEY_DSA_KEYGEN 121
|
||||
|
||||
/* Reason codes. */
|
||||
# define DSA_R_BAD_Q_VALUE 102
|
||||
# define DSA_R_BN_DECODE_ERROR 108
|
||||
# define DSA_R_BN_ERROR 109
|
||||
# define DSA_R_DECODE_ERROR 104
|
||||
# define DSA_R_INVALID_DIGEST_TYPE 106
|
||||
# define DSA_R_INVALID_PARAMETERS 112
|
||||
# define DSA_R_MISSING_PARAMETERS 101
|
||||
# define DSA_R_MODULUS_TOO_LARGE 103
|
||||
# define DSA_R_NO_PARAMETERS_SET 107
|
||||
# define DSA_R_PARAMETER_ENCODING_ERROR 105
|
||||
# define DSA_R_Q_NOT_PRIME 113
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* Copyright 2005-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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_DTLS1_H
|
||||
# define HEADER_DTLS1_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
# define DTLS1_VERSION 0xFEFF
|
||||
# define DTLS1_2_VERSION 0xFEFD
|
||||
# define DTLS_MIN_VERSION DTLS1_VERSION
|
||||
# define DTLS_MAX_VERSION DTLS1_2_VERSION
|
||||
# define DTLS1_VERSION_MAJOR 0xFE
|
||||
|
||||
# define DTLS1_BAD_VER 0x0100
|
||||
|
||||
/* Special value for method supporting multiple versions */
|
||||
# define DTLS_ANY_VERSION 0x1FFFF
|
||||
|
||||
/* lengths of messages */
|
||||
# define DTLS1_COOKIE_LENGTH 256
|
||||
|
||||
# define DTLS1_RT_HEADER_LENGTH 13
|
||||
|
||||
# define DTLS1_HM_HEADER_LENGTH 12
|
||||
|
||||
# define DTLS1_HM_BAD_FRAGMENT -2
|
||||
# define DTLS1_HM_FRAGMENT_RETRY -3
|
||||
|
||||
# define DTLS1_CCS_HEADER_LENGTH 1
|
||||
|
||||
# ifdef DTLS1_AD_MISSING_HANDSHAKE_MESSAGE
|
||||
# define DTLS1_AL_HEADER_LENGTH 7
|
||||
# else
|
||||
# define DTLS1_AL_HEADER_LENGTH 2
|
||||
# endif
|
||||
|
||||
|
||||
/* Timeout multipliers (timeout slice is defined in apps/timeouts.h */
|
||||
# define DTLS1_TMO_READ_COUNT 2
|
||||
# define DTLS1_TMO_WRITE_COUNT 2
|
||||
|
||||
# define DTLS1_TMO_ALERT_COUNT 12
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -0,0 +1,311 @@
|
|||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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_E_OS2_H
|
||||
# define HEADER_E_OS2_H
|
||||
|
||||
# include <openssl/opensslconf.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
* Detect operating systems. This probably needs completing.
|
||||
* The result is that at least one OPENSSL_SYS_os macro should be defined.
|
||||
* However, if none is defined, Unix is assumed.
|
||||
**/
|
||||
|
||||
# define OPENSSL_SYS_UNIX
|
||||
|
||||
/* --------------------- Microsoft operating systems ---------------------- */
|
||||
|
||||
/*
|
||||
* Note that MSDOS actually denotes 32-bit environments running on top of
|
||||
* MS-DOS, such as DJGPP one.
|
||||
*/
|
||||
# if defined(OPENSSL_SYS_MSDOS)
|
||||
# undef OPENSSL_SYS_UNIX
|
||||
# endif
|
||||
|
||||
/*
|
||||
* For 32 bit environment, there seems to be the CygWin environment and then
|
||||
* all the others that try to do the same thing Microsoft does...
|
||||
*/
|
||||
/*
|
||||
* UEFI lives here because it might be built with a Microsoft toolchain and
|
||||
* we need to avoid the false positive match on Windows.
|
||||
*/
|
||||
# if defined(OPENSSL_SYS_UEFI)
|
||||
# undef OPENSSL_SYS_UNIX
|
||||
# elif defined(OPENSSL_SYS_UWIN)
|
||||
# undef OPENSSL_SYS_UNIX
|
||||
# define OPENSSL_SYS_WIN32_UWIN
|
||||
# else
|
||||
# if defined(__CYGWIN__) || defined(OPENSSL_SYS_CYGWIN)
|
||||
# undef OPENSSL_SYS_UNIX
|
||||
# define OPENSSL_SYS_WIN32_CYGWIN
|
||||
# else
|
||||
# if defined(_WIN32) || defined(OPENSSL_SYS_WIN32)
|
||||
# undef OPENSSL_SYS_UNIX
|
||||
# if !defined(OPENSSL_SYS_WIN32)
|
||||
# define OPENSSL_SYS_WIN32
|
||||
# endif
|
||||
# endif
|
||||
# if defined(_WIN64) || defined(OPENSSL_SYS_WIN64)
|
||||
# undef OPENSSL_SYS_UNIX
|
||||
# if !defined(OPENSSL_SYS_WIN64)
|
||||
# define OPENSSL_SYS_WIN64
|
||||
# endif
|
||||
# endif
|
||||
# if defined(OPENSSL_SYS_WINNT)
|
||||
# undef OPENSSL_SYS_UNIX
|
||||
# endif
|
||||
# if defined(OPENSSL_SYS_WINCE)
|
||||
# undef OPENSSL_SYS_UNIX
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
|
||||
/* Anything that tries to look like Microsoft is "Windows" */
|
||||
# if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WIN64) || defined(OPENSSL_SYS_WINNT) || defined(OPENSSL_SYS_WINCE)
|
||||
# undef OPENSSL_SYS_UNIX
|
||||
# define OPENSSL_SYS_WINDOWS
|
||||
# ifndef OPENSSL_SYS_MSDOS
|
||||
# define OPENSSL_SYS_MSDOS
|
||||
# endif
|
||||
# endif
|
||||
|
||||
/*
|
||||
* DLL settings. This part is a bit tough, because it's up to the
|
||||
* application implementor how he or she will link the application, so it
|
||||
* requires some macro to be used.
|
||||
*/
|
||||
# ifdef OPENSSL_SYS_WINDOWS
|
||||
# ifndef OPENSSL_OPT_WINDLL
|
||||
# if defined(_WINDLL) /* This is used when building OpenSSL to
|
||||
* indicate that DLL linkage should be used */
|
||||
# define OPENSSL_OPT_WINDLL
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
|
||||
/* ------------------------------- OpenVMS -------------------------------- */
|
||||
# if defined(__VMS) || defined(VMS) || defined(OPENSSL_SYS_VMS)
|
||||
# if !defined(OPENSSL_SYS_VMS)
|
||||
# undef OPENSSL_SYS_UNIX
|
||||
# endif
|
||||
# define OPENSSL_SYS_VMS
|
||||
# if defined(__DECC)
|
||||
# define OPENSSL_SYS_VMS_DECC
|
||||
# elif defined(__DECCXX)
|
||||
# define OPENSSL_SYS_VMS_DECC
|
||||
# define OPENSSL_SYS_VMS_DECCXX
|
||||
# else
|
||||
# define OPENSSL_SYS_VMS_NODECC
|
||||
# endif
|
||||
# endif
|
||||
|
||||
/* -------------------------------- Unix ---------------------------------- */
|
||||
# ifdef OPENSSL_SYS_UNIX
|
||||
# if defined(linux) || defined(__linux__) && !defined(OPENSSL_SYS_LINUX)
|
||||
# define OPENSSL_SYS_LINUX
|
||||
# endif
|
||||
# if defined(_AIX) && !defined(OPENSSL_SYS_AIX)
|
||||
# define OPENSSL_SYS_AIX
|
||||
# endif
|
||||
# endif
|
||||
|
||||
/* -------------------------------- VOS ----------------------------------- */
|
||||
# if defined(__VOS__) && !defined(OPENSSL_SYS_VOS)
|
||||
# define OPENSSL_SYS_VOS
|
||||
# ifdef __HPPA__
|
||||
# define OPENSSL_SYS_VOS_HPPA
|
||||
# endif
|
||||
# ifdef __IA32__
|
||||
# define OPENSSL_SYS_VOS_IA32
|
||||
# endif
|
||||
# endif
|
||||
|
||||
/**
|
||||
* That's it for OS-specific stuff
|
||||
*****************************************************************************/
|
||||
|
||||
/* Specials for I/O an exit */
|
||||
# ifdef OPENSSL_SYS_MSDOS
|
||||
# define OPENSSL_UNISTD_IO <io.h>
|
||||
# define OPENSSL_DECLARE_EXIT extern void exit(int);
|
||||
# else
|
||||
# define OPENSSL_UNISTD_IO OPENSSL_UNISTD
|
||||
# define OPENSSL_DECLARE_EXIT /* declared in unistd.h */
|
||||
# endif
|
||||
|
||||
/*-
|
||||
* Definitions of OPENSSL_GLOBAL and OPENSSL_EXTERN, to define and declare
|
||||
* certain global symbols that, with some compilers under VMS, have to be
|
||||
* defined and declared explicitly with globaldef and globalref.
|
||||
* Definitions of OPENSSL_EXPORT and OPENSSL_IMPORT, to define and declare
|
||||
* DLL exports and imports for compilers under Win32. These are a little
|
||||
* more complicated to use. Basically, for any library that exports some
|
||||
* global variables, the following code must be present in the header file
|
||||
* that declares them, before OPENSSL_EXTERN is used:
|
||||
*
|
||||
* #ifdef SOME_BUILD_FLAG_MACRO
|
||||
* # undef OPENSSL_EXTERN
|
||||
* # define OPENSSL_EXTERN OPENSSL_EXPORT
|
||||
* #endif
|
||||
*
|
||||
* The default is to have OPENSSL_EXPORT, OPENSSL_EXTERN and OPENSSL_GLOBAL
|
||||
* have some generally sensible values.
|
||||
*/
|
||||
|
||||
# if defined(OPENSSL_SYS_VMS_NODECC)
|
||||
# define OPENSSL_EXPORT globalref
|
||||
# define OPENSSL_EXTERN globalref
|
||||
# define OPENSSL_GLOBAL globaldef
|
||||
# elif defined(OPENSSL_SYS_WINDOWS) && defined(OPENSSL_OPT_WINDLL)
|
||||
# define OPENSSL_EXPORT extern __declspec(dllexport)
|
||||
# define OPENSSL_EXTERN extern __declspec(dllimport)
|
||||
# define OPENSSL_GLOBAL
|
||||
# else
|
||||
# define OPENSSL_EXPORT extern
|
||||
# define OPENSSL_EXTERN extern
|
||||
# define OPENSSL_GLOBAL
|
||||
# endif
|
||||
|
||||
/*-
|
||||
* Macros to allow global variables to be reached through function calls when
|
||||
* required (if a shared library version requires it, for example.
|
||||
* The way it's done allows definitions like this:
|
||||
*
|
||||
* // in foobar.c
|
||||
* OPENSSL_IMPLEMENT_GLOBAL(int,foobar,0)
|
||||
* // in foobar.h
|
||||
* OPENSSL_DECLARE_GLOBAL(int,foobar);
|
||||
* #define foobar OPENSSL_GLOBAL_REF(foobar)
|
||||
*/
|
||||
# ifdef OPENSSL_EXPORT_VAR_AS_FUNCTION
|
||||
# define OPENSSL_IMPLEMENT_GLOBAL(type,name,value) \
|
||||
type *_shadow_##name(void) \
|
||||
{ static type _hide_##name=value; return &_hide_##name; }
|
||||
# define OPENSSL_DECLARE_GLOBAL(type,name) type *_shadow_##name(void)
|
||||
# define OPENSSL_GLOBAL_REF(name) (*(_shadow_##name()))
|
||||
# else
|
||||
# define OPENSSL_IMPLEMENT_GLOBAL(type,name,value) OPENSSL_GLOBAL type _shadow_##name=value;
|
||||
# define OPENSSL_DECLARE_GLOBAL(type,name) OPENSSL_EXPORT type _shadow_##name
|
||||
# define OPENSSL_GLOBAL_REF(name) _shadow_##name
|
||||
# endif
|
||||
|
||||
# ifdef _WIN32
|
||||
# ifdef _WIN64
|
||||
# define ossl_ssize_t __int64
|
||||
# define OSSL_SSIZE_MAX _I64_MAX
|
||||
# else
|
||||
# define ossl_ssize_t int
|
||||
# define OSSL_SSIZE_MAX INT_MAX
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# if defined(OPENSSL_SYS_UEFI) && !defined(ssize_t)
|
||||
# define ossl_ssize_t int
|
||||
# define OSSL_SSIZE_MAX INT_MAX
|
||||
# endif
|
||||
|
||||
# ifndef ossl_ssize_t
|
||||
# define ossl_ssize_t ssize_t
|
||||
# if defined(SSIZE_MAX)
|
||||
# define OSSL_SSIZE_MAX SSIZE_MAX
|
||||
# elif defined(_POSIX_SSIZE_MAX)
|
||||
# define OSSL_SSIZE_MAX _POSIX_SSIZE_MAX
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifdef DEBUG_UNUSED
|
||||
# define __owur __attribute__((__warn_unused_result__))
|
||||
# else
|
||||
# define __owur
|
||||
# endif
|
||||
|
||||
/* Standard integer types */
|
||||
# if defined(OPENSSL_SYS_UEFI)
|
||||
typedef INT8 int8_t;
|
||||
typedef UINT8 uint8_t;
|
||||
typedef INT16 int16_t;
|
||||
typedef UINT16 uint16_t;
|
||||
typedef INT32 int32_t;
|
||||
typedef UINT32 uint32_t;
|
||||
typedef INT64 int64_t;
|
||||
typedef UINT64 uint64_t;
|
||||
# define PRIu64 "%Lu"
|
||||
# elif (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
|
||||
defined(__osf__) || defined(__sgi) || defined(__hpux) || \
|
||||
defined(OPENSSL_SYS_VMS) || defined (__OpenBSD__)
|
||||
# include <inttypes.h>
|
||||
# elif defined(_MSC_VER) && _MSC_VER<=1500
|
||||
/*
|
||||
* minimally required typdefs for systems not supporting inttypes.h or
|
||||
* stdint.h: currently just older VC++
|
||||
*/
|
||||
typedef signed char int8_t;
|
||||
typedef unsigned char uint8_t;
|
||||
typedef short int16_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef int int32_t;
|
||||
typedef unsigned int uint32_t;
|
||||
typedef __int64 int64_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
# else
|
||||
# include <stdint.h>
|
||||
# endif
|
||||
|
||||
/*
|
||||
* We need a format operator for some client tools for uint64_t. If inttypes.h
|
||||
* isn't available or did not define it, just go with hard-coded.
|
||||
*/
|
||||
# ifndef PRIu64
|
||||
# ifdef SIXTY_FOUR_BIT_LONG
|
||||
# define PRIu64 "lu"
|
||||
# else
|
||||
# define PRIu64 "llu"
|
||||
# endif
|
||||
# endif
|
||||
|
||||
/* ossl_inline: portable inline definition usable in public headers */
|
||||
# if !defined(inline) && !defined(__cplusplus)
|
||||
# if defined(__STDC_VERSION__) && __STDC_VERSION__>=199901L
|
||||
/* just use inline */
|
||||
# define ossl_inline inline
|
||||
# elif defined(__GNUC__) && __GNUC__>=2
|
||||
# define ossl_inline __inline__
|
||||
# elif defined(_MSC_VER)
|
||||
/*
|
||||
* Visual Studio: inline is available in C++ only, however
|
||||
* __inline is available for C, see
|
||||
* http://msdn.microsoft.com/en-us/library/z8y1yy88.aspx
|
||||
*/
|
||||
# define ossl_inline __inline
|
||||
# else
|
||||
# define ossl_inline
|
||||
# endif
|
||||
# else
|
||||
# define ossl_inline inline
|
||||
# endif
|
||||
|
||||
# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
|
||||
# define ossl_noreturn _Noreturn
|
||||
# elif defined(__GNUC__) && __GNUC__ >= 2
|
||||
# define ossl_noreturn __attribute__((noreturn))
|
||||
# else
|
||||
# define ossl_noreturn
|
||||
# endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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_EBCDIC_H
|
||||
# define HEADER_EBCDIC_H
|
||||
|
||||
# include <stdlib.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Avoid name clashes with other applications */
|
||||
# define os_toascii _openssl_os_toascii
|
||||
# define os_toebcdic _openssl_os_toebcdic
|
||||
# define ebcdic2ascii _openssl_ebcdic2ascii
|
||||
# define ascii2ebcdic _openssl_ascii2ebcdic
|
||||
|
||||
extern const unsigned char os_toascii[256];
|
||||
extern const unsigned char os_toebcdic[256];
|
||||
void *ebcdic2ascii(void *dest, const void *srce, size_t count);
|
||||
void *ascii2ebcdic(void *dest, const void *srce, size_t count);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,10 @@
|
|||
/*
|
||||
* Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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/ec.h>
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
/*
|
||||
* Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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/ec.h>
|
||||
|
|
@ -0,0 +1,842 @@
|
|||
/*
|
||||
* Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
|
||||
* ECDH support in OpenSSL originally developed by
|
||||
* SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.
|
||||
*/
|
||||
|
||||
#ifndef HEADER_ENGINE_H
|
||||
# define HEADER_ENGINE_H
|
||||
|
||||
# include <openssl/opensslconf.h>
|
||||
|
||||
# ifndef OPENSSL_NO_ENGINE
|
||||
# if OPENSSL_API_COMPAT < 0x10100000L
|
||||
# include <openssl/bn.h>
|
||||
# include <openssl/rsa.h>
|
||||
# include <openssl/dsa.h>
|
||||
# include <openssl/dh.h>
|
||||
# include <openssl/ec.h>
|
||||
# include <openssl/rand.h>
|
||||
# include <openssl/ui.h>
|
||||
# include <openssl/err.h>
|
||||
# endif
|
||||
# include <openssl/ossl_typ.h>
|
||||
# include <openssl/symhacks.h>
|
||||
# include <openssl/x509.h>
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
# endif
|
||||
|
||||
/*
|
||||
* These flags are used to control combinations of algorithm (methods) by
|
||||
* bitwise "OR"ing.
|
||||
*/
|
||||
# define ENGINE_METHOD_RSA (unsigned int)0x0001
|
||||
# define ENGINE_METHOD_DSA (unsigned int)0x0002
|
||||
# define ENGINE_METHOD_DH (unsigned int)0x0004
|
||||
# define ENGINE_METHOD_RAND (unsigned int)0x0008
|
||||
# define ENGINE_METHOD_CIPHERS (unsigned int)0x0040
|
||||
# define ENGINE_METHOD_DIGESTS (unsigned int)0x0080
|
||||
# define ENGINE_METHOD_PKEY_METHS (unsigned int)0x0200
|
||||
# define ENGINE_METHOD_PKEY_ASN1_METHS (unsigned int)0x0400
|
||||
# define ENGINE_METHOD_EC (unsigned int)0x0800
|
||||
/* Obvious all-or-nothing cases. */
|
||||
# define ENGINE_METHOD_ALL (unsigned int)0xFFFF
|
||||
# define ENGINE_METHOD_NONE (unsigned int)0x0000
|
||||
|
||||
/*
|
||||
* This(ese) flag(s) controls behaviour of the ENGINE_TABLE mechanism used
|
||||
* internally to control registration of ENGINE implementations, and can be
|
||||
* set by ENGINE_set_table_flags(). The "NOINIT" flag prevents attempts to
|
||||
* initialise registered ENGINEs if they are not already initialised.
|
||||
*/
|
||||
# define ENGINE_TABLE_FLAG_NOINIT (unsigned int)0x0001
|
||||
|
||||
/* ENGINE flags that can be set by ENGINE_set_flags(). */
|
||||
/* Not used */
|
||||
/* #define ENGINE_FLAGS_MALLOCED 0x0001 */
|
||||
|
||||
/*
|
||||
* This flag is for ENGINEs that wish to handle the various 'CMD'-related
|
||||
* control commands on their own. Without this flag, ENGINE_ctrl() handles
|
||||
* these control commands on behalf of the ENGINE using their "cmd_defns"
|
||||
* data.
|
||||
*/
|
||||
# define ENGINE_FLAGS_MANUAL_CMD_CTRL (int)0x0002
|
||||
|
||||
/*
|
||||
* This flag is for ENGINEs who return new duplicate structures when found
|
||||
* via "ENGINE_by_id()". When an ENGINE must store state (eg. if
|
||||
* ENGINE_ctrl() commands are called in sequence as part of some stateful
|
||||
* process like key-generation setup and execution), it can set this flag -
|
||||
* then each attempt to obtain the ENGINE will result in it being copied into
|
||||
* a new structure. Normally, ENGINEs don't declare this flag so
|
||||
* ENGINE_by_id() just increments the existing ENGINE's structural reference
|
||||
* count.
|
||||
*/
|
||||
# define ENGINE_FLAGS_BY_ID_COPY (int)0x0004
|
||||
|
||||
/*
|
||||
* This flag if for an ENGINE that does not want its methods registered as
|
||||
* part of ENGINE_register_all_complete() for example if the methods are not
|
||||
* usable as default methods.
|
||||
*/
|
||||
|
||||
# define ENGINE_FLAGS_NO_REGISTER_ALL (int)0x0008
|
||||
|
||||
/*
|
||||
* ENGINEs can support their own command types, and these flags are used in
|
||||
* ENGINE_CTRL_GET_CMD_FLAGS to indicate to the caller what kind of input
|
||||
* each command expects. Currently only numeric and string input is
|
||||
* supported. If a control command supports none of the _NUMERIC, _STRING, or
|
||||
* _NO_INPUT options, then it is regarded as an "internal" control command -
|
||||
* and not for use in config setting situations. As such, they're not
|
||||
* available to the ENGINE_ctrl_cmd_string() function, only raw ENGINE_ctrl()
|
||||
* access. Changes to this list of 'command types' should be reflected
|
||||
* carefully in ENGINE_cmd_is_executable() and ENGINE_ctrl_cmd_string().
|
||||
*/
|
||||
|
||||
/* accepts a 'long' input value (3rd parameter to ENGINE_ctrl) */
|
||||
# define ENGINE_CMD_FLAG_NUMERIC (unsigned int)0x0001
|
||||
/*
|
||||
* accepts string input (cast from 'void*' to 'const char *', 4th parameter
|
||||
* to ENGINE_ctrl)
|
||||
*/
|
||||
# define ENGINE_CMD_FLAG_STRING (unsigned int)0x0002
|
||||
/*
|
||||
* Indicates that the control command takes *no* input. Ie. the control
|
||||
* command is unparameterised.
|
||||
*/
|
||||
# define ENGINE_CMD_FLAG_NO_INPUT (unsigned int)0x0004
|
||||
/*
|
||||
* Indicates that the control command is internal. This control command won't
|
||||
* be shown in any output, and is only usable through the ENGINE_ctrl_cmd()
|
||||
* function.
|
||||
*/
|
||||
# define ENGINE_CMD_FLAG_INTERNAL (unsigned int)0x0008
|
||||
|
||||
/*
|
||||
* NB: These 3 control commands are deprecated and should not be used.
|
||||
* ENGINEs relying on these commands should compile conditional support for
|
||||
* compatibility (eg. if these symbols are defined) but should also migrate
|
||||
* the same functionality to their own ENGINE-specific control functions that
|
||||
* can be "discovered" by calling applications. The fact these control
|
||||
* commands wouldn't be "executable" (ie. usable by text-based config)
|
||||
* doesn't change the fact that application code can find and use them
|
||||
* without requiring per-ENGINE hacking.
|
||||
*/
|
||||
|
||||
/*
|
||||
* These flags are used to tell the ctrl function what should be done. All
|
||||
* command numbers are shared between all engines, even if some don't make
|
||||
* sense to some engines. In such a case, they do nothing but return the
|
||||
* error ENGINE_R_CTRL_COMMAND_NOT_IMPLEMENTED.
|
||||
*/
|
||||
# define ENGINE_CTRL_SET_LOGSTREAM 1
|
||||
# define ENGINE_CTRL_SET_PASSWORD_CALLBACK 2
|
||||
# define ENGINE_CTRL_HUP 3/* Close and reinitialise
|
||||
* any handles/connections
|
||||
* etc. */
|
||||
# define ENGINE_CTRL_SET_USER_INTERFACE 4/* Alternative to callback */
|
||||
# define ENGINE_CTRL_SET_CALLBACK_DATA 5/* User-specific data, used
|
||||
* when calling the password
|
||||
* callback and the user
|
||||
* interface */
|
||||
# define ENGINE_CTRL_LOAD_CONFIGURATION 6/* Load a configuration,
|
||||
* given a string that
|
||||
* represents a file name
|
||||
* or so */
|
||||
# define ENGINE_CTRL_LOAD_SECTION 7/* Load data from a given
|
||||
* section in the already
|
||||
* loaded configuration */
|
||||
|
||||
/*
|
||||
* These control commands allow an application to deal with an arbitrary
|
||||
* engine in a dynamic way. Warn: Negative return values indicate errors FOR
|
||||
* THESE COMMANDS because zero is used to indicate 'end-of-list'. Other
|
||||
* commands, including ENGINE-specific command types, return zero for an
|
||||
* error. An ENGINE can choose to implement these ctrl functions, and can
|
||||
* internally manage things however it chooses - it does so by setting the
|
||||
* ENGINE_FLAGS_MANUAL_CMD_CTRL flag (using ENGINE_set_flags()). Otherwise
|
||||
* the ENGINE_ctrl() code handles this on the ENGINE's behalf using the
|
||||
* cmd_defns data (set using ENGINE_set_cmd_defns()). This means an ENGINE's
|
||||
* ctrl() handler need only implement its own commands - the above "meta"
|
||||
* commands will be taken care of.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Returns non-zero if the supplied ENGINE has a ctrl() handler. If "not",
|
||||
* then all the remaining control commands will return failure, so it is
|
||||
* worth checking this first if the caller is trying to "discover" the
|
||||
* engine's capabilities and doesn't want errors generated unnecessarily.
|
||||
*/
|
||||
# define ENGINE_CTRL_HAS_CTRL_FUNCTION 10
|
||||
/*
|
||||
* Returns a positive command number for the first command supported by the
|
||||
* engine. Returns zero if no ctrl commands are supported.
|
||||
*/
|
||||
# define ENGINE_CTRL_GET_FIRST_CMD_TYPE 11
|
||||
/*
|
||||
* The 'long' argument specifies a command implemented by the engine, and the
|
||||
* return value is the next command supported, or zero if there are no more.
|
||||
*/
|
||||
# define ENGINE_CTRL_GET_NEXT_CMD_TYPE 12
|
||||
/*
|
||||
* The 'void*' argument is a command name (cast from 'const char *'), and the
|
||||
* return value is the command that corresponds to it.
|
||||
*/
|
||||
# define ENGINE_CTRL_GET_CMD_FROM_NAME 13
|
||||
/*
|
||||
* The next two allow a command to be converted into its corresponding string
|
||||
* form. In each case, the 'long' argument supplies the command. In the
|
||||
* NAME_LEN case, the return value is the length of the command name (not
|
||||
* counting a trailing EOL). In the NAME case, the 'void*' argument must be a
|
||||
* string buffer large enough, and it will be populated with the name of the
|
||||
* command (WITH a trailing EOL).
|
||||
*/
|
||||
# define ENGINE_CTRL_GET_NAME_LEN_FROM_CMD 14
|
||||
# define ENGINE_CTRL_GET_NAME_FROM_CMD 15
|
||||
/* The next two are similar but give a "short description" of a command. */
|
||||
# define ENGINE_CTRL_GET_DESC_LEN_FROM_CMD 16
|
||||
# define ENGINE_CTRL_GET_DESC_FROM_CMD 17
|
||||
/*
|
||||
* With this command, the return value is the OR'd combination of
|
||||
* ENGINE_CMD_FLAG_*** values that indicate what kind of input a given
|
||||
* engine-specific ctrl command expects.
|
||||
*/
|
||||
# define ENGINE_CTRL_GET_CMD_FLAGS 18
|
||||
|
||||
/*
|
||||
* ENGINE implementations should start the numbering of their own control
|
||||
* commands from this value. (ie. ENGINE_CMD_BASE, ENGINE_CMD_BASE + 1, etc).
|
||||
*/
|
||||
# define ENGINE_CMD_BASE 200
|
||||
|
||||
/*
|
||||
* NB: These 2 nCipher "chil" control commands are deprecated, and their
|
||||
* functionality is now available through ENGINE-specific control commands
|
||||
* (exposed through the above-mentioned 'CMD'-handling). Code using these 2
|
||||
* commands should be migrated to the more general command handling before
|
||||
* these are removed.
|
||||
*/
|
||||
|
||||
/* Flags specific to the nCipher "chil" engine */
|
||||
# define ENGINE_CTRL_CHIL_SET_FORKCHECK 100
|
||||
/*
|
||||
* Depending on the value of the (long)i argument, this sets or
|
||||
* unsets the SimpleForkCheck flag in the CHIL API to enable or
|
||||
* disable checking and workarounds for applications that fork().
|
||||
*/
|
||||
# define ENGINE_CTRL_CHIL_NO_LOCKING 101
|
||||
/*
|
||||
* This prevents the initialisation function from providing mutex
|
||||
* callbacks to the nCipher library.
|
||||
*/
|
||||
|
||||
/*
|
||||
* If an ENGINE supports its own specific control commands and wishes the
|
||||
* framework to handle the above 'ENGINE_CMD_***'-manipulation commands on
|
||||
* its behalf, it should supply a null-terminated array of ENGINE_CMD_DEFN
|
||||
* entries to ENGINE_set_cmd_defns(). It should also implement a ctrl()
|
||||
* handler that supports the stated commands (ie. the "cmd_num" entries as
|
||||
* described by the array). NB: The array must be ordered in increasing order
|
||||
* of cmd_num. "null-terminated" means that the last ENGINE_CMD_DEFN element
|
||||
* has cmd_num set to zero and/or cmd_name set to NULL.
|
||||
*/
|
||||
typedef struct ENGINE_CMD_DEFN_st {
|
||||
unsigned int cmd_num; /* The command number */
|
||||
const char *cmd_name; /* The command name itself */
|
||||
const char *cmd_desc; /* A short description of the command */
|
||||
unsigned int cmd_flags; /* The input the command expects */
|
||||
} ENGINE_CMD_DEFN;
|
||||
|
||||
/* Generic function pointer */
|
||||
typedef int (*ENGINE_GEN_FUNC_PTR) (void);
|
||||
/* Generic function pointer taking no arguments */
|
||||
typedef int (*ENGINE_GEN_INT_FUNC_PTR) (ENGINE *);
|
||||
/* Specific control function pointer */
|
||||
typedef int (*ENGINE_CTRL_FUNC_PTR) (ENGINE *, int, long, void *,
|
||||
void (*f) (void));
|
||||
/* Generic load_key function pointer */
|
||||
typedef EVP_PKEY *(*ENGINE_LOAD_KEY_PTR)(ENGINE *, const char *,
|
||||
UI_METHOD *ui_method,
|
||||
void *callback_data);
|
||||
typedef int (*ENGINE_SSL_CLIENT_CERT_PTR) (ENGINE *, SSL *ssl,
|
||||
STACK_OF(X509_NAME) *ca_dn,
|
||||
X509 **pcert, EVP_PKEY **pkey,
|
||||
STACK_OF(X509) **pother,
|
||||
UI_METHOD *ui_method,
|
||||
void *callback_data);
|
||||
/*-
|
||||
* These callback types are for an ENGINE's handler for cipher and digest logic.
|
||||
* These handlers have these prototypes;
|
||||
* int foo(ENGINE *e, const EVP_CIPHER **cipher, const int **nids, int nid);
|
||||
* int foo(ENGINE *e, const EVP_MD **digest, const int **nids, int nid);
|
||||
* Looking at how to implement these handlers in the case of cipher support, if
|
||||
* the framework wants the EVP_CIPHER for 'nid', it will call;
|
||||
* foo(e, &p_evp_cipher, NULL, nid); (return zero for failure)
|
||||
* If the framework wants a list of supported 'nid's, it will call;
|
||||
* foo(e, NULL, &p_nids, 0); (returns number of 'nids' or -1 for error)
|
||||
*/
|
||||
/*
|
||||
* Returns to a pointer to the array of supported cipher 'nid's. If the
|
||||
* second parameter is non-NULL it is set to the size of the returned array.
|
||||
*/
|
||||
typedef int (*ENGINE_CIPHERS_PTR) (ENGINE *, const EVP_CIPHER **,
|
||||
const int **, int);
|
||||
typedef int (*ENGINE_DIGESTS_PTR) (ENGINE *, const EVP_MD **, const int **,
|
||||
int);
|
||||
typedef int (*ENGINE_PKEY_METHS_PTR) (ENGINE *, EVP_PKEY_METHOD **,
|
||||
const int **, int);
|
||||
typedef int (*ENGINE_PKEY_ASN1_METHS_PTR) (ENGINE *, EVP_PKEY_ASN1_METHOD **,
|
||||
const int **, int);
|
||||
/*
|
||||
* STRUCTURE functions ... all of these functions deal with pointers to
|
||||
* ENGINE structures where the pointers have a "structural reference". This
|
||||
* means that their reference is to allowed access to the structure but it
|
||||
* does not imply that the structure is functional. To simply increment or
|
||||
* decrement the structural reference count, use ENGINE_by_id and
|
||||
* ENGINE_free. NB: This is not required when iterating using ENGINE_get_next
|
||||
* as it will automatically decrement the structural reference count of the
|
||||
* "current" ENGINE and increment the structural reference count of the
|
||||
* ENGINE it returns (unless it is NULL).
|
||||
*/
|
||||
|
||||
/* Get the first/last "ENGINE" type available. */
|
||||
ENGINE *ENGINE_get_first(void);
|
||||
ENGINE *ENGINE_get_last(void);
|
||||
/* Iterate to the next/previous "ENGINE" type (NULL = end of the list). */
|
||||
ENGINE *ENGINE_get_next(ENGINE *e);
|
||||
ENGINE *ENGINE_get_prev(ENGINE *e);
|
||||
/* Add another "ENGINE" type into the array. */
|
||||
int ENGINE_add(ENGINE *e);
|
||||
/* Remove an existing "ENGINE" type from the array. */
|
||||
int ENGINE_remove(ENGINE *e);
|
||||
/* Retrieve an engine from the list by its unique "id" value. */
|
||||
ENGINE *ENGINE_by_id(const char *id);
|
||||
|
||||
#if OPENSSL_API_COMPAT < 0x10100000L
|
||||
# define ENGINE_load_openssl() \
|
||||
OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_OPENSSL, NULL)
|
||||
# define ENGINE_load_dynamic() \
|
||||
OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_DYNAMIC, NULL)
|
||||
# ifndef OPENSSL_NO_STATIC_ENGINE
|
||||
# define ENGINE_load_padlock() \
|
||||
OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_PADLOCK, NULL)
|
||||
# define ENGINE_load_capi() \
|
||||
OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_CAPI, NULL)
|
||||
# define ENGINE_load_dasync() \
|
||||
OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_DASYNC, NULL)
|
||||
# define ENGINE_load_afalg() \
|
||||
OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_AFALG, NULL)
|
||||
# endif
|
||||
# define ENGINE_load_cryptodev() \
|
||||
OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_CRYPTODEV, NULL)
|
||||
# define ENGINE_load_rdrand() \
|
||||
OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_RDRAND, NULL)
|
||||
#endif
|
||||
void ENGINE_load_builtin_engines(void);
|
||||
|
||||
/*
|
||||
* Get and set global flags (ENGINE_TABLE_FLAG_***) for the implementation
|
||||
* "registry" handling.
|
||||
*/
|
||||
unsigned int ENGINE_get_table_flags(void);
|
||||
void ENGINE_set_table_flags(unsigned int flags);
|
||||
|
||||
/*- Manage registration of ENGINEs per "table". For each type, there are 3
|
||||
* functions;
|
||||
* ENGINE_register_***(e) - registers the implementation from 'e' (if it has one)
|
||||
* ENGINE_unregister_***(e) - unregister the implementation from 'e'
|
||||
* ENGINE_register_all_***() - call ENGINE_register_***() for each 'e' in the list
|
||||
* Cleanup is automatically registered from each table when required.
|
||||
*/
|
||||
|
||||
int ENGINE_register_RSA(ENGINE *e);
|
||||
void ENGINE_unregister_RSA(ENGINE *e);
|
||||
void ENGINE_register_all_RSA(void);
|
||||
|
||||
int ENGINE_register_DSA(ENGINE *e);
|
||||
void ENGINE_unregister_DSA(ENGINE *e);
|
||||
void ENGINE_register_all_DSA(void);
|
||||
|
||||
int ENGINE_register_EC(ENGINE *e);
|
||||
void ENGINE_unregister_EC(ENGINE *e);
|
||||
void ENGINE_register_all_EC(void);
|
||||
|
||||
int ENGINE_register_DH(ENGINE *e);
|
||||
void ENGINE_unregister_DH(ENGINE *e);
|
||||
void ENGINE_register_all_DH(void);
|
||||
|
||||
int ENGINE_register_RAND(ENGINE *e);
|
||||
void ENGINE_unregister_RAND(ENGINE *e);
|
||||
void ENGINE_register_all_RAND(void);
|
||||
|
||||
int ENGINE_register_ciphers(ENGINE *e);
|
||||
void ENGINE_unregister_ciphers(ENGINE *e);
|
||||
void ENGINE_register_all_ciphers(void);
|
||||
|
||||
int ENGINE_register_digests(ENGINE *e);
|
||||
void ENGINE_unregister_digests(ENGINE *e);
|
||||
void ENGINE_register_all_digests(void);
|
||||
|
||||
int ENGINE_register_pkey_meths(ENGINE *e);
|
||||
void ENGINE_unregister_pkey_meths(ENGINE *e);
|
||||
void ENGINE_register_all_pkey_meths(void);
|
||||
|
||||
int ENGINE_register_pkey_asn1_meths(ENGINE *e);
|
||||
void ENGINE_unregister_pkey_asn1_meths(ENGINE *e);
|
||||
void ENGINE_register_all_pkey_asn1_meths(void);
|
||||
|
||||
/*
|
||||
* These functions register all support from the above categories. Note, use
|
||||
* of these functions can result in static linkage of code your application
|
||||
* may not need. If you only need a subset of functionality, consider using
|
||||
* more selective initialisation.
|
||||
*/
|
||||
int ENGINE_register_complete(ENGINE *e);
|
||||
int ENGINE_register_all_complete(void);
|
||||
|
||||
/*
|
||||
* Send parametrised control commands to the engine. The possibilities to
|
||||
* send down an integer, a pointer to data or a function pointer are
|
||||
* provided. Any of the parameters may or may not be NULL, depending on the
|
||||
* command number. In actuality, this function only requires a structural
|
||||
* (rather than functional) reference to an engine, but many control commands
|
||||
* may require the engine be functional. The caller should be aware of trying
|
||||
* commands that require an operational ENGINE, and only use functional
|
||||
* references in such situations.
|
||||
*/
|
||||
int ENGINE_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f) (void));
|
||||
|
||||
/*
|
||||
* This function tests if an ENGINE-specific command is usable as a
|
||||
* "setting". Eg. in an application's config file that gets processed through
|
||||
* ENGINE_ctrl_cmd_string(). If this returns zero, it is not available to
|
||||
* ENGINE_ctrl_cmd_string(), only ENGINE_ctrl().
|
||||
*/
|
||||
int ENGINE_cmd_is_executable(ENGINE *e, int cmd);
|
||||
|
||||
/*
|
||||
* This function works like ENGINE_ctrl() with the exception of taking a
|
||||
* command name instead of a command number, and can handle optional
|
||||
* commands. See the comment on ENGINE_ctrl_cmd_string() for an explanation
|
||||
* on how to use the cmd_name and cmd_optional.
|
||||
*/
|
||||
int ENGINE_ctrl_cmd(ENGINE *e, const char *cmd_name,
|
||||
long i, void *p, void (*f) (void), int cmd_optional);
|
||||
|
||||
/*
|
||||
* This function passes a command-name and argument to an ENGINE. The
|
||||
* cmd_name is converted to a command number and the control command is
|
||||
* called using 'arg' as an argument (unless the ENGINE doesn't support such
|
||||
* a command, in which case no control command is called). The command is
|
||||
* checked for input flags, and if necessary the argument will be converted
|
||||
* to a numeric value. If cmd_optional is non-zero, then if the ENGINE
|
||||
* doesn't support the given cmd_name the return value will be success
|
||||
* anyway. This function is intended for applications to use so that users
|
||||
* (or config files) can supply engine-specific config data to the ENGINE at
|
||||
* run-time to control behaviour of specific engines. As such, it shouldn't
|
||||
* be used for calling ENGINE_ctrl() functions that return data, deal with
|
||||
* binary data, or that are otherwise supposed to be used directly through
|
||||
* ENGINE_ctrl() in application code. Any "return" data from an ENGINE_ctrl()
|
||||
* operation in this function will be lost - the return value is interpreted
|
||||
* as failure if the return value is zero, success otherwise, and this
|
||||
* function returns a boolean value as a result. In other words, vendors of
|
||||
* 'ENGINE'-enabled devices should write ENGINE implementations with
|
||||
* parameterisations that work in this scheme, so that compliant ENGINE-based
|
||||
* applications can work consistently with the same configuration for the
|
||||
* same ENGINE-enabled devices, across applications.
|
||||
*/
|
||||
int ENGINE_ctrl_cmd_string(ENGINE *e, const char *cmd_name, const char *arg,
|
||||
int cmd_optional);
|
||||
|
||||
/*
|
||||
* These functions are useful for manufacturing new ENGINE structures. They
|
||||
* don't address reference counting at all - one uses them to populate an
|
||||
* ENGINE structure with personalised implementations of things prior to
|
||||
* using it directly or adding it to the builtin ENGINE list in OpenSSL.
|
||||
* These are also here so that the ENGINE structure doesn't have to be
|
||||
* exposed and break binary compatibility!
|
||||
*/
|
||||
ENGINE *ENGINE_new(void);
|
||||
int ENGINE_free(ENGINE *e);
|
||||
int ENGINE_up_ref(ENGINE *e);
|
||||
int ENGINE_set_id(ENGINE *e, const char *id);
|
||||
int ENGINE_set_name(ENGINE *e, const char *name);
|
||||
int ENGINE_set_RSA(ENGINE *e, const RSA_METHOD *rsa_meth);
|
||||
int ENGINE_set_DSA(ENGINE *e, const DSA_METHOD *dsa_meth);
|
||||
int ENGINE_set_EC(ENGINE *e, const EC_KEY_METHOD *ecdsa_meth);
|
||||
int ENGINE_set_DH(ENGINE *e, const DH_METHOD *dh_meth);
|
||||
int ENGINE_set_RAND(ENGINE *e, const RAND_METHOD *rand_meth);
|
||||
int ENGINE_set_destroy_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR destroy_f);
|
||||
int ENGINE_set_init_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR init_f);
|
||||
int ENGINE_set_finish_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR finish_f);
|
||||
int ENGINE_set_ctrl_function(ENGINE *e, ENGINE_CTRL_FUNC_PTR ctrl_f);
|
||||
int ENGINE_set_load_privkey_function(ENGINE *e,
|
||||
ENGINE_LOAD_KEY_PTR loadpriv_f);
|
||||
int ENGINE_set_load_pubkey_function(ENGINE *e, ENGINE_LOAD_KEY_PTR loadpub_f);
|
||||
int ENGINE_set_load_ssl_client_cert_function(ENGINE *e,
|
||||
ENGINE_SSL_CLIENT_CERT_PTR
|
||||
loadssl_f);
|
||||
int ENGINE_set_ciphers(ENGINE *e, ENGINE_CIPHERS_PTR f);
|
||||
int ENGINE_set_digests(ENGINE *e, ENGINE_DIGESTS_PTR f);
|
||||
int ENGINE_set_pkey_meths(ENGINE *e, ENGINE_PKEY_METHS_PTR f);
|
||||
int ENGINE_set_pkey_asn1_meths(ENGINE *e, ENGINE_PKEY_ASN1_METHS_PTR f);
|
||||
int ENGINE_set_flags(ENGINE *e, int flags);
|
||||
int ENGINE_set_cmd_defns(ENGINE *e, const ENGINE_CMD_DEFN *defns);
|
||||
/* These functions allow control over any per-structure ENGINE data. */
|
||||
#define ENGINE_get_ex_new_index(l, p, newf, dupf, freef) \
|
||||
CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_ENGINE, l, p, newf, dupf, freef)
|
||||
int ENGINE_set_ex_data(ENGINE *e, int idx, void *arg);
|
||||
void *ENGINE_get_ex_data(const ENGINE *e, int idx);
|
||||
|
||||
#if OPENSSL_API_COMPAT < 0x10100000L
|
||||
/*
|
||||
* This function previously cleaned up anything that needs it. Auto-deinit will
|
||||
* now take care of it so it is no longer required to call this function.
|
||||
*/
|
||||
# define ENGINE_cleanup() while(0) continue
|
||||
#endif
|
||||
|
||||
/*
|
||||
* These return values from within the ENGINE structure. These can be useful
|
||||
* with functional references as well as structural references - it depends
|
||||
* which you obtained. Using the result for functional purposes if you only
|
||||
* obtained a structural reference may be problematic!
|
||||
*/
|
||||
const char *ENGINE_get_id(const ENGINE *e);
|
||||
const char *ENGINE_get_name(const ENGINE *e);
|
||||
const RSA_METHOD *ENGINE_get_RSA(const ENGINE *e);
|
||||
const DSA_METHOD *ENGINE_get_DSA(const ENGINE *e);
|
||||
const EC_KEY_METHOD *ENGINE_get_EC(const ENGINE *e);
|
||||
const DH_METHOD *ENGINE_get_DH(const ENGINE *e);
|
||||
const RAND_METHOD *ENGINE_get_RAND(const ENGINE *e);
|
||||
ENGINE_GEN_INT_FUNC_PTR ENGINE_get_destroy_function(const ENGINE *e);
|
||||
ENGINE_GEN_INT_FUNC_PTR ENGINE_get_init_function(const ENGINE *e);
|
||||
ENGINE_GEN_INT_FUNC_PTR ENGINE_get_finish_function(const ENGINE *e);
|
||||
ENGINE_CTRL_FUNC_PTR ENGINE_get_ctrl_function(const ENGINE *e);
|
||||
ENGINE_LOAD_KEY_PTR ENGINE_get_load_privkey_function(const ENGINE *e);
|
||||
ENGINE_LOAD_KEY_PTR ENGINE_get_load_pubkey_function(const ENGINE *e);
|
||||
ENGINE_SSL_CLIENT_CERT_PTR ENGINE_get_ssl_client_cert_function(const ENGINE
|
||||
*e);
|
||||
ENGINE_CIPHERS_PTR ENGINE_get_ciphers(const ENGINE *e);
|
||||
ENGINE_DIGESTS_PTR ENGINE_get_digests(const ENGINE *e);
|
||||
ENGINE_PKEY_METHS_PTR ENGINE_get_pkey_meths(const ENGINE *e);
|
||||
ENGINE_PKEY_ASN1_METHS_PTR ENGINE_get_pkey_asn1_meths(const ENGINE *e);
|
||||
const EVP_CIPHER *ENGINE_get_cipher(ENGINE *e, int nid);
|
||||
const EVP_MD *ENGINE_get_digest(ENGINE *e, int nid);
|
||||
const EVP_PKEY_METHOD *ENGINE_get_pkey_meth(ENGINE *e, int nid);
|
||||
const EVP_PKEY_ASN1_METHOD *ENGINE_get_pkey_asn1_meth(ENGINE *e, int nid);
|
||||
const EVP_PKEY_ASN1_METHOD *ENGINE_get_pkey_asn1_meth_str(ENGINE *e,
|
||||
const char *str,
|
||||
int len);
|
||||
const EVP_PKEY_ASN1_METHOD *ENGINE_pkey_asn1_find_str(ENGINE **pe,
|
||||
const char *str,
|
||||
int len);
|
||||
const ENGINE_CMD_DEFN *ENGINE_get_cmd_defns(const ENGINE *e);
|
||||
int ENGINE_get_flags(const ENGINE *e);
|
||||
|
||||
/*
|
||||
* FUNCTIONAL functions. These functions deal with ENGINE structures that
|
||||
* have (or will) be initialised for use. Broadly speaking, the structural
|
||||
* functions are useful for iterating the list of available engine types,
|
||||
* creating new engine types, and other "list" operations. These functions
|
||||
* actually deal with ENGINEs that are to be used. As such these functions
|
||||
* can fail (if applicable) when particular engines are unavailable - eg. if
|
||||
* a hardware accelerator is not attached or not functioning correctly. Each
|
||||
* ENGINE has 2 reference counts; structural and functional. Every time a
|
||||
* functional reference is obtained or released, a corresponding structural
|
||||
* reference is automatically obtained or released too.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Initialise a engine type for use (or up its reference count if it's
|
||||
* already in use). This will fail if the engine is not currently operational
|
||||
* and cannot initialise.
|
||||
*/
|
||||
int ENGINE_init(ENGINE *e);
|
||||
/*
|
||||
* Free a functional reference to a engine type. This does not require a
|
||||
* corresponding call to ENGINE_free as it also releases a structural
|
||||
* reference.
|
||||
*/
|
||||
int ENGINE_finish(ENGINE *e);
|
||||
|
||||
/*
|
||||
* The following functions handle keys that are stored in some secondary
|
||||
* location, handled by the engine. The storage may be on a card or
|
||||
* whatever.
|
||||
*/
|
||||
EVP_PKEY *ENGINE_load_private_key(ENGINE *e, const char *key_id,
|
||||
UI_METHOD *ui_method, void *callback_data);
|
||||
EVP_PKEY *ENGINE_load_public_key(ENGINE *e, const char *key_id,
|
||||
UI_METHOD *ui_method, void *callback_data);
|
||||
int ENGINE_load_ssl_client_cert(ENGINE *e, SSL *s,
|
||||
STACK_OF(X509_NAME) *ca_dn, X509 **pcert,
|
||||
EVP_PKEY **ppkey, STACK_OF(X509) **pother,
|
||||
UI_METHOD *ui_method, void *callback_data);
|
||||
|
||||
/*
|
||||
* This returns a pointer for the current ENGINE structure that is (by
|
||||
* default) performing any RSA operations. The value returned is an
|
||||
* incremented reference, so it should be free'd (ENGINE_finish) before it is
|
||||
* discarded.
|
||||
*/
|
||||
ENGINE *ENGINE_get_default_RSA(void);
|
||||
/* Same for the other "methods" */
|
||||
ENGINE *ENGINE_get_default_DSA(void);
|
||||
ENGINE *ENGINE_get_default_EC(void);
|
||||
ENGINE *ENGINE_get_default_DH(void);
|
||||
ENGINE *ENGINE_get_default_RAND(void);
|
||||
/*
|
||||
* These functions can be used to get a functional reference to perform
|
||||
* ciphering or digesting corresponding to "nid".
|
||||
*/
|
||||
ENGINE *ENGINE_get_cipher_engine(int nid);
|
||||
ENGINE *ENGINE_get_digest_engine(int nid);
|
||||
ENGINE *ENGINE_get_pkey_meth_engine(int nid);
|
||||
ENGINE *ENGINE_get_pkey_asn1_meth_engine(int nid);
|
||||
|
||||
/*
|
||||
* This sets a new default ENGINE structure for performing RSA operations. If
|
||||
* the result is non-zero (success) then the ENGINE structure will have had
|
||||
* its reference count up'd so the caller should still free their own
|
||||
* reference 'e'.
|
||||
*/
|
||||
int ENGINE_set_default_RSA(ENGINE *e);
|
||||
int ENGINE_set_default_string(ENGINE *e, const char *def_list);
|
||||
/* Same for the other "methods" */
|
||||
int ENGINE_set_default_DSA(ENGINE *e);
|
||||
int ENGINE_set_default_EC(ENGINE *e);
|
||||
int ENGINE_set_default_DH(ENGINE *e);
|
||||
int ENGINE_set_default_RAND(ENGINE *e);
|
||||
int ENGINE_set_default_ciphers(ENGINE *e);
|
||||
int ENGINE_set_default_digests(ENGINE *e);
|
||||
int ENGINE_set_default_pkey_meths(ENGINE *e);
|
||||
int ENGINE_set_default_pkey_asn1_meths(ENGINE *e);
|
||||
|
||||
/*
|
||||
* The combination "set" - the flags are bitwise "OR"d from the
|
||||
* ENGINE_METHOD_*** defines above. As with the "ENGINE_register_complete()"
|
||||
* function, this function can result in unnecessary static linkage. If your
|
||||
* application requires only specific functionality, consider using more
|
||||
* selective functions.
|
||||
*/
|
||||
int ENGINE_set_default(ENGINE *e, unsigned int flags);
|
||||
|
||||
void ENGINE_add_conf_module(void);
|
||||
|
||||
/* Deprecated functions ... */
|
||||
/* int ENGINE_clear_defaults(void); */
|
||||
|
||||
/**************************/
|
||||
/* DYNAMIC ENGINE SUPPORT */
|
||||
/**************************/
|
||||
|
||||
/* Binary/behaviour compatibility levels */
|
||||
# define OSSL_DYNAMIC_VERSION (unsigned long)0x00030000
|
||||
/*
|
||||
* Binary versions older than this are too old for us (whether we're a loader
|
||||
* or a loadee)
|
||||
*/
|
||||
# define OSSL_DYNAMIC_OLDEST (unsigned long)0x00030000
|
||||
|
||||
/*
|
||||
* When compiling an ENGINE entirely as an external shared library, loadable
|
||||
* by the "dynamic" ENGINE, these types are needed. The 'dynamic_fns'
|
||||
* structure type provides the calling application's (or library's) error
|
||||
* functionality and memory management function pointers to the loaded
|
||||
* library. These should be used/set in the loaded library code so that the
|
||||
* loading application's 'state' will be used/changed in all operations. The
|
||||
* 'static_state' pointer allows the loaded library to know if it shares the
|
||||
* same static data as the calling application (or library), and thus whether
|
||||
* these callbacks need to be set or not.
|
||||
*/
|
||||
typedef void *(*dyn_MEM_malloc_fn) (size_t, const char *, int);
|
||||
typedef void *(*dyn_MEM_realloc_fn) (void *, size_t, const char *, int);
|
||||
typedef void (*dyn_MEM_free_fn) (void *, const char *, int);
|
||||
typedef struct st_dynamic_MEM_fns {
|
||||
dyn_MEM_malloc_fn malloc_fn;
|
||||
dyn_MEM_realloc_fn realloc_fn;
|
||||
dyn_MEM_free_fn free_fn;
|
||||
} dynamic_MEM_fns;
|
||||
/*
|
||||
* FIXME: Perhaps the memory and locking code (crypto.h) should declare and
|
||||
* use these types so we (and any other dependent code) can simplify a bit??
|
||||
*/
|
||||
/* The top-level structure */
|
||||
typedef struct st_dynamic_fns {
|
||||
void *static_state;
|
||||
dynamic_MEM_fns mem_fns;
|
||||
} dynamic_fns;
|
||||
|
||||
/*
|
||||
* The version checking function should be of this prototype. NB: The
|
||||
* ossl_version value passed in is the OSSL_DYNAMIC_VERSION of the loading
|
||||
* code. If this function returns zero, it indicates a (potential) version
|
||||
* incompatibility and the loaded library doesn't believe it can proceed.
|
||||
* Otherwise, the returned value is the (latest) version supported by the
|
||||
* loading library. The loader may still decide that the loaded code's
|
||||
* version is unsatisfactory and could veto the load. The function is
|
||||
* expected to be implemented with the symbol name "v_check", and a default
|
||||
* implementation can be fully instantiated with
|
||||
* IMPLEMENT_DYNAMIC_CHECK_FN().
|
||||
*/
|
||||
typedef unsigned long (*dynamic_v_check_fn) (unsigned long ossl_version);
|
||||
# define IMPLEMENT_DYNAMIC_CHECK_FN() \
|
||||
OPENSSL_EXPORT unsigned long v_check(unsigned long v); \
|
||||
OPENSSL_EXPORT unsigned long v_check(unsigned long v) { \
|
||||
if (v >= OSSL_DYNAMIC_OLDEST) return OSSL_DYNAMIC_VERSION; \
|
||||
return 0; }
|
||||
|
||||
/*
|
||||
* This function is passed the ENGINE structure to initialise with its own
|
||||
* function and command settings. It should not adjust the structural or
|
||||
* functional reference counts. If this function returns zero, (a) the load
|
||||
* will be aborted, (b) the previous ENGINE state will be memcpy'd back onto
|
||||
* the structure, and (c) the shared library will be unloaded. So
|
||||
* implementations should do their own internal cleanup in failure
|
||||
* circumstances otherwise they could leak. The 'id' parameter, if non-NULL,
|
||||
* represents the ENGINE id that the loader is looking for. If this is NULL,
|
||||
* the shared library can choose to return failure or to initialise a
|
||||
* 'default' ENGINE. If non-NULL, the shared library must initialise only an
|
||||
* ENGINE matching the passed 'id'. The function is expected to be
|
||||
* implemented with the symbol name "bind_engine". A standard implementation
|
||||
* can be instantiated with IMPLEMENT_DYNAMIC_BIND_FN(fn) where the parameter
|
||||
* 'fn' is a callback function that populates the ENGINE structure and
|
||||
* returns an int value (zero for failure). 'fn' should have prototype;
|
||||
* [static] int fn(ENGINE *e, const char *id);
|
||||
*/
|
||||
typedef int (*dynamic_bind_engine) (ENGINE *e, const char *id,
|
||||
const dynamic_fns *fns);
|
||||
# define IMPLEMENT_DYNAMIC_BIND_FN(fn) \
|
||||
OPENSSL_EXPORT \
|
||||
int bind_engine(ENGINE *e, const char *id, const dynamic_fns *fns); \
|
||||
OPENSSL_EXPORT \
|
||||
int bind_engine(ENGINE *e, const char *id, const dynamic_fns *fns) { \
|
||||
if (ENGINE_get_static_state() == fns->static_state) goto skip_cbs; \
|
||||
CRYPTO_set_mem_functions(fns->mem_fns.malloc_fn, \
|
||||
fns->mem_fns.realloc_fn, \
|
||||
fns->mem_fns.free_fn); \
|
||||
skip_cbs: \
|
||||
if (!fn(e, id)) return 0; \
|
||||
return 1; }
|
||||
|
||||
/*
|
||||
* If the loading application (or library) and the loaded ENGINE library
|
||||
* share the same static data (eg. they're both dynamically linked to the
|
||||
* same libcrypto.so) we need a way to avoid trying to set system callbacks -
|
||||
* this would fail, and for the same reason that it's unnecessary to try. If
|
||||
* the loaded ENGINE has (or gets from through the loader) its own copy of
|
||||
* the libcrypto static data, we will need to set the callbacks. The easiest
|
||||
* way to detect this is to have a function that returns a pointer to some
|
||||
* static data and let the loading application and loaded ENGINE compare
|
||||
* their respective values.
|
||||
*/
|
||||
void *ENGINE_get_static_state(void);
|
||||
|
||||
# if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(HAVE_CRYPTODEV)
|
||||
DEPRECATEDIN_1_1_0(void ENGINE_setup_bsd_cryptodev(void))
|
||||
# endif
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
/*
|
||||
* The following lines are auto generated by the script mkerr.pl. Any changes
|
||||
* made after this point may be overwritten when the script is next run.
|
||||
*/
|
||||
|
||||
int ERR_load_ENGINE_strings(void);
|
||||
|
||||
/* Error codes for the ENGINE functions. */
|
||||
|
||||
/* Function codes. */
|
||||
# define ENGINE_F_DYNAMIC_CTRL 180
|
||||
# define ENGINE_F_DYNAMIC_GET_DATA_CTX 181
|
||||
# define ENGINE_F_DYNAMIC_LOAD 182
|
||||
# define ENGINE_F_DYNAMIC_SET_DATA_CTX 183
|
||||
# define ENGINE_F_ENGINE_ADD 105
|
||||
# define ENGINE_F_ENGINE_BY_ID 106
|
||||
# define ENGINE_F_ENGINE_CMD_IS_EXECUTABLE 170
|
||||
# define ENGINE_F_ENGINE_CTRL 142
|
||||
# define ENGINE_F_ENGINE_CTRL_CMD 178
|
||||
# define ENGINE_F_ENGINE_CTRL_CMD_STRING 171
|
||||
# define ENGINE_F_ENGINE_FINISH 107
|
||||
# define ENGINE_F_ENGINE_GET_CIPHER 185
|
||||
# define ENGINE_F_ENGINE_GET_DIGEST 186
|
||||
# define ENGINE_F_ENGINE_GET_FIRST 195
|
||||
# define ENGINE_F_ENGINE_GET_LAST 196
|
||||
# define ENGINE_F_ENGINE_GET_NEXT 115
|
||||
# define ENGINE_F_ENGINE_GET_PKEY_ASN1_METH 193
|
||||
# define ENGINE_F_ENGINE_GET_PKEY_METH 192
|
||||
# define ENGINE_F_ENGINE_GET_PREV 116
|
||||
# define ENGINE_F_ENGINE_INIT 119
|
||||
# define ENGINE_F_ENGINE_LIST_ADD 120
|
||||
# define ENGINE_F_ENGINE_LIST_REMOVE 121
|
||||
# define ENGINE_F_ENGINE_LOAD_PRIVATE_KEY 150
|
||||
# define ENGINE_F_ENGINE_LOAD_PUBLIC_KEY 151
|
||||
# define ENGINE_F_ENGINE_LOAD_SSL_CLIENT_CERT 194
|
||||
# define ENGINE_F_ENGINE_NEW 122
|
||||
# define ENGINE_F_ENGINE_PKEY_ASN1_FIND_STR 197
|
||||
# define ENGINE_F_ENGINE_REMOVE 123
|
||||
# define ENGINE_F_ENGINE_SET_DEFAULT_STRING 189
|
||||
# define ENGINE_F_ENGINE_SET_ID 129
|
||||
# define ENGINE_F_ENGINE_SET_NAME 130
|
||||
# define ENGINE_F_ENGINE_TABLE_REGISTER 184
|
||||
# define ENGINE_F_ENGINE_UNLOCKED_FINISH 191
|
||||
# define ENGINE_F_ENGINE_UP_REF 190
|
||||
# define ENGINE_F_INT_CTRL_HELPER 172
|
||||
# define ENGINE_F_INT_ENGINE_CONFIGURE 188
|
||||
# define ENGINE_F_INT_ENGINE_MODULE_INIT 187
|
||||
|
||||
/* Reason codes. */
|
||||
# define ENGINE_R_ALREADY_LOADED 100
|
||||
# define ENGINE_R_ARGUMENT_IS_NOT_A_NUMBER 133
|
||||
# define ENGINE_R_CMD_NOT_EXECUTABLE 134
|
||||
# define ENGINE_R_COMMAND_TAKES_INPUT 135
|
||||
# define ENGINE_R_COMMAND_TAKES_NO_INPUT 136
|
||||
# define ENGINE_R_CONFLICTING_ENGINE_ID 103
|
||||
# define ENGINE_R_CTRL_COMMAND_NOT_IMPLEMENTED 119
|
||||
# define ENGINE_R_DSO_FAILURE 104
|
||||
# define ENGINE_R_DSO_NOT_FOUND 132
|
||||
# define ENGINE_R_ENGINES_SECTION_ERROR 148
|
||||
# define ENGINE_R_ENGINE_CONFIGURATION_ERROR 102
|
||||
# define ENGINE_R_ENGINE_IS_NOT_IN_LIST 105
|
||||
# define ENGINE_R_ENGINE_SECTION_ERROR 149
|
||||
# define ENGINE_R_FAILED_LOADING_PRIVATE_KEY 128
|
||||
# define ENGINE_R_FAILED_LOADING_PUBLIC_KEY 129
|
||||
# define ENGINE_R_FINISH_FAILED 106
|
||||
# define ENGINE_R_ID_OR_NAME_MISSING 108
|
||||
# define ENGINE_R_INIT_FAILED 109
|
||||
# define ENGINE_R_INTERNAL_LIST_ERROR 110
|
||||
# define ENGINE_R_INVALID_ARGUMENT 143
|
||||
# define ENGINE_R_INVALID_CMD_NAME 137
|
||||
# define ENGINE_R_INVALID_CMD_NUMBER 138
|
||||
# define ENGINE_R_INVALID_INIT_VALUE 151
|
||||
# define ENGINE_R_INVALID_STRING 150
|
||||
# define ENGINE_R_NOT_INITIALISED 117
|
||||
# define ENGINE_R_NOT_LOADED 112
|
||||
# define ENGINE_R_NO_CONTROL_FUNCTION 120
|
||||
# define ENGINE_R_NO_INDEX 144
|
||||
# define ENGINE_R_NO_LOAD_FUNCTION 125
|
||||
# define ENGINE_R_NO_REFERENCE 130
|
||||
# define ENGINE_R_NO_SUCH_ENGINE 116
|
||||
# define ENGINE_R_UNIMPLEMENTED_CIPHER 146
|
||||
# define ENGINE_R_UNIMPLEMENTED_DIGEST 147
|
||||
# define ENGINE_R_UNIMPLEMENTED_PUBLIC_KEY_METHOD 101
|
||||
# define ENGINE_R_VERSION_INCOMPATIBILITY 145
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
|
@ -0,0 +1,259 @@
|
|||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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_ERR_H
|
||||
# define HEADER_ERR_H
|
||||
|
||||
# include <openssl/e_os2.h>
|
||||
|
||||
# ifndef OPENSSL_NO_STDIO
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
# endif
|
||||
|
||||
# include <openssl/ossl_typ.h>
|
||||
# include <openssl/bio.h>
|
||||
# include <openssl/lhash.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
# ifndef OPENSSL_NO_ERR
|
||||
# define ERR_PUT_error(a,b,c,d,e) ERR_put_error(a,b,c,d,e)
|
||||
# else
|
||||
# define ERR_PUT_error(a,b,c,d,e) ERR_put_error(a,b,c,NULL,0)
|
||||
# endif
|
||||
|
||||
# include <errno.h>
|
||||
|
||||
# define ERR_TXT_MALLOCED 0x01
|
||||
# define ERR_TXT_STRING 0x02
|
||||
|
||||
# define ERR_FLAG_MARK 0x01
|
||||
|
||||
# define ERR_NUM_ERRORS 16
|
||||
typedef struct err_state_st {
|
||||
int err_flags[ERR_NUM_ERRORS];
|
||||
unsigned long err_buffer[ERR_NUM_ERRORS];
|
||||
char *err_data[ERR_NUM_ERRORS];
|
||||
int err_data_flags[ERR_NUM_ERRORS];
|
||||
const char *err_file[ERR_NUM_ERRORS];
|
||||
int err_line[ERR_NUM_ERRORS];
|
||||
int top, bottom;
|
||||
} ERR_STATE;
|
||||
|
||||
/* library */
|
||||
# define ERR_LIB_NONE 1
|
||||
# define ERR_LIB_SYS 2
|
||||
# define ERR_LIB_BN 3
|
||||
# define ERR_LIB_RSA 4
|
||||
# define ERR_LIB_DH 5
|
||||
# define ERR_LIB_EVP 6
|
||||
# define ERR_LIB_BUF 7
|
||||
# define ERR_LIB_OBJ 8
|
||||
# define ERR_LIB_PEM 9
|
||||
# define ERR_LIB_DSA 10
|
||||
# define ERR_LIB_X509 11
|
||||
/* #define ERR_LIB_METH 12 */
|
||||
# define ERR_LIB_ASN1 13
|
||||
# define ERR_LIB_CONF 14
|
||||
# define ERR_LIB_CRYPTO 15
|
||||
# define ERR_LIB_EC 16
|
||||
# define ERR_LIB_SSL 20
|
||||
/* #define ERR_LIB_SSL23 21 */
|
||||
/* #define ERR_LIB_SSL2 22 */
|
||||
/* #define ERR_LIB_SSL3 23 */
|
||||
/* #define ERR_LIB_RSAREF 30 */
|
||||
/* #define ERR_LIB_PROXY 31 */
|
||||
# define ERR_LIB_BIO 32
|
||||
# define ERR_LIB_PKCS7 33
|
||||
# define ERR_LIB_X509V3 34
|
||||
# define ERR_LIB_PKCS12 35
|
||||
# define ERR_LIB_RAND 36
|
||||
# define ERR_LIB_DSO 37
|
||||
# define ERR_LIB_ENGINE 38
|
||||
# define ERR_LIB_OCSP 39
|
||||
# define ERR_LIB_UI 40
|
||||
# define ERR_LIB_COMP 41
|
||||
# define ERR_LIB_ECDSA 42
|
||||
# define ERR_LIB_ECDH 43
|
||||
# define ERR_LIB_STORE 44
|
||||
# define ERR_LIB_FIPS 45
|
||||
# define ERR_LIB_CMS 46
|
||||
# define ERR_LIB_TS 47
|
||||
# define ERR_LIB_HMAC 48
|
||||
# define ERR_LIB_JPAKE 49
|
||||
# define ERR_LIB_CT 50
|
||||
# define ERR_LIB_ASYNC 51
|
||||
# define ERR_LIB_KDF 52
|
||||
|
||||
# define ERR_LIB_USER 128
|
||||
|
||||
# define SYSerr(f,r) ERR_PUT_error(ERR_LIB_SYS,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
||||
# define BNerr(f,r) ERR_PUT_error(ERR_LIB_BN,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
||||
# define RSAerr(f,r) ERR_PUT_error(ERR_LIB_RSA,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
||||
# define DHerr(f,r) ERR_PUT_error(ERR_LIB_DH,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
||||
# define EVPerr(f,r) ERR_PUT_error(ERR_LIB_EVP,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
||||
# define BUFerr(f,r) ERR_PUT_error(ERR_LIB_BUF,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
||||
# define OBJerr(f,r) ERR_PUT_error(ERR_LIB_OBJ,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
||||
# define PEMerr(f,r) ERR_PUT_error(ERR_LIB_PEM,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
||||
# define DSAerr(f,r) ERR_PUT_error(ERR_LIB_DSA,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
||||
# define X509err(f,r) ERR_PUT_error(ERR_LIB_X509,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
||||
# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
||||
# define CONFerr(f,r) ERR_PUT_error(ERR_LIB_CONF,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
||||
# define CRYPTOerr(f,r) ERR_PUT_error(ERR_LIB_CRYPTO,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
||||
# define ECerr(f,r) ERR_PUT_error(ERR_LIB_EC,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
||||
# define SSLerr(f,r) ERR_PUT_error(ERR_LIB_SSL,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
||||
# define BIOerr(f,r) ERR_PUT_error(ERR_LIB_BIO,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
||||
# define PKCS7err(f,r) ERR_PUT_error(ERR_LIB_PKCS7,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
||||
# define X509V3err(f,r) ERR_PUT_error(ERR_LIB_X509V3,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
||||
# define PKCS12err(f,r) ERR_PUT_error(ERR_LIB_PKCS12,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
||||
# define RANDerr(f,r) ERR_PUT_error(ERR_LIB_RAND,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
||||
# define DSOerr(f,r) ERR_PUT_error(ERR_LIB_DSO,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
||||
# define ENGINEerr(f,r) ERR_PUT_error(ERR_LIB_ENGINE,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
||||
# define OCSPerr(f,r) ERR_PUT_error(ERR_LIB_OCSP,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
||||
# define UIerr(f,r) ERR_PUT_error(ERR_LIB_UI,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
||||
# define COMPerr(f,r) ERR_PUT_error(ERR_LIB_COMP,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
||||
# define ECDSAerr(f,r) ERR_PUT_error(ERR_LIB_ECDSA,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
||||
# define ECDHerr(f,r) ERR_PUT_error(ERR_LIB_ECDH,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
||||
# define STOREerr(f,r) ERR_PUT_error(ERR_LIB_STORE,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
||||
# define FIPSerr(f,r) ERR_PUT_error(ERR_LIB_FIPS,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
||||
# define CMSerr(f,r) ERR_PUT_error(ERR_LIB_CMS,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
||||
# define TSerr(f,r) ERR_PUT_error(ERR_LIB_TS,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
||||
# define HMACerr(f,r) ERR_PUT_error(ERR_LIB_HMAC,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
||||
# define JPAKEerr(f,r) ERR_PUT_error(ERR_LIB_JPAKE,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
||||
# define CTerr(f,r) ERR_PUT_error(ERR_LIB_CT,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
||||
# define ASYNCerr(f,r) ERR_PUT_error(ERR_LIB_ASYNC,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
||||
# define KDFerr(f,r) ERR_PUT_error(ERR_LIB_KDF,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
||||
|
||||
# define ERR_PACK(l,f,r) ( \
|
||||
(((unsigned int)(l) & 0x0FF) << 24L) | \
|
||||
(((unsigned int)(f) & 0xFFF) << 12L) | \
|
||||
(((unsigned int)(r) & 0xFFF) ) )
|
||||
# define ERR_GET_LIB(l) (int)(((l) >> 24L) & 0x0FFL)
|
||||
# define ERR_GET_FUNC(l) (int)(((l) >> 12L) & 0xFFFL)
|
||||
# define ERR_GET_REASON(l) (int)( (l) & 0xFFFL)
|
||||
|
||||
/* OS functions */
|
||||
# define SYS_F_FOPEN 1
|
||||
# define SYS_F_CONNECT 2
|
||||
# define SYS_F_GETSERVBYNAME 3
|
||||
# define SYS_F_SOCKET 4
|
||||
# define SYS_F_IOCTLSOCKET 5
|
||||
# define SYS_F_BIND 6
|
||||
# define SYS_F_LISTEN 7
|
||||
# define SYS_F_ACCEPT 8
|
||||
# define SYS_F_WSASTARTUP 9/* Winsock stuff */
|
||||
# define SYS_F_OPENDIR 10
|
||||
# define SYS_F_FREAD 11
|
||||
# define SYS_F_GETADDRINFO 12
|
||||
# define SYS_F_GETNAMEINFO 13
|
||||
# define SYS_F_SETSOCKOPT 14
|
||||
# define SYS_F_GETSOCKOPT 15
|
||||
# define SYS_F_GETSOCKNAME 16
|
||||
# define SYS_F_GETHOSTBYNAME 17
|
||||
|
||||
/* reasons */
|
||||
# define ERR_R_SYS_LIB ERR_LIB_SYS/* 2 */
|
||||
# define ERR_R_BN_LIB ERR_LIB_BN/* 3 */
|
||||
# define ERR_R_RSA_LIB ERR_LIB_RSA/* 4 */
|
||||
# define ERR_R_DH_LIB ERR_LIB_DH/* 5 */
|
||||
# define ERR_R_EVP_LIB ERR_LIB_EVP/* 6 */
|
||||
# define ERR_R_BUF_LIB ERR_LIB_BUF/* 7 */
|
||||
# define ERR_R_OBJ_LIB ERR_LIB_OBJ/* 8 */
|
||||
# define ERR_R_PEM_LIB ERR_LIB_PEM/* 9 */
|
||||
# define ERR_R_DSA_LIB ERR_LIB_DSA/* 10 */
|
||||
# define ERR_R_X509_LIB ERR_LIB_X509/* 11 */
|
||||
# define ERR_R_ASN1_LIB ERR_LIB_ASN1/* 13 */
|
||||
# define ERR_R_EC_LIB ERR_LIB_EC/* 16 */
|
||||
# define ERR_R_BIO_LIB ERR_LIB_BIO/* 32 */
|
||||
# define ERR_R_PKCS7_LIB ERR_LIB_PKCS7/* 33 */
|
||||
# define ERR_R_X509V3_LIB ERR_LIB_X509V3/* 34 */
|
||||
# define ERR_R_ENGINE_LIB ERR_LIB_ENGINE/* 38 */
|
||||
# define ERR_R_ECDSA_LIB ERR_LIB_ECDSA/* 42 */
|
||||
|
||||
# define ERR_R_NESTED_ASN1_ERROR 58
|
||||
# define ERR_R_MISSING_ASN1_EOS 63
|
||||
|
||||
/* fatal error */
|
||||
# define ERR_R_FATAL 64
|
||||
# define ERR_R_MALLOC_FAILURE (1|ERR_R_FATAL)
|
||||
# define ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED (2|ERR_R_FATAL)
|
||||
# define ERR_R_PASSED_NULL_PARAMETER (3|ERR_R_FATAL)
|
||||
# define ERR_R_INTERNAL_ERROR (4|ERR_R_FATAL)
|
||||
# define ERR_R_DISABLED (5|ERR_R_FATAL)
|
||||
# define ERR_R_INIT_FAIL (6|ERR_R_FATAL)
|
||||
# define ERR_R_PASSED_INVALID_ARGUMENT (7)
|
||||
|
||||
/*
|
||||
* 99 is the maximum possible ERR_R_... code, higher values are reserved for
|
||||
* the individual libraries
|
||||
*/
|
||||
|
||||
typedef struct ERR_string_data_st {
|
||||
unsigned long error;
|
||||
const char *string;
|
||||
} ERR_STRING_DATA;
|
||||
|
||||
DEFINE_LHASH_OF(ERR_STRING_DATA);
|
||||
|
||||
void ERR_put_error(int lib, int func, int reason, const char *file, int line);
|
||||
void ERR_set_error_data(char *data, int flags);
|
||||
|
||||
unsigned long ERR_get_error(void);
|
||||
unsigned long ERR_get_error_line(const char **file, int *line);
|
||||
unsigned long ERR_get_error_line_data(const char **file, int *line,
|
||||
const char **data, int *flags);
|
||||
unsigned long ERR_peek_error(void);
|
||||
unsigned long ERR_peek_error_line(const char **file, int *line);
|
||||
unsigned long ERR_peek_error_line_data(const char **file, int *line,
|
||||
const char **data, int *flags);
|
||||
unsigned long ERR_peek_last_error(void);
|
||||
unsigned long ERR_peek_last_error_line(const char **file, int *line);
|
||||
unsigned long ERR_peek_last_error_line_data(const char **file, int *line,
|
||||
const char **data, int *flags);
|
||||
void ERR_clear_error(void);
|
||||
char *ERR_error_string(unsigned long e, char *buf);
|
||||
void ERR_error_string_n(unsigned long e, char *buf, size_t len);
|
||||
const char *ERR_lib_error_string(unsigned long e);
|
||||
const char *ERR_func_error_string(unsigned long e);
|
||||
const char *ERR_reason_error_string(unsigned long e);
|
||||
void ERR_print_errors_cb(int (*cb) (const char *str, size_t len, void *u),
|
||||
void *u);
|
||||
# ifndef OPENSSL_NO_STDIO
|
||||
void ERR_print_errors_fp(FILE *fp);
|
||||
# endif
|
||||
void ERR_print_errors(BIO *bp);
|
||||
void ERR_add_error_data(int num, ...);
|
||||
void ERR_add_error_vdata(int num, va_list args);
|
||||
int ERR_load_strings(int lib, ERR_STRING_DATA str[]);
|
||||
int ERR_unload_strings(int lib, ERR_STRING_DATA str[]);
|
||||
int ERR_load_ERR_strings(void);
|
||||
|
||||
#if OPENSSL_API_COMPAT < 0x10100000L
|
||||
# define ERR_load_crypto_strings() \
|
||||
OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL)
|
||||
# define ERR_free_strings() while(0) continue
|
||||
#endif
|
||||
|
||||
DEPRECATEDIN_1_1_0(void ERR_remove_thread_state(void *))
|
||||
DEPRECATEDIN_1_0_0(void ERR_remove_state(unsigned long pid))
|
||||
ERR_STATE *ERR_get_state(void);
|
||||
|
||||
int ERR_get_next_error_library(void);
|
||||
|
||||
int ERR_set_mark(void);
|
||||
int ERR_pop_to_mark(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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_H
|
||||
# define HEADER_HMAC_H
|
||||
|
||||
# include <openssl/opensslconf.h>
|
||||
|
||||
# include <openssl/evp.h>
|
||||
|
||||
# define HMAC_MAX_MD_CBLOCK 128/* largest known is SHA512 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
size_t HMAC_size(const HMAC_CTX *e);
|
||||
HMAC_CTX *HMAC_CTX_new(void);
|
||||
int HMAC_CTX_reset(HMAC_CTX *ctx);
|
||||
void HMAC_CTX_free(HMAC_CTX *ctx);
|
||||
|
||||
DEPRECATEDIN_1_1_0(__owur int HMAC_Init(HMAC_CTX *ctx, const void *key, int len,
|
||||
const EVP_MD *md))
|
||||
|
||||
/*__owur*/ int HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len,
|
||||
const EVP_MD *md, ENGINE *impl);
|
||||
/*__owur*/ int HMAC_Update(HMAC_CTX *ctx, const unsigned char *data,
|
||||
size_t len);
|
||||
/*__owur*/ int HMAC_Final(HMAC_CTX *ctx, unsigned char *md,
|
||||
unsigned int *len);
|
||||
unsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len,
|
||||
const unsigned char *d, size_t n, unsigned char *md,
|
||||
unsigned int *md_len);
|
||||
__owur int HMAC_CTX_copy(HMAC_CTX *dctx, HMAC_CTX *sctx);
|
||||
|
||||
void HMAC_CTX_set_flags(HMAC_CTX *ctx, unsigned long flags);
|
||||
const EVP_MD *HMAC_CTX_get_md(const HMAC_CTX *ctx);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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_IDEA_H
|
||||
# define HEADER_IDEA_H
|
||||
|
||||
# include <openssl/opensslconf.h>
|
||||
|
||||
# ifndef OPENSSL_NO_IDEA
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
# endif
|
||||
|
||||
typedef unsigned int IDEA_INT;
|
||||
|
||||
# define IDEA_ENCRYPT 1
|
||||
# define IDEA_DECRYPT 0
|
||||
|
||||
# define IDEA_BLOCK 8
|
||||
# define IDEA_KEY_LENGTH 16
|
||||
|
||||
typedef struct idea_key_st {
|
||||
IDEA_INT data[9][6];
|
||||
} IDEA_KEY_SCHEDULE;
|
||||
|
||||
const char *IDEA_options(void);
|
||||
void IDEA_ecb_encrypt(const unsigned char *in, unsigned char *out,
|
||||
IDEA_KEY_SCHEDULE *ks);
|
||||
void IDEA_set_encrypt_key(const unsigned char *key, IDEA_KEY_SCHEDULE *ks);
|
||||
void IDEA_set_decrypt_key(IDEA_KEY_SCHEDULE *ek, IDEA_KEY_SCHEDULE *dk);
|
||||
void IDEA_cbc_encrypt(const unsigned char *in, unsigned char *out,
|
||||
long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv,
|
||||
int enc);
|
||||
void IDEA_cfb64_encrypt(const unsigned char *in, unsigned char *out,
|
||||
long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv,
|
||||
int *num, int enc);
|
||||
void IDEA_ofb64_encrypt(const unsigned char *in, unsigned char *out,
|
||||
long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv,
|
||||
int *num);
|
||||
void IDEA_encrypt(unsigned long *in, IDEA_KEY_SCHEDULE *ks);
|
||||
|
||||
# if OPENSSL_API_COMPAT < 0x10100000L
|
||||
# define idea_options IDEA_options
|
||||
# define idea_ecb_encrypt IDEA_ecb_encrypt
|
||||
# define idea_set_encrypt_key IDEA_set_encrypt_key
|
||||
# define idea_set_decrypt_key IDEA_set_decrypt_key
|
||||
# define idea_cbc_encrypt IDEA_cbc_encrypt
|
||||
# define idea_cfb64_encrypt IDEA_cfb64_encrypt
|
||||
# define idea_ofb64_encrypt IDEA_ofb64_encrypt
|
||||
# define idea_encrypt IDEA_encrypt
|
||||
# endif
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
* Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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_KDF_H
|
||||
# define HEADER_KDF_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
# define EVP_PKEY_CTRL_TLS_MD (EVP_PKEY_ALG_CTRL)
|
||||
# define EVP_PKEY_CTRL_TLS_SECRET (EVP_PKEY_ALG_CTRL + 1)
|
||||
# define EVP_PKEY_CTRL_TLS_SEED (EVP_PKEY_ALG_CTRL + 2)
|
||||
# define EVP_PKEY_CTRL_HKDF_MD (EVP_PKEY_ALG_CTRL + 3)
|
||||
# define EVP_PKEY_CTRL_HKDF_SALT (EVP_PKEY_ALG_CTRL + 4)
|
||||
# define EVP_PKEY_CTRL_HKDF_KEY (EVP_PKEY_ALG_CTRL + 5)
|
||||
# define EVP_PKEY_CTRL_HKDF_INFO (EVP_PKEY_ALG_CTRL + 6)
|
||||
|
||||
# define EVP_PKEY_CTX_set_tls1_prf_md(pctx, md) \
|
||||
EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \
|
||||
EVP_PKEY_CTRL_TLS_MD, 0, (void *)md)
|
||||
|
||||
# define EVP_PKEY_CTX_set1_tls1_prf_secret(pctx, sec, seclen) \
|
||||
EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \
|
||||
EVP_PKEY_CTRL_TLS_SECRET, seclen, (void *)sec)
|
||||
|
||||
# define EVP_PKEY_CTX_add1_tls1_prf_seed(pctx, seed, seedlen) \
|
||||
EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \
|
||||
EVP_PKEY_CTRL_TLS_SEED, seedlen, (void *)seed)
|
||||
|
||||
# define EVP_PKEY_CTX_set_hkdf_md(pctx, md) \
|
||||
EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \
|
||||
EVP_PKEY_CTRL_HKDF_MD, 0, (void *)md)
|
||||
|
||||
# define EVP_PKEY_CTX_set1_hkdf_salt(pctx, salt, saltlen) \
|
||||
EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \
|
||||
EVP_PKEY_CTRL_HKDF_SALT, saltlen, (void *)salt)
|
||||
|
||||
# define EVP_PKEY_CTX_set1_hkdf_key(pctx, key, keylen) \
|
||||
EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \
|
||||
EVP_PKEY_CTRL_HKDF_KEY, keylen, (void *)key)
|
||||
|
||||
# define EVP_PKEY_CTX_add1_hkdf_info(pctx, info, infolen) \
|
||||
EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \
|
||||
EVP_PKEY_CTRL_HKDF_INFO, infolen, (void *)info)
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
/*
|
||||
* The following lines are auto generated by the script mkerr.pl. Any changes
|
||||
* made after this point may be overwritten when the script is next run.
|
||||
*/
|
||||
|
||||
int ERR_load_KDF_strings(void);
|
||||
|
||||
/* Error codes for the KDF functions. */
|
||||
|
||||
/* Function codes. */
|
||||
# define KDF_F_PKEY_TLS1_PRF_CTRL_STR 100
|
||||
# define KDF_F_PKEY_TLS1_PRF_DERIVE 101
|
||||
|
||||
/* Reason codes. */
|
||||
# define KDF_R_INVALID_DIGEST 100
|
||||
# define KDF_R_MISSING_PARAMETER 101
|
||||
# define KDF_R_VALUE_MISSING 102
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
|
@ -0,0 +1,204 @@
|
|||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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
|
||||
*/
|
||||
|
||||
/*
|
||||
* Header for dynamic hash table routines Author - Eric Young
|
||||
*/
|
||||
|
||||
#ifndef HEADER_LHASH_H
|
||||
# define HEADER_LHASH_H
|
||||
|
||||
# include <openssl/e_os2.h>
|
||||
# include <openssl/bio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct lhash_node_st OPENSSL_LH_NODE;
|
||||
typedef int (*OPENSSL_LH_COMPFUNC) (const void *, const void *);
|
||||
typedef unsigned long (*OPENSSL_LH_HASHFUNC) (const void *);
|
||||
typedef void (*OPENSSL_LH_DOALL_FUNC) (void *);
|
||||
typedef void (*OPENSSL_LH_DOALL_FUNCARG) (void *, void *);
|
||||
typedef struct lhash_st OPENSSL_LHASH;
|
||||
|
||||
/*
|
||||
* Macros for declaring and implementing type-safe wrappers for LHASH
|
||||
* callbacks. This way, callbacks can be provided to LHASH structures without
|
||||
* function pointer casting and the macro-defined callbacks provide
|
||||
* per-variable casting before deferring to the underlying type-specific
|
||||
* callbacks. NB: It is possible to place a "static" in front of both the
|
||||
* DECLARE and IMPLEMENT macros if the functions are strictly internal.
|
||||
*/
|
||||
|
||||
/* First: "hash" functions */
|
||||
# define DECLARE_LHASH_HASH_FN(name, o_type) \
|
||||
unsigned long name##_LHASH_HASH(const void *);
|
||||
# define IMPLEMENT_LHASH_HASH_FN(name, o_type) \
|
||||
unsigned long name##_LHASH_HASH(const void *arg) { \
|
||||
const o_type *a = arg; \
|
||||
return name##_hash(a); }
|
||||
# define LHASH_HASH_FN(name) name##_LHASH_HASH
|
||||
|
||||
/* Second: "compare" functions */
|
||||
# define DECLARE_LHASH_COMP_FN(name, o_type) \
|
||||
int name##_LHASH_COMP(const void *, const void *);
|
||||
# define IMPLEMENT_LHASH_COMP_FN(name, o_type) \
|
||||
int name##_LHASH_COMP(const void *arg1, const void *arg2) { \
|
||||
const o_type *a = arg1; \
|
||||
const o_type *b = arg2; \
|
||||
return name##_cmp(a,b); }
|
||||
# define LHASH_COMP_FN(name) name##_LHASH_COMP
|
||||
|
||||
/* Fourth: "doall_arg" functions */
|
||||
# define DECLARE_LHASH_DOALL_ARG_FN(name, o_type, a_type) \
|
||||
void name##_LHASH_DOALL_ARG(void *, void *);
|
||||
# define IMPLEMENT_LHASH_DOALL_ARG_FN(name, o_type, a_type) \
|
||||
void name##_LHASH_DOALL_ARG(void *arg1, void *arg2) { \
|
||||
o_type *a = arg1; \
|
||||
a_type *b = arg2; \
|
||||
name##_doall_arg(a, b); }
|
||||
# define LHASH_DOALL_ARG_FN(name) name##_LHASH_DOALL_ARG
|
||||
|
||||
|
||||
# define LH_LOAD_MULT 256
|
||||
|
||||
int OPENSSL_LH_error(OPENSSL_LHASH *lh);
|
||||
OPENSSL_LHASH *OPENSSL_LH_new(OPENSSL_LH_HASHFUNC h, OPENSSL_LH_COMPFUNC c);
|
||||
void OPENSSL_LH_free(OPENSSL_LHASH *lh);
|
||||
void *OPENSSL_LH_insert(OPENSSL_LHASH *lh, void *data);
|
||||
void *OPENSSL_LH_delete(OPENSSL_LHASH *lh, const void *data);
|
||||
void *OPENSSL_LH_retrieve(OPENSSL_LHASH *lh, const void *data);
|
||||
void OPENSSL_LH_doall(OPENSSL_LHASH *lh, OPENSSL_LH_DOALL_FUNC func);
|
||||
void OPENSSL_LH_doall_arg(OPENSSL_LHASH *lh, OPENSSL_LH_DOALL_FUNCARG func, void *arg);
|
||||
unsigned long OPENSSL_LH_strhash(const char *c);
|
||||
unsigned long OPENSSL_LH_num_items(const OPENSSL_LHASH *lh);
|
||||
unsigned long OPENSSL_LH_get_down_load(const OPENSSL_LHASH *lh);
|
||||
void OPENSSL_LH_set_down_load(OPENSSL_LHASH *lh, unsigned long down_load);
|
||||
|
||||
# ifndef OPENSSL_NO_STDIO
|
||||
void OPENSSL_LH_stats(const OPENSSL_LHASH *lh, FILE *fp);
|
||||
void OPENSSL_LH_node_stats(const OPENSSL_LHASH *lh, FILE *fp);
|
||||
void OPENSSL_LH_node_usage_stats(const OPENSSL_LHASH *lh, FILE *fp);
|
||||
# endif
|
||||
void OPENSSL_LH_stats_bio(const OPENSSL_LHASH *lh, BIO *out);
|
||||
void OPENSSL_LH_node_stats_bio(const OPENSSL_LHASH *lh, BIO *out);
|
||||
void OPENSSL_LH_node_usage_stats_bio(const OPENSSL_LHASH *lh, BIO *out);
|
||||
|
||||
# if OPENSSL_API_COMPAT < 0x10100000L
|
||||
# define _LHASH OPENSSL_LHASH
|
||||
# define LHASH_NODE OPENSSL_LH_NODE
|
||||
# define lh_error OPENSSL_LH_error
|
||||
# define lh_new OPENSSL_lh_new
|
||||
# define lh_free OPENSSL_LH_free
|
||||
# define lh_insert OPENSSL_LH_insert
|
||||
# define lh_delete OPENSSL_LH_delete
|
||||
# define lh_retrieve OPENSSL_LH_retrieve
|
||||
# define lh_doall OPENSSL_LH_doall
|
||||
# define lh_doall_arg OPENSSL_LH_doall_arg
|
||||
# define lh_strhash OPENSSL_LH_strhash
|
||||
# define lh_num_items OPENSSL_LH_num_items
|
||||
# ifndef OPENSSL_NO_STDIO
|
||||
# define lh_stats OPENSSL_LH_stats
|
||||
# define lh_node_stats OPENSSL_LH_node_stats
|
||||
# define lh_node_usage_stats OPENSSL_LH_node_usage_stats
|
||||
# endif
|
||||
# define lh_stats_bio OPENSSL_LH_stats_bio
|
||||
# define lh_node_stats_bio OPENSSL_LH_node_stats_bio
|
||||
# define lh_node_usage_stats_bio OPENSSL_LH_node_usage_stats_bio
|
||||
# endif
|
||||
|
||||
/* Type checking... */
|
||||
|
||||
# define LHASH_OF(type) struct lhash_st_##type
|
||||
|
||||
# define DEFINE_LHASH_OF(type) \
|
||||
LHASH_OF(type) { union lh_##type##_dummy { void* d1; unsigned long d2; int d3; } dummy; }; \
|
||||
static ossl_inline LHASH_OF(type) * \
|
||||
lh_##type##_new(unsigned long (*hfn)(const type *), \
|
||||
int (*cfn)(const type *, const type *)) \
|
||||
{ \
|
||||
return (LHASH_OF(type) *) \
|
||||
OPENSSL_LH_new((OPENSSL_LH_HASHFUNC)hfn, (OPENSSL_LH_COMPFUNC)cfn); \
|
||||
} \
|
||||
static ossl_inline void lh_##type##_free(LHASH_OF(type) *lh) \
|
||||
{ \
|
||||
OPENSSL_LH_free((OPENSSL_LHASH *)lh); \
|
||||
} \
|
||||
static ossl_inline type *lh_##type##_insert(LHASH_OF(type) *lh, type *d) \
|
||||
{ \
|
||||
return (type *)OPENSSL_LH_insert((OPENSSL_LHASH *)lh, d); \
|
||||
} \
|
||||
static ossl_inline type *lh_##type##_delete(LHASH_OF(type) *lh, const type *d) \
|
||||
{ \
|
||||
return (type *)OPENSSL_LH_delete((OPENSSL_LHASH *)lh, d); \
|
||||
} \
|
||||
static ossl_inline type *lh_##type##_retrieve(LHASH_OF(type) *lh, const type *d) \
|
||||
{ \
|
||||
return (type *)OPENSSL_LH_retrieve((OPENSSL_LHASH *)lh, d); \
|
||||
} \
|
||||
static ossl_inline int lh_##type##_error(LHASH_OF(type) *lh) \
|
||||
{ \
|
||||
return OPENSSL_LH_error((OPENSSL_LHASH *)lh); \
|
||||
} \
|
||||
static ossl_inline unsigned long lh_##type##_num_items(LHASH_OF(type) *lh) \
|
||||
{ \
|
||||
return OPENSSL_LH_num_items((OPENSSL_LHASH *)lh); \
|
||||
} \
|
||||
static ossl_inline void lh_##type##_node_stats_bio(const LHASH_OF(type) *lh, BIO *out) \
|
||||
{ \
|
||||
OPENSSL_LH_node_stats_bio((const OPENSSL_LHASH *)lh, out); \
|
||||
} \
|
||||
static ossl_inline void lh_##type##_node_usage_stats_bio(const LHASH_OF(type) *lh, BIO *out) \
|
||||
{ \
|
||||
OPENSSL_LH_node_usage_stats_bio((const OPENSSL_LHASH *)lh, out); \
|
||||
} \
|
||||
static ossl_inline void lh_##type##_stats_bio(const LHASH_OF(type) *lh, BIO *out) \
|
||||
{ \
|
||||
OPENSSL_LH_stats_bio((const OPENSSL_LHASH *)lh, out); \
|
||||
} \
|
||||
static ossl_inline unsigned long lh_##type##_get_down_load(LHASH_OF(type) *lh) \
|
||||
{ \
|
||||
return OPENSSL_LH_get_down_load((OPENSSL_LHASH *)lh); \
|
||||
} \
|
||||
static ossl_inline void lh_##type##_set_down_load(LHASH_OF(type) *lh, unsigned long dl) \
|
||||
{ \
|
||||
OPENSSL_LH_set_down_load((OPENSSL_LHASH *)lh, dl); \
|
||||
} \
|
||||
static ossl_inline void lh_##type##_doall(LHASH_OF(type) *lh, \
|
||||
void (*doall)(type *)) \
|
||||
{ \
|
||||
OPENSSL_LH_doall((OPENSSL_LHASH *)lh, (OPENSSL_LH_DOALL_FUNC)doall); \
|
||||
} \
|
||||
LHASH_OF(type)
|
||||
|
||||
#define IMPLEMENT_LHASH_DOALL_ARG_CONST(type, argtype) \
|
||||
int_implement_lhash_doall(type, argtype, const type)
|
||||
|
||||
#define IMPLEMENT_LHASH_DOALL_ARG(type, argtype) \
|
||||
int_implement_lhash_doall(type, argtype, type)
|
||||
|
||||
#define int_implement_lhash_doall(type, argtype, cbargtype) \
|
||||
static ossl_inline void \
|
||||
lh_##type##_doall_##argtype(LHASH_OF(type) *lh, \
|
||||
void (*fn)(cbargtype *, argtype *), \
|
||||
argtype *arg) \
|
||||
{ \
|
||||
OPENSSL_LH_doall_arg((OPENSSL_LHASH *)lh, (OPENSSL_LH_DOALL_FUNCARG)fn, (void *)arg); \
|
||||
} \
|
||||
LHASH_OF(type)
|
||||
|
||||
DEFINE_LHASH_OF(OPENSSL_STRING);
|
||||
DEFINE_LHASH_OF(OPENSSL_CSTRING);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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_MD2_H
|
||||
# define HEADER_MD2_H
|
||||
|
||||
# include <openssl/opensslconf.h>
|
||||
|
||||
# ifndef OPENSSL_NO_MD2
|
||||
# include <stddef.h>
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
# endif
|
||||
|
||||
typedef unsigned char MD2_INT;
|
||||
|
||||
# define MD2_DIGEST_LENGTH 16
|
||||
# define MD2_BLOCK 16
|
||||
|
||||
typedef struct MD2state_st {
|
||||
unsigned int num;
|
||||
unsigned char data[MD2_BLOCK];
|
||||
MD2_INT cksm[MD2_BLOCK];
|
||||
MD2_INT state[MD2_BLOCK];
|
||||
} MD2_CTX;
|
||||
|
||||
const char *MD2_options(void);
|
||||
int MD2_Init(MD2_CTX *c);
|
||||
int MD2_Update(MD2_CTX *c, const unsigned char *data, size_t len);
|
||||
int MD2_Final(unsigned char *md, MD2_CTX *c);
|
||||
unsigned char *MD2(const unsigned char *d, size_t n, unsigned char *md);
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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_MD4_H
|
||||
# define HEADER_MD4_H
|
||||
|
||||
# include <openssl/opensslconf.h>
|
||||
|
||||
# ifndef OPENSSL_NO_MD4
|
||||
# include <openssl/e_os2.h>
|
||||
# include <stddef.h>
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
# endif
|
||||
|
||||
/*-
|
||||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
* ! MD4_LONG has to be at least 32 bits wide. !
|
||||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
*/
|
||||
# define MD4_LONG unsigned int
|
||||
|
||||
# define MD4_CBLOCK 64
|
||||
# define MD4_LBLOCK (MD4_CBLOCK/4)
|
||||
# define MD4_DIGEST_LENGTH 16
|
||||
|
||||
typedef struct MD4state_st {
|
||||
MD4_LONG A, B, C, D;
|
||||
MD4_LONG Nl, Nh;
|
||||
MD4_LONG data[MD4_LBLOCK];
|
||||
unsigned int num;
|
||||
} MD4_CTX;
|
||||
|
||||
int MD4_Init(MD4_CTX *c);
|
||||
int MD4_Update(MD4_CTX *c, const void *data, size_t len);
|
||||
int MD4_Final(unsigned char *md, MD4_CTX *c);
|
||||
unsigned char *MD4(const unsigned char *d, size_t n, unsigned char *md);
|
||||
void MD4_Transform(MD4_CTX *c, const unsigned char *b);
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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_MD5_H
|
||||
# define HEADER_MD5_H
|
||||
|
||||
# include <openssl/opensslconf.h>
|
||||
|
||||
# ifndef OPENSSL_NO_MD5
|
||||
# include <openssl/e_os2.h>
|
||||
# include <stddef.h>
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
# endif
|
||||
|
||||
/*
|
||||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
* ! MD5_LONG has to be at least 32 bits wide. !
|
||||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
*/
|
||||
# define MD5_LONG unsigned int
|
||||
|
||||
# define MD5_CBLOCK 64
|
||||
# define MD5_LBLOCK (MD5_CBLOCK/4)
|
||||
# define MD5_DIGEST_LENGTH 16
|
||||
|
||||
typedef struct MD5state_st {
|
||||
MD5_LONG A, B, C, D;
|
||||
MD5_LONG Nl, Nh;
|
||||
MD5_LONG data[MD5_LBLOCK];
|
||||
unsigned int num;
|
||||
} MD5_CTX;
|
||||
|
||||
int MD5_Init(MD5_CTX *c);
|
||||
int MD5_Update(MD5_CTX *c, const void *data, size_t len);
|
||||
int MD5_Final(unsigned char *md, MD5_CTX *c);
|
||||
unsigned char *MD5(const unsigned char *d, size_t n, unsigned char *md);
|
||||
void MD5_Transform(MD5_CTX *c, const unsigned char *b);
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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_MDC2_H
|
||||
# define HEADER_MDC2_H
|
||||
|
||||
# include <openssl/opensslconf.h>
|
||||
|
||||
#ifndef OPENSSL_NO_MDC2
|
||||
# include <stdlib.h>
|
||||
# include <openssl/des.h>
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
# endif
|
||||
|
||||
# define MDC2_BLOCK 8
|
||||
# define MDC2_DIGEST_LENGTH 16
|
||||
|
||||
typedef struct mdc2_ctx_st {
|
||||
unsigned int num;
|
||||
unsigned char data[MDC2_BLOCK];
|
||||
DES_cblock h, hh;
|
||||
int pad_type; /* either 1 or 2, default 1 */
|
||||
} MDC2_CTX;
|
||||
|
||||
int MDC2_Init(MDC2_CTX *c);
|
||||
int MDC2_Update(MDC2_CTX *c, const unsigned char *data, size_t len);
|
||||
int MDC2_Final(unsigned char *md, MDC2_CTX *c);
|
||||
unsigned char *MDC2(const unsigned char *d, size_t n, unsigned char *md);
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,203 @@
|
|||
/*
|
||||
* Copyright 2008-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
typedef void (*block128_f) (const unsigned char in[16],
|
||||
unsigned char out[16], const void *key);
|
||||
|
||||
typedef void (*cbc128_f) (const unsigned char *in, unsigned char *out,
|
||||
size_t len, const void *key,
|
||||
unsigned char ivec[16], int enc);
|
||||
|
||||
typedef void (*ctr128_f) (const unsigned char *in, unsigned char *out,
|
||||
size_t blocks, const void *key,
|
||||
const unsigned char ivec[16]);
|
||||
|
||||
typedef void (*ccm128_f) (const unsigned char *in, unsigned char *out,
|
||||
size_t blocks, const void *key,
|
||||
const unsigned char ivec[16],
|
||||
unsigned char cmac[16]);
|
||||
|
||||
void CRYPTO_cbc128_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t len, const void *key,
|
||||
unsigned char ivec[16], block128_f block);
|
||||
void CRYPTO_cbc128_decrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t len, const void *key,
|
||||
unsigned char ivec[16], block128_f block);
|
||||
|
||||
void CRYPTO_ctr128_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t len, const void *key,
|
||||
unsigned char ivec[16],
|
||||
unsigned char ecount_buf[16], unsigned int *num,
|
||||
block128_f block);
|
||||
|
||||
void CRYPTO_ctr128_encrypt_ctr32(const unsigned char *in, unsigned char *out,
|
||||
size_t len, const void *key,
|
||||
unsigned char ivec[16],
|
||||
unsigned char ecount_buf[16],
|
||||
unsigned int *num, ctr128_f ctr);
|
||||
|
||||
void CRYPTO_ofb128_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t len, const void *key,
|
||||
unsigned char ivec[16], int *num,
|
||||
block128_f block);
|
||||
|
||||
void CRYPTO_cfb128_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t len, const void *key,
|
||||
unsigned char ivec[16], int *num,
|
||||
int enc, block128_f block);
|
||||
void CRYPTO_cfb128_8_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t length, const void *key,
|
||||
unsigned char ivec[16], int *num,
|
||||
int enc, block128_f block);
|
||||
void CRYPTO_cfb128_1_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t bits, const void *key,
|
||||
unsigned char ivec[16], int *num,
|
||||
int enc, block128_f block);
|
||||
|
||||
size_t CRYPTO_cts128_encrypt_block(const unsigned char *in,
|
||||
unsigned char *out, size_t len,
|
||||
const void *key, unsigned char ivec[16],
|
||||
block128_f block);
|
||||
size_t CRYPTO_cts128_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t len, const void *key,
|
||||
unsigned char ivec[16], cbc128_f cbc);
|
||||
size_t CRYPTO_cts128_decrypt_block(const unsigned char *in,
|
||||
unsigned char *out, size_t len,
|
||||
const void *key, unsigned char ivec[16],
|
||||
block128_f block);
|
||||
size_t CRYPTO_cts128_decrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t len, const void *key,
|
||||
unsigned char ivec[16], cbc128_f cbc);
|
||||
|
||||
size_t CRYPTO_nistcts128_encrypt_block(const unsigned char *in,
|
||||
unsigned char *out, size_t len,
|
||||
const void *key,
|
||||
unsigned char ivec[16],
|
||||
block128_f block);
|
||||
size_t CRYPTO_nistcts128_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t len, const void *key,
|
||||
unsigned char ivec[16], cbc128_f cbc);
|
||||
size_t CRYPTO_nistcts128_decrypt_block(const unsigned char *in,
|
||||
unsigned char *out, size_t len,
|
||||
const void *key,
|
||||
unsigned char ivec[16],
|
||||
block128_f block);
|
||||
size_t CRYPTO_nistcts128_decrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t len, const void *key,
|
||||
unsigned char ivec[16], cbc128_f cbc);
|
||||
|
||||
typedef struct gcm128_context GCM128_CONTEXT;
|
||||
|
||||
GCM128_CONTEXT *CRYPTO_gcm128_new(void *key, block128_f block);
|
||||
void CRYPTO_gcm128_init(GCM128_CONTEXT *ctx, void *key, block128_f block);
|
||||
void CRYPTO_gcm128_setiv(GCM128_CONTEXT *ctx, const unsigned char *iv,
|
||||
size_t len);
|
||||
int CRYPTO_gcm128_aad(GCM128_CONTEXT *ctx, const unsigned char *aad,
|
||||
size_t len);
|
||||
int CRYPTO_gcm128_encrypt(GCM128_CONTEXT *ctx,
|
||||
const unsigned char *in, unsigned char *out,
|
||||
size_t len);
|
||||
int CRYPTO_gcm128_decrypt(GCM128_CONTEXT *ctx,
|
||||
const unsigned char *in, unsigned char *out,
|
||||
size_t len);
|
||||
int CRYPTO_gcm128_encrypt_ctr32(GCM128_CONTEXT *ctx,
|
||||
const unsigned char *in, unsigned char *out,
|
||||
size_t len, ctr128_f stream);
|
||||
int CRYPTO_gcm128_decrypt_ctr32(GCM128_CONTEXT *ctx,
|
||||
const unsigned char *in, unsigned char *out,
|
||||
size_t len, ctr128_f stream);
|
||||
int CRYPTO_gcm128_finish(GCM128_CONTEXT *ctx, const unsigned char *tag,
|
||||
size_t len);
|
||||
void CRYPTO_gcm128_tag(GCM128_CONTEXT *ctx, unsigned char *tag, size_t len);
|
||||
void CRYPTO_gcm128_release(GCM128_CONTEXT *ctx);
|
||||
|
||||
typedef struct ccm128_context CCM128_CONTEXT;
|
||||
|
||||
void CRYPTO_ccm128_init(CCM128_CONTEXT *ctx,
|
||||
unsigned int M, unsigned int L, void *key,
|
||||
block128_f block);
|
||||
int CRYPTO_ccm128_setiv(CCM128_CONTEXT *ctx, const unsigned char *nonce,
|
||||
size_t nlen, size_t mlen);
|
||||
void CRYPTO_ccm128_aad(CCM128_CONTEXT *ctx, const unsigned char *aad,
|
||||
size_t alen);
|
||||
int CRYPTO_ccm128_encrypt(CCM128_CONTEXT *ctx, const unsigned char *inp,
|
||||
unsigned char *out, size_t len);
|
||||
int CRYPTO_ccm128_decrypt(CCM128_CONTEXT *ctx, const unsigned char *inp,
|
||||
unsigned char *out, size_t len);
|
||||
int CRYPTO_ccm128_encrypt_ccm64(CCM128_CONTEXT *ctx, const unsigned char *inp,
|
||||
unsigned char *out, size_t len,
|
||||
ccm128_f stream);
|
||||
int CRYPTO_ccm128_decrypt_ccm64(CCM128_CONTEXT *ctx, const unsigned char *inp,
|
||||
unsigned char *out, size_t len,
|
||||
ccm128_f stream);
|
||||
size_t CRYPTO_ccm128_tag(CCM128_CONTEXT *ctx, unsigned char *tag, size_t len);
|
||||
|
||||
typedef struct xts128_context XTS128_CONTEXT;
|
||||
|
||||
int CRYPTO_xts128_encrypt(const XTS128_CONTEXT *ctx,
|
||||
const unsigned char iv[16],
|
||||
const unsigned char *inp, unsigned char *out,
|
||||
size_t len, int enc);
|
||||
|
||||
size_t CRYPTO_128_wrap(void *key, const unsigned char *iv,
|
||||
unsigned char *out,
|
||||
const unsigned char *in, size_t inlen,
|
||||
block128_f block);
|
||||
|
||||
size_t CRYPTO_128_unwrap(void *key, const unsigned char *iv,
|
||||
unsigned char *out,
|
||||
const unsigned char *in, size_t inlen,
|
||||
block128_f block);
|
||||
size_t CRYPTO_128_wrap_pad(void *key, const unsigned char *icv,
|
||||
unsigned char *out, const unsigned char *in,
|
||||
size_t inlen, block128_f block);
|
||||
size_t CRYPTO_128_unwrap_pad(void *key, const unsigned char *icv,
|
||||
unsigned char *out, const unsigned char *in,
|
||||
size_t inlen, block128_f block);
|
||||
|
||||
#ifndef OPENSSL_NO_OCB
|
||||
typedef struct ocb128_context OCB128_CONTEXT;
|
||||
|
||||
typedef void (*ocb128_f) (const unsigned char *in, unsigned char *out,
|
||||
size_t blocks, const void *key,
|
||||
size_t start_block_num,
|
||||
unsigned char offset_i[16],
|
||||
const unsigned char L_[][16],
|
||||
unsigned char checksum[16]);
|
||||
|
||||
OCB128_CONTEXT *CRYPTO_ocb128_new(void *keyenc, void *keydec,
|
||||
block128_f encrypt, block128_f decrypt,
|
||||
ocb128_f stream);
|
||||
int CRYPTO_ocb128_init(OCB128_CONTEXT *ctx, void *keyenc, void *keydec,
|
||||
block128_f encrypt, block128_f decrypt,
|
||||
ocb128_f stream);
|
||||
int CRYPTO_ocb128_copy_ctx(OCB128_CONTEXT *dest, OCB128_CONTEXT *src,
|
||||
void *keyenc, void *keydec);
|
||||
int CRYPTO_ocb128_setiv(OCB128_CONTEXT *ctx, const unsigned char *iv,
|
||||
size_t len, size_t taglen);
|
||||
int CRYPTO_ocb128_aad(OCB128_CONTEXT *ctx, const unsigned char *aad,
|
||||
size_t len);
|
||||
int CRYPTO_ocb128_encrypt(OCB128_CONTEXT *ctx, const unsigned char *in,
|
||||
unsigned char *out, size_t len);
|
||||
int CRYPTO_ocb128_decrypt(OCB128_CONTEXT *ctx, const unsigned char *in,
|
||||
unsigned char *out, size_t len);
|
||||
int CRYPTO_ocb128_finish(OCB128_CONTEXT *ctx, const unsigned char *tag,
|
||||
size_t len);
|
||||
int CRYPTO_ocb128_tag(OCB128_CONTEXT *ctx, unsigned char *tag, size_t len);
|
||||
void CRYPTO_ocb128_cleanup(OCB128_CONTEXT *ctx);
|
||||
#endif /* OPENSSL_NO_OCB */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,412 @@
|
|||
/*
|
||||
* Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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_OCSP_H
|
||||
# define HEADER_OCSP_H
|
||||
|
||||
#include <openssl/opensslconf.h>
|
||||
|
||||
/*
|
||||
* These definitions are outside the OPENSSL_NO_OCSP guard because although for
|
||||
* historical reasons they have OCSP_* names, they can actually be used
|
||||
* independently of OCSP. E.g. see RFC5280
|
||||
*/
|
||||
/*-
|
||||
* CRLReason ::= ENUMERATED {
|
||||
* unspecified (0),
|
||||
* keyCompromise (1),
|
||||
* cACompromise (2),
|
||||
* affiliationChanged (3),
|
||||
* superseded (4),
|
||||
* cessationOfOperation (5),
|
||||
* certificateHold (6),
|
||||
* removeFromCRL (8) }
|
||||
*/
|
||||
# define OCSP_REVOKED_STATUS_NOSTATUS -1
|
||||
# define OCSP_REVOKED_STATUS_UNSPECIFIED 0
|
||||
# define OCSP_REVOKED_STATUS_KEYCOMPROMISE 1
|
||||
# define OCSP_REVOKED_STATUS_CACOMPROMISE 2
|
||||
# define OCSP_REVOKED_STATUS_AFFILIATIONCHANGED 3
|
||||
# define OCSP_REVOKED_STATUS_SUPERSEDED 4
|
||||
# define OCSP_REVOKED_STATUS_CESSATIONOFOPERATION 5
|
||||
# define OCSP_REVOKED_STATUS_CERTIFICATEHOLD 6
|
||||
# define OCSP_REVOKED_STATUS_REMOVEFROMCRL 8
|
||||
|
||||
|
||||
# ifndef OPENSSL_NO_OCSP
|
||||
|
||||
# include <openssl/ossl_typ.h>
|
||||
# include <openssl/x509.h>
|
||||
# include <openssl/x509v3.h>
|
||||
# include <openssl/safestack.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Various flags and values */
|
||||
|
||||
# define OCSP_DEFAULT_NONCE_LENGTH 16
|
||||
|
||||
# define OCSP_NOCERTS 0x1
|
||||
# define OCSP_NOINTERN 0x2
|
||||
# define OCSP_NOSIGS 0x4
|
||||
# define OCSP_NOCHAIN 0x8
|
||||
# define OCSP_NOVERIFY 0x10
|
||||
# define OCSP_NOEXPLICIT 0x20
|
||||
# define OCSP_NOCASIGN 0x40
|
||||
# define OCSP_NODELEGATED 0x80
|
||||
# define OCSP_NOCHECKS 0x100
|
||||
# define OCSP_TRUSTOTHER 0x200
|
||||
# define OCSP_RESPID_KEY 0x400
|
||||
# define OCSP_NOTIME 0x800
|
||||
|
||||
typedef struct ocsp_cert_id_st OCSP_CERTID;
|
||||
|
||||
DEFINE_STACK_OF(OCSP_CERTID)
|
||||
|
||||
typedef struct ocsp_one_request_st OCSP_ONEREQ;
|
||||
|
||||
DEFINE_STACK_OF(OCSP_ONEREQ)
|
||||
|
||||
typedef struct ocsp_req_info_st OCSP_REQINFO;
|
||||
typedef struct ocsp_signature_st OCSP_SIGNATURE;
|
||||
typedef struct ocsp_request_st OCSP_REQUEST;
|
||||
|
||||
# define OCSP_RESPONSE_STATUS_SUCCESSFUL 0
|
||||
# define OCSP_RESPONSE_STATUS_MALFORMEDREQUEST 1
|
||||
# define OCSP_RESPONSE_STATUS_INTERNALERROR 2
|
||||
# define OCSP_RESPONSE_STATUS_TRYLATER 3
|
||||
# define OCSP_RESPONSE_STATUS_SIGREQUIRED 5
|
||||
# define OCSP_RESPONSE_STATUS_UNAUTHORIZED 6
|
||||
|
||||
typedef struct ocsp_resp_bytes_st OCSP_RESPBYTES;
|
||||
|
||||
# define V_OCSP_RESPID_NAME 0
|
||||
# define V_OCSP_RESPID_KEY 1
|
||||
|
||||
DEFINE_STACK_OF(OCSP_RESPID)
|
||||
DECLARE_ASN1_FUNCTIONS(OCSP_RESPID)
|
||||
|
||||
typedef struct ocsp_revoked_info_st OCSP_REVOKEDINFO;
|
||||
|
||||
# define V_OCSP_CERTSTATUS_GOOD 0
|
||||
# define V_OCSP_CERTSTATUS_REVOKED 1
|
||||
# define V_OCSP_CERTSTATUS_UNKNOWN 2
|
||||
|
||||
typedef struct ocsp_cert_status_st OCSP_CERTSTATUS;
|
||||
typedef struct ocsp_single_response_st OCSP_SINGLERESP;
|
||||
|
||||
DEFINE_STACK_OF(OCSP_SINGLERESP)
|
||||
|
||||
typedef struct ocsp_response_data_st OCSP_RESPDATA;
|
||||
|
||||
typedef struct ocsp_basic_response_st OCSP_BASICRESP;
|
||||
|
||||
typedef struct ocsp_crl_id_st OCSP_CRLID;
|
||||
typedef struct ocsp_service_locator_st OCSP_SERVICELOC;
|
||||
|
||||
# define PEM_STRING_OCSP_REQUEST "OCSP REQUEST"
|
||||
# define PEM_STRING_OCSP_RESPONSE "OCSP RESPONSE"
|
||||
|
||||
# define d2i_OCSP_REQUEST_bio(bp,p) ASN1_d2i_bio_of(OCSP_REQUEST,OCSP_REQUEST_new,d2i_OCSP_REQUEST,bp,p)
|
||||
|
||||
# define d2i_OCSP_RESPONSE_bio(bp,p) ASN1_d2i_bio_of(OCSP_RESPONSE,OCSP_RESPONSE_new,d2i_OCSP_RESPONSE,bp,p)
|
||||
|
||||
# define PEM_read_bio_OCSP_REQUEST(bp,x,cb) (OCSP_REQUEST *)PEM_ASN1_read_bio( \
|
||||
(char *(*)())d2i_OCSP_REQUEST,PEM_STRING_OCSP_REQUEST,bp,(char **)x,cb,NULL)
|
||||
|
||||
# define PEM_read_bio_OCSP_RESPONSE(bp,x,cb)(OCSP_RESPONSE *)PEM_ASN1_read_bio(\
|
||||
(char *(*)())d2i_OCSP_RESPONSE,PEM_STRING_OCSP_RESPONSE,bp,(char **)x,cb,NULL)
|
||||
|
||||
# define PEM_write_bio_OCSP_REQUEST(bp,o) \
|
||||
PEM_ASN1_write_bio((int (*)())i2d_OCSP_REQUEST,PEM_STRING_OCSP_REQUEST,\
|
||||
bp,(char *)o, NULL,NULL,0,NULL,NULL)
|
||||
|
||||
# define PEM_write_bio_OCSP_RESPONSE(bp,o) \
|
||||
PEM_ASN1_write_bio((int (*)())i2d_OCSP_RESPONSE,PEM_STRING_OCSP_RESPONSE,\
|
||||
bp,(char *)o, NULL,NULL,0,NULL,NULL)
|
||||
|
||||
# define i2d_OCSP_RESPONSE_bio(bp,o) ASN1_i2d_bio_of(OCSP_RESPONSE,i2d_OCSP_RESPONSE,bp,o)
|
||||
|
||||
# define i2d_OCSP_REQUEST_bio(bp,o) ASN1_i2d_bio_of(OCSP_REQUEST,i2d_OCSP_REQUEST,bp,o)
|
||||
|
||||
# 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_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)
|
||||
|
||||
# define ASN1_BIT_STRING_digest(data,type,md,len) \
|
||||
ASN1_item_digest(ASN1_ITEM_rptr(ASN1_BIT_STRING),type,data,md,len)
|
||||
|
||||
# define OCSP_CERTSTATUS_dup(cs)\
|
||||
(OCSP_CERTSTATUS*)ASN1_dup((int(*)())i2d_OCSP_CERTSTATUS,\
|
||||
(char *(*)())d2i_OCSP_CERTSTATUS,(char *)(cs))
|
||||
|
||||
OCSP_CERTID *OCSP_CERTID_dup(OCSP_CERTID *id);
|
||||
|
||||
OCSP_RESPONSE *OCSP_sendreq_bio(BIO *b, const char *path, OCSP_REQUEST *req);
|
||||
OCSP_REQ_CTX *OCSP_sendreq_new(BIO *io, const char *path, OCSP_REQUEST *req,
|
||||
int maxline);
|
||||
int OCSP_REQ_CTX_nbio(OCSP_REQ_CTX *rctx);
|
||||
int OCSP_sendreq_nbio(OCSP_RESPONSE **presp, OCSP_REQ_CTX *rctx);
|
||||
OCSP_REQ_CTX *OCSP_REQ_CTX_new(BIO *io, int maxline);
|
||||
void OCSP_REQ_CTX_free(OCSP_REQ_CTX *rctx);
|
||||
void OCSP_set_max_response_length(OCSP_REQ_CTX *rctx, unsigned long len);
|
||||
int OCSP_REQ_CTX_i2d(OCSP_REQ_CTX *rctx, const ASN1_ITEM *it,
|
||||
ASN1_VALUE *val);
|
||||
int OCSP_REQ_CTX_nbio_d2i(OCSP_REQ_CTX *rctx, ASN1_VALUE **pval,
|
||||
const ASN1_ITEM *it);
|
||||
BIO *OCSP_REQ_CTX_get0_mem_bio(OCSP_REQ_CTX *rctx);
|
||||
int OCSP_REQ_CTX_i2d(OCSP_REQ_CTX *rctx, const ASN1_ITEM *it,
|
||||
ASN1_VALUE *val);
|
||||
int OCSP_REQ_CTX_http(OCSP_REQ_CTX *rctx, const char *op, const char *path);
|
||||
int OCSP_REQ_CTX_set1_req(OCSP_REQ_CTX *rctx, OCSP_REQUEST *req);
|
||||
int OCSP_REQ_CTX_add1_header(OCSP_REQ_CTX *rctx,
|
||||
const char *name, const char *value);
|
||||
|
||||
OCSP_CERTID *OCSP_cert_to_id(const EVP_MD *dgst, const X509 *subject,
|
||||
const X509 *issuer);
|
||||
|
||||
OCSP_CERTID *OCSP_cert_id_new(const EVP_MD *dgst,
|
||||
const X509_NAME *issuerName,
|
||||
const ASN1_BIT_STRING *issuerKey,
|
||||
const ASN1_INTEGER *serialNumber);
|
||||
|
||||
OCSP_ONEREQ *OCSP_request_add0_id(OCSP_REQUEST *req, OCSP_CERTID *cid);
|
||||
|
||||
int OCSP_request_add1_nonce(OCSP_REQUEST *req, unsigned char *val, int len);
|
||||
int OCSP_basic_add1_nonce(OCSP_BASICRESP *resp, unsigned char *val, int len);
|
||||
int OCSP_check_nonce(OCSP_REQUEST *req, OCSP_BASICRESP *bs);
|
||||
int OCSP_copy_nonce(OCSP_BASICRESP *resp, OCSP_REQUEST *req);
|
||||
|
||||
int OCSP_request_set1_name(OCSP_REQUEST *req, X509_NAME *nm);
|
||||
int OCSP_request_add1_cert(OCSP_REQUEST *req, X509 *cert);
|
||||
|
||||
int OCSP_request_sign(OCSP_REQUEST *req,
|
||||
X509 *signer,
|
||||
EVP_PKEY *key,
|
||||
const EVP_MD *dgst,
|
||||
STACK_OF(X509) *certs, unsigned long flags);
|
||||
|
||||
int OCSP_response_status(OCSP_RESPONSE *resp);
|
||||
OCSP_BASICRESP *OCSP_response_get1_basic(OCSP_RESPONSE *resp);
|
||||
|
||||
const ASN1_OCTET_STRING *OCSP_resp_get0_signature(const OCSP_BASICRESP *bs);
|
||||
|
||||
int OCSP_resp_count(OCSP_BASICRESP *bs);
|
||||
OCSP_SINGLERESP *OCSP_resp_get0(OCSP_BASICRESP *bs, int idx);
|
||||
const ASN1_GENERALIZEDTIME *OCSP_resp_get0_produced_at(const OCSP_BASICRESP* bs);
|
||||
const STACK_OF(X509) *OCSP_resp_get0_certs(const OCSP_BASICRESP *bs);
|
||||
int OCSP_resp_get0_id(const OCSP_BASICRESP *bs,
|
||||
const ASN1_OCTET_STRING **pid,
|
||||
const X509_NAME **pname);
|
||||
|
||||
int OCSP_resp_find(OCSP_BASICRESP *bs, OCSP_CERTID *id, int last);
|
||||
int OCSP_single_get0_status(OCSP_SINGLERESP *single, int *reason,
|
||||
ASN1_GENERALIZEDTIME **revtime,
|
||||
ASN1_GENERALIZEDTIME **thisupd,
|
||||
ASN1_GENERALIZEDTIME **nextupd);
|
||||
int OCSP_resp_find_status(OCSP_BASICRESP *bs, OCSP_CERTID *id, int *status,
|
||||
int *reason,
|
||||
ASN1_GENERALIZEDTIME **revtime,
|
||||
ASN1_GENERALIZEDTIME **thisupd,
|
||||
ASN1_GENERALIZEDTIME **nextupd);
|
||||
int OCSP_check_validity(ASN1_GENERALIZEDTIME *thisupd,
|
||||
ASN1_GENERALIZEDTIME *nextupd, long sec, long maxsec);
|
||||
|
||||
int OCSP_request_verify(OCSP_REQUEST *req, STACK_OF(X509) *certs,
|
||||
X509_STORE *store, unsigned long flags);
|
||||
|
||||
int OCSP_parse_url(const char *url, char **phost, char **pport, char **ppath,
|
||||
int *pssl);
|
||||
|
||||
int OCSP_id_issuer_cmp(OCSP_CERTID *a, OCSP_CERTID *b);
|
||||
int OCSP_id_cmp(OCSP_CERTID *a, OCSP_CERTID *b);
|
||||
|
||||
int OCSP_request_onereq_count(OCSP_REQUEST *req);
|
||||
OCSP_ONEREQ *OCSP_request_onereq_get0(OCSP_REQUEST *req, int i);
|
||||
OCSP_CERTID *OCSP_onereq_get0_id(OCSP_ONEREQ *one);
|
||||
int OCSP_id_get0_info(ASN1_OCTET_STRING **piNameHash, ASN1_OBJECT **pmd,
|
||||
ASN1_OCTET_STRING **pikeyHash,
|
||||
ASN1_INTEGER **pserial, OCSP_CERTID *cid);
|
||||
int OCSP_request_is_signed(OCSP_REQUEST *req);
|
||||
OCSP_RESPONSE *OCSP_response_create(int status, OCSP_BASICRESP *bs);
|
||||
OCSP_SINGLERESP *OCSP_basic_add1_status(OCSP_BASICRESP *rsp,
|
||||
OCSP_CERTID *cid,
|
||||
int status, int reason,
|
||||
ASN1_TIME *revtime,
|
||||
ASN1_TIME *thisupd,
|
||||
ASN1_TIME *nextupd);
|
||||
int OCSP_basic_add1_cert(OCSP_BASICRESP *resp, X509 *cert);
|
||||
int OCSP_basic_sign(OCSP_BASICRESP *brsp,
|
||||
X509 *signer, EVP_PKEY *key, const EVP_MD *dgst,
|
||||
STACK_OF(X509) *certs, unsigned long flags);
|
||||
int OCSP_RESPID_set_by_name(OCSP_RESPID *respid, X509 *cert);
|
||||
int OCSP_RESPID_set_by_key(OCSP_RESPID *respid, X509 *cert);
|
||||
int OCSP_RESPID_match(OCSP_RESPID *respid, X509 *cert);
|
||||
|
||||
X509_EXTENSION *OCSP_crlID_new(const char *url, long *n, char *tim);
|
||||
|
||||
X509_EXTENSION *OCSP_accept_responses_new(char **oids);
|
||||
|
||||
X509_EXTENSION *OCSP_archive_cutoff_new(char *tim);
|
||||
|
||||
X509_EXTENSION *OCSP_url_svcloc_new(X509_NAME *issuer, const char **urls);
|
||||
|
||||
int OCSP_REQUEST_get_ext_count(OCSP_REQUEST *x);
|
||||
int OCSP_REQUEST_get_ext_by_NID(OCSP_REQUEST *x, int nid, int lastpos);
|
||||
int OCSP_REQUEST_get_ext_by_OBJ(OCSP_REQUEST *x, const ASN1_OBJECT *obj,
|
||||
int lastpos);
|
||||
int OCSP_REQUEST_get_ext_by_critical(OCSP_REQUEST *x, int crit, int lastpos);
|
||||
X509_EXTENSION *OCSP_REQUEST_get_ext(OCSP_REQUEST *x, int loc);
|
||||
X509_EXTENSION *OCSP_REQUEST_delete_ext(OCSP_REQUEST *x, int loc);
|
||||
void *OCSP_REQUEST_get1_ext_d2i(OCSP_REQUEST *x, int nid, int *crit,
|
||||
int *idx);
|
||||
int OCSP_REQUEST_add1_ext_i2d(OCSP_REQUEST *x, int nid, void *value, int crit,
|
||||
unsigned long flags);
|
||||
int OCSP_REQUEST_add_ext(OCSP_REQUEST *x, X509_EXTENSION *ex, int loc);
|
||||
|
||||
int OCSP_ONEREQ_get_ext_count(OCSP_ONEREQ *x);
|
||||
int OCSP_ONEREQ_get_ext_by_NID(OCSP_ONEREQ *x, int nid, int lastpos);
|
||||
int OCSP_ONEREQ_get_ext_by_OBJ(OCSP_ONEREQ *x, const ASN1_OBJECT *obj, int lastpos);
|
||||
int OCSP_ONEREQ_get_ext_by_critical(OCSP_ONEREQ *x, int crit, int lastpos);
|
||||
X509_EXTENSION *OCSP_ONEREQ_get_ext(OCSP_ONEREQ *x, int loc);
|
||||
X509_EXTENSION *OCSP_ONEREQ_delete_ext(OCSP_ONEREQ *x, int loc);
|
||||
void *OCSP_ONEREQ_get1_ext_d2i(OCSP_ONEREQ *x, int nid, int *crit, int *idx);
|
||||
int OCSP_ONEREQ_add1_ext_i2d(OCSP_ONEREQ *x, int nid, void *value, int crit,
|
||||
unsigned long flags);
|
||||
int OCSP_ONEREQ_add_ext(OCSP_ONEREQ *x, X509_EXTENSION *ex, int loc);
|
||||
|
||||
int OCSP_BASICRESP_get_ext_count(OCSP_BASICRESP *x);
|
||||
int OCSP_BASICRESP_get_ext_by_NID(OCSP_BASICRESP *x, int nid, int lastpos);
|
||||
int OCSP_BASICRESP_get_ext_by_OBJ(OCSP_BASICRESP *x, const ASN1_OBJECT *obj,
|
||||
int lastpos);
|
||||
int OCSP_BASICRESP_get_ext_by_critical(OCSP_BASICRESP *x, int crit,
|
||||
int lastpos);
|
||||
X509_EXTENSION *OCSP_BASICRESP_get_ext(OCSP_BASICRESP *x, int loc);
|
||||
X509_EXTENSION *OCSP_BASICRESP_delete_ext(OCSP_BASICRESP *x, int loc);
|
||||
void *OCSP_BASICRESP_get1_ext_d2i(OCSP_BASICRESP *x, int nid, int *crit,
|
||||
int *idx);
|
||||
int OCSP_BASICRESP_add1_ext_i2d(OCSP_BASICRESP *x, int nid, void *value,
|
||||
int crit, unsigned long flags);
|
||||
int OCSP_BASICRESP_add_ext(OCSP_BASICRESP *x, X509_EXTENSION *ex, int loc);
|
||||
|
||||
int OCSP_SINGLERESP_get_ext_count(OCSP_SINGLERESP *x);
|
||||
int OCSP_SINGLERESP_get_ext_by_NID(OCSP_SINGLERESP *x, int nid, int lastpos);
|
||||
int OCSP_SINGLERESP_get_ext_by_OBJ(OCSP_SINGLERESP *x, const ASN1_OBJECT *obj,
|
||||
int lastpos);
|
||||
int OCSP_SINGLERESP_get_ext_by_critical(OCSP_SINGLERESP *x, int crit,
|
||||
int lastpos);
|
||||
X509_EXTENSION *OCSP_SINGLERESP_get_ext(OCSP_SINGLERESP *x, int loc);
|
||||
X509_EXTENSION *OCSP_SINGLERESP_delete_ext(OCSP_SINGLERESP *x, int loc);
|
||||
void *OCSP_SINGLERESP_get1_ext_d2i(OCSP_SINGLERESP *x, int nid, int *crit,
|
||||
int *idx);
|
||||
int OCSP_SINGLERESP_add1_ext_i2d(OCSP_SINGLERESP *x, int nid, void *value,
|
||||
int crit, unsigned long flags);
|
||||
int OCSP_SINGLERESP_add_ext(OCSP_SINGLERESP *x, X509_EXTENSION *ex, int loc);
|
||||
const OCSP_CERTID *OCSP_SINGLERESP_get0_id(const OCSP_SINGLERESP *x);
|
||||
|
||||
DECLARE_ASN1_FUNCTIONS(OCSP_SINGLERESP)
|
||||
DECLARE_ASN1_FUNCTIONS(OCSP_CERTSTATUS)
|
||||
DECLARE_ASN1_FUNCTIONS(OCSP_REVOKEDINFO)
|
||||
DECLARE_ASN1_FUNCTIONS(OCSP_BASICRESP)
|
||||
DECLARE_ASN1_FUNCTIONS(OCSP_RESPDATA)
|
||||
DECLARE_ASN1_FUNCTIONS(OCSP_RESPID)
|
||||
DECLARE_ASN1_FUNCTIONS(OCSP_RESPONSE)
|
||||
DECLARE_ASN1_FUNCTIONS(OCSP_RESPBYTES)
|
||||
DECLARE_ASN1_FUNCTIONS(OCSP_ONEREQ)
|
||||
DECLARE_ASN1_FUNCTIONS(OCSP_CERTID)
|
||||
DECLARE_ASN1_FUNCTIONS(OCSP_REQUEST)
|
||||
DECLARE_ASN1_FUNCTIONS(OCSP_SIGNATURE)
|
||||
DECLARE_ASN1_FUNCTIONS(OCSP_REQINFO)
|
||||
DECLARE_ASN1_FUNCTIONS(OCSP_CRLID)
|
||||
DECLARE_ASN1_FUNCTIONS(OCSP_SERVICELOC)
|
||||
|
||||
const char *OCSP_response_status_str(long s);
|
||||
const char *OCSP_cert_status_str(long s);
|
||||
const char *OCSP_crl_reason_str(long s);
|
||||
|
||||
int OCSP_REQUEST_print(BIO *bp, OCSP_REQUEST *a, unsigned long flags);
|
||||
int OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE *o, unsigned long flags);
|
||||
|
||||
int OCSP_basic_verify(OCSP_BASICRESP *bs, STACK_OF(X509) *certs,
|
||||
X509_STORE *st, unsigned long flags);
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
/*
|
||||
* The following lines are auto generated by the script mkerr.pl. Any changes
|
||||
* made after this point may be overwritten when the script is next run.
|
||||
*/
|
||||
|
||||
int ERR_load_OCSP_strings(void);
|
||||
|
||||
/* Error codes for the OCSP functions. */
|
||||
|
||||
/* Function codes. */
|
||||
# define OCSP_F_D2I_OCSP_NONCE 102
|
||||
# define OCSP_F_OCSP_BASIC_ADD1_STATUS 103
|
||||
# define OCSP_F_OCSP_BASIC_SIGN 104
|
||||
# define OCSP_F_OCSP_BASIC_VERIFY 105
|
||||
# define OCSP_F_OCSP_CERT_ID_NEW 101
|
||||
# define OCSP_F_OCSP_CHECK_DELEGATED 106
|
||||
# define OCSP_F_OCSP_CHECK_IDS 107
|
||||
# define OCSP_F_OCSP_CHECK_ISSUER 108
|
||||
# define OCSP_F_OCSP_CHECK_VALIDITY 115
|
||||
# define OCSP_F_OCSP_MATCH_ISSUERID 109
|
||||
# define OCSP_F_OCSP_PARSE_URL 114
|
||||
# define OCSP_F_OCSP_REQUEST_SIGN 110
|
||||
# define OCSP_F_OCSP_REQUEST_VERIFY 116
|
||||
# define OCSP_F_OCSP_RESPONSE_GET1_BASIC 111
|
||||
# define OCSP_F_PARSE_HTTP_LINE1 118
|
||||
|
||||
/* Reason codes. */
|
||||
# define OCSP_R_CERTIFICATE_VERIFY_ERROR 101
|
||||
# define OCSP_R_DIGEST_ERR 102
|
||||
# define OCSP_R_ERROR_IN_NEXTUPDATE_FIELD 122
|
||||
# define OCSP_R_ERROR_IN_THISUPDATE_FIELD 123
|
||||
# define OCSP_R_ERROR_PARSING_URL 121
|
||||
# define OCSP_R_MISSING_OCSPSIGNING_USAGE 103
|
||||
# define OCSP_R_NEXTUPDATE_BEFORE_THISUPDATE 124
|
||||
# define OCSP_R_NOT_BASIC_RESPONSE 104
|
||||
# define OCSP_R_NO_CERTIFICATES_IN_CHAIN 105
|
||||
# define OCSP_R_NO_RESPONSE_DATA 108
|
||||
# define OCSP_R_NO_REVOKED_TIME 109
|
||||
# define OCSP_R_NO_SIGNER_KEY 130
|
||||
# define OCSP_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE 110
|
||||
# define OCSP_R_REQUEST_NOT_SIGNED 128
|
||||
# define OCSP_R_RESPONSE_CONTAINS_NO_REVOCATION_DATA 111
|
||||
# define OCSP_R_ROOT_CA_NOT_TRUSTED 112
|
||||
# define OCSP_R_SERVER_RESPONSE_ERROR 114
|
||||
# define OCSP_R_SERVER_RESPONSE_PARSE_ERROR 115
|
||||
# define OCSP_R_SIGNATURE_FAILURE 117
|
||||
# define OCSP_R_SIGNER_CERTIFICATE_NOT_FOUND 118
|
||||
# define OCSP_R_STATUS_EXPIRED 125
|
||||
# define OCSP_R_STATUS_NOT_YET_VALID 126
|
||||
# define OCSP_R_STATUS_TOO_OLD 127
|
||||
# define OCSP_R_UNKNOWN_MESSAGE_DIGEST 119
|
||||
# define OCSP_R_UNKNOWN_NID 120
|
||||
# define OCSP_R_UNSUPPORTED_REQUESTORNAME_TYPE 129
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
|
@ -0,0 +1,169 @@
|
|||
/*
|
||||
* WARNING: do not edit!
|
||||
* Generated by Makefile from include/openssl/opensslconf.h.in
|
||||
*
|
||||
* Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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 __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef OPENSSL_ALGORITHM_DEFINES
|
||||
# error OPENSSL_ALGORITHM_DEFINES no longer supported
|
||||
#endif
|
||||
|
||||
/*
|
||||
* OpenSSL was configured with the following options:
|
||||
*/
|
||||
|
||||
#ifndef OPENSSL_NO_MD2
|
||||
# define OPENSSL_NO_MD2
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_RC5
|
||||
# define OPENSSL_NO_RC5
|
||||
#endif
|
||||
#ifndef OPENSSL_THREADS
|
||||
# define OPENSSL_THREADS
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_ASAN
|
||||
# define OPENSSL_NO_ASAN
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
|
||||
# define OPENSSL_NO_CRYPTO_MDEBUG
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE
|
||||
# define OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128
|
||||
# define OPENSSL_NO_EC_NISTP_64_GCC_128
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_EGD
|
||||
# define OPENSSL_NO_EGD
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_FUZZ_AFL
|
||||
# define OPENSSL_NO_FUZZ_AFL
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_FUZZ_LIBFUZZER
|
||||
# define OPENSSL_NO_FUZZ_LIBFUZZER
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_HEARTBEATS
|
||||
# define OPENSSL_NO_HEARTBEATS
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_MSAN
|
||||
# define OPENSSL_NO_MSAN
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SCTP
|
||||
# define OPENSSL_NO_SCTP
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SSL_TRACE
|
||||
# define OPENSSL_NO_SSL_TRACE
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SSL3
|
||||
# define OPENSSL_NO_SSL3
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SSL3_METHOD
|
||||
# define OPENSSL_NO_SSL3_METHOD
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_UBSAN
|
||||
# define OPENSSL_NO_UBSAN
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_UNIT_TEST
|
||||
# define OPENSSL_NO_UNIT_TEST
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_WEAK_SSL_CIPHERS
|
||||
# define OPENSSL_NO_WEAK_SSL_CIPHERS
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_AFALGENG
|
||||
# define OPENSSL_NO_AFALGENG
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Sometimes OPENSSSL_NO_xxx ends up with an empty file and some compilers
|
||||
* don't like that. This will hopefully silence them.
|
||||
*/
|
||||
#define NON_EMPTY_TRANSLATION_UNIT static void *dummy = &dummy;
|
||||
|
||||
/*
|
||||
* Applications should use -DOPENSSL_API_COMPAT=<version> to suppress the
|
||||
* declarations of functions deprecated in or before <version>. Otherwise, they
|
||||
* still won't see them if the library has been built to disable deprecated
|
||||
* functions.
|
||||
*/
|
||||
#if defined(OPENSSL_NO_DEPRECATED)
|
||||
# define DECLARE_DEPRECATED(f)
|
||||
#elif __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 0)
|
||||
# define DECLARE_DEPRECATED(f) f __attribute__ ((deprecated));
|
||||
#else
|
||||
# define DECLARE_DEPRECATED(f) f;
|
||||
#endif
|
||||
|
||||
#ifndef OPENSSL_FILE
|
||||
# ifdef OPENSSL_NO_FILENAMES
|
||||
# define OPENSSL_FILE ""
|
||||
# define OPENSSL_LINE 0
|
||||
# else
|
||||
# define OPENSSL_FILE __FILE__
|
||||
# define OPENSSL_LINE __LINE__
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef OPENSSL_MIN_API
|
||||
# define OPENSSL_MIN_API 0
|
||||
#endif
|
||||
|
||||
#if !defined(OPENSSL_API_COMPAT) || OPENSSL_API_COMPAT < OPENSSL_MIN_API
|
||||
# undef OPENSSL_API_COMPAT
|
||||
# define OPENSSL_API_COMPAT OPENSSL_MIN_API
|
||||
#endif
|
||||
|
||||
#if OPENSSL_API_COMPAT < 0x10100000L
|
||||
# define DEPRECATEDIN_1_1_0(f) DECLARE_DEPRECATED(f)
|
||||
#else
|
||||
# define DEPRECATEDIN_1_1_0(f)
|
||||
#endif
|
||||
|
||||
#if OPENSSL_API_COMPAT < 0x10000000L
|
||||
# define DEPRECATEDIN_1_0_0(f) DECLARE_DEPRECATED(f)
|
||||
#else
|
||||
# define DEPRECATEDIN_1_0_0(f)
|
||||
#endif
|
||||
|
||||
#if OPENSSL_API_COMPAT < 0x00908000L
|
||||
# define DEPRECATEDIN_0_9_8(f) DECLARE_DEPRECATED(f)
|
||||
#else
|
||||
# define DEPRECATEDIN_0_9_8(f)
|
||||
#endif
|
||||
|
||||
#define OPENSSL_CPUID_OBJ
|
||||
|
||||
/* Generate 80386 code? */
|
||||
#undef I386_ONLY
|
||||
|
||||
#undef OPENSSL_UNISTD
|
||||
#define OPENSSL_UNISTD <unistd.h>
|
||||
|
||||
#undef OPENSSL_EXPORT_VAR_AS_FUNCTION
|
||||
|
||||
/*
|
||||
* The following are cipher-specific, but are part of the public API.
|
||||
*/
|
||||
#if !defined(OPENSSL_SYS_UEFI)
|
||||
# define BN_LLONG
|
||||
/* Only one for the following should be defined */
|
||||
# undef SIXTY_FOUR_BIT_LONG
|
||||
# undef SIXTY_FOUR_BIT
|
||||
# define THIRTY_TWO_BIT
|
||||
#endif
|
||||
|
||||
#define RC4_INT unsigned char
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
@ -0,0 +1,169 @@
|
|||
/*
|
||||
* WARNING: do not edit!
|
||||
* Generated by Makefile from include/openssl/opensslconf.h.in
|
||||
*
|
||||
* Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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 __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef OPENSSL_ALGORITHM_DEFINES
|
||||
# error OPENSSL_ALGORITHM_DEFINES no longer supported
|
||||
#endif
|
||||
|
||||
/*
|
||||
* OpenSSL was configured with the following options:
|
||||
*/
|
||||
|
||||
#ifndef OPENSSL_NO_MD2
|
||||
# define OPENSSL_NO_MD2
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_RC5
|
||||
# define OPENSSL_NO_RC5
|
||||
#endif
|
||||
#ifndef OPENSSL_THREADS
|
||||
# define OPENSSL_THREADS
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_ASAN
|
||||
# define OPENSSL_NO_ASAN
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
|
||||
# define OPENSSL_NO_CRYPTO_MDEBUG
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE
|
||||
# define OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128
|
||||
# define OPENSSL_NO_EC_NISTP_64_GCC_128
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_EGD
|
||||
# define OPENSSL_NO_EGD
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_FUZZ_AFL
|
||||
# define OPENSSL_NO_FUZZ_AFL
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_FUZZ_LIBFUZZER
|
||||
# define OPENSSL_NO_FUZZ_LIBFUZZER
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_HEARTBEATS
|
||||
# define OPENSSL_NO_HEARTBEATS
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_MSAN
|
||||
# define OPENSSL_NO_MSAN
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SCTP
|
||||
# define OPENSSL_NO_SCTP
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SSL_TRACE
|
||||
# define OPENSSL_NO_SSL_TRACE
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SSL3
|
||||
# define OPENSSL_NO_SSL3
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SSL3_METHOD
|
||||
# define OPENSSL_NO_SSL3_METHOD
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_UBSAN
|
||||
# define OPENSSL_NO_UBSAN
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_UNIT_TEST
|
||||
# define OPENSSL_NO_UNIT_TEST
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_WEAK_SSL_CIPHERS
|
||||
# define OPENSSL_NO_WEAK_SSL_CIPHERS
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_AFALGENG
|
||||
# define OPENSSL_NO_AFALGENG
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Sometimes OPENSSSL_NO_xxx ends up with an empty file and some compilers
|
||||
* don't like that. This will hopefully silence them.
|
||||
*/
|
||||
#define NON_EMPTY_TRANSLATION_UNIT static void *dummy = &dummy;
|
||||
|
||||
/*
|
||||
* Applications should use -DOPENSSL_API_COMPAT=<version> to suppress the
|
||||
* declarations of functions deprecated in or before <version>. Otherwise, they
|
||||
* still won't see them if the library has been built to disable deprecated
|
||||
* functions.
|
||||
*/
|
||||
#if defined(OPENSSL_NO_DEPRECATED)
|
||||
# define DECLARE_DEPRECATED(f)
|
||||
#elif __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 0)
|
||||
# define DECLARE_DEPRECATED(f) f __attribute__ ((deprecated));
|
||||
#else
|
||||
# define DECLARE_DEPRECATED(f) f;
|
||||
#endif
|
||||
|
||||
#ifndef OPENSSL_FILE
|
||||
# ifdef OPENSSL_NO_FILENAMES
|
||||
# define OPENSSL_FILE ""
|
||||
# define OPENSSL_LINE 0
|
||||
# else
|
||||
# define OPENSSL_FILE __FILE__
|
||||
# define OPENSSL_LINE __LINE__
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef OPENSSL_MIN_API
|
||||
# define OPENSSL_MIN_API 0
|
||||
#endif
|
||||
|
||||
#if !defined(OPENSSL_API_COMPAT) || OPENSSL_API_COMPAT < OPENSSL_MIN_API
|
||||
# undef OPENSSL_API_COMPAT
|
||||
# define OPENSSL_API_COMPAT OPENSSL_MIN_API
|
||||
#endif
|
||||
|
||||
#if OPENSSL_API_COMPAT < 0x10100000L
|
||||
# define DEPRECATEDIN_1_1_0(f) DECLARE_DEPRECATED(f)
|
||||
#else
|
||||
# define DEPRECATEDIN_1_1_0(f)
|
||||
#endif
|
||||
|
||||
#if OPENSSL_API_COMPAT < 0x10000000L
|
||||
# define DEPRECATEDIN_1_0_0(f) DECLARE_DEPRECATED(f)
|
||||
#else
|
||||
# define DEPRECATEDIN_1_0_0(f)
|
||||
#endif
|
||||
|
||||
#if OPENSSL_API_COMPAT < 0x00908000L
|
||||
# define DEPRECATEDIN_0_9_8(f) DECLARE_DEPRECATED(f)
|
||||
#else
|
||||
# define DEPRECATEDIN_0_9_8(f)
|
||||
#endif
|
||||
|
||||
#define OPENSSL_CPUID_OBJ
|
||||
|
||||
/* Generate 80386 code? */
|
||||
#undef I386_ONLY
|
||||
|
||||
#undef OPENSSL_UNISTD
|
||||
#define OPENSSL_UNISTD <unistd.h>
|
||||
|
||||
#undef OPENSSL_EXPORT_VAR_AS_FUNCTION
|
||||
|
||||
/*
|
||||
* The following are cipher-specific, but are part of the public API.
|
||||
*/
|
||||
#if !defined(OPENSSL_SYS_UEFI)
|
||||
# undef BN_LLONG
|
||||
/* Only one for the following should be defined */
|
||||
# define SIXTY_FOUR_BIT_LONG
|
||||
# undef SIXTY_FOUR_BIT
|
||||
# undef THIRTY_TWO_BIT
|
||||
#endif
|
||||
|
||||
#define RC4_INT unsigned char
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
@ -0,0 +1,169 @@
|
|||
/*
|
||||
* WARNING: do not edit!
|
||||
* Generated by Makefile from include/openssl/opensslconf.h.in
|
||||
*
|
||||
* Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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 __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef OPENSSL_ALGORITHM_DEFINES
|
||||
# error OPENSSL_ALGORITHM_DEFINES no longer supported
|
||||
#endif
|
||||
|
||||
/*
|
||||
* OpenSSL was configured with the following options:
|
||||
*/
|
||||
|
||||
#ifndef OPENSSL_NO_MD2
|
||||
# define OPENSSL_NO_MD2
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_RC5
|
||||
# define OPENSSL_NO_RC5
|
||||
#endif
|
||||
#ifndef OPENSSL_THREADS
|
||||
# define OPENSSL_THREADS
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_ASAN
|
||||
# define OPENSSL_NO_ASAN
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
|
||||
# define OPENSSL_NO_CRYPTO_MDEBUG
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE
|
||||
# define OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128
|
||||
# define OPENSSL_NO_EC_NISTP_64_GCC_128
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_EGD
|
||||
# define OPENSSL_NO_EGD
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_FUZZ_AFL
|
||||
# define OPENSSL_NO_FUZZ_AFL
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_FUZZ_LIBFUZZER
|
||||
# define OPENSSL_NO_FUZZ_LIBFUZZER
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_HEARTBEATS
|
||||
# define OPENSSL_NO_HEARTBEATS
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_MSAN
|
||||
# define OPENSSL_NO_MSAN
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SCTP
|
||||
# define OPENSSL_NO_SCTP
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SSL_TRACE
|
||||
# define OPENSSL_NO_SSL_TRACE
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SSL3
|
||||
# define OPENSSL_NO_SSL3
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SSL3_METHOD
|
||||
# define OPENSSL_NO_SSL3_METHOD
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_UBSAN
|
||||
# define OPENSSL_NO_UBSAN
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_UNIT_TEST
|
||||
# define OPENSSL_NO_UNIT_TEST
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_WEAK_SSL_CIPHERS
|
||||
# define OPENSSL_NO_WEAK_SSL_CIPHERS
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_AFALGENG
|
||||
# define OPENSSL_NO_AFALGENG
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Sometimes OPENSSSL_NO_xxx ends up with an empty file and some compilers
|
||||
* don't like that. This will hopefully silence them.
|
||||
*/
|
||||
#define NON_EMPTY_TRANSLATION_UNIT static void *dummy = &dummy;
|
||||
|
||||
/*
|
||||
* Applications should use -DOPENSSL_API_COMPAT=<version> to suppress the
|
||||
* declarations of functions deprecated in or before <version>. Otherwise, they
|
||||
* still won't see them if the library has been built to disable deprecated
|
||||
* functions.
|
||||
*/
|
||||
#if defined(OPENSSL_NO_DEPRECATED)
|
||||
# define DECLARE_DEPRECATED(f)
|
||||
#elif __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 0)
|
||||
# define DECLARE_DEPRECATED(f) f __attribute__ ((deprecated));
|
||||
#else
|
||||
# define DECLARE_DEPRECATED(f) f;
|
||||
#endif
|
||||
|
||||
#ifndef OPENSSL_FILE
|
||||
# ifdef OPENSSL_NO_FILENAMES
|
||||
# define OPENSSL_FILE ""
|
||||
# define OPENSSL_LINE 0
|
||||
# else
|
||||
# define OPENSSL_FILE __FILE__
|
||||
# define OPENSSL_LINE __LINE__
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef OPENSSL_MIN_API
|
||||
# define OPENSSL_MIN_API 0
|
||||
#endif
|
||||
|
||||
#if !defined(OPENSSL_API_COMPAT) || OPENSSL_API_COMPAT < OPENSSL_MIN_API
|
||||
# undef OPENSSL_API_COMPAT
|
||||
# define OPENSSL_API_COMPAT OPENSSL_MIN_API
|
||||
#endif
|
||||
|
||||
#if OPENSSL_API_COMPAT < 0x10100000L
|
||||
# define DEPRECATEDIN_1_1_0(f) DECLARE_DEPRECATED(f)
|
||||
#else
|
||||
# define DEPRECATEDIN_1_1_0(f)
|
||||
#endif
|
||||
|
||||
#if OPENSSL_API_COMPAT < 0x10000000L
|
||||
# define DEPRECATEDIN_1_0_0(f) DECLARE_DEPRECATED(f)
|
||||
#else
|
||||
# define DEPRECATEDIN_1_0_0(f)
|
||||
#endif
|
||||
|
||||
#if OPENSSL_API_COMPAT < 0x00908000L
|
||||
# define DEPRECATEDIN_0_9_8(f) DECLARE_DEPRECATED(f)
|
||||
#else
|
||||
# define DEPRECATEDIN_0_9_8(f)
|
||||
#endif
|
||||
|
||||
#define OPENSSL_CPUID_OBJ
|
||||
|
||||
/* Generate 80386 code? */
|
||||
#undef I386_ONLY
|
||||
|
||||
#undef OPENSSL_UNISTD
|
||||
#define OPENSSL_UNISTD <unistd.h>
|
||||
|
||||
#undef OPENSSL_EXPORT_VAR_AS_FUNCTION
|
||||
|
||||
/*
|
||||
* The following are cipher-specific, but are part of the public API.
|
||||
*/
|
||||
#if !defined(OPENSSL_SYS_UEFI)
|
||||
# define BN_LLONG
|
||||
/* Only one for the following should be defined */
|
||||
# undef SIXTY_FOUR_BIT_LONG
|
||||
# undef SIXTY_FOUR_BIT
|
||||
# define THIRTY_TWO_BIT
|
||||
#endif
|
||||
|
||||
#define RC4_INT unsigned int
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
#ifdef __aarch64__
|
||||
#include "opensslconf-arm64.h"
|
||||
#elif __arm__
|
||||
#include "opensslconf-arm32.h"
|
||||
#elif __i386__
|
||||
#include "opensslconf-x86.h"
|
||||
#else
|
||||
#error "Unsupported architecture!"
|
||||
#endif
|
||||
|
|
@ -0,0 +1,105 @@
|
|||
/*
|
||||
* Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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_OPENSSLV_H
|
||||
# define HEADER_OPENSSLV_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*-
|
||||
* Numeric release version identifier:
|
||||
* MNNFFPPS: major minor fix patch status
|
||||
* The status nibble has one of the values 0 for development, 1 to e for betas
|
||||
* 1 to 14, and f for release. The patch level is exactly that.
|
||||
* For example:
|
||||
* 0.9.3-dev 0x00903000
|
||||
* 0.9.3-beta1 0x00903001
|
||||
* 0.9.3-beta2-dev 0x00903002
|
||||
* 0.9.3-beta2 0x00903002 (same as ...beta2-dev)
|
||||
* 0.9.3 0x0090300f
|
||||
* 0.9.3a 0x0090301f
|
||||
* 0.9.4 0x0090400f
|
||||
* 1.2.3z 0x102031af
|
||||
*
|
||||
* For continuity reasons (because 0.9.5 is already out, and is coded
|
||||
* 0x00905100), between 0.9.5 and 0.9.6 the coding of the patch level
|
||||
* part is slightly different, by setting the highest bit. This means
|
||||
* that 0.9.5a looks like this: 0x0090581f. At 0.9.6, we can start
|
||||
* with 0x0090600S...
|
||||
*
|
||||
* (Prior to 0.9.3-dev a different scheme was used: 0.9.2b is 0x0922.)
|
||||
* (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for
|
||||
* major minor fix final patch/beta)
|
||||
*/
|
||||
# define OPENSSL_VERSION_NUMBER 0x1010003fL
|
||||
# ifdef OPENSSL_FIPS
|
||||
# define OPENSSL_VERSION_TEXT "OpenSSL 1.1.0c-fips 10 Nov 2016"
|
||||
# else
|
||||
# define OPENSSL_VERSION_TEXT "OpenSSL 1.1.0c 10 Nov 2016"
|
||||
# endif
|
||||
|
||||
/*-
|
||||
* The macros below are to be used for shared library (.so, .dll, ...)
|
||||
* versioning. That kind of versioning works a bit differently between
|
||||
* operating systems. The most usual scheme is to set a major and a minor
|
||||
* number, and have the runtime loader check that the major number is equal
|
||||
* to what it was at application link time, while the minor number has to
|
||||
* be greater or equal to what it was at application link time. With this
|
||||
* scheme, the version number is usually part of the file name, like this:
|
||||
*
|
||||
* libcrypto.so.0.9
|
||||
*
|
||||
* Some unixen also make a softlink with the major version number only:
|
||||
*
|
||||
* libcrypto.so.0
|
||||
*
|
||||
* On Tru64 and IRIX 6.x it works a little bit differently. There, the
|
||||
* shared library version is stored in the file, and is actually a series
|
||||
* of versions, separated by colons. The rightmost version present in the
|
||||
* library when linking an application is stored in the application to be
|
||||
* matched at run time. When the application is run, a check is done to
|
||||
* see if the library version stored in the application matches any of the
|
||||
* versions in the version string of the library itself.
|
||||
* This version string can be constructed in any way, depending on what
|
||||
* kind of matching is desired. However, to implement the same scheme as
|
||||
* the one used in the other unixen, all compatible versions, from lowest
|
||||
* to highest, should be part of the string. Consecutive builds would
|
||||
* give the following versions strings:
|
||||
*
|
||||
* 3.0
|
||||
* 3.0:3.1
|
||||
* 3.0:3.1:3.2
|
||||
* 4.0
|
||||
* 4.0:4.1
|
||||
*
|
||||
* Notice how version 4 is completely incompatible with version, and
|
||||
* therefore give the breach you can see.
|
||||
*
|
||||
* There may be other schemes as well that I haven't yet discovered.
|
||||
*
|
||||
* So, here's the way it works here: first of all, the library version
|
||||
* number doesn't need at all to match the overall OpenSSL version.
|
||||
* However, it's nice and more understandable if it actually does.
|
||||
* The current library version is stored in the macro SHLIB_VERSION_NUMBER,
|
||||
* which is just a piece of text in the format "M.m.e" (Major, minor, edit).
|
||||
* For the sake of Tru64, IRIX, and any other OS that behaves in similar ways,
|
||||
* we need to keep a history of version numbers, which is done in the
|
||||
* macro SHLIB_VERSION_HISTORY. The numbers are separated by colons and
|
||||
* should only keep the versions that are binary compatible with the current.
|
||||
*/
|
||||
# define SHLIB_VERSION_HISTORY ""
|
||||
# define SHLIB_VERSION_NUMBER "1.1"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* HEADER_OPENSSLV_H */
|
||||
|
|
@ -0,0 +1,190 @@
|
|||
/*
|
||||
* Copyright 2001-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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_OPENSSL_TYPES_H
|
||||
# define HEADER_OPENSSL_TYPES_H
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
# include <openssl/e_os2.h>
|
||||
|
||||
# ifdef NO_ASN1_TYPEDEFS
|
||||
# define ASN1_INTEGER ASN1_STRING
|
||||
# define ASN1_ENUMERATED ASN1_STRING
|
||||
# define ASN1_BIT_STRING ASN1_STRING
|
||||
# define ASN1_OCTET_STRING ASN1_STRING
|
||||
# define ASN1_PRINTABLESTRING ASN1_STRING
|
||||
# define ASN1_T61STRING ASN1_STRING
|
||||
# define ASN1_IA5STRING ASN1_STRING
|
||||
# define ASN1_UTCTIME ASN1_STRING
|
||||
# define ASN1_GENERALIZEDTIME ASN1_STRING
|
||||
# define ASN1_TIME ASN1_STRING
|
||||
# define ASN1_GENERALSTRING ASN1_STRING
|
||||
# define ASN1_UNIVERSALSTRING ASN1_STRING
|
||||
# define ASN1_BMPSTRING ASN1_STRING
|
||||
# define ASN1_VISIBLESTRING ASN1_STRING
|
||||
# define ASN1_UTF8STRING ASN1_STRING
|
||||
# define ASN1_BOOLEAN int
|
||||
# define ASN1_NULL int
|
||||
# else
|
||||
typedef struct asn1_string_st ASN1_INTEGER;
|
||||
typedef struct asn1_string_st ASN1_ENUMERATED;
|
||||
typedef struct asn1_string_st ASN1_BIT_STRING;
|
||||
typedef struct asn1_string_st ASN1_OCTET_STRING;
|
||||
typedef struct asn1_string_st ASN1_PRINTABLESTRING;
|
||||
typedef struct asn1_string_st ASN1_T61STRING;
|
||||
typedef struct asn1_string_st ASN1_IA5STRING;
|
||||
typedef struct asn1_string_st ASN1_GENERALSTRING;
|
||||
typedef struct asn1_string_st ASN1_UNIVERSALSTRING;
|
||||
typedef struct asn1_string_st ASN1_BMPSTRING;
|
||||
typedef struct asn1_string_st ASN1_UTCTIME;
|
||||
typedef struct asn1_string_st ASN1_TIME;
|
||||
typedef struct asn1_string_st ASN1_GENERALIZEDTIME;
|
||||
typedef struct asn1_string_st ASN1_VISIBLESTRING;
|
||||
typedef struct asn1_string_st ASN1_UTF8STRING;
|
||||
typedef struct asn1_string_st ASN1_STRING;
|
||||
typedef int ASN1_BOOLEAN;
|
||||
typedef int ASN1_NULL;
|
||||
# endif
|
||||
|
||||
typedef struct asn1_object_st ASN1_OBJECT;
|
||||
|
||||
typedef struct ASN1_ITEM_st ASN1_ITEM;
|
||||
typedef struct asn1_pctx_st ASN1_PCTX;
|
||||
typedef struct asn1_sctx_st ASN1_SCTX;
|
||||
|
||||
# ifdef _WIN32
|
||||
# undef X509_NAME
|
||||
# undef X509_EXTENSIONS
|
||||
# undef PKCS7_ISSUER_AND_SERIAL
|
||||
# undef PKCS7_SIGNER_INFO
|
||||
# undef OCSP_REQUEST
|
||||
# undef OCSP_RESPONSE
|
||||
# endif
|
||||
|
||||
# ifdef BIGNUM
|
||||
# undef BIGNUM
|
||||
# endif
|
||||
struct dane_st;
|
||||
typedef struct bio_st BIO;
|
||||
typedef struct bignum_st BIGNUM;
|
||||
typedef struct bignum_ctx BN_CTX;
|
||||
typedef struct bn_blinding_st BN_BLINDING;
|
||||
typedef struct bn_mont_ctx_st BN_MONT_CTX;
|
||||
typedef struct bn_recp_ctx_st BN_RECP_CTX;
|
||||
typedef struct bn_gencb_st BN_GENCB;
|
||||
|
||||
typedef struct buf_mem_st BUF_MEM;
|
||||
|
||||
typedef struct evp_cipher_st EVP_CIPHER;
|
||||
typedef struct evp_cipher_ctx_st EVP_CIPHER_CTX;
|
||||
typedef struct evp_md_st EVP_MD;
|
||||
typedef struct evp_md_ctx_st EVP_MD_CTX;
|
||||
typedef struct evp_pkey_st EVP_PKEY;
|
||||
|
||||
typedef struct evp_pkey_asn1_method_st EVP_PKEY_ASN1_METHOD;
|
||||
|
||||
typedef struct evp_pkey_method_st EVP_PKEY_METHOD;
|
||||
typedef struct evp_pkey_ctx_st EVP_PKEY_CTX;
|
||||
|
||||
typedef struct evp_Encode_Ctx_st EVP_ENCODE_CTX;
|
||||
|
||||
typedef struct hmac_ctx_st HMAC_CTX;
|
||||
|
||||
typedef struct dh_st DH;
|
||||
typedef struct dh_method DH_METHOD;
|
||||
|
||||
typedef struct dsa_st DSA;
|
||||
typedef struct dsa_method DSA_METHOD;
|
||||
|
||||
typedef struct rsa_st RSA;
|
||||
typedef struct rsa_meth_st RSA_METHOD;
|
||||
|
||||
typedef struct ec_key_st EC_KEY;
|
||||
typedef struct ec_key_method_st EC_KEY_METHOD;
|
||||
|
||||
typedef struct rand_meth_st RAND_METHOD;
|
||||
|
||||
typedef struct ssl_dane_st SSL_DANE;
|
||||
typedef struct x509_st X509;
|
||||
typedef struct X509_algor_st X509_ALGOR;
|
||||
typedef struct X509_crl_st X509_CRL;
|
||||
typedef struct x509_crl_method_st X509_CRL_METHOD;
|
||||
typedef struct x509_revoked_st X509_REVOKED;
|
||||
typedef struct X509_name_st X509_NAME;
|
||||
typedef struct X509_pubkey_st X509_PUBKEY;
|
||||
typedef struct x509_store_st X509_STORE;
|
||||
typedef struct x509_store_ctx_st X509_STORE_CTX;
|
||||
|
||||
typedef struct x509_object_st X509_OBJECT;
|
||||
typedef struct x509_lookup_st X509_LOOKUP;
|
||||
typedef struct x509_lookup_method_st X509_LOOKUP_METHOD;
|
||||
typedef struct X509_VERIFY_PARAM_st X509_VERIFY_PARAM;
|
||||
|
||||
typedef struct pkcs8_priv_key_info_st PKCS8_PRIV_KEY_INFO;
|
||||
|
||||
typedef struct v3_ext_ctx X509V3_CTX;
|
||||
typedef struct conf_st CONF;
|
||||
typedef struct ossl_init_settings_st OPENSSL_INIT_SETTINGS;
|
||||
|
||||
typedef struct ui_st UI;
|
||||
typedef struct ui_method_st UI_METHOD;
|
||||
|
||||
typedef struct engine_st ENGINE;
|
||||
typedef struct ssl_st SSL;
|
||||
typedef struct ssl_ctx_st SSL_CTX;
|
||||
|
||||
typedef struct comp_ctx_st COMP_CTX;
|
||||
typedef struct comp_method_st COMP_METHOD;
|
||||
|
||||
typedef struct X509_POLICY_NODE_st X509_POLICY_NODE;
|
||||
typedef struct X509_POLICY_LEVEL_st X509_POLICY_LEVEL;
|
||||
typedef struct X509_POLICY_TREE_st X509_POLICY_TREE;
|
||||
typedef struct X509_POLICY_CACHE_st X509_POLICY_CACHE;
|
||||
|
||||
typedef struct AUTHORITY_KEYID_st AUTHORITY_KEYID;
|
||||
typedef struct DIST_POINT_st DIST_POINT;
|
||||
typedef struct ISSUING_DIST_POINT_st ISSUING_DIST_POINT;
|
||||
typedef struct NAME_CONSTRAINTS_st NAME_CONSTRAINTS;
|
||||
|
||||
typedef struct crypto_ex_data_st CRYPTO_EX_DATA;
|
||||
|
||||
typedef struct ocsp_req_ctx_st OCSP_REQ_CTX;
|
||||
typedef struct ocsp_response_st OCSP_RESPONSE;
|
||||
typedef struct ocsp_responder_id_st OCSP_RESPID;
|
||||
|
||||
typedef struct sct_st SCT;
|
||||
typedef struct sct_ctx_st SCT_CTX;
|
||||
typedef struct ctlog_st CTLOG;
|
||||
typedef struct ctlog_store_st CTLOG_STORE;
|
||||
typedef struct ct_policy_eval_ctx_st CT_POLICY_EVAL_CTX;
|
||||
|
||||
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L && \
|
||||
defined(INTMAX_MAX) && defined(UINTMAX_MAX)
|
||||
typedef intmax_t ossl_intmax_t;
|
||||
typedef uintmax_t ossl_uintmax_t;
|
||||
#else
|
||||
/*
|
||||
* Not long long, because the C-library can only be expected to provide
|
||||
* strtoll(), strtoull() at the same time as intmax_t and strtoimax(),
|
||||
* strtoumax(). Since we use these for parsing arguments, we need the
|
||||
* conversion functions, not just the sizes.
|
||||
*/
|
||||
typedef long ossl_intmax_t;
|
||||
typedef unsigned long ossl_uintmax_t;
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* def HEADER_OPENSSL_TYPES_H */
|
||||
|
|
@ -0,0 +1,501 @@
|
|||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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_PEM_H
|
||||
# define HEADER_PEM_H
|
||||
|
||||
# include <openssl/e_os2.h>
|
||||
# include <openssl/bio.h>
|
||||
# include <openssl/stack.h>
|
||||
# include <openssl/evp.h>
|
||||
# include <openssl/x509.h>
|
||||
# include <openssl/pem2.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
# define PEM_BUFSIZE 1024
|
||||
|
||||
# define PEM_STRING_X509_OLD "X509 CERTIFICATE"
|
||||
# define PEM_STRING_X509 "CERTIFICATE"
|
||||
# define PEM_STRING_X509_TRUSTED "TRUSTED CERTIFICATE"
|
||||
# define PEM_STRING_X509_REQ_OLD "NEW CERTIFICATE REQUEST"
|
||||
# define PEM_STRING_X509_REQ "CERTIFICATE REQUEST"
|
||||
# define PEM_STRING_X509_CRL "X509 CRL"
|
||||
# define PEM_STRING_EVP_PKEY "ANY PRIVATE KEY"
|
||||
# define PEM_STRING_PUBLIC "PUBLIC KEY"
|
||||
# define PEM_STRING_RSA "RSA PRIVATE KEY"
|
||||
# define PEM_STRING_RSA_PUBLIC "RSA PUBLIC KEY"
|
||||
# define PEM_STRING_DSA "DSA PRIVATE KEY"
|
||||
# define PEM_STRING_DSA_PUBLIC "DSA PUBLIC KEY"
|
||||
# define PEM_STRING_PKCS7 "PKCS7"
|
||||
# define PEM_STRING_PKCS7_SIGNED "PKCS #7 SIGNED DATA"
|
||||
# define PEM_STRING_PKCS8 "ENCRYPTED PRIVATE KEY"
|
||||
# define PEM_STRING_PKCS8INF "PRIVATE KEY"
|
||||
# define PEM_STRING_DHPARAMS "DH PARAMETERS"
|
||||
# define PEM_STRING_DHXPARAMS "X9.42 DH PARAMETERS"
|
||||
# define PEM_STRING_SSL_SESSION "SSL SESSION PARAMETERS"
|
||||
# define PEM_STRING_DSAPARAMS "DSA PARAMETERS"
|
||||
# define PEM_STRING_ECDSA_PUBLIC "ECDSA PUBLIC KEY"
|
||||
# define PEM_STRING_ECPARAMETERS "EC PARAMETERS"
|
||||
# define PEM_STRING_ECPRIVATEKEY "EC PRIVATE KEY"
|
||||
# define PEM_STRING_PARAMETERS "PARAMETERS"
|
||||
# define PEM_STRING_CMS "CMS"
|
||||
|
||||
# define PEM_TYPE_ENCRYPTED 10
|
||||
# define PEM_TYPE_MIC_ONLY 20
|
||||
# define PEM_TYPE_MIC_CLEAR 30
|
||||
# define PEM_TYPE_CLEAR 40
|
||||
|
||||
typedef struct pem_recip_st {
|
||||
char *name;
|
||||
X509_NAME *dn;
|
||||
int cipher;
|
||||
int key_enc;
|
||||
/* char iv[8]; unused and wrong size */
|
||||
} PEM_USER;
|
||||
|
||||
typedef struct pem_ctx_st {
|
||||
int type; /* what type of object */
|
||||
struct {
|
||||
int version;
|
||||
int mode;
|
||||
} proc_type;
|
||||
|
||||
char *domain;
|
||||
|
||||
struct {
|
||||
int cipher;
|
||||
/*-
|
||||
unused, and wrong size
|
||||
unsigned char iv[8]; */
|
||||
} DEK_info;
|
||||
|
||||
PEM_USER *originator;
|
||||
|
||||
int num_recipient;
|
||||
PEM_USER **recipient;
|
||||
|
||||
/*-
|
||||
XXX(ben): don#t think this is used!
|
||||
STACK *x509_chain; / * certificate chain */
|
||||
EVP_MD *md; /* signature type */
|
||||
|
||||
int md_enc; /* is the md encrypted or not? */
|
||||
int md_len; /* length of md_data */
|
||||
char *md_data; /* message digest, could be pkey encrypted */
|
||||
|
||||
EVP_CIPHER *dec; /* date encryption cipher */
|
||||
int key_len; /* key length */
|
||||
unsigned char *key; /* key */
|
||||
/*-
|
||||
unused, and wrong size
|
||||
unsigned char iv[8]; */
|
||||
|
||||
int data_enc; /* is the data encrypted */
|
||||
int data_len;
|
||||
unsigned char *data;
|
||||
} PEM_CTX;
|
||||
|
||||
/*
|
||||
* These macros make the PEM_read/PEM_write functions easier to maintain and
|
||||
* write. Now they are all implemented with either: IMPLEMENT_PEM_rw(...) or
|
||||
* IMPLEMENT_PEM_rw_cb(...)
|
||||
*/
|
||||
|
||||
# ifdef OPENSSL_NO_STDIO
|
||||
|
||||
# define IMPLEMENT_PEM_read_fp(name, type, str, asn1) /**/
|
||||
# define IMPLEMENT_PEM_write_fp(name, type, str, asn1) /**/
|
||||
# define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) /**/
|
||||
# define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) /**/
|
||||
# define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) /**/
|
||||
# else
|
||||
|
||||
# define IMPLEMENT_PEM_read_fp(name, type, str, asn1) \
|
||||
type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u)\
|
||||
{ \
|
||||
return PEM_ASN1_read((d2i_of_void *)d2i_##asn1, str,fp,(void **)x,cb,u); \
|
||||
}
|
||||
|
||||
# define IMPLEMENT_PEM_write_fp(name, type, str, asn1) \
|
||||
int PEM_write_##name(FILE *fp, type *x) \
|
||||
{ \
|
||||
return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,NULL,NULL,0,NULL,NULL); \
|
||||
}
|
||||
|
||||
# define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) \
|
||||
int PEM_write_##name(FILE *fp, const type *x) \
|
||||
{ \
|
||||
return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,(void *)x,NULL,NULL,0,NULL,NULL); \
|
||||
}
|
||||
|
||||
# define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) \
|
||||
int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \
|
||||
unsigned char *kstr, int klen, pem_password_cb *cb, \
|
||||
void *u) \
|
||||
{ \
|
||||
return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u); \
|
||||
}
|
||||
|
||||
# define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) \
|
||||
int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \
|
||||
unsigned char *kstr, int klen, pem_password_cb *cb, \
|
||||
void *u) \
|
||||
{ \
|
||||
return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u); \
|
||||
}
|
||||
|
||||
# endif
|
||||
|
||||
# define IMPLEMENT_PEM_read_bio(name, type, str, asn1) \
|
||||
type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u)\
|
||||
{ \
|
||||
return PEM_ASN1_read_bio((d2i_of_void *)d2i_##asn1, str,bp,(void **)x,cb,u); \
|
||||
}
|
||||
|
||||
# define IMPLEMENT_PEM_write_bio(name, type, str, asn1) \
|
||||
int PEM_write_bio_##name(BIO *bp, type *x) \
|
||||
{ \
|
||||
return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,x,NULL,NULL,0,NULL,NULL); \
|
||||
}
|
||||
|
||||
# define IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \
|
||||
int PEM_write_bio_##name(BIO *bp, const type *x) \
|
||||
{ \
|
||||
return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,(void *)x,NULL,NULL,0,NULL,NULL); \
|
||||
}
|
||||
|
||||
# define IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \
|
||||
int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \
|
||||
unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \
|
||||
{ \
|
||||
return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,x,enc,kstr,klen,cb,u); \
|
||||
}
|
||||
|
||||
# define IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \
|
||||
int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \
|
||||
unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \
|
||||
{ \
|
||||
return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,(void *)x,enc,kstr,klen,cb,u); \
|
||||
}
|
||||
|
||||
# define IMPLEMENT_PEM_write(name, type, str, asn1) \
|
||||
IMPLEMENT_PEM_write_bio(name, type, str, asn1) \
|
||||
IMPLEMENT_PEM_write_fp(name, type, str, asn1)
|
||||
|
||||
# define IMPLEMENT_PEM_write_const(name, type, str, asn1) \
|
||||
IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \
|
||||
IMPLEMENT_PEM_write_fp_const(name, type, str, asn1)
|
||||
|
||||
# define IMPLEMENT_PEM_write_cb(name, type, str, asn1) \
|
||||
IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \
|
||||
IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1)
|
||||
|
||||
# define IMPLEMENT_PEM_write_cb_const(name, type, str, asn1) \
|
||||
IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \
|
||||
IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1)
|
||||
|
||||
# define IMPLEMENT_PEM_read(name, type, str, asn1) \
|
||||
IMPLEMENT_PEM_read_bio(name, type, str, asn1) \
|
||||
IMPLEMENT_PEM_read_fp(name, type, str, asn1)
|
||||
|
||||
# define IMPLEMENT_PEM_rw(name, type, str, asn1) \
|
||||
IMPLEMENT_PEM_read(name, type, str, asn1) \
|
||||
IMPLEMENT_PEM_write(name, type, str, asn1)
|
||||
|
||||
# define IMPLEMENT_PEM_rw_const(name, type, str, asn1) \
|
||||
IMPLEMENT_PEM_read(name, type, str, asn1) \
|
||||
IMPLEMENT_PEM_write_const(name, type, str, asn1)
|
||||
|
||||
# define IMPLEMENT_PEM_rw_cb(name, type, str, asn1) \
|
||||
IMPLEMENT_PEM_read(name, type, str, asn1) \
|
||||
IMPLEMENT_PEM_write_cb(name, type, str, asn1)
|
||||
|
||||
/* These are the same except they are for the declarations */
|
||||
|
||||
# if defined(OPENSSL_NO_STDIO)
|
||||
|
||||
# define DECLARE_PEM_read_fp(name, type) /**/
|
||||
# define DECLARE_PEM_write_fp(name, type) /**/
|
||||
# define DECLARE_PEM_write_fp_const(name, type) /**/
|
||||
# define DECLARE_PEM_write_cb_fp(name, type) /**/
|
||||
# else
|
||||
|
||||
# define DECLARE_PEM_read_fp(name, type) \
|
||||
type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u);
|
||||
|
||||
# define DECLARE_PEM_write_fp(name, type) \
|
||||
int PEM_write_##name(FILE *fp, type *x);
|
||||
|
||||
# define DECLARE_PEM_write_fp_const(name, type) \
|
||||
int PEM_write_##name(FILE *fp, const type *x);
|
||||
|
||||
# define DECLARE_PEM_write_cb_fp(name, type) \
|
||||
int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \
|
||||
unsigned char *kstr, int klen, pem_password_cb *cb, void *u);
|
||||
|
||||
# endif
|
||||
|
||||
# define DECLARE_PEM_read_bio(name, type) \
|
||||
type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u);
|
||||
|
||||
# define DECLARE_PEM_write_bio(name, type) \
|
||||
int PEM_write_bio_##name(BIO *bp, type *x);
|
||||
|
||||
# define DECLARE_PEM_write_bio_const(name, type) \
|
||||
int PEM_write_bio_##name(BIO *bp, const type *x);
|
||||
|
||||
# define DECLARE_PEM_write_cb_bio(name, type) \
|
||||
int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \
|
||||
unsigned char *kstr, int klen, pem_password_cb *cb, void *u);
|
||||
|
||||
# define DECLARE_PEM_write(name, type) \
|
||||
DECLARE_PEM_write_bio(name, type) \
|
||||
DECLARE_PEM_write_fp(name, type)
|
||||
# define DECLARE_PEM_write_const(name, type) \
|
||||
DECLARE_PEM_write_bio_const(name, type) \
|
||||
DECLARE_PEM_write_fp_const(name, type)
|
||||
# define DECLARE_PEM_write_cb(name, type) \
|
||||
DECLARE_PEM_write_cb_bio(name, type) \
|
||||
DECLARE_PEM_write_cb_fp(name, type)
|
||||
# define DECLARE_PEM_read(name, type) \
|
||||
DECLARE_PEM_read_bio(name, type) \
|
||||
DECLARE_PEM_read_fp(name, type)
|
||||
# define DECLARE_PEM_rw(name, type) \
|
||||
DECLARE_PEM_read(name, type) \
|
||||
DECLARE_PEM_write(name, type)
|
||||
# define DECLARE_PEM_rw_const(name, type) \
|
||||
DECLARE_PEM_read(name, type) \
|
||||
DECLARE_PEM_write_const(name, type)
|
||||
# define DECLARE_PEM_rw_cb(name, type) \
|
||||
DECLARE_PEM_read(name, type) \
|
||||
DECLARE_PEM_write_cb(name, type)
|
||||
typedef int pem_password_cb (char *buf, int size, int rwflag, void *userdata);
|
||||
|
||||
int PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher);
|
||||
int PEM_do_header(EVP_CIPHER_INFO *cipher, unsigned char *data, long *len,
|
||||
pem_password_cb *callback, void *u);
|
||||
|
||||
int PEM_read_bio(BIO *bp, char **name, char **header,
|
||||
unsigned char **data, long *len);
|
||||
int PEM_write_bio(BIO *bp, const char *name, const char *hdr,
|
||||
const unsigned char *data, long len);
|
||||
int PEM_bytes_read_bio(unsigned char **pdata, long *plen, char **pnm,
|
||||
const char *name, BIO *bp, pem_password_cb *cb,
|
||||
void *u);
|
||||
void *PEM_ASN1_read_bio(d2i_of_void *d2i, const char *name, BIO *bp, void **x,
|
||||
pem_password_cb *cb, void *u);
|
||||
int PEM_ASN1_write_bio(i2d_of_void *i2d, const char *name, BIO *bp, void *x,
|
||||
const EVP_CIPHER *enc, unsigned char *kstr, int klen,
|
||||
pem_password_cb *cb, void *u);
|
||||
|
||||
STACK_OF(X509_INFO) *PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk,
|
||||
pem_password_cb *cb, void *u);
|
||||
int PEM_X509_INFO_write_bio(BIO *bp, X509_INFO *xi, EVP_CIPHER *enc,
|
||||
unsigned char *kstr, int klen,
|
||||
pem_password_cb *cd, void *u);
|
||||
|
||||
#ifndef OPENSSL_NO_STDIO
|
||||
int PEM_read(FILE *fp, char **name, char **header,
|
||||
unsigned char **data, long *len);
|
||||
int PEM_write(FILE *fp, const char *name, const char *hdr,
|
||||
const unsigned char *data, long len);
|
||||
void *PEM_ASN1_read(d2i_of_void *d2i, const char *name, FILE *fp, void **x,
|
||||
pem_password_cb *cb, void *u);
|
||||
int PEM_ASN1_write(i2d_of_void *i2d, const char *name, FILE *fp,
|
||||
void *x, const EVP_CIPHER *enc, unsigned char *kstr,
|
||||
int klen, pem_password_cb *callback, void *u);
|
||||
STACK_OF(X509_INFO) *PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk,
|
||||
pem_password_cb *cb, void *u);
|
||||
#endif
|
||||
|
||||
int PEM_SignInit(EVP_MD_CTX *ctx, EVP_MD *type);
|
||||
int PEM_SignUpdate(EVP_MD_CTX *ctx, unsigned char *d, unsigned int cnt);
|
||||
int PEM_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret,
|
||||
unsigned int *siglen, EVP_PKEY *pkey);
|
||||
|
||||
int PEM_def_callback(char *buf, int num, int w, void *key);
|
||||
void PEM_proc_type(char *buf, int type);
|
||||
void PEM_dek_info(char *buf, const char *type, int len, char *str);
|
||||
|
||||
# include <openssl/symhacks.h>
|
||||
|
||||
DECLARE_PEM_rw(X509, X509)
|
||||
DECLARE_PEM_rw(X509_AUX, X509)
|
||||
DECLARE_PEM_rw(X509_REQ, X509_REQ)
|
||||
DECLARE_PEM_write(X509_REQ_NEW, X509_REQ)
|
||||
DECLARE_PEM_rw(X509_CRL, X509_CRL)
|
||||
DECLARE_PEM_rw(PKCS7, PKCS7)
|
||||
DECLARE_PEM_rw(NETSCAPE_CERT_SEQUENCE, NETSCAPE_CERT_SEQUENCE)
|
||||
DECLARE_PEM_rw(PKCS8, X509_SIG)
|
||||
DECLARE_PEM_rw(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO)
|
||||
# ifndef OPENSSL_NO_RSA
|
||||
DECLARE_PEM_rw_cb(RSAPrivateKey, RSA)
|
||||
DECLARE_PEM_rw_const(RSAPublicKey, RSA)
|
||||
DECLARE_PEM_rw(RSA_PUBKEY, RSA)
|
||||
# endif
|
||||
# ifndef OPENSSL_NO_DSA
|
||||
DECLARE_PEM_rw_cb(DSAPrivateKey, DSA)
|
||||
DECLARE_PEM_rw(DSA_PUBKEY, DSA)
|
||||
DECLARE_PEM_rw_const(DSAparams, DSA)
|
||||
# endif
|
||||
# ifndef OPENSSL_NO_EC
|
||||
DECLARE_PEM_rw_const(ECPKParameters, EC_GROUP)
|
||||
DECLARE_PEM_rw_cb(ECPrivateKey, EC_KEY)
|
||||
DECLARE_PEM_rw(EC_PUBKEY, EC_KEY)
|
||||
# endif
|
||||
# ifndef OPENSSL_NO_DH
|
||||
DECLARE_PEM_rw_const(DHparams, DH)
|
||||
DECLARE_PEM_write_const(DHxparams, DH)
|
||||
# endif
|
||||
DECLARE_PEM_rw_cb(PrivateKey, EVP_PKEY)
|
||||
DECLARE_PEM_rw(PUBKEY, EVP_PKEY)
|
||||
|
||||
int PEM_write_bio_PrivateKey_traditional(BIO *bp, EVP_PKEY *x,
|
||||
const EVP_CIPHER *enc,
|
||||
unsigned char *kstr, int klen,
|
||||
pem_password_cb *cb, void *u);
|
||||
|
||||
int PEM_write_bio_PKCS8PrivateKey_nid(BIO *bp, EVP_PKEY *x, int nid,
|
||||
char *kstr, int klen,
|
||||
pem_password_cb *cb, void *u);
|
||||
int PEM_write_bio_PKCS8PrivateKey(BIO *, EVP_PKEY *, const EVP_CIPHER *,
|
||||
char *, int, pem_password_cb *, void *);
|
||||
int i2d_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc,
|
||||
char *kstr, int klen,
|
||||
pem_password_cb *cb, void *u);
|
||||
int i2d_PKCS8PrivateKey_nid_bio(BIO *bp, EVP_PKEY *x, int nid,
|
||||
char *kstr, int klen,
|
||||
pem_password_cb *cb, void *u);
|
||||
EVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, pem_password_cb *cb,
|
||||
void *u);
|
||||
|
||||
# ifndef OPENSSL_NO_STDIO
|
||||
int i2d_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc,
|
||||
char *kstr, int klen,
|
||||
pem_password_cb *cb, void *u);
|
||||
int i2d_PKCS8PrivateKey_nid_fp(FILE *fp, EVP_PKEY *x, int nid,
|
||||
char *kstr, int klen,
|
||||
pem_password_cb *cb, void *u);
|
||||
int PEM_write_PKCS8PrivateKey_nid(FILE *fp, EVP_PKEY *x, int nid,
|
||||
char *kstr, int klen,
|
||||
pem_password_cb *cb, void *u);
|
||||
|
||||
EVP_PKEY *d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, pem_password_cb *cb,
|
||||
void *u);
|
||||
|
||||
int PEM_write_PKCS8PrivateKey(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc,
|
||||
char *kstr, int klen, pem_password_cb *cd,
|
||||
void *u);
|
||||
# endif
|
||||
EVP_PKEY *PEM_read_bio_Parameters(BIO *bp, EVP_PKEY **x);
|
||||
int PEM_write_bio_Parameters(BIO *bp, EVP_PKEY *x);
|
||||
|
||||
# ifndef OPENSSL_NO_DSA
|
||||
EVP_PKEY *b2i_PrivateKey(const unsigned char **in, long length);
|
||||
EVP_PKEY *b2i_PublicKey(const unsigned char **in, long length);
|
||||
EVP_PKEY *b2i_PrivateKey_bio(BIO *in);
|
||||
EVP_PKEY *b2i_PublicKey_bio(BIO *in);
|
||||
int i2b_PrivateKey_bio(BIO *out, EVP_PKEY *pk);
|
||||
int i2b_PublicKey_bio(BIO *out, EVP_PKEY *pk);
|
||||
# ifndef OPENSSL_NO_RC4
|
||||
EVP_PKEY *b2i_PVK_bio(BIO *in, pem_password_cb *cb, void *u);
|
||||
int i2b_PVK_bio(BIO *out, EVP_PKEY *pk, int enclevel,
|
||||
pem_password_cb *cb, void *u);
|
||||
# endif
|
||||
# endif
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
/*
|
||||
* The following lines are auto generated by the script mkerr.pl. Any changes
|
||||
* made after this point may be overwritten when the script is next run.
|
||||
*/
|
||||
|
||||
int ERR_load_PEM_strings(void);
|
||||
|
||||
/* Error codes for the PEM functions. */
|
||||
|
||||
/* Function codes. */
|
||||
# define PEM_F_B2I_DSS 127
|
||||
# define PEM_F_B2I_PVK_BIO 128
|
||||
# define PEM_F_B2I_RSA 129
|
||||
# define PEM_F_CHECK_BITLEN_DSA 130
|
||||
# define PEM_F_CHECK_BITLEN_RSA 131
|
||||
# define PEM_F_D2I_PKCS8PRIVATEKEY_BIO 120
|
||||
# define PEM_F_D2I_PKCS8PRIVATEKEY_FP 121
|
||||
# define PEM_F_DO_B2I 132
|
||||
# define PEM_F_DO_B2I_BIO 133
|
||||
# define PEM_F_DO_BLOB_HEADER 134
|
||||
# define PEM_F_DO_PK8PKEY 126
|
||||
# define PEM_F_DO_PK8PKEY_FP 125
|
||||
# define PEM_F_DO_PVK_BODY 135
|
||||
# define PEM_F_DO_PVK_HEADER 136
|
||||
# define PEM_F_I2B_PVK 137
|
||||
# define PEM_F_I2B_PVK_BIO 138
|
||||
# define PEM_F_LOAD_IV 101
|
||||
# define PEM_F_PEM_ASN1_READ 102
|
||||
# define PEM_F_PEM_ASN1_READ_BIO 103
|
||||
# define PEM_F_PEM_ASN1_WRITE 104
|
||||
# define PEM_F_PEM_ASN1_WRITE_BIO 105
|
||||
# define PEM_F_PEM_DEF_CALLBACK 100
|
||||
# define PEM_F_PEM_DO_HEADER 106
|
||||
# define PEM_F_PEM_GET_EVP_CIPHER_INFO 107
|
||||
# define PEM_F_PEM_READ 108
|
||||
# define PEM_F_PEM_READ_BIO 109
|
||||
# define PEM_F_PEM_READ_BIO_DHPARAMS 141
|
||||
# define PEM_F_PEM_READ_BIO_PARAMETERS 140
|
||||
# define PEM_F_PEM_READ_BIO_PRIVATEKEY 123
|
||||
# define PEM_F_PEM_READ_DHPARAMS 142
|
||||
# define PEM_F_PEM_READ_PRIVATEKEY 124
|
||||
# define PEM_F_PEM_SIGNFINAL 112
|
||||
# define PEM_F_PEM_WRITE 113
|
||||
# define PEM_F_PEM_WRITE_BIO 114
|
||||
# define PEM_F_PEM_WRITE_PRIVATEKEY 139
|
||||
# define PEM_F_PEM_X509_INFO_READ 115
|
||||
# define PEM_F_PEM_X509_INFO_READ_BIO 116
|
||||
# define PEM_F_PEM_X509_INFO_WRITE_BIO 117
|
||||
|
||||
/* Reason codes. */
|
||||
# define PEM_R_BAD_BASE64_DECODE 100
|
||||
# define PEM_R_BAD_DECRYPT 101
|
||||
# define PEM_R_BAD_END_LINE 102
|
||||
# define PEM_R_BAD_IV_CHARS 103
|
||||
# define PEM_R_BAD_MAGIC_NUMBER 116
|
||||
# define PEM_R_BAD_PASSWORD_READ 104
|
||||
# define PEM_R_BAD_VERSION_NUMBER 117
|
||||
# define PEM_R_BIO_WRITE_FAILURE 118
|
||||
# define PEM_R_CIPHER_IS_NULL 127
|
||||
# define PEM_R_ERROR_CONVERTING_PRIVATE_KEY 115
|
||||
# define PEM_R_EXPECTING_PRIVATE_KEY_BLOB 119
|
||||
# define PEM_R_EXPECTING_PUBLIC_KEY_BLOB 120
|
||||
# define PEM_R_HEADER_TOO_LONG 128
|
||||
# define PEM_R_INCONSISTENT_HEADER 121
|
||||
# define PEM_R_KEYBLOB_HEADER_PARSE_ERROR 122
|
||||
# define PEM_R_KEYBLOB_TOO_SHORT 123
|
||||
# define PEM_R_MISSING_DEK_IV 129
|
||||
# define PEM_R_NOT_DEK_INFO 105
|
||||
# define PEM_R_NOT_ENCRYPTED 106
|
||||
# define PEM_R_NOT_PROC_TYPE 107
|
||||
# define PEM_R_NO_START_LINE 108
|
||||
# define PEM_R_PROBLEMS_GETTING_PASSWORD 109
|
||||
# define PEM_R_PVK_DATA_TOO_SHORT 124
|
||||
# define PEM_R_PVK_TOO_SHORT 125
|
||||
# define PEM_R_READ_KEY 111
|
||||
# define PEM_R_SHORT_HEADER 112
|
||||
# define PEM_R_UNEXPECTED_DEK_IV 130
|
||||
# define PEM_R_UNSUPPORTED_CIPHER 113
|
||||
# define PEM_R_UNSUPPORTED_ENCRYPTION 114
|
||||
# define PEM_R_UNSUPPORTED_KEY_COMPONENTS 126
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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 __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef HEADER_PEM_H
|
||||
int ERR_load_PEM_strings(void);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
@ -0,0 +1,282 @@
|
|||
/*
|
||||
* Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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_PKCS12_H
|
||||
# define HEADER_PKCS12_H
|
||||
|
||||
# include <openssl/bio.h>
|
||||
# include <openssl/x509.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
# define PKCS12_KEY_ID 1
|
||||
# define PKCS12_IV_ID 2
|
||||
# define PKCS12_MAC_ID 3
|
||||
|
||||
/* Default iteration count */
|
||||
# ifndef PKCS12_DEFAULT_ITER
|
||||
# define PKCS12_DEFAULT_ITER PKCS5_DEFAULT_ITER
|
||||
# endif
|
||||
|
||||
# define PKCS12_MAC_KEY_LENGTH 20
|
||||
|
||||
# define PKCS12_SALT_LEN 8
|
||||
|
||||
/* It's not clear if these are actually needed... */
|
||||
# define PKCS12_key_gen PKCS12_key_gen_utf8
|
||||
# define PKCS12_add_friendlyname PKCS12_add_friendlyname_utf8
|
||||
|
||||
/* MS key usage constants */
|
||||
|
||||
# define KEY_EX 0x10
|
||||
# define KEY_SIG 0x80
|
||||
|
||||
typedef struct PKCS12_MAC_DATA_st PKCS12_MAC_DATA;
|
||||
|
||||
typedef struct PKCS12_st PKCS12;
|
||||
|
||||
typedef struct PKCS12_SAFEBAG_st PKCS12_SAFEBAG;
|
||||
|
||||
DEFINE_STACK_OF(PKCS12_SAFEBAG)
|
||||
|
||||
typedef struct pkcs12_bag_st PKCS12_BAGS;
|
||||
|
||||
# define PKCS12_ERROR 0
|
||||
# define PKCS12_OK 1
|
||||
|
||||
/* Compatibility macros */
|
||||
|
||||
#if OPENSSL_API_COMPAT < 0x10100000L
|
||||
|
||||
# define M_PKCS12_bag_type PKCS12_bag_type
|
||||
# define M_PKCS12_cert_bag_type PKCS12_cert_bag_type
|
||||
# define M_PKCS12_crl_bag_type PKCS12_cert_bag_type
|
||||
|
||||
# define PKCS12_certbag2x509 PKCS12_SAFEBAG_get1_cert
|
||||
# define PKCS12_certbag2scrl PKCS12_SAFEBAG_get1_crl
|
||||
# define PKCS12_bag_type PKCS12_SAFEBAG_get_nid
|
||||
# define PKCS12_cert_bag_type PKCS12_SAFEBAG_get_bag_nid
|
||||
# define PKCS12_x5092certbag PKCS12_SAFEBAG_create_cert
|
||||
# define PKCS12_x509crl2certbag PKCS12_SAFEBAG_create_crl
|
||||
# define PKCS12_MAKE_KEYBAG PKCS12_SAFEBAG_create0_p8inf
|
||||
# define PKCS12_MAKE_SHKEYBAG PKCS12_SAFEBAG_create_pkcs8_encrypt
|
||||
|
||||
#endif
|
||||
|
||||
DEPRECATEDIN_1_1_0(ASN1_TYPE *PKCS12_get_attr(const PKCS12_SAFEBAG *bag, int attr_nid))
|
||||
|
||||
ASN1_TYPE *PKCS8_get_attr(PKCS8_PRIV_KEY_INFO *p8, int attr_nid);
|
||||
int PKCS12_mac_present(const PKCS12 *p12);
|
||||
void PKCS12_get0_mac(const ASN1_OCTET_STRING **pmac,
|
||||
const X509_ALGOR **pmacalg,
|
||||
const ASN1_OCTET_STRING **psalt,
|
||||
const ASN1_INTEGER **piter,
|
||||
const PKCS12 *p12);
|
||||
|
||||
const ASN1_TYPE *PKCS12_SAFEBAG_get0_attr(const PKCS12_SAFEBAG *bag,
|
||||
int attr_nid);
|
||||
const ASN1_OBJECT *PKCS12_SAFEBAG_get0_type(const PKCS12_SAFEBAG *bag);
|
||||
int PKCS12_SAFEBAG_get_nid(const PKCS12_SAFEBAG *bag);
|
||||
int PKCS12_SAFEBAG_get_bag_nid(const PKCS12_SAFEBAG *bag);
|
||||
|
||||
X509 *PKCS12_SAFEBAG_get1_cert(const PKCS12_SAFEBAG *bag);
|
||||
X509_CRL *PKCS12_SAFEBAG_get1_crl(const PKCS12_SAFEBAG *bag);
|
||||
const STACK_OF(PKCS12_SAFEBAG) *
|
||||
PKCS12_SAFEBAG_get0_safes(const PKCS12_SAFEBAG *bag);
|
||||
const PKCS8_PRIV_KEY_INFO *PKCS12_SAFEBAG_get0_p8inf(const PKCS12_SAFEBAG *bag);
|
||||
const X509_SIG *PKCS12_SAFEBAG_get0_pkcs8(const PKCS12_SAFEBAG *bag);
|
||||
|
||||
PKCS12_SAFEBAG *PKCS12_SAFEBAG_create_cert(X509 *x509);
|
||||
PKCS12_SAFEBAG *PKCS12_SAFEBAG_create_crl(X509_CRL *crl);
|
||||
PKCS12_SAFEBAG *PKCS12_SAFEBAG_create0_p8inf(PKCS8_PRIV_KEY_INFO *p8);
|
||||
PKCS12_SAFEBAG *PKCS12_SAFEBAG_create0_pkcs8(X509_SIG *p8);
|
||||
PKCS12_SAFEBAG *PKCS12_SAFEBAG_create_pkcs8_encrypt(int pbe_nid,
|
||||
const char *pass,
|
||||
int passlen,
|
||||
unsigned char *salt,
|
||||
int saltlen, int iter,
|
||||
PKCS8_PRIV_KEY_INFO *p8inf);
|
||||
|
||||
PKCS12_SAFEBAG *PKCS12_item_pack_safebag(void *obj, const ASN1_ITEM *it,
|
||||
int nid1, int nid2);
|
||||
PKCS8_PRIV_KEY_INFO *PKCS8_decrypt(const X509_SIG *p8, const char *pass,
|
||||
int passlen);
|
||||
PKCS8_PRIV_KEY_INFO *PKCS12_decrypt_skey(const PKCS12_SAFEBAG *bag,
|
||||
const char *pass, int passlen);
|
||||
X509_SIG *PKCS8_encrypt(int pbe_nid, const EVP_CIPHER *cipher,
|
||||
const char *pass, int passlen, unsigned char *salt,
|
||||
int saltlen, int iter, PKCS8_PRIV_KEY_INFO *p8);
|
||||
X509_SIG *PKCS8_set0_pbe(const char *pass, int passlen,
|
||||
PKCS8_PRIV_KEY_INFO *p8inf, X509_ALGOR *pbe);
|
||||
PKCS7 *PKCS12_pack_p7data(STACK_OF(PKCS12_SAFEBAG) *sk);
|
||||
STACK_OF(PKCS12_SAFEBAG) *PKCS12_unpack_p7data(PKCS7 *p7);
|
||||
PKCS7 *PKCS12_pack_p7encdata(int pbe_nid, const char *pass, int passlen,
|
||||
unsigned char *salt, int saltlen, int iter,
|
||||
STACK_OF(PKCS12_SAFEBAG) *bags);
|
||||
STACK_OF(PKCS12_SAFEBAG) *PKCS12_unpack_p7encdata(PKCS7 *p7, const char *pass,
|
||||
int passlen);
|
||||
|
||||
int PKCS12_pack_authsafes(PKCS12 *p12, STACK_OF(PKCS7) *safes);
|
||||
STACK_OF(PKCS7) *PKCS12_unpack_authsafes(const PKCS12 *p12);
|
||||
|
||||
int PKCS12_add_localkeyid(PKCS12_SAFEBAG *bag, unsigned char *name,
|
||||
int namelen);
|
||||
int PKCS12_add_friendlyname_asc(PKCS12_SAFEBAG *bag, const char *name,
|
||||
int namelen);
|
||||
int PKCS12_add_friendlyname_utf8(PKCS12_SAFEBAG *bag, const char *name,
|
||||
int namelen);
|
||||
int PKCS12_add_CSPName_asc(PKCS12_SAFEBAG *bag, const char *name,
|
||||
int namelen);
|
||||
int PKCS12_add_friendlyname_uni(PKCS12_SAFEBAG *bag,
|
||||
const unsigned char *name, int namelen);
|
||||
int PKCS8_add_keyusage(PKCS8_PRIV_KEY_INFO *p8, int usage);
|
||||
ASN1_TYPE *PKCS12_get_attr_gen(const STACK_OF(X509_ATTRIBUTE) *attrs,
|
||||
int attr_nid);
|
||||
char *PKCS12_get_friendlyname(PKCS12_SAFEBAG *bag);
|
||||
const STACK_OF(X509_ATTRIBUTE) *
|
||||
PKCS12_SAFEBAG_get0_attrs(const PKCS12_SAFEBAG *bag);
|
||||
unsigned char *PKCS12_pbe_crypt(const X509_ALGOR *algor,
|
||||
const char *pass, int passlen,
|
||||
const unsigned char *in, int inlen,
|
||||
unsigned char **data, int *datalen,
|
||||
int en_de);
|
||||
void *PKCS12_item_decrypt_d2i(const X509_ALGOR *algor, const ASN1_ITEM *it,
|
||||
const char *pass, int passlen,
|
||||
const ASN1_OCTET_STRING *oct, int zbuf);
|
||||
ASN1_OCTET_STRING *PKCS12_item_i2d_encrypt(X509_ALGOR *algor,
|
||||
const ASN1_ITEM *it,
|
||||
const char *pass, int passlen,
|
||||
void *obj, int zbuf);
|
||||
PKCS12 *PKCS12_init(int mode);
|
||||
int PKCS12_key_gen_asc(const char *pass, int passlen, unsigned char *salt,
|
||||
int saltlen, int id, int iter, int n,
|
||||
unsigned char *out, const EVP_MD *md_type);
|
||||
int PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt,
|
||||
int saltlen, int id, int iter, int n,
|
||||
unsigned char *out, const EVP_MD *md_type);
|
||||
int PKCS12_key_gen_utf8(const char *pass, int passlen, unsigned char *salt,
|
||||
int saltlen, int id, int iter, int n,
|
||||
unsigned char *out, const EVP_MD *md_type);
|
||||
int PKCS12_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
|
||||
ASN1_TYPE *param, const EVP_CIPHER *cipher,
|
||||
const EVP_MD *md_type, int en_de);
|
||||
int PKCS12_gen_mac(PKCS12 *p12, const char *pass, int passlen,
|
||||
unsigned char *mac, unsigned int *maclen);
|
||||
int PKCS12_verify_mac(PKCS12 *p12, const char *pass, int passlen);
|
||||
int PKCS12_set_mac(PKCS12 *p12, const char *pass, int passlen,
|
||||
unsigned char *salt, int saltlen, int iter,
|
||||
const EVP_MD *md_type);
|
||||
int PKCS12_setup_mac(PKCS12 *p12, int iter, unsigned char *salt,
|
||||
int saltlen, const EVP_MD *md_type);
|
||||
unsigned char *OPENSSL_asc2uni(const char *asc, int asclen,
|
||||
unsigned char **uni, int *unilen);
|
||||
char *OPENSSL_uni2asc(const unsigned char *uni, int unilen);
|
||||
unsigned char *OPENSSL_utf82uni(const char *asc, int asclen,
|
||||
unsigned char **uni, int *unilen);
|
||||
char *OPENSSL_uni2utf8(const unsigned char *uni, int unilen);
|
||||
|
||||
DECLARE_ASN1_FUNCTIONS(PKCS12)
|
||||
DECLARE_ASN1_FUNCTIONS(PKCS12_MAC_DATA)
|
||||
DECLARE_ASN1_FUNCTIONS(PKCS12_SAFEBAG)
|
||||
DECLARE_ASN1_FUNCTIONS(PKCS12_BAGS)
|
||||
|
||||
DECLARE_ASN1_ITEM(PKCS12_SAFEBAGS)
|
||||
DECLARE_ASN1_ITEM(PKCS12_AUTHSAFES)
|
||||
|
||||
void PKCS12_PBE_add(void);
|
||||
int PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert,
|
||||
STACK_OF(X509) **ca);
|
||||
PKCS12 *PKCS12_create(const char *pass, const char *name, EVP_PKEY *pkey,
|
||||
X509 *cert, STACK_OF(X509) *ca, int nid_key, int nid_cert,
|
||||
int iter, int mac_iter, int keytype);
|
||||
|
||||
PKCS12_SAFEBAG *PKCS12_add_cert(STACK_OF(PKCS12_SAFEBAG) **pbags, X509 *cert);
|
||||
PKCS12_SAFEBAG *PKCS12_add_key(STACK_OF(PKCS12_SAFEBAG) **pbags,
|
||||
EVP_PKEY *key, int key_usage, int iter,
|
||||
int key_nid, const char *pass);
|
||||
int PKCS12_add_safe(STACK_OF(PKCS7) **psafes, STACK_OF(PKCS12_SAFEBAG) *bags,
|
||||
int safe_nid, int iter, const char *pass);
|
||||
PKCS12 *PKCS12_add_safes(STACK_OF(PKCS7) *safes, int p7_nid);
|
||||
|
||||
int i2d_PKCS12_bio(BIO *bp, PKCS12 *p12);
|
||||
# ifndef OPENSSL_NO_STDIO
|
||||
int i2d_PKCS12_fp(FILE *fp, PKCS12 *p12);
|
||||
# endif
|
||||
PKCS12 *d2i_PKCS12_bio(BIO *bp, PKCS12 **p12);
|
||||
# ifndef OPENSSL_NO_STDIO
|
||||
PKCS12 *d2i_PKCS12_fp(FILE *fp, PKCS12 **p12);
|
||||
# endif
|
||||
int PKCS12_newpass(PKCS12 *p12, const char *oldpass, const char *newpass);
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
/*
|
||||
* The following lines are auto generated by the script mkerr.pl. Any changes
|
||||
* made after this point may be overwritten when the script is next run.
|
||||
*/
|
||||
|
||||
int ERR_load_PKCS12_strings(void);
|
||||
|
||||
/* Error codes for the PKCS12 functions. */
|
||||
|
||||
/* Function codes. */
|
||||
# define PKCS12_F_PKCS12_CREATE 105
|
||||
# define PKCS12_F_PKCS12_GEN_MAC 107
|
||||
# define PKCS12_F_PKCS12_INIT 109
|
||||
# define PKCS12_F_PKCS12_ITEM_DECRYPT_D2I 106
|
||||
# define PKCS12_F_PKCS12_ITEM_I2D_ENCRYPT 108
|
||||
# define PKCS12_F_PKCS12_ITEM_PACK_SAFEBAG 117
|
||||
# define PKCS12_F_PKCS12_KEY_GEN_ASC 110
|
||||
# define PKCS12_F_PKCS12_KEY_GEN_UNI 111
|
||||
# define PKCS12_F_PKCS12_KEY_GEN_UTF8 116
|
||||
# define PKCS12_F_PKCS12_NEWPASS 128
|
||||
# define PKCS12_F_PKCS12_PACK_P7DATA 114
|
||||
# define PKCS12_F_PKCS12_PACK_P7ENCDATA 115
|
||||
# define PKCS12_F_PKCS12_PARSE 118
|
||||
# define PKCS12_F_PKCS12_PBE_CRYPT 119
|
||||
# define PKCS12_F_PKCS12_PBE_KEYIVGEN 120
|
||||
# define PKCS12_F_PKCS12_SAFEBAG_CREATE0_P8INF 112
|
||||
# define PKCS12_F_PKCS12_SAFEBAG_CREATE0_PKCS8 113
|
||||
# define PKCS12_F_PKCS12_SAFEBAG_CREATE_PKCS8_ENCRYPT 133
|
||||
# define PKCS12_F_PKCS12_SETUP_MAC 122
|
||||
# define PKCS12_F_PKCS12_SET_MAC 123
|
||||
# define PKCS12_F_PKCS12_UNPACK_AUTHSAFES 130
|
||||
# define PKCS12_F_PKCS12_UNPACK_P7DATA 131
|
||||
# define PKCS12_F_PKCS12_VERIFY_MAC 126
|
||||
# define PKCS12_F_PKCS8_ENCRYPT 125
|
||||
# define PKCS12_F_PKCS8_SET0_PBE 132
|
||||
|
||||
/* Reason codes. */
|
||||
# define PKCS12_R_CANT_PACK_STRUCTURE 100
|
||||
# define PKCS12_R_CONTENT_TYPE_NOT_DATA 121
|
||||
# define PKCS12_R_DECODE_ERROR 101
|
||||
# define PKCS12_R_ENCODE_ERROR 102
|
||||
# define PKCS12_R_ENCRYPT_ERROR 103
|
||||
# define PKCS12_R_ERROR_SETTING_ENCRYPTED_DATA_TYPE 120
|
||||
# define PKCS12_R_INVALID_NULL_ARGUMENT 104
|
||||
# define PKCS12_R_INVALID_NULL_PKCS12_POINTER 105
|
||||
# define PKCS12_R_IV_GEN_ERROR 106
|
||||
# define PKCS12_R_KEY_GEN_ERROR 107
|
||||
# define PKCS12_R_MAC_ABSENT 108
|
||||
# define PKCS12_R_MAC_GENERATION_ERROR 109
|
||||
# define PKCS12_R_MAC_SETUP_ERROR 110
|
||||
# define PKCS12_R_MAC_STRING_SET_ERROR 111
|
||||
# define PKCS12_R_MAC_VERIFY_FAILURE 113
|
||||
# define PKCS12_R_PARSE_ERROR 114
|
||||
# define PKCS12_R_PKCS12_ALGOR_CIPHERINIT_ERROR 115
|
||||
# define PKCS12_R_PKCS12_CIPHERFINAL_ERROR 116
|
||||
# define PKCS12_R_PKCS12_PBE_CRYPT_ERROR 117
|
||||
# define PKCS12_R_UNKNOWN_DIGEST_ALGORITHM 118
|
||||
# define PKCS12_R_UNSUPPORTED_PKCS12_MODE 119
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
|
@ -0,0 +1,404 @@
|
|||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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_PKCS7_H
|
||||
# define HEADER_PKCS7_H
|
||||
|
||||
# include <openssl/asn1.h>
|
||||
# include <openssl/bio.h>
|
||||
# include <openssl/e_os2.h>
|
||||
|
||||
# include <openssl/symhacks.h>
|
||||
# include <openssl/ossl_typ.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*-
|
||||
Encryption_ID DES-CBC
|
||||
Digest_ID MD5
|
||||
Digest_Encryption_ID rsaEncryption
|
||||
Key_Encryption_ID rsaEncryption
|
||||
*/
|
||||
|
||||
typedef struct pkcs7_issuer_and_serial_st {
|
||||
X509_NAME *issuer;
|
||||
ASN1_INTEGER *serial;
|
||||
} PKCS7_ISSUER_AND_SERIAL;
|
||||
|
||||
typedef struct pkcs7_signer_info_st {
|
||||
ASN1_INTEGER *version; /* version 1 */
|
||||
PKCS7_ISSUER_AND_SERIAL *issuer_and_serial;
|
||||
X509_ALGOR *digest_alg;
|
||||
STACK_OF(X509_ATTRIBUTE) *auth_attr; /* [ 0 ] */
|
||||
X509_ALGOR *digest_enc_alg;
|
||||
ASN1_OCTET_STRING *enc_digest;
|
||||
STACK_OF(X509_ATTRIBUTE) *unauth_attr; /* [ 1 ] */
|
||||
/* The private key to sign with */
|
||||
EVP_PKEY *pkey;
|
||||
} PKCS7_SIGNER_INFO;
|
||||
|
||||
DEFINE_STACK_OF(PKCS7_SIGNER_INFO)
|
||||
|
||||
typedef struct pkcs7_recip_info_st {
|
||||
ASN1_INTEGER *version; /* version 0 */
|
||||
PKCS7_ISSUER_AND_SERIAL *issuer_and_serial;
|
||||
X509_ALGOR *key_enc_algor;
|
||||
ASN1_OCTET_STRING *enc_key;
|
||||
X509 *cert; /* get the pub-key from this */
|
||||
} PKCS7_RECIP_INFO;
|
||||
|
||||
DEFINE_STACK_OF(PKCS7_RECIP_INFO)
|
||||
|
||||
typedef struct pkcs7_signed_st {
|
||||
ASN1_INTEGER *version; /* version 1 */
|
||||
STACK_OF(X509_ALGOR) *md_algs; /* md used */
|
||||
STACK_OF(X509) *cert; /* [ 0 ] */
|
||||
STACK_OF(X509_CRL) *crl; /* [ 1 ] */
|
||||
STACK_OF(PKCS7_SIGNER_INFO) *signer_info;
|
||||
struct pkcs7_st *contents;
|
||||
} PKCS7_SIGNED;
|
||||
/*
|
||||
* The above structure is very very similar to PKCS7_SIGN_ENVELOPE. How about
|
||||
* merging the two
|
||||
*/
|
||||
|
||||
typedef struct pkcs7_enc_content_st {
|
||||
ASN1_OBJECT *content_type;
|
||||
X509_ALGOR *algorithm;
|
||||
ASN1_OCTET_STRING *enc_data; /* [ 0 ] */
|
||||
const EVP_CIPHER *cipher;
|
||||
} PKCS7_ENC_CONTENT;
|
||||
|
||||
typedef struct pkcs7_enveloped_st {
|
||||
ASN1_INTEGER *version; /* version 0 */
|
||||
STACK_OF(PKCS7_RECIP_INFO) *recipientinfo;
|
||||
PKCS7_ENC_CONTENT *enc_data;
|
||||
} PKCS7_ENVELOPE;
|
||||
|
||||
typedef struct pkcs7_signedandenveloped_st {
|
||||
ASN1_INTEGER *version; /* version 1 */
|
||||
STACK_OF(X509_ALGOR) *md_algs; /* md used */
|
||||
STACK_OF(X509) *cert; /* [ 0 ] */
|
||||
STACK_OF(X509_CRL) *crl; /* [ 1 ] */
|
||||
STACK_OF(PKCS7_SIGNER_INFO) *signer_info;
|
||||
PKCS7_ENC_CONTENT *enc_data;
|
||||
STACK_OF(PKCS7_RECIP_INFO) *recipientinfo;
|
||||
} PKCS7_SIGN_ENVELOPE;
|
||||
|
||||
typedef struct pkcs7_digest_st {
|
||||
ASN1_INTEGER *version; /* version 0 */
|
||||
X509_ALGOR *md; /* md used */
|
||||
struct pkcs7_st *contents;
|
||||
ASN1_OCTET_STRING *digest;
|
||||
} PKCS7_DIGEST;
|
||||
|
||||
typedef struct pkcs7_encrypted_st {
|
||||
ASN1_INTEGER *version; /* version 0 */
|
||||
PKCS7_ENC_CONTENT *enc_data;
|
||||
} PKCS7_ENCRYPT;
|
||||
|
||||
typedef struct pkcs7_st {
|
||||
/*
|
||||
* The following is non NULL if it contains ASN1 encoding of this
|
||||
* structure
|
||||
*/
|
||||
unsigned char *asn1;
|
||||
long length;
|
||||
# define PKCS7_S_HEADER 0
|
||||
# define PKCS7_S_BODY 1
|
||||
# define PKCS7_S_TAIL 2
|
||||
int state; /* used during processing */
|
||||
int detached;
|
||||
ASN1_OBJECT *type;
|
||||
/* content as defined by the type */
|
||||
/*
|
||||
* all encryption/message digests are applied to the 'contents', leaving
|
||||
* out the 'type' field.
|
||||
*/
|
||||
union {
|
||||
char *ptr;
|
||||
/* NID_pkcs7_data */
|
||||
ASN1_OCTET_STRING *data;
|
||||
/* NID_pkcs7_signed */
|
||||
PKCS7_SIGNED *sign;
|
||||
/* NID_pkcs7_enveloped */
|
||||
PKCS7_ENVELOPE *enveloped;
|
||||
/* NID_pkcs7_signedAndEnveloped */
|
||||
PKCS7_SIGN_ENVELOPE *signed_and_enveloped;
|
||||
/* NID_pkcs7_digest */
|
||||
PKCS7_DIGEST *digest;
|
||||
/* NID_pkcs7_encrypted */
|
||||
PKCS7_ENCRYPT *encrypted;
|
||||
/* Anything else */
|
||||
ASN1_TYPE *other;
|
||||
} d;
|
||||
} PKCS7;
|
||||
|
||||
DEFINE_STACK_OF(PKCS7)
|
||||
|
||||
# define PKCS7_OP_SET_DETACHED_SIGNATURE 1
|
||||
# define PKCS7_OP_GET_DETACHED_SIGNATURE 2
|
||||
|
||||
# define PKCS7_get_signed_attributes(si) ((si)->auth_attr)
|
||||
# define PKCS7_get_attributes(si) ((si)->unauth_attr)
|
||||
|
||||
# define PKCS7_type_is_signed(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_signed)
|
||||
# define PKCS7_type_is_encrypted(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_encrypted)
|
||||
# define PKCS7_type_is_enveloped(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_enveloped)
|
||||
# define PKCS7_type_is_signedAndEnveloped(a) \
|
||||
(OBJ_obj2nid((a)->type) == NID_pkcs7_signedAndEnveloped)
|
||||
# define PKCS7_type_is_data(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_data)
|
||||
# define PKCS7_type_is_digest(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_digest)
|
||||
|
||||
# define PKCS7_set_detached(p,v) \
|
||||
PKCS7_ctrl(p,PKCS7_OP_SET_DETACHED_SIGNATURE,v,NULL)
|
||||
# define PKCS7_get_detached(p) \
|
||||
PKCS7_ctrl(p,PKCS7_OP_GET_DETACHED_SIGNATURE,0,NULL)
|
||||
|
||||
# define PKCS7_is_detached(p7) (PKCS7_type_is_signed(p7) && PKCS7_get_detached(p7))
|
||||
|
||||
/* S/MIME related flags */
|
||||
|
||||
# define PKCS7_TEXT 0x1
|
||||
# define PKCS7_NOCERTS 0x2
|
||||
# define PKCS7_NOSIGS 0x4
|
||||
# define PKCS7_NOCHAIN 0x8
|
||||
# define PKCS7_NOINTERN 0x10
|
||||
# define PKCS7_NOVERIFY 0x20
|
||||
# define PKCS7_DETACHED 0x40
|
||||
# define PKCS7_BINARY 0x80
|
||||
# define PKCS7_NOATTR 0x100
|
||||
# define PKCS7_NOSMIMECAP 0x200
|
||||
# define PKCS7_NOOLDMIMETYPE 0x400
|
||||
# define PKCS7_CRLFEOL 0x800
|
||||
# define PKCS7_STREAM 0x1000
|
||||
# define PKCS7_NOCRL 0x2000
|
||||
# define PKCS7_PARTIAL 0x4000
|
||||
# define PKCS7_REUSE_DIGEST 0x8000
|
||||
# define PKCS7_NO_DUAL_CONTENT 0x10000
|
||||
|
||||
/* Flags: for compatibility with older code */
|
||||
|
||||
# define SMIME_TEXT PKCS7_TEXT
|
||||
# define SMIME_NOCERTS PKCS7_NOCERTS
|
||||
# define SMIME_NOSIGS PKCS7_NOSIGS
|
||||
# define SMIME_NOCHAIN PKCS7_NOCHAIN
|
||||
# define SMIME_NOINTERN PKCS7_NOINTERN
|
||||
# define SMIME_NOVERIFY PKCS7_NOVERIFY
|
||||
# define SMIME_DETACHED PKCS7_DETACHED
|
||||
# define SMIME_BINARY PKCS7_BINARY
|
||||
# define SMIME_NOATTR PKCS7_NOATTR
|
||||
|
||||
/* CRLF ASCII canonicalisation */
|
||||
# define SMIME_ASCIICRLF 0x80000
|
||||
|
||||
DECLARE_ASN1_FUNCTIONS(PKCS7_ISSUER_AND_SERIAL)
|
||||
|
||||
int PKCS7_ISSUER_AND_SERIAL_digest(PKCS7_ISSUER_AND_SERIAL *data,
|
||||
const EVP_MD *type, unsigned char *md,
|
||||
unsigned int *len);
|
||||
# ifndef OPENSSL_NO_STDIO
|
||||
PKCS7 *d2i_PKCS7_fp(FILE *fp, PKCS7 **p7);
|
||||
int i2d_PKCS7_fp(FILE *fp, PKCS7 *p7);
|
||||
# endif
|
||||
PKCS7 *PKCS7_dup(PKCS7 *p7);
|
||||
PKCS7 *d2i_PKCS7_bio(BIO *bp, PKCS7 **p7);
|
||||
int i2d_PKCS7_bio(BIO *bp, PKCS7 *p7);
|
||||
int i2d_PKCS7_bio_stream(BIO *out, PKCS7 *p7, BIO *in, int flags);
|
||||
int PEM_write_bio_PKCS7_stream(BIO *out, PKCS7 *p7, BIO *in, int flags);
|
||||
|
||||
DECLARE_ASN1_FUNCTIONS(PKCS7_SIGNER_INFO)
|
||||
DECLARE_ASN1_FUNCTIONS(PKCS7_RECIP_INFO)
|
||||
DECLARE_ASN1_FUNCTIONS(PKCS7_SIGNED)
|
||||
DECLARE_ASN1_FUNCTIONS(PKCS7_ENC_CONTENT)
|
||||
DECLARE_ASN1_FUNCTIONS(PKCS7_ENVELOPE)
|
||||
DECLARE_ASN1_FUNCTIONS(PKCS7_SIGN_ENVELOPE)
|
||||
DECLARE_ASN1_FUNCTIONS(PKCS7_DIGEST)
|
||||
DECLARE_ASN1_FUNCTIONS(PKCS7_ENCRYPT)
|
||||
DECLARE_ASN1_FUNCTIONS(PKCS7)
|
||||
|
||||
DECLARE_ASN1_ITEM(PKCS7_ATTR_SIGN)
|
||||
DECLARE_ASN1_ITEM(PKCS7_ATTR_VERIFY)
|
||||
|
||||
DECLARE_ASN1_NDEF_FUNCTION(PKCS7)
|
||||
DECLARE_ASN1_PRINT_FUNCTION(PKCS7)
|
||||
|
||||
long PKCS7_ctrl(PKCS7 *p7, int cmd, long larg, char *parg);
|
||||
|
||||
int PKCS7_set_type(PKCS7 *p7, int type);
|
||||
int PKCS7_set0_type_other(PKCS7 *p7, int type, ASN1_TYPE *other);
|
||||
int PKCS7_set_content(PKCS7 *p7, PKCS7 *p7_data);
|
||||
int PKCS7_SIGNER_INFO_set(PKCS7_SIGNER_INFO *p7i, X509 *x509, EVP_PKEY *pkey,
|
||||
const EVP_MD *dgst);
|
||||
int PKCS7_SIGNER_INFO_sign(PKCS7_SIGNER_INFO *si);
|
||||
int PKCS7_add_signer(PKCS7 *p7, PKCS7_SIGNER_INFO *p7i);
|
||||
int PKCS7_add_certificate(PKCS7 *p7, X509 *x509);
|
||||
int PKCS7_add_crl(PKCS7 *p7, X509_CRL *x509);
|
||||
int PKCS7_content_new(PKCS7 *p7, int nid);
|
||||
int PKCS7_dataVerify(X509_STORE *cert_store, X509_STORE_CTX *ctx,
|
||||
BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si);
|
||||
int PKCS7_signatureVerify(BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si,
|
||||
X509 *x509);
|
||||
|
||||
BIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio);
|
||||
int PKCS7_dataFinal(PKCS7 *p7, BIO *bio);
|
||||
BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert);
|
||||
|
||||
PKCS7_SIGNER_INFO *PKCS7_add_signature(PKCS7 *p7, X509 *x509,
|
||||
EVP_PKEY *pkey, const EVP_MD *dgst);
|
||||
X509 *PKCS7_cert_from_signer_info(PKCS7 *p7, PKCS7_SIGNER_INFO *si);
|
||||
int PKCS7_set_digest(PKCS7 *p7, const EVP_MD *md);
|
||||
STACK_OF(PKCS7_SIGNER_INFO) *PKCS7_get_signer_info(PKCS7 *p7);
|
||||
|
||||
PKCS7_RECIP_INFO *PKCS7_add_recipient(PKCS7 *p7, X509 *x509);
|
||||
void PKCS7_SIGNER_INFO_get0_algs(PKCS7_SIGNER_INFO *si, EVP_PKEY **pk,
|
||||
X509_ALGOR **pdig, X509_ALGOR **psig);
|
||||
void PKCS7_RECIP_INFO_get0_alg(PKCS7_RECIP_INFO *ri, X509_ALGOR **penc);
|
||||
int PKCS7_add_recipient_info(PKCS7 *p7, PKCS7_RECIP_INFO *ri);
|
||||
int PKCS7_RECIP_INFO_set(PKCS7_RECIP_INFO *p7i, X509 *x509);
|
||||
int PKCS7_set_cipher(PKCS7 *p7, const EVP_CIPHER *cipher);
|
||||
int PKCS7_stream(unsigned char ***boundary, PKCS7 *p7);
|
||||
|
||||
PKCS7_ISSUER_AND_SERIAL *PKCS7_get_issuer_and_serial(PKCS7 *p7, int idx);
|
||||
ASN1_OCTET_STRING *PKCS7_digest_from_attributes(STACK_OF(X509_ATTRIBUTE) *sk);
|
||||
int PKCS7_add_signed_attribute(PKCS7_SIGNER_INFO *p7si, int nid, int type,
|
||||
void *data);
|
||||
int PKCS7_add_attribute(PKCS7_SIGNER_INFO *p7si, int nid, int atrtype,
|
||||
void *value);
|
||||
ASN1_TYPE *PKCS7_get_attribute(PKCS7_SIGNER_INFO *si, int nid);
|
||||
ASN1_TYPE *PKCS7_get_signed_attribute(PKCS7_SIGNER_INFO *si, int nid);
|
||||
int PKCS7_set_signed_attributes(PKCS7_SIGNER_INFO *p7si,
|
||||
STACK_OF(X509_ATTRIBUTE) *sk);
|
||||
int PKCS7_set_attributes(PKCS7_SIGNER_INFO *p7si,
|
||||
STACK_OF(X509_ATTRIBUTE) *sk);
|
||||
|
||||
PKCS7 *PKCS7_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs,
|
||||
BIO *data, int flags);
|
||||
|
||||
PKCS7_SIGNER_INFO *PKCS7_sign_add_signer(PKCS7 *p7,
|
||||
X509 *signcert, EVP_PKEY *pkey,
|
||||
const EVP_MD *md, int flags);
|
||||
|
||||
int PKCS7_final(PKCS7 *p7, BIO *data, int flags);
|
||||
int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store,
|
||||
BIO *indata, BIO *out, int flags);
|
||||
STACK_OF(X509) *PKCS7_get0_signers(PKCS7 *p7, STACK_OF(X509) *certs,
|
||||
int flags);
|
||||
PKCS7 *PKCS7_encrypt(STACK_OF(X509) *certs, BIO *in, const EVP_CIPHER *cipher,
|
||||
int flags);
|
||||
int PKCS7_decrypt(PKCS7 *p7, EVP_PKEY *pkey, X509 *cert, BIO *data,
|
||||
int flags);
|
||||
|
||||
int PKCS7_add_attrib_smimecap(PKCS7_SIGNER_INFO *si,
|
||||
STACK_OF(X509_ALGOR) *cap);
|
||||
STACK_OF(X509_ALGOR) *PKCS7_get_smimecap(PKCS7_SIGNER_INFO *si);
|
||||
int PKCS7_simple_smimecap(STACK_OF(X509_ALGOR) *sk, int nid, int arg);
|
||||
|
||||
int PKCS7_add_attrib_content_type(PKCS7_SIGNER_INFO *si, ASN1_OBJECT *coid);
|
||||
int PKCS7_add0_attrib_signing_time(PKCS7_SIGNER_INFO *si, ASN1_TIME *t);
|
||||
int PKCS7_add1_attrib_digest(PKCS7_SIGNER_INFO *si,
|
||||
const unsigned char *md, int mdlen);
|
||||
|
||||
int SMIME_write_PKCS7(BIO *bio, PKCS7 *p7, BIO *data, int flags);
|
||||
PKCS7 *SMIME_read_PKCS7(BIO *bio, BIO **bcont);
|
||||
|
||||
BIO *BIO_new_PKCS7(BIO *out, PKCS7 *p7);
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
/*
|
||||
* The following lines are auto generated by the script mkerr.pl. Any changes
|
||||
* made after this point may be overwritten when the script is next run.
|
||||
*/
|
||||
|
||||
int ERR_load_PKCS7_strings(void);
|
||||
|
||||
/* Error codes for the PKCS7 functions. */
|
||||
|
||||
/* Function codes. */
|
||||
# define PKCS7_F_DO_PKCS7_SIGNED_ATTRIB 136
|
||||
# define PKCS7_F_PKCS7_ADD0_ATTRIB_SIGNING_TIME 135
|
||||
# define PKCS7_F_PKCS7_ADD_ATTRIB_SMIMECAP 118
|
||||
# define PKCS7_F_PKCS7_ADD_CERTIFICATE 100
|
||||
# define PKCS7_F_PKCS7_ADD_CRL 101
|
||||
# define PKCS7_F_PKCS7_ADD_RECIPIENT_INFO 102
|
||||
# define PKCS7_F_PKCS7_ADD_SIGNATURE 131
|
||||
# define PKCS7_F_PKCS7_ADD_SIGNER 103
|
||||
# define PKCS7_F_PKCS7_BIO_ADD_DIGEST 125
|
||||
# define PKCS7_F_PKCS7_COPY_EXISTING_DIGEST 138
|
||||
# define PKCS7_F_PKCS7_CTRL 104
|
||||
# define PKCS7_F_PKCS7_DATADECODE 112
|
||||
# define PKCS7_F_PKCS7_DATAFINAL 128
|
||||
# define PKCS7_F_PKCS7_DATAINIT 105
|
||||
# define PKCS7_F_PKCS7_DATAVERIFY 107
|
||||
# define PKCS7_F_PKCS7_DECRYPT 114
|
||||
# define PKCS7_F_PKCS7_DECRYPT_RINFO 133
|
||||
# define PKCS7_F_PKCS7_ENCODE_RINFO 132
|
||||
# define PKCS7_F_PKCS7_ENCRYPT 115
|
||||
# define PKCS7_F_PKCS7_FINAL 134
|
||||
# define PKCS7_F_PKCS7_FIND_DIGEST 127
|
||||
# define PKCS7_F_PKCS7_GET0_SIGNERS 124
|
||||
# define PKCS7_F_PKCS7_RECIP_INFO_SET 130
|
||||
# define PKCS7_F_PKCS7_SET_CIPHER 108
|
||||
# define PKCS7_F_PKCS7_SET_CONTENT 109
|
||||
# define PKCS7_F_PKCS7_SET_DIGEST 126
|
||||
# define PKCS7_F_PKCS7_SET_TYPE 110
|
||||
# define PKCS7_F_PKCS7_SIGN 116
|
||||
# define PKCS7_F_PKCS7_SIGNATUREVERIFY 113
|
||||
# define PKCS7_F_PKCS7_SIGNER_INFO_SET 129
|
||||
# define PKCS7_F_PKCS7_SIGNER_INFO_SIGN 139
|
||||
# define PKCS7_F_PKCS7_SIGN_ADD_SIGNER 137
|
||||
# define PKCS7_F_PKCS7_SIMPLE_SMIMECAP 119
|
||||
# define PKCS7_F_PKCS7_VERIFY 117
|
||||
|
||||
/* Reason codes. */
|
||||
# define PKCS7_R_CERTIFICATE_VERIFY_ERROR 117
|
||||
# define PKCS7_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER 144
|
||||
# define PKCS7_R_CIPHER_NOT_INITIALIZED 116
|
||||
# define PKCS7_R_CONTENT_AND_DATA_PRESENT 118
|
||||
# define PKCS7_R_CTRL_ERROR 152
|
||||
# define PKCS7_R_DECRYPT_ERROR 119
|
||||
# define PKCS7_R_DIGEST_FAILURE 101
|
||||
# define PKCS7_R_ENCRYPTION_CTRL_FAILURE 149
|
||||
# define PKCS7_R_ENCRYPTION_NOT_SUPPORTED_FOR_THIS_KEY_TYPE 150
|
||||
# define PKCS7_R_ERROR_ADDING_RECIPIENT 120
|
||||
# define PKCS7_R_ERROR_SETTING_CIPHER 121
|
||||
# define PKCS7_R_INVALID_NULL_POINTER 143
|
||||
# define PKCS7_R_INVALID_SIGNED_DATA_TYPE 155
|
||||
# define PKCS7_R_NO_CONTENT 122
|
||||
# define PKCS7_R_NO_DEFAULT_DIGEST 151
|
||||
# define PKCS7_R_NO_MATCHING_DIGEST_TYPE_FOUND 154
|
||||
# define PKCS7_R_NO_RECIPIENT_MATCHES_CERTIFICATE 115
|
||||
# define PKCS7_R_NO_SIGNATURES_ON_DATA 123
|
||||
# define PKCS7_R_NO_SIGNERS 142
|
||||
# define PKCS7_R_OPERATION_NOT_SUPPORTED_ON_THIS_TYPE 104
|
||||
# define PKCS7_R_PKCS7_ADD_SIGNATURE_ERROR 124
|
||||
# define PKCS7_R_PKCS7_ADD_SIGNER_ERROR 153
|
||||
# define PKCS7_R_PKCS7_DATASIGN 145
|
||||
# define PKCS7_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE 127
|
||||
# define PKCS7_R_SIGNATURE_FAILURE 105
|
||||
# define PKCS7_R_SIGNER_CERTIFICATE_NOT_FOUND 128
|
||||
# define PKCS7_R_SIGNING_CTRL_FAILURE 147
|
||||
# define PKCS7_R_SIGNING_NOT_SUPPORTED_FOR_THIS_KEY_TYPE 148
|
||||
# define PKCS7_R_SMIME_TEXT_ERROR 129
|
||||
# define PKCS7_R_UNABLE_TO_FIND_CERTIFICATE 106
|
||||
# define PKCS7_R_UNABLE_TO_FIND_MEM_BIO 107
|
||||
# define PKCS7_R_UNABLE_TO_FIND_MESSAGE_DIGEST 108
|
||||
# define PKCS7_R_UNKNOWN_DIGEST_TYPE 109
|
||||
# define PKCS7_R_UNKNOWN_OPERATION 110
|
||||
# define PKCS7_R_UNSUPPORTED_CIPHER_TYPE 111
|
||||
# define PKCS7_R_UNSUPPORTED_CONTENT_TYPE 112
|
||||
# define PKCS7_R_WRONG_CONTENT_TYPE 113
|
||||
# define PKCS7_R_WRONG_PKCS7_TYPE 114
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
|
@ -0,0 +1,89 @@
|
|||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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_H
|
||||
# define HEADER_RAND_H
|
||||
|
||||
# include <stdlib.h>
|
||||
# include <openssl/ossl_typ.h>
|
||||
# include <openssl/e_os2.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Already defined in ossl_typ.h */
|
||||
/* typedef struct rand_meth_st RAND_METHOD; */
|
||||
|
||||
struct rand_meth_st {
|
||||
int (*seed) (const void *buf, int num);
|
||||
int (*bytes) (unsigned char *buf, int num);
|
||||
void (*cleanup) (void);
|
||||
int (*add) (const void *buf, int num, double entropy);
|
||||
int (*pseudorand) (unsigned char *buf, int num);
|
||||
int (*status) (void);
|
||||
};
|
||||
|
||||
# ifdef BN_DEBUG
|
||||
extern int rand_predictable;
|
||||
# endif
|
||||
|
||||
int RAND_set_rand_method(const RAND_METHOD *meth);
|
||||
const RAND_METHOD *RAND_get_rand_method(void);
|
||||
# ifndef OPENSSL_NO_ENGINE
|
||||
int RAND_set_rand_engine(ENGINE *engine);
|
||||
# endif
|
||||
RAND_METHOD *RAND_OpenSSL(void);
|
||||
#if OPENSSL_API_COMPAT < 0x10100000L
|
||||
# define RAND_cleanup() while(0) continue
|
||||
#endif
|
||||
int RAND_bytes(unsigned char *buf, int num);
|
||||
DEPRECATEDIN_1_1_0(int RAND_pseudo_bytes(unsigned char *buf, int num))
|
||||
void RAND_seed(const void *buf, int num);
|
||||
#if defined(__ANDROID__) && defined(__NDK_FPABI__)
|
||||
__NDK_FPABI__ /* __attribute__((pcs("aapcs"))) on ARM */
|
||||
#endif
|
||||
void RAND_add(const void *buf, int num, double entropy);
|
||||
int RAND_load_file(const char *file, long max_bytes);
|
||||
int RAND_write_file(const char *file);
|
||||
const char *RAND_file_name(char *file, size_t num);
|
||||
int RAND_status(void);
|
||||
# ifndef OPENSSL_NO_EGD
|
||||
int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes);
|
||||
int RAND_egd(const char *path);
|
||||
int RAND_egd_bytes(const char *path, int bytes);
|
||||
# endif
|
||||
int RAND_poll(void);
|
||||
|
||||
#if defined(_WIN32) && (defined(BASETYPES) || defined(_WINDEF_H))
|
||||
/* application has to include <windows.h> in order to use these */
|
||||
DEPRECATEDIN_1_1_0(void RAND_screen(void))
|
||||
DEPRECATEDIN_1_1_0(int RAND_event(UINT, WPARAM, LPARAM))
|
||||
#endif
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
/*
|
||||
* The following lines are auto generated by the script mkerr.pl. Any changes
|
||||
* made after this point may be overwritten when the script is next run.
|
||||
*/
|
||||
|
||||
int ERR_load_RAND_strings(void);
|
||||
|
||||
/* Error codes for the RAND functions. */
|
||||
|
||||
/* Function codes. */
|
||||
# define RAND_F_RAND_BYTES 100
|
||||
|
||||
/* Reason codes. */
|
||||
# define RAND_R_PRNG_NOT_SEEDED 100
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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_RC2_H
|
||||
# define HEADER_RC2_H
|
||||
|
||||
# include <openssl/opensslconf.h>
|
||||
|
||||
# ifndef OPENSSL_NO_RC2
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
# endif
|
||||
|
||||
typedef unsigned int RC2_INT;
|
||||
|
||||
# define RC2_ENCRYPT 1
|
||||
# define RC2_DECRYPT 0
|
||||
|
||||
# define RC2_BLOCK 8
|
||||
# define RC2_KEY_LENGTH 16
|
||||
|
||||
typedef struct rc2_key_st {
|
||||
RC2_INT data[64];
|
||||
} RC2_KEY;
|
||||
|
||||
void RC2_set_key(RC2_KEY *key, int len, const unsigned char *data, int bits);
|
||||
void RC2_ecb_encrypt(const unsigned char *in, unsigned char *out,
|
||||
RC2_KEY *key, int enc);
|
||||
void RC2_encrypt(unsigned long *data, RC2_KEY *key);
|
||||
void RC2_decrypt(unsigned long *data, RC2_KEY *key);
|
||||
void RC2_cbc_encrypt(const unsigned char *in, unsigned char *out, long length,
|
||||
RC2_KEY *ks, unsigned char *iv, int enc);
|
||||
void RC2_cfb64_encrypt(const unsigned char *in, unsigned char *out,
|
||||
long length, RC2_KEY *schedule, unsigned char *ivec,
|
||||
int *num, int enc);
|
||||
void RC2_ofb64_encrypt(const unsigned char *in, unsigned char *out,
|
||||
long length, RC2_KEY *schedule, unsigned char *ivec,
|
||||
int *num);
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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_H
|
||||
# define HEADER_RC4_H
|
||||
|
||||
# include <openssl/opensslconf.h>
|
||||
|
||||
# ifndef OPENSSL_NO_RC4
|
||||
# include <stddef.h>
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct rc4_key_st {
|
||||
RC4_INT x, y;
|
||||
RC4_INT data[256];
|
||||
} RC4_KEY;
|
||||
|
||||
const char *RC4_options(void);
|
||||
void RC4_set_key(RC4_KEY *key, int len, const unsigned char *data);
|
||||
void RC4(RC4_KEY *key, size_t len, const unsigned char *indata,
|
||||
unsigned char *outdata);
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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_RC5_H
|
||||
# define HEADER_RC5_H
|
||||
|
||||
# include <openssl/opensslconf.h>
|
||||
|
||||
# ifndef OPENSSL_NO_RC5
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
# endif
|
||||
|
||||
# define RC5_ENCRYPT 1
|
||||
# define RC5_DECRYPT 0
|
||||
|
||||
# define RC5_32_INT unsigned int
|
||||
|
||||
# define RC5_32_BLOCK 8
|
||||
# define RC5_32_KEY_LENGTH 16/* This is a default, max is 255 */
|
||||
|
||||
/*
|
||||
* This are the only values supported. Tweak the code if you want more The
|
||||
* most supported modes will be RC5-32/12/16 RC5-32/16/8
|
||||
*/
|
||||
# define RC5_8_ROUNDS 8
|
||||
# define RC5_12_ROUNDS 12
|
||||
# define RC5_16_ROUNDS 16
|
||||
|
||||
typedef struct rc5_key_st {
|
||||
/* Number of rounds */
|
||||
int rounds;
|
||||
RC5_32_INT data[2 * (RC5_16_ROUNDS + 1)];
|
||||
} RC5_32_KEY;
|
||||
|
||||
void RC5_32_set_key(RC5_32_KEY *key, int len, const unsigned char *data,
|
||||
int rounds);
|
||||
void RC5_32_ecb_encrypt(const unsigned char *in, unsigned char *out,
|
||||
RC5_32_KEY *key, int enc);
|
||||
void RC5_32_encrypt(unsigned long *data, RC5_32_KEY *key);
|
||||
void RC5_32_decrypt(unsigned long *data, RC5_32_KEY *key);
|
||||
void RC5_32_cbc_encrypt(const unsigned char *in, unsigned char *out,
|
||||
long length, RC5_32_KEY *ks, unsigned char *iv,
|
||||
int enc);
|
||||
void RC5_32_cfb64_encrypt(const unsigned char *in, unsigned char *out,
|
||||
long length, RC5_32_KEY *schedule,
|
||||
unsigned char *ivec, int *num, int enc);
|
||||
void RC5_32_ofb64_encrypt(const unsigned char *in, unsigned char *out,
|
||||
long length, RC5_32_KEY *schedule,
|
||||
unsigned char *ivec, int *num);
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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_RIPEMD_H
|
||||
# define HEADER_RIPEMD_H
|
||||
|
||||
# include <openssl/opensslconf.h>
|
||||
|
||||
#ifndef OPENSSL_NO_RMD160
|
||||
# include <openssl/e_os2.h>
|
||||
# include <stddef.h>
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
# endif
|
||||
|
||||
# define RIPEMD160_LONG unsigned int
|
||||
|
||||
# define RIPEMD160_CBLOCK 64
|
||||
# define RIPEMD160_LBLOCK (RIPEMD160_CBLOCK/4)
|
||||
# define RIPEMD160_DIGEST_LENGTH 20
|
||||
|
||||
typedef struct RIPEMD160state_st {
|
||||
RIPEMD160_LONG A, B, C, D, E;
|
||||
RIPEMD160_LONG Nl, Nh;
|
||||
RIPEMD160_LONG data[RIPEMD160_LBLOCK];
|
||||
unsigned int num;
|
||||
} RIPEMD160_CTX;
|
||||
|
||||
int RIPEMD160_Init(RIPEMD160_CTX *c);
|
||||
int RIPEMD160_Update(RIPEMD160_CTX *c, const void *data, size_t len);
|
||||
int RIPEMD160_Final(unsigned char *md, RIPEMD160_CTX *c);
|
||||
unsigned char *RIPEMD160(const unsigned char *d, size_t n, unsigned char *md);
|
||||
void RIPEMD160_Transform(RIPEMD160_CTX *c, const unsigned char *b);
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
# endif
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,589 @@
|
|||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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_RSA_H
|
||||
# define HEADER_RSA_H
|
||||
|
||||
# include <openssl/opensslconf.h>
|
||||
|
||||
# ifndef OPENSSL_NO_RSA
|
||||
# include <openssl/asn1.h>
|
||||
# include <openssl/bio.h>
|
||||
# include <openssl/crypto.h>
|
||||
# include <openssl/ossl_typ.h>
|
||||
# if OPENSSL_API_COMPAT < 0x10100000L
|
||||
# include <openssl/bn.h>
|
||||
# endif
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
# endif
|
||||
|
||||
/* The types RSA and RSA_METHOD are defined in ossl_typ.h */
|
||||
|
||||
# ifndef OPENSSL_RSA_MAX_MODULUS_BITS
|
||||
# define OPENSSL_RSA_MAX_MODULUS_BITS 16384
|
||||
# endif
|
||||
|
||||
# define OPENSSL_RSA_FIPS_MIN_MODULUS_BITS 1024
|
||||
|
||||
# ifndef OPENSSL_RSA_SMALL_MODULUS_BITS
|
||||
# define OPENSSL_RSA_SMALL_MODULUS_BITS 3072
|
||||
# endif
|
||||
# ifndef OPENSSL_RSA_MAX_PUBEXP_BITS
|
||||
|
||||
/* exponent limit enforced for "large" modulus only */
|
||||
# define OPENSSL_RSA_MAX_PUBEXP_BITS 64
|
||||
# endif
|
||||
|
||||
# define RSA_3 0x3L
|
||||
# define RSA_F4 0x10001L
|
||||
|
||||
# define RSA_METHOD_FLAG_NO_CHECK 0x0001/* don't check pub/private
|
||||
* match */
|
||||
|
||||
# define RSA_FLAG_CACHE_PUBLIC 0x0002
|
||||
# define RSA_FLAG_CACHE_PRIVATE 0x0004
|
||||
# define RSA_FLAG_BLINDING 0x0008
|
||||
# define RSA_FLAG_THREAD_SAFE 0x0010
|
||||
/*
|
||||
* This flag means the private key operations will be handled by rsa_mod_exp
|
||||
* and that they do not depend on the private key components being present:
|
||||
* for example a key stored in external hardware. Without this flag
|
||||
* bn_mod_exp gets called when private key components are absent.
|
||||
*/
|
||||
# define RSA_FLAG_EXT_PKEY 0x0020
|
||||
|
||||
/*
|
||||
* new with 0.9.6j and 0.9.7b; the built-in
|
||||
* RSA implementation now uses blinding by
|
||||
* default (ignoring RSA_FLAG_BLINDING),
|
||||
* but other engines might not need it
|
||||
*/
|
||||
# define RSA_FLAG_NO_BLINDING 0x0080
|
||||
# if OPENSSL_API_COMPAT < 0x10100000L
|
||||
/*
|
||||
* Does nothing. Previously this switched off constant time behaviour.
|
||||
*/
|
||||
# define RSA_FLAG_NO_CONSTTIME 0x0000
|
||||
# endif
|
||||
# if OPENSSL_API_COMPAT < 0x00908000L
|
||||
/* deprecated name for the flag*/
|
||||
/*
|
||||
* new with 0.9.7h; the built-in RSA
|
||||
* implementation now uses constant time
|
||||
* modular exponentiation for secret exponents
|
||||
* by default. This flag causes the
|
||||
* faster variable sliding window method to
|
||||
* be used for all exponents.
|
||||
*/
|
||||
# define RSA_FLAG_NO_EXP_CONSTTIME RSA_FLAG_NO_CONSTTIME
|
||||
# endif
|
||||
|
||||
# define EVP_PKEY_CTX_set_rsa_padding(ctx, pad) \
|
||||
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, -1, EVP_PKEY_CTRL_RSA_PADDING, \
|
||||
pad, NULL)
|
||||
|
||||
# define EVP_PKEY_CTX_get_rsa_padding(ctx, ppad) \
|
||||
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, -1, \
|
||||
EVP_PKEY_CTRL_GET_RSA_PADDING, 0, ppad)
|
||||
|
||||
# define EVP_PKEY_CTX_set_rsa_pss_saltlen(ctx, len) \
|
||||
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, \
|
||||
(EVP_PKEY_OP_SIGN|EVP_PKEY_OP_VERIFY), \
|
||||
EVP_PKEY_CTRL_RSA_PSS_SALTLEN, \
|
||||
len, NULL)
|
||||
|
||||
# define EVP_PKEY_CTX_get_rsa_pss_saltlen(ctx, plen) \
|
||||
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, \
|
||||
(EVP_PKEY_OP_SIGN|EVP_PKEY_OP_VERIFY), \
|
||||
EVP_PKEY_CTRL_GET_RSA_PSS_SALTLEN, \
|
||||
0, plen)
|
||||
|
||||
# define EVP_PKEY_CTX_set_rsa_keygen_bits(ctx, bits) \
|
||||
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_KEYGEN, \
|
||||
EVP_PKEY_CTRL_RSA_KEYGEN_BITS, bits, NULL)
|
||||
|
||||
# define EVP_PKEY_CTX_set_rsa_keygen_pubexp(ctx, pubexp) \
|
||||
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_KEYGEN, \
|
||||
EVP_PKEY_CTRL_RSA_KEYGEN_PUBEXP, 0, pubexp)
|
||||
|
||||
# define EVP_PKEY_CTX_set_rsa_mgf1_md(ctx, md) \
|
||||
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, \
|
||||
EVP_PKEY_OP_TYPE_SIG | EVP_PKEY_OP_TYPE_CRYPT, \
|
||||
EVP_PKEY_CTRL_RSA_MGF1_MD, 0, (void *)md)
|
||||
|
||||
# define EVP_PKEY_CTX_set_rsa_oaep_md(ctx, md) \
|
||||
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_TYPE_CRYPT, \
|
||||
EVP_PKEY_CTRL_RSA_OAEP_MD, 0, (void *)md)
|
||||
|
||||
# define EVP_PKEY_CTX_get_rsa_mgf1_md(ctx, pmd) \
|
||||
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, \
|
||||
EVP_PKEY_OP_TYPE_SIG | EVP_PKEY_OP_TYPE_CRYPT, \
|
||||
EVP_PKEY_CTRL_GET_RSA_MGF1_MD, 0, (void *)pmd)
|
||||
|
||||
# define EVP_PKEY_CTX_get_rsa_oaep_md(ctx, pmd) \
|
||||
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_TYPE_CRYPT, \
|
||||
EVP_PKEY_CTRL_GET_RSA_OAEP_MD, 0, (void *)pmd)
|
||||
|
||||
# define EVP_PKEY_CTX_set0_rsa_oaep_label(ctx, l, llen) \
|
||||
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_TYPE_CRYPT, \
|
||||
EVP_PKEY_CTRL_RSA_OAEP_LABEL, llen, (void *)l)
|
||||
|
||||
# define EVP_PKEY_CTX_get0_rsa_oaep_label(ctx, l) \
|
||||
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_TYPE_CRYPT, \
|
||||
EVP_PKEY_CTRL_GET_RSA_OAEP_LABEL, 0, (void *)l)
|
||||
|
||||
# define EVP_PKEY_CTRL_RSA_PADDING (EVP_PKEY_ALG_CTRL + 1)
|
||||
# define EVP_PKEY_CTRL_RSA_PSS_SALTLEN (EVP_PKEY_ALG_CTRL + 2)
|
||||
|
||||
# define EVP_PKEY_CTRL_RSA_KEYGEN_BITS (EVP_PKEY_ALG_CTRL + 3)
|
||||
# define EVP_PKEY_CTRL_RSA_KEYGEN_PUBEXP (EVP_PKEY_ALG_CTRL + 4)
|
||||
# define EVP_PKEY_CTRL_RSA_MGF1_MD (EVP_PKEY_ALG_CTRL + 5)
|
||||
|
||||
# define EVP_PKEY_CTRL_GET_RSA_PADDING (EVP_PKEY_ALG_CTRL + 6)
|
||||
# define EVP_PKEY_CTRL_GET_RSA_PSS_SALTLEN (EVP_PKEY_ALG_CTRL + 7)
|
||||
# define EVP_PKEY_CTRL_GET_RSA_MGF1_MD (EVP_PKEY_ALG_CTRL + 8)
|
||||
|
||||
# define EVP_PKEY_CTRL_RSA_OAEP_MD (EVP_PKEY_ALG_CTRL + 9)
|
||||
# define EVP_PKEY_CTRL_RSA_OAEP_LABEL (EVP_PKEY_ALG_CTRL + 10)
|
||||
|
||||
# define EVP_PKEY_CTRL_GET_RSA_OAEP_MD (EVP_PKEY_ALG_CTRL + 11)
|
||||
# define EVP_PKEY_CTRL_GET_RSA_OAEP_LABEL (EVP_PKEY_ALG_CTRL + 12)
|
||||
|
||||
# define RSA_PKCS1_PADDING 1
|
||||
# define RSA_SSLV23_PADDING 2
|
||||
# define RSA_NO_PADDING 3
|
||||
# define RSA_PKCS1_OAEP_PADDING 4
|
||||
# define RSA_X931_PADDING 5
|
||||
/* EVP_PKEY_ only */
|
||||
# define RSA_PKCS1_PSS_PADDING 6
|
||||
|
||||
# define RSA_PKCS1_PADDING_SIZE 11
|
||||
|
||||
# define RSA_set_app_data(s,arg) RSA_set_ex_data(s,0,arg)
|
||||
# define RSA_get_app_data(s) RSA_get_ex_data(s,0)
|
||||
|
||||
RSA *RSA_new(void);
|
||||
RSA *RSA_new_method(ENGINE *engine);
|
||||
int RSA_bits(const RSA *rsa);
|
||||
int RSA_size(const RSA *rsa);
|
||||
int RSA_security_bits(const RSA *rsa);
|
||||
|
||||
int RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d);
|
||||
int RSA_set0_factors(RSA *r, BIGNUM *p, BIGNUM *q);
|
||||
int RSA_set0_crt_params(RSA *r,BIGNUM *dmp1, BIGNUM *dmq1, BIGNUM *iqmp);
|
||||
void RSA_get0_key(const RSA *r,
|
||||
const BIGNUM **n, const BIGNUM **e, const BIGNUM **d);
|
||||
void RSA_get0_factors(const RSA *r, const BIGNUM **p, const BIGNUM **q);
|
||||
void RSA_get0_crt_params(const RSA *r,
|
||||
const BIGNUM **dmp1, const BIGNUM **dmq1,
|
||||
const BIGNUM **iqmp);
|
||||
void RSA_clear_flags(RSA *r, int flags);
|
||||
int RSA_test_flags(const RSA *r, int flags);
|
||||
void RSA_set_flags(RSA *r, int flags);
|
||||
ENGINE *RSA_get0_engine(const RSA *r);
|
||||
|
||||
/* Deprecated version */
|
||||
DEPRECATEDIN_0_9_8(RSA *RSA_generate_key(int bits, unsigned long e, void
|
||||
(*callback) (int, int, void *),
|
||||
void *cb_arg))
|
||||
|
||||
/* New version */
|
||||
int RSA_generate_key_ex(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb);
|
||||
|
||||
int RSA_X931_derive_ex(RSA *rsa, BIGNUM *p1, BIGNUM *p2, BIGNUM *q1,
|
||||
BIGNUM *q2, const BIGNUM *Xp1, const BIGNUM *Xp2,
|
||||
const BIGNUM *Xp, const BIGNUM *Xq1, const BIGNUM *Xq2,
|
||||
const BIGNUM *Xq, const BIGNUM *e, BN_GENCB *cb);
|
||||
int RSA_X931_generate_key_ex(RSA *rsa, int bits, const BIGNUM *e,
|
||||
BN_GENCB *cb);
|
||||
|
||||
int RSA_check_key(const RSA *);
|
||||
int RSA_check_key_ex(const RSA *, BN_GENCB *cb);
|
||||
/* next 4 return -1 on error */
|
||||
int RSA_public_encrypt(int flen, const unsigned char *from,
|
||||
unsigned char *to, RSA *rsa, int padding);
|
||||
int RSA_private_encrypt(int flen, const unsigned char *from,
|
||||
unsigned char *to, RSA *rsa, int padding);
|
||||
int RSA_public_decrypt(int flen, const unsigned char *from,
|
||||
unsigned char *to, RSA *rsa, int padding);
|
||||
int RSA_private_decrypt(int flen, const unsigned char *from,
|
||||
unsigned char *to, RSA *rsa, int padding);
|
||||
void RSA_free(RSA *r);
|
||||
/* "up" the RSA object's reference count */
|
||||
int RSA_up_ref(RSA *r);
|
||||
|
||||
int RSA_flags(const RSA *r);
|
||||
|
||||
void RSA_set_default_method(const RSA_METHOD *meth);
|
||||
const RSA_METHOD *RSA_get_default_method(void);
|
||||
const RSA_METHOD *RSA_get_method(const RSA *rsa);
|
||||
int RSA_set_method(RSA *rsa, const RSA_METHOD *meth);
|
||||
|
||||
/* these are the actual RSA functions */
|
||||
const RSA_METHOD *RSA_PKCS1_OpenSSL(void);
|
||||
|
||||
const RSA_METHOD *RSA_null_method(void);
|
||||
|
||||
DECLARE_ASN1_ENCODE_FUNCTIONS_const(RSA, RSAPublicKey)
|
||||
DECLARE_ASN1_ENCODE_FUNCTIONS_const(RSA, RSAPrivateKey)
|
||||
|
||||
typedef struct rsa_pss_params_st {
|
||||
X509_ALGOR *hashAlgorithm;
|
||||
X509_ALGOR *maskGenAlgorithm;
|
||||
ASN1_INTEGER *saltLength;
|
||||
ASN1_INTEGER *trailerField;
|
||||
} RSA_PSS_PARAMS;
|
||||
|
||||
DECLARE_ASN1_FUNCTIONS(RSA_PSS_PARAMS)
|
||||
|
||||
typedef struct rsa_oaep_params_st {
|
||||
X509_ALGOR *hashFunc;
|
||||
X509_ALGOR *maskGenFunc;
|
||||
X509_ALGOR *pSourceFunc;
|
||||
} RSA_OAEP_PARAMS;
|
||||
|
||||
DECLARE_ASN1_FUNCTIONS(RSA_OAEP_PARAMS)
|
||||
|
||||
# ifndef OPENSSL_NO_STDIO
|
||||
int RSA_print_fp(FILE *fp, const RSA *r, int offset);
|
||||
# endif
|
||||
|
||||
int RSA_print(BIO *bp, const RSA *r, int offset);
|
||||
|
||||
/*
|
||||
* The following 2 functions sign and verify a X509_SIG ASN1 object inside
|
||||
* PKCS#1 padded RSA encryption
|
||||
*/
|
||||
int RSA_sign(int type, const unsigned char *m, unsigned int m_length,
|
||||
unsigned char *sigret, unsigned int *siglen, RSA *rsa);
|
||||
int RSA_verify(int type, const unsigned char *m, unsigned int m_length,
|
||||
const unsigned char *sigbuf, unsigned int siglen, RSA *rsa);
|
||||
|
||||
/*
|
||||
* The following 2 function sign and verify a ASN1_OCTET_STRING object inside
|
||||
* PKCS#1 padded RSA encryption
|
||||
*/
|
||||
int RSA_sign_ASN1_OCTET_STRING(int type,
|
||||
const unsigned char *m, unsigned int m_length,
|
||||
unsigned char *sigret, unsigned int *siglen,
|
||||
RSA *rsa);
|
||||
int RSA_verify_ASN1_OCTET_STRING(int type, const unsigned char *m,
|
||||
unsigned int m_length, unsigned char *sigbuf,
|
||||
unsigned int siglen, RSA *rsa);
|
||||
|
||||
int RSA_blinding_on(RSA *rsa, BN_CTX *ctx);
|
||||
void RSA_blinding_off(RSA *rsa);
|
||||
BN_BLINDING *RSA_setup_blinding(RSA *rsa, BN_CTX *ctx);
|
||||
|
||||
int RSA_padding_add_PKCS1_type_1(unsigned char *to, int tlen,
|
||||
const unsigned char *f, int fl);
|
||||
int RSA_padding_check_PKCS1_type_1(unsigned char *to, int tlen,
|
||||
const unsigned char *f, int fl,
|
||||
int rsa_len);
|
||||
int RSA_padding_add_PKCS1_type_2(unsigned char *to, int tlen,
|
||||
const unsigned char *f, int fl);
|
||||
int RSA_padding_check_PKCS1_type_2(unsigned char *to, int tlen,
|
||||
const unsigned char *f, int fl,
|
||||
int rsa_len);
|
||||
int PKCS1_MGF1(unsigned char *mask, long len, const unsigned char *seed,
|
||||
long seedlen, const EVP_MD *dgst);
|
||||
int RSA_padding_add_PKCS1_OAEP(unsigned char *to, int tlen,
|
||||
const unsigned char *f, int fl,
|
||||
const unsigned char *p, int pl);
|
||||
int RSA_padding_check_PKCS1_OAEP(unsigned char *to, int tlen,
|
||||
const unsigned char *f, int fl, int rsa_len,
|
||||
const unsigned char *p, int pl);
|
||||
int RSA_padding_add_PKCS1_OAEP_mgf1(unsigned char *to, int tlen,
|
||||
const unsigned char *from, int flen,
|
||||
const unsigned char *param, int plen,
|
||||
const EVP_MD *md, const EVP_MD *mgf1md);
|
||||
int RSA_padding_check_PKCS1_OAEP_mgf1(unsigned char *to, int tlen,
|
||||
const unsigned char *from, int flen,
|
||||
int num, const unsigned char *param,
|
||||
int plen, const EVP_MD *md,
|
||||
const EVP_MD *mgf1md);
|
||||
int RSA_padding_add_SSLv23(unsigned char *to, int tlen,
|
||||
const unsigned char *f, int fl);
|
||||
int RSA_padding_check_SSLv23(unsigned char *to, int tlen,
|
||||
const unsigned char *f, int fl, int rsa_len);
|
||||
int RSA_padding_add_none(unsigned char *to, int tlen, const unsigned char *f,
|
||||
int fl);
|
||||
int RSA_padding_check_none(unsigned char *to, int tlen,
|
||||
const unsigned char *f, int fl, int rsa_len);
|
||||
int RSA_padding_add_X931(unsigned char *to, int tlen, const unsigned char *f,
|
||||
int fl);
|
||||
int RSA_padding_check_X931(unsigned char *to, int tlen,
|
||||
const unsigned char *f, int fl, int rsa_len);
|
||||
int RSA_X931_hash_id(int nid);
|
||||
|
||||
int RSA_verify_PKCS1_PSS(RSA *rsa, const unsigned char *mHash,
|
||||
const EVP_MD *Hash, const unsigned char *EM,
|
||||
int sLen);
|
||||
int RSA_padding_add_PKCS1_PSS(RSA *rsa, unsigned char *EM,
|
||||
const unsigned char *mHash, const EVP_MD *Hash,
|
||||
int sLen);
|
||||
|
||||
int RSA_verify_PKCS1_PSS_mgf1(RSA *rsa, const unsigned char *mHash,
|
||||
const EVP_MD *Hash, const EVP_MD *mgf1Hash,
|
||||
const unsigned char *EM, int sLen);
|
||||
|
||||
int RSA_padding_add_PKCS1_PSS_mgf1(RSA *rsa, unsigned char *EM,
|
||||
const unsigned char *mHash,
|
||||
const EVP_MD *Hash, const EVP_MD *mgf1Hash,
|
||||
int sLen);
|
||||
|
||||
#define RSA_get_ex_new_index(l, p, newf, dupf, freef) \
|
||||
CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_RSA, l, p, newf, dupf, freef)
|
||||
int RSA_set_ex_data(RSA *r, int idx, void *arg);
|
||||
void *RSA_get_ex_data(const RSA *r, int idx);
|
||||
|
||||
RSA *RSAPublicKey_dup(RSA *rsa);
|
||||
RSA *RSAPrivateKey_dup(RSA *rsa);
|
||||
|
||||
/*
|
||||
* If this flag is set the RSA method is FIPS compliant and can be used in
|
||||
* FIPS mode. This is set in the validated module method. If an application
|
||||
* sets this flag in its own methods it is its responsibility to ensure the
|
||||
* result is compliant.
|
||||
*/
|
||||
|
||||
# define RSA_FLAG_FIPS_METHOD 0x0400
|
||||
|
||||
/*
|
||||
* If this flag is set the operations normally disabled in FIPS mode are
|
||||
* permitted it is then the applications responsibility to ensure that the
|
||||
* usage is compliant.
|
||||
*/
|
||||
|
||||
# define RSA_FLAG_NON_FIPS_ALLOW 0x0400
|
||||
/*
|
||||
* Application has decided PRNG is good enough to generate a key: don't
|
||||
* check.
|
||||
*/
|
||||
# define RSA_FLAG_CHECKED 0x0800
|
||||
|
||||
RSA_METHOD *RSA_meth_new(const char *name, int flags);
|
||||
void RSA_meth_free(RSA_METHOD *meth);
|
||||
RSA_METHOD *RSA_meth_dup(const RSA_METHOD *meth);
|
||||
const char *RSA_meth_get0_name(const RSA_METHOD *meth);
|
||||
int RSA_meth_set1_name(RSA_METHOD *meth, const char *name);
|
||||
int RSA_meth_get_flags(RSA_METHOD *meth);
|
||||
int RSA_meth_set_flags(RSA_METHOD *meth, int flags);
|
||||
void *RSA_meth_get0_app_data(const RSA_METHOD *meth);
|
||||
int RSA_meth_set0_app_data(RSA_METHOD *meth, void *app_data);
|
||||
int (*RSA_meth_get_pub_enc(const RSA_METHOD *meth))
|
||||
(int flen, const unsigned char *from,
|
||||
unsigned char *to, RSA *rsa, int padding);
|
||||
int RSA_meth_set_pub_enc(RSA_METHOD *rsa,
|
||||
int (*pub_enc) (int flen, const unsigned char *from,
|
||||
unsigned char *to, RSA *rsa,
|
||||
int padding));
|
||||
int (*RSA_meth_get_pub_dec(const RSA_METHOD *meth))
|
||||
(int flen, const unsigned char *from,
|
||||
unsigned char *to, RSA *rsa, int padding);
|
||||
int RSA_meth_set_pub_dec(RSA_METHOD *rsa,
|
||||
int (*pub_dec) (int flen, const unsigned char *from,
|
||||
unsigned char *to, RSA *rsa,
|
||||
int padding));
|
||||
int (*RSA_meth_get_priv_enc(const RSA_METHOD *meth))
|
||||
(int flen, const unsigned char *from,
|
||||
unsigned char *to, RSA *rsa, int padding);
|
||||
int RSA_meth_set_priv_enc(RSA_METHOD *rsa,
|
||||
int (*priv_enc) (int flen, const unsigned char *from,
|
||||
unsigned char *to, RSA *rsa,
|
||||
int padding));
|
||||
int (*RSA_meth_get_priv_dec(const RSA_METHOD *meth))
|
||||
(int flen, const unsigned char *from,
|
||||
unsigned char *to, RSA *rsa, int padding);
|
||||
int RSA_meth_set_priv_dec(RSA_METHOD *rsa,
|
||||
int (*priv_dec) (int flen, const unsigned char *from,
|
||||
unsigned char *to, RSA *rsa,
|
||||
int padding));
|
||||
int (*RSA_meth_get_mod_exp(const RSA_METHOD *meth))
|
||||
(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx);
|
||||
int RSA_meth_set_mod_exp(RSA_METHOD *rsa,
|
||||
int (*mod_exp) (BIGNUM *r0, const BIGNUM *I, RSA *rsa,
|
||||
BN_CTX *ctx));
|
||||
int (*RSA_meth_get_bn_mod_exp(const RSA_METHOD *meth))
|
||||
(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
|
||||
const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
|
||||
int RSA_meth_set_bn_mod_exp(RSA_METHOD *rsa,
|
||||
int (*bn_mod_exp) (BIGNUM *r,
|
||||
const BIGNUM *a,
|
||||
const BIGNUM *p,
|
||||
const BIGNUM *m,
|
||||
BN_CTX *ctx,
|
||||
BN_MONT_CTX *m_ctx));
|
||||
int (*RSA_meth_get_init(const RSA_METHOD *meth)) (RSA *rsa);
|
||||
int RSA_meth_set_init(RSA_METHOD *rsa, int (*init) (RSA *rsa));
|
||||
int (*RSA_meth_get_finish(const RSA_METHOD *meth)) (RSA *rsa);
|
||||
int RSA_meth_set_finish(RSA_METHOD *rsa, int (*finish) (RSA *rsa));
|
||||
int (*RSA_meth_get_sign(const RSA_METHOD *meth))
|
||||
(int type,
|
||||
const unsigned char *m, unsigned int m_length,
|
||||
unsigned char *sigret, unsigned int *siglen,
|
||||
const RSA *rsa);
|
||||
int RSA_meth_set_sign(RSA_METHOD *rsa,
|
||||
int (*sign) (int type, const unsigned char *m,
|
||||
unsigned int m_length,
|
||||
unsigned char *sigret, unsigned int *siglen,
|
||||
const RSA *rsa));
|
||||
int (*RSA_meth_get_verify(const RSA_METHOD *meth))
|
||||
(int dtype, const unsigned char *m,
|
||||
unsigned int m_length, const unsigned char *sigbuf,
|
||||
unsigned int siglen, const RSA *rsa);
|
||||
int RSA_meth_set_verify(RSA_METHOD *rsa,
|
||||
int (*verify) (int dtype, const unsigned char *m,
|
||||
unsigned int m_length,
|
||||
const unsigned char *sigbuf,
|
||||
unsigned int siglen, const RSA *rsa));
|
||||
int (*RSA_meth_get_keygen(const RSA_METHOD *meth))
|
||||
(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb);
|
||||
int RSA_meth_set_keygen(RSA_METHOD *rsa,
|
||||
int (*keygen) (RSA *rsa, int bits, BIGNUM *e,
|
||||
BN_GENCB *cb));
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
/*
|
||||
* The following lines are auto generated by the script mkerr.pl. Any changes
|
||||
* made after this point may be overwritten when the script is next run.
|
||||
*/
|
||||
|
||||
int ERR_load_RSA_strings(void);
|
||||
|
||||
/* Error codes for the RSA functions. */
|
||||
|
||||
/* Function codes. */
|
||||
# define RSA_F_CHECK_PADDING_MD 140
|
||||
# define RSA_F_ENCODE_PKCS1 146
|
||||
# define RSA_F_INT_RSA_VERIFY 145
|
||||
# define RSA_F_OLD_RSA_PRIV_DECODE 147
|
||||
# define RSA_F_PKEY_RSA_CTRL 143
|
||||
# define RSA_F_PKEY_RSA_CTRL_STR 144
|
||||
# define RSA_F_PKEY_RSA_SIGN 142
|
||||
# define RSA_F_PKEY_RSA_VERIFYRECOVER 141
|
||||
# define RSA_F_RSA_ALGOR_TO_MD 156
|
||||
# define RSA_F_RSA_BUILTIN_KEYGEN 129
|
||||
# define RSA_F_RSA_CHECK_KEY 123
|
||||
# define RSA_F_RSA_CHECK_KEY_EX 160
|
||||
# define RSA_F_RSA_CMS_DECRYPT 159
|
||||
# define RSA_F_RSA_ITEM_VERIFY 148
|
||||
# define RSA_F_RSA_METH_DUP 161
|
||||
# define RSA_F_RSA_METH_NEW 162
|
||||
# define RSA_F_RSA_METH_SET1_NAME 163
|
||||
# define RSA_F_RSA_MGF1_TO_MD 157
|
||||
# define RSA_F_RSA_NEW_METHOD 106
|
||||
# define RSA_F_RSA_NULL 124
|
||||
# define RSA_F_RSA_NULL_PRIVATE_DECRYPT 132
|
||||
# define RSA_F_RSA_NULL_PRIVATE_ENCRYPT 133
|
||||
# define RSA_F_RSA_NULL_PUBLIC_DECRYPT 134
|
||||
# define RSA_F_RSA_NULL_PUBLIC_ENCRYPT 135
|
||||
# define RSA_F_RSA_OSSL_PRIVATE_DECRYPT 101
|
||||
# define RSA_F_RSA_OSSL_PRIVATE_ENCRYPT 102
|
||||
# define RSA_F_RSA_OSSL_PUBLIC_DECRYPT 103
|
||||
# define RSA_F_RSA_OSSL_PUBLIC_ENCRYPT 104
|
||||
# define RSA_F_RSA_PADDING_ADD_NONE 107
|
||||
# define RSA_F_RSA_PADDING_ADD_PKCS1_OAEP 121
|
||||
# define RSA_F_RSA_PADDING_ADD_PKCS1_OAEP_MGF1 154
|
||||
# define RSA_F_RSA_PADDING_ADD_PKCS1_PSS 125
|
||||
# define RSA_F_RSA_PADDING_ADD_PKCS1_PSS_MGF1 152
|
||||
# define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_1 108
|
||||
# define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_2 109
|
||||
# define RSA_F_RSA_PADDING_ADD_SSLV23 110
|
||||
# define RSA_F_RSA_PADDING_ADD_X931 127
|
||||
# define RSA_F_RSA_PADDING_CHECK_NONE 111
|
||||
# define RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP 122
|
||||
# define RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP_MGF1 153
|
||||
# define RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_1 112
|
||||
# define RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2 113
|
||||
# define RSA_F_RSA_PADDING_CHECK_SSLV23 114
|
||||
# define RSA_F_RSA_PADDING_CHECK_X931 128
|
||||
# define RSA_F_RSA_PRINT 115
|
||||
# define RSA_F_RSA_PRINT_FP 116
|
||||
# define RSA_F_RSA_PRIV_ENCODE 138
|
||||
# define RSA_F_RSA_PSS_TO_CTX 155
|
||||
# define RSA_F_RSA_PUB_DECODE 139
|
||||
# define RSA_F_RSA_SETUP_BLINDING 136
|
||||
# define RSA_F_RSA_SIGN 117
|
||||
# define RSA_F_RSA_SIGN_ASN1_OCTET_STRING 118
|
||||
# define RSA_F_RSA_VERIFY 119
|
||||
# define RSA_F_RSA_VERIFY_ASN1_OCTET_STRING 120
|
||||
# define RSA_F_RSA_VERIFY_PKCS1_PSS_MGF1 126
|
||||
|
||||
/* Reason codes. */
|
||||
# define RSA_R_ALGORITHM_MISMATCH 100
|
||||
# define RSA_R_BAD_E_VALUE 101
|
||||
# define RSA_R_BAD_FIXED_HEADER_DECRYPT 102
|
||||
# define RSA_R_BAD_PAD_BYTE_COUNT 103
|
||||
# define RSA_R_BAD_SIGNATURE 104
|
||||
# define RSA_R_BLOCK_TYPE_IS_NOT_01 106
|
||||
# define RSA_R_BLOCK_TYPE_IS_NOT_02 107
|
||||
# define RSA_R_DATA_GREATER_THAN_MOD_LEN 108
|
||||
# define RSA_R_DATA_TOO_LARGE 109
|
||||
# define RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 110
|
||||
# define RSA_R_DATA_TOO_LARGE_FOR_MODULUS 132
|
||||
# define RSA_R_DATA_TOO_SMALL 111
|
||||
# define RSA_R_DATA_TOO_SMALL_FOR_KEY_SIZE 122
|
||||
# define RSA_R_DIGEST_DOES_NOT_MATCH 158
|
||||
# define RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY 112
|
||||
# define RSA_R_DMP1_NOT_CONGRUENT_TO_D 124
|
||||
# define RSA_R_DMQ1_NOT_CONGRUENT_TO_D 125
|
||||
# define RSA_R_D_E_NOT_CONGRUENT_TO_1 123
|
||||
# define RSA_R_FIRST_OCTET_INVALID 133
|
||||
# define RSA_R_ILLEGAL_OR_UNSUPPORTED_PADDING_MODE 144
|
||||
# define RSA_R_INVALID_DIGEST 157
|
||||
# define RSA_R_INVALID_DIGEST_LENGTH 143
|
||||
# define RSA_R_INVALID_HEADER 137
|
||||
# define RSA_R_INVALID_LABEL 160
|
||||
# define RSA_R_INVALID_MESSAGE_LENGTH 131
|
||||
# define RSA_R_INVALID_MGF1_MD 156
|
||||
# define RSA_R_INVALID_OAEP_PARAMETERS 161
|
||||
# define RSA_R_INVALID_PADDING 138
|
||||
# define RSA_R_INVALID_PADDING_MODE 141
|
||||
# define RSA_R_INVALID_PSS_PARAMETERS 149
|
||||
# define RSA_R_INVALID_PSS_SALTLEN 146
|
||||
# define RSA_R_INVALID_SALT_LENGTH 150
|
||||
# define RSA_R_INVALID_TRAILER 139
|
||||
# define RSA_R_INVALID_X931_DIGEST 142
|
||||
# define RSA_R_IQMP_NOT_INVERSE_OF_Q 126
|
||||
# define RSA_R_KEY_SIZE_TOO_SMALL 120
|
||||
# define RSA_R_LAST_OCTET_INVALID 134
|
||||
# define RSA_R_MODULUS_TOO_LARGE 105
|
||||
# define RSA_R_NO_PUBLIC_EXPONENT 140
|
||||
# define RSA_R_NULL_BEFORE_BLOCK_MISSING 113
|
||||
# define RSA_R_N_DOES_NOT_EQUAL_P_Q 127
|
||||
# define RSA_R_OAEP_DECODING_ERROR 121
|
||||
# define RSA_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE 148
|
||||
# define RSA_R_PADDING_CHECK_FAILED 114
|
||||
# define RSA_R_PKCS_DECODING_ERROR 159
|
||||
# define RSA_R_P_NOT_PRIME 128
|
||||
# define RSA_R_Q_NOT_PRIME 129
|
||||
# define RSA_R_RSA_OPERATIONS_NOT_SUPPORTED 130
|
||||
# define RSA_R_SLEN_CHECK_FAILED 136
|
||||
# define RSA_R_SLEN_RECOVERY_FAILED 135
|
||||
# define RSA_R_SSLV3_ROLLBACK_ATTACK 115
|
||||
# define RSA_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 116
|
||||
# define RSA_R_UNKNOWN_ALGORITHM_TYPE 117
|
||||
# define RSA_R_UNKNOWN_DIGEST 166
|
||||
# define RSA_R_UNKNOWN_MASK_DIGEST 151
|
||||
# define RSA_R_UNKNOWN_PADDING_TYPE 118
|
||||
# define RSA_R_UNSUPPORTED_ENCRYPTION_TYPE 162
|
||||
# define RSA_R_UNSUPPORTED_LABEL_SOURCE 163
|
||||
# define RSA_R_UNSUPPORTED_MASK_ALGORITHM 153
|
||||
# define RSA_R_UNSUPPORTED_MASK_PARAMETER 154
|
||||
# define RSA_R_UNSUPPORTED_SIGNATURE_TYPE 155
|
||||
# define RSA_R_VALUE_MISSING 147
|
||||
# define RSA_R_WRONG_SIGNATURE_LENGTH 119
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
|
@ -0,0 +1,164 @@
|
|||
/*
|
||||
* Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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_SAFESTACK_H
|
||||
# define HEADER_SAFESTACK_H
|
||||
|
||||
# include <openssl/stack.h>
|
||||
# include <openssl/e_os2.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
# define STACK_OF(type) struct stack_st_##type
|
||||
|
||||
# define SKM_DEFINE_STACK_OF(t1, t2, t3) \
|
||||
STACK_OF(t1); \
|
||||
typedef int (*sk_##t1##_compfunc)(const t3 * const *a, const t3 *const *b); \
|
||||
typedef void (*sk_##t1##_freefunc)(t3 *a); \
|
||||
typedef t3 * (*sk_##t1##_copyfunc)(const t3 *a); \
|
||||
static ossl_inline int sk_##t1##_num(const STACK_OF(t1) *sk) \
|
||||
{ \
|
||||
return OPENSSL_sk_num((const OPENSSL_STACK *)sk); \
|
||||
} \
|
||||
static ossl_inline t2 *sk_##t1##_value(const STACK_OF(t1) *sk, int idx) \
|
||||
{ \
|
||||
return (t2 *)OPENSSL_sk_value((const OPENSSL_STACK *)sk, idx); \
|
||||
} \
|
||||
static ossl_inline STACK_OF(t1) *sk_##t1##_new(sk_##t1##_compfunc compare) \
|
||||
{ \
|
||||
return (STACK_OF(t1) *)OPENSSL_sk_new((OPENSSL_sk_compfunc)compare); \
|
||||
} \
|
||||
static ossl_inline STACK_OF(t1) *sk_##t1##_new_null(void) \
|
||||
{ \
|
||||
return (STACK_OF(t1) *)OPENSSL_sk_new_null(); \
|
||||
} \
|
||||
static ossl_inline void sk_##t1##_free(STACK_OF(t1) *sk) \
|
||||
{ \
|
||||
OPENSSL_sk_free((OPENSSL_STACK *)sk); \
|
||||
} \
|
||||
static ossl_inline void sk_##t1##_zero(STACK_OF(t1) *sk) \
|
||||
{ \
|
||||
OPENSSL_sk_zero((OPENSSL_STACK *)sk); \
|
||||
} \
|
||||
static ossl_inline t2 *sk_##t1##_delete(STACK_OF(t1) *sk, int i) \
|
||||
{ \
|
||||
return (t2 *)OPENSSL_sk_delete((OPENSSL_STACK *)sk, i); \
|
||||
} \
|
||||
static ossl_inline t2 *sk_##t1##_delete_ptr(STACK_OF(t1) *sk, t2 *ptr) \
|
||||
{ \
|
||||
return (t2 *)OPENSSL_sk_delete_ptr((OPENSSL_STACK *)sk, \
|
||||
(const void *)ptr); \
|
||||
} \
|
||||
static ossl_inline int sk_##t1##_push(STACK_OF(t1) *sk, t2 *ptr) \
|
||||
{ \
|
||||
return OPENSSL_sk_push((OPENSSL_STACK *)sk, (const void *)ptr); \
|
||||
} \
|
||||
static ossl_inline int sk_##t1##_unshift(STACK_OF(t1) *sk, t2 *ptr) \
|
||||
{ \
|
||||
return OPENSSL_sk_unshift((OPENSSL_STACK *)sk, (const void *)ptr); \
|
||||
} \
|
||||
static ossl_inline t2 *sk_##t1##_pop(STACK_OF(t1) *sk) \
|
||||
{ \
|
||||
return (t2 *)OPENSSL_sk_pop((OPENSSL_STACK *)sk); \
|
||||
} \
|
||||
static ossl_inline t2 *sk_##t1##_shift(STACK_OF(t1) *sk) \
|
||||
{ \
|
||||
return (t2 *)OPENSSL_sk_shift((OPENSSL_STACK *)sk); \
|
||||
} \
|
||||
static ossl_inline void sk_##t1##_pop_free(STACK_OF(t1) *sk, sk_##t1##_freefunc freefunc) \
|
||||
{ \
|
||||
OPENSSL_sk_pop_free((OPENSSL_STACK *)sk, (OPENSSL_sk_freefunc)freefunc); \
|
||||
} \
|
||||
static ossl_inline int sk_##t1##_insert(STACK_OF(t1) *sk, t2 *ptr, int idx) \
|
||||
{ \
|
||||
return OPENSSL_sk_insert((OPENSSL_STACK *)sk, (const void *)ptr, idx); \
|
||||
} \
|
||||
static ossl_inline t2 *sk_##t1##_set(STACK_OF(t1) *sk, int idx, t2 *ptr) \
|
||||
{ \
|
||||
return (t2 *)OPENSSL_sk_set((OPENSSL_STACK *)sk, idx, (const void *)ptr); \
|
||||
} \
|
||||
static ossl_inline int sk_##t1##_find(STACK_OF(t1) *sk, t2 *ptr) \
|
||||
{ \
|
||||
return OPENSSL_sk_find((OPENSSL_STACK *)sk, (const void *)ptr); \
|
||||
} \
|
||||
static ossl_inline int sk_##t1##_find_ex(STACK_OF(t1) *sk, t2 *ptr) \
|
||||
{ \
|
||||
return OPENSSL_sk_find_ex((OPENSSL_STACK *)sk, (const void *)ptr); \
|
||||
} \
|
||||
static ossl_inline void sk_##t1##_sort(STACK_OF(t1) *sk) \
|
||||
{ \
|
||||
OPENSSL_sk_sort((OPENSSL_STACK *)sk); \
|
||||
} \
|
||||
static ossl_inline int sk_##t1##_is_sorted(const STACK_OF(t1) *sk) \
|
||||
{ \
|
||||
return OPENSSL_sk_is_sorted((const OPENSSL_STACK *)sk); \
|
||||
} \
|
||||
static ossl_inline STACK_OF(t1) * sk_##t1##_dup(const STACK_OF(t1) *sk) \
|
||||
{ \
|
||||
return (STACK_OF(t1) *)OPENSSL_sk_dup((const OPENSSL_STACK *)sk); \
|
||||
} \
|
||||
static ossl_inline STACK_OF(t1) *sk_##t1##_deep_copy(const STACK_OF(t1) *sk, \
|
||||
sk_##t1##_copyfunc copyfunc, \
|
||||
sk_##t1##_freefunc freefunc) \
|
||||
{ \
|
||||
return (STACK_OF(t1) *)OPENSSL_sk_deep_copy((const OPENSSL_STACK *)sk, \
|
||||
(OPENSSL_sk_copyfunc)copyfunc, \
|
||||
(OPENSSL_sk_freefunc)freefunc); \
|
||||
} \
|
||||
static ossl_inline sk_##t1##_compfunc sk_##t1##_set_cmp_func(STACK_OF(t1) *sk, sk_##t1##_compfunc compare) \
|
||||
{ \
|
||||
return (sk_##t1##_compfunc)OPENSSL_sk_set_cmp_func((OPENSSL_STACK *)sk, (OPENSSL_sk_compfunc)compare); \
|
||||
}
|
||||
|
||||
# define DEFINE_SPECIAL_STACK_OF(t1, t2) SKM_DEFINE_STACK_OF(t1, t2, t2)
|
||||
# define DEFINE_STACK_OF(t) SKM_DEFINE_STACK_OF(t, t, t)
|
||||
# define DEFINE_SPECIAL_STACK_OF_CONST(t1, t2) \
|
||||
SKM_DEFINE_STACK_OF(t1, const t2, t2)
|
||||
# define DEFINE_STACK_OF_CONST(t) SKM_DEFINE_STACK_OF(t, const t, t)
|
||||
|
||||
/*-
|
||||
* Strings are special: normally an lhash entry will point to a single
|
||||
* (somewhat) mutable object. In the case of strings:
|
||||
*
|
||||
* a) Instead of a single char, there is an array of chars, NUL-terminated.
|
||||
* b) The string may have be immutable.
|
||||
*
|
||||
* So, they need their own declarations. Especially important for
|
||||
* type-checking tools, such as Deputy.
|
||||
*
|
||||
* In practice, however, it appears to be hard to have a const
|
||||
* string. For now, I'm settling for dealing with the fact it is a
|
||||
* string at all.
|
||||
*/
|
||||
typedef char *OPENSSL_STRING;
|
||||
typedef const char *OPENSSL_CSTRING;
|
||||
|
||||
/*-
|
||||
* Confusingly, LHASH_OF(STRING) deals with char ** throughout, but
|
||||
* STACK_OF(STRING) is really more like STACK_OF(char), only, as mentioned
|
||||
* above, instead of a single char each entry is a NUL-terminated array of
|
||||
* chars. So, we have to implement STRING specially for STACK_OF. This is
|
||||
* dealt with in the autogenerated macros below.
|
||||
*/
|
||||
DEFINE_SPECIAL_STACK_OF(OPENSSL_STRING, char)
|
||||
DEFINE_SPECIAL_STACK_OF_CONST(OPENSSL_CSTRING, char)
|
||||
|
||||
/*
|
||||
* Similarly, we sometimes use a block of characters, NOT nul-terminated.
|
||||
* These should also be distinguished from "normal" stacks.
|
||||
*/
|
||||
typedef void *OPENSSL_BLOCK;
|
||||
DEFINE_SPECIAL_STACK_OF(OPENSSL_BLOCK, void)
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
|
@ -0,0 +1,98 @@
|
|||
/*
|
||||
* Copyright 2007-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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_H
|
||||
# define HEADER_SEED_H
|
||||
|
||||
# include <openssl/opensslconf.h>
|
||||
|
||||
# ifndef OPENSSL_NO_SEED
|
||||
# include <openssl/e_os2.h>
|
||||
# include <openssl/crypto.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* look whether we need 'long' to get 32 bits */
|
||||
# ifdef AES_LONG
|
||||
# ifndef SEED_LONG
|
||||
# define SEED_LONG 1
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# if !defined(NO_SYS_TYPES_H)
|
||||
# include <sys/types.h>
|
||||
# endif
|
||||
|
||||
# define SEED_BLOCK_SIZE 16
|
||||
# define SEED_KEY_LENGTH 16
|
||||
|
||||
typedef struct seed_key_st {
|
||||
# ifdef SEED_LONG
|
||||
unsigned long data[32];
|
||||
# else
|
||||
unsigned int data[32];
|
||||
# endif
|
||||
} SEED_KEY_SCHEDULE;
|
||||
|
||||
void SEED_set_key(const unsigned char rawkey[SEED_KEY_LENGTH],
|
||||
SEED_KEY_SCHEDULE *ks);
|
||||
|
||||
void SEED_encrypt(const unsigned char s[SEED_BLOCK_SIZE],
|
||||
unsigned char d[SEED_BLOCK_SIZE],
|
||||
const SEED_KEY_SCHEDULE *ks);
|
||||
void SEED_decrypt(const unsigned char s[SEED_BLOCK_SIZE],
|
||||
unsigned char d[SEED_BLOCK_SIZE],
|
||||
const SEED_KEY_SCHEDULE *ks);
|
||||
|
||||
void SEED_ecb_encrypt(const unsigned char *in, unsigned char *out,
|
||||
const SEED_KEY_SCHEDULE *ks, int enc);
|
||||
void SEED_cbc_encrypt(const unsigned char *in, unsigned char *out, size_t len,
|
||||
const SEED_KEY_SCHEDULE *ks,
|
||||
unsigned char ivec[SEED_BLOCK_SIZE], int enc);
|
||||
void SEED_cfb128_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t len, const SEED_KEY_SCHEDULE *ks,
|
||||
unsigned char ivec[SEED_BLOCK_SIZE], int *num,
|
||||
int enc);
|
||||
void SEED_ofb128_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t len, const SEED_KEY_SCHEDULE *ks,
|
||||
unsigned char ivec[SEED_BLOCK_SIZE], int *num);
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,119 @@
|
|||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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_SHA_H
|
||||
# define HEADER_SHA_H
|
||||
|
||||
# include <openssl/e_os2.h>
|
||||
# include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*-
|
||||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
* ! SHA_LONG has to be at least 32 bits wide. !
|
||||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
*/
|
||||
# define SHA_LONG unsigned int
|
||||
|
||||
# define SHA_LBLOCK 16
|
||||
# define SHA_CBLOCK (SHA_LBLOCK*4)/* SHA treats input data as a
|
||||
* contiguous array of 32 bit wide
|
||||
* big-endian values. */
|
||||
# define SHA_LAST_BLOCK (SHA_CBLOCK-8)
|
||||
# define SHA_DIGEST_LENGTH 20
|
||||
|
||||
typedef struct SHAstate_st {
|
||||
SHA_LONG h0, h1, h2, h3, h4;
|
||||
SHA_LONG Nl, Nh;
|
||||
SHA_LONG data[SHA_LBLOCK];
|
||||
unsigned int num;
|
||||
} SHA_CTX;
|
||||
|
||||
int SHA1_Init(SHA_CTX *c);
|
||||
int SHA1_Update(SHA_CTX *c, const void *data, size_t len);
|
||||
int SHA1_Final(unsigned char *md, SHA_CTX *c);
|
||||
unsigned char *SHA1(const unsigned char *d, size_t n, unsigned char *md);
|
||||
void SHA1_Transform(SHA_CTX *c, const unsigned char *data);
|
||||
|
||||
# define SHA256_CBLOCK (SHA_LBLOCK*4)/* SHA-256 treats input data as a
|
||||
* contiguous array of 32 bit wide
|
||||
* big-endian values. */
|
||||
|
||||
typedef struct SHA256state_st {
|
||||
SHA_LONG h[8];
|
||||
SHA_LONG Nl, Nh;
|
||||
SHA_LONG data[SHA_LBLOCK];
|
||||
unsigned int num, md_len;
|
||||
} SHA256_CTX;
|
||||
|
||||
int SHA224_Init(SHA256_CTX *c);
|
||||
int SHA224_Update(SHA256_CTX *c, const void *data, size_t len);
|
||||
int SHA224_Final(unsigned char *md, SHA256_CTX *c);
|
||||
unsigned char *SHA224(const unsigned char *d, size_t n, unsigned char *md);
|
||||
int SHA256_Init(SHA256_CTX *c);
|
||||
int SHA256_Update(SHA256_CTX *c, const void *data, size_t len);
|
||||
int SHA256_Final(unsigned char *md, SHA256_CTX *c);
|
||||
unsigned char *SHA256(const unsigned char *d, size_t n, unsigned char *md);
|
||||
void SHA256_Transform(SHA256_CTX *c, const unsigned char *data);
|
||||
|
||||
# define SHA224_DIGEST_LENGTH 28
|
||||
# define SHA256_DIGEST_LENGTH 32
|
||||
# define SHA384_DIGEST_LENGTH 48
|
||||
# define SHA512_DIGEST_LENGTH 64
|
||||
|
||||
/*
|
||||
* Unlike 32-bit digest algorithms, SHA-512 *relies* on SHA_LONG64
|
||||
* being exactly 64-bit wide. See Implementation Notes in sha512.c
|
||||
* for further details.
|
||||
*/
|
||||
/*
|
||||
* SHA-512 treats input data as a
|
||||
* contiguous array of 64 bit
|
||||
* wide big-endian values.
|
||||
*/
|
||||
# define SHA512_CBLOCK (SHA_LBLOCK*8)
|
||||
# if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32__)
|
||||
# define SHA_LONG64 unsigned __int64
|
||||
# define U64(C) C##UI64
|
||||
# elif defined(__arch64__)
|
||||
# define SHA_LONG64 unsigned long
|
||||
# define U64(C) C##UL
|
||||
# else
|
||||
# define SHA_LONG64 unsigned long long
|
||||
# define U64(C) C##ULL
|
||||
# endif
|
||||
|
||||
typedef struct SHA512state_st {
|
||||
SHA_LONG64 h[8];
|
||||
SHA_LONG64 Nl, Nh;
|
||||
union {
|
||||
SHA_LONG64 d[SHA_LBLOCK];
|
||||
unsigned char p[SHA512_CBLOCK];
|
||||
} u;
|
||||
unsigned int num, md_len;
|
||||
} SHA512_CTX;
|
||||
|
||||
int SHA384_Init(SHA512_CTX *c);
|
||||
int SHA384_Update(SHA512_CTX *c, const void *data, size_t len);
|
||||
int SHA384_Final(unsigned char *md, SHA512_CTX *c);
|
||||
unsigned char *SHA384(const unsigned char *d, size_t n, unsigned char *md);
|
||||
int SHA512_Init(SHA512_CTX *c);
|
||||
int SHA512_Update(SHA512_CTX *c, const void *data, size_t len);
|
||||
int SHA512_Final(unsigned char *md, SHA512_CTX *c);
|
||||
unsigned char *SHA512(const unsigned char *d, size_t n, unsigned char *md);
|
||||
void SHA512_Transform(SHA512_CTX *c, const unsigned char *data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,131 @@
|
|||
/*
|
||||
* Copyright 2011-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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_SRP_H
|
||||
# define HEADER_SRP_H
|
||||
|
||||
#include <openssl/opensslconf.h>
|
||||
|
||||
#ifndef OPENSSL_NO_SRP
|
||||
# include <stdio.h>
|
||||
# include <string.h>
|
||||
# include <openssl/safestack.h>
|
||||
# include <openssl/bn.h>
|
||||
# include <openssl/crypto.h>
|
||||
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
# endif
|
||||
|
||||
typedef struct SRP_gN_cache_st {
|
||||
char *b64_bn;
|
||||
BIGNUM *bn;
|
||||
} SRP_gN_cache;
|
||||
|
||||
|
||||
DEFINE_STACK_OF(SRP_gN_cache)
|
||||
|
||||
typedef struct SRP_user_pwd_st {
|
||||
/* Owned by us. */
|
||||
char *id;
|
||||
BIGNUM *s;
|
||||
BIGNUM *v;
|
||||
/* Not owned by us. */
|
||||
const BIGNUM *g;
|
||||
const BIGNUM *N;
|
||||
/* Owned by us. */
|
||||
char *info;
|
||||
} SRP_user_pwd;
|
||||
|
||||
void SRP_user_pwd_free(SRP_user_pwd *user_pwd);
|
||||
|
||||
DEFINE_STACK_OF(SRP_user_pwd)
|
||||
|
||||
typedef struct SRP_VBASE_st {
|
||||
STACK_OF(SRP_user_pwd) *users_pwd;
|
||||
STACK_OF(SRP_gN_cache) *gN_cache;
|
||||
/* to simulate a user */
|
||||
char *seed_key;
|
||||
const BIGNUM *default_g;
|
||||
const BIGNUM *default_N;
|
||||
} SRP_VBASE;
|
||||
|
||||
/*
|
||||
* Internal structure storing N and g pair
|
||||
*/
|
||||
typedef struct SRP_gN_st {
|
||||
char *id;
|
||||
const BIGNUM *g;
|
||||
const BIGNUM *N;
|
||||
} SRP_gN;
|
||||
|
||||
DEFINE_STACK_OF(SRP_gN)
|
||||
|
||||
SRP_VBASE *SRP_VBASE_new(char *seed_key);
|
||||
void SRP_VBASE_free(SRP_VBASE *vb);
|
||||
int SRP_VBASE_init(SRP_VBASE *vb, char *verifier_file);
|
||||
|
||||
/* This method ignores the configured seed and fails for an unknown user. */
|
||||
DEPRECATEDIN_1_1_0(SRP_user_pwd *SRP_VBASE_get_by_user(SRP_VBASE *vb, char *username))
|
||||
/* NOTE: unlike in SRP_VBASE_get_by_user, caller owns the returned pointer.*/
|
||||
SRP_user_pwd *SRP_VBASE_get1_by_user(SRP_VBASE *vb, char *username);
|
||||
|
||||
char *SRP_create_verifier(const char *user, const char *pass, char **salt,
|
||||
char **verifier, const char *N, const char *g);
|
||||
int SRP_create_verifier_BN(const char *user, const char *pass, BIGNUM **salt,
|
||||
BIGNUM **verifier, const BIGNUM *N,
|
||||
const BIGNUM *g);
|
||||
|
||||
# define SRP_NO_ERROR 0
|
||||
# define SRP_ERR_VBASE_INCOMPLETE_FILE 1
|
||||
# define SRP_ERR_VBASE_BN_LIB 2
|
||||
# define SRP_ERR_OPEN_FILE 3
|
||||
# define SRP_ERR_MEMORY 4
|
||||
|
||||
# define DB_srptype 0
|
||||
# define DB_srpverifier 1
|
||||
# define DB_srpsalt 2
|
||||
# define DB_srpid 3
|
||||
# define DB_srpgN 4
|
||||
# define DB_srpinfo 5
|
||||
# undef DB_NUMBER
|
||||
# define DB_NUMBER 6
|
||||
|
||||
# define DB_SRP_INDEX 'I'
|
||||
# define DB_SRP_VALID 'V'
|
||||
# define DB_SRP_REVOKED 'R'
|
||||
# define DB_SRP_MODIF 'v'
|
||||
|
||||
/* see srp.c */
|
||||
char *SRP_check_known_gN_param(const BIGNUM *g, const BIGNUM *N);
|
||||
SRP_gN *SRP_get_default_gN(const char *id);
|
||||
|
||||
/* server side .... */
|
||||
BIGNUM *SRP_Calc_server_key(const BIGNUM *A, const BIGNUM *v, const BIGNUM *u,
|
||||
const BIGNUM *b, const BIGNUM *N);
|
||||
BIGNUM *SRP_Calc_B(const BIGNUM *b, const BIGNUM *N, const BIGNUM *g,
|
||||
const BIGNUM *v);
|
||||
int SRP_Verify_A_mod_N(const BIGNUM *A, const BIGNUM *N);
|
||||
BIGNUM *SRP_Calc_u(const BIGNUM *A, const BIGNUM *B, const BIGNUM *N);
|
||||
|
||||
/* client side .... */
|
||||
BIGNUM *SRP_Calc_x(const BIGNUM *s, const char *user, const char *pass);
|
||||
BIGNUM *SRP_Calc_A(const BIGNUM *a, const BIGNUM *N, const BIGNUM *g);
|
||||
BIGNUM *SRP_Calc_client_key(const BIGNUM *N, const BIGNUM *B, const BIGNUM *g,
|
||||
const BIGNUM *x, const BIGNUM *a, const BIGNUM *u);
|
||||
int SRP_Verify_B_mod_N(const BIGNUM *B, const BIGNUM *N);
|
||||
|
||||
# define SRP_MINIMAL_N 1024
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Copyright 2011-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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
|
||||
*/
|
||||
|
||||
/*
|
||||
* DTLS code by Eric Rescorla <ekr@rtfm.com>
|
||||
*
|
||||
* Copyright (C) 2006, Network Resonance, Inc. Copyright (C) 2011, RTFM, Inc.
|
||||
*/
|
||||
|
||||
#ifndef HEADER_D1_SRTP_H
|
||||
# define HEADER_D1_SRTP_H
|
||||
|
||||
# include <openssl/ssl.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
# define SRTP_AES128_CM_SHA1_80 0x0001
|
||||
# define SRTP_AES128_CM_SHA1_32 0x0002
|
||||
# define SRTP_AES128_F8_SHA1_80 0x0003
|
||||
# define SRTP_AES128_F8_SHA1_32 0x0004
|
||||
# define SRTP_NULL_SHA1_80 0x0005
|
||||
# define SRTP_NULL_SHA1_32 0x0006
|
||||
|
||||
/* AEAD SRTP protection profiles from RFC 7714 */
|
||||
# define SRTP_AEAD_AES_128_GCM 0x0007
|
||||
# define SRTP_AEAD_AES_256_GCM 0x0008
|
||||
|
||||
# ifndef OPENSSL_NO_SRTP
|
||||
|
||||
__owur int SSL_CTX_set_tlsext_use_srtp(SSL_CTX *ctx, const char *profiles);
|
||||
__owur int SSL_set_tlsext_use_srtp(SSL *ctx, const char *profiles);
|
||||
|
||||
__owur STACK_OF(SRTP_PROTECTION_PROFILE) *SSL_get_srtp_profiles(SSL *ssl);
|
||||
__owur SRTP_PROTECTION_PROFILE *SSL_get_selected_srtp_profile(SSL *s);
|
||||
|
||||
# endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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_SSL2_H
|
||||
# define HEADER_SSL2_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
# define SSL2_VERSION 0x0002
|
||||
|
||||
# define SSL2_MT_CLIENT_HELLO 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -0,0 +1,307 @@
|
|||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
|
||||
* ECC cipher suite support in OpenSSL originally developed by
|
||||
* SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.
|
||||
*/
|
||||
|
||||
#ifndef HEADER_SSL3_H
|
||||
# define HEADER_SSL3_H
|
||||
|
||||
# include <openssl/comp.h>
|
||||
# include <openssl/buffer.h>
|
||||
# include <openssl/evp.h>
|
||||
# include <openssl/ssl.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Signalling cipher suite value from RFC 5746
|
||||
* (TLS_EMPTY_RENEGOTIATION_INFO_SCSV)
|
||||
*/
|
||||
# define SSL3_CK_SCSV 0x030000FF
|
||||
|
||||
/*
|
||||
* Signalling cipher suite value from draft-ietf-tls-downgrade-scsv-00
|
||||
* (TLS_FALLBACK_SCSV)
|
||||
*/
|
||||
# define SSL3_CK_FALLBACK_SCSV 0x03005600
|
||||
|
||||
# define SSL3_CK_RSA_NULL_MD5 0x03000001
|
||||
# define SSL3_CK_RSA_NULL_SHA 0x03000002
|
||||
# define SSL3_CK_RSA_RC4_40_MD5 0x03000003
|
||||
# define SSL3_CK_RSA_RC4_128_MD5 0x03000004
|
||||
# define SSL3_CK_RSA_RC4_128_SHA 0x03000005
|
||||
# define SSL3_CK_RSA_RC2_40_MD5 0x03000006
|
||||
# define SSL3_CK_RSA_IDEA_128_SHA 0x03000007
|
||||
# define SSL3_CK_RSA_DES_40_CBC_SHA 0x03000008
|
||||
# define SSL3_CK_RSA_DES_64_CBC_SHA 0x03000009
|
||||
# define SSL3_CK_RSA_DES_192_CBC3_SHA 0x0300000A
|
||||
|
||||
# define SSL3_CK_DH_DSS_DES_40_CBC_SHA 0x0300000B
|
||||
# define SSL3_CK_DH_DSS_DES_64_CBC_SHA 0x0300000C
|
||||
# define SSL3_CK_DH_DSS_DES_192_CBC3_SHA 0x0300000D
|
||||
# define SSL3_CK_DH_RSA_DES_40_CBC_SHA 0x0300000E
|
||||
# define SSL3_CK_DH_RSA_DES_64_CBC_SHA 0x0300000F
|
||||
# define SSL3_CK_DH_RSA_DES_192_CBC3_SHA 0x03000010
|
||||
|
||||
# define SSL3_CK_DHE_DSS_DES_40_CBC_SHA 0x03000011
|
||||
# define SSL3_CK_EDH_DSS_DES_40_CBC_SHA SSL3_CK_DHE_DSS_DES_40_CBC_SHA
|
||||
# define SSL3_CK_DHE_DSS_DES_64_CBC_SHA 0x03000012
|
||||
# define SSL3_CK_EDH_DSS_DES_64_CBC_SHA SSL3_CK_DHE_DSS_DES_64_CBC_SHA
|
||||
# define SSL3_CK_DHE_DSS_DES_192_CBC3_SHA 0x03000013
|
||||
# define SSL3_CK_EDH_DSS_DES_192_CBC3_SHA SSL3_CK_DHE_DSS_DES_192_CBC3_SHA
|
||||
# define SSL3_CK_DHE_RSA_DES_40_CBC_SHA 0x03000014
|
||||
# define SSL3_CK_EDH_RSA_DES_40_CBC_SHA SSL3_CK_DHE_RSA_DES_40_CBC_SHA
|
||||
# define SSL3_CK_DHE_RSA_DES_64_CBC_SHA 0x03000015
|
||||
# define SSL3_CK_EDH_RSA_DES_64_CBC_SHA SSL3_CK_DHE_RSA_DES_64_CBC_SHA
|
||||
# define SSL3_CK_DHE_RSA_DES_192_CBC3_SHA 0x03000016
|
||||
# define SSL3_CK_EDH_RSA_DES_192_CBC3_SHA SSL3_CK_DHE_RSA_DES_192_CBC3_SHA
|
||||
|
||||
# define SSL3_CK_ADH_RC4_40_MD5 0x03000017
|
||||
# define SSL3_CK_ADH_RC4_128_MD5 0x03000018
|
||||
# define SSL3_CK_ADH_DES_40_CBC_SHA 0x03000019
|
||||
# define SSL3_CK_ADH_DES_64_CBC_SHA 0x0300001A
|
||||
# define SSL3_CK_ADH_DES_192_CBC_SHA 0x0300001B
|
||||
|
||||
# define SSL3_TXT_RSA_NULL_MD5 "NULL-MD5"
|
||||
# define SSL3_TXT_RSA_NULL_SHA "NULL-SHA"
|
||||
# define SSL3_TXT_RSA_RC4_40_MD5 "EXP-RC4-MD5"
|
||||
# define SSL3_TXT_RSA_RC4_128_MD5 "RC4-MD5"
|
||||
# define SSL3_TXT_RSA_RC4_128_SHA "RC4-SHA"
|
||||
# define SSL3_TXT_RSA_RC2_40_MD5 "EXP-RC2-CBC-MD5"
|
||||
# define SSL3_TXT_RSA_IDEA_128_SHA "IDEA-CBC-SHA"
|
||||
# define SSL3_TXT_RSA_DES_40_CBC_SHA "EXP-DES-CBC-SHA"
|
||||
# define SSL3_TXT_RSA_DES_64_CBC_SHA "DES-CBC-SHA"
|
||||
# define SSL3_TXT_RSA_DES_192_CBC3_SHA "DES-CBC3-SHA"
|
||||
|
||||
# define SSL3_TXT_DH_DSS_DES_40_CBC_SHA "EXP-DH-DSS-DES-CBC-SHA"
|
||||
# define SSL3_TXT_DH_DSS_DES_64_CBC_SHA "DH-DSS-DES-CBC-SHA"
|
||||
# define SSL3_TXT_DH_DSS_DES_192_CBC3_SHA "DH-DSS-DES-CBC3-SHA"
|
||||
# define SSL3_TXT_DH_RSA_DES_40_CBC_SHA "EXP-DH-RSA-DES-CBC-SHA"
|
||||
# define SSL3_TXT_DH_RSA_DES_64_CBC_SHA "DH-RSA-DES-CBC-SHA"
|
||||
# define SSL3_TXT_DH_RSA_DES_192_CBC3_SHA "DH-RSA-DES-CBC3-SHA"
|
||||
|
||||
# define SSL3_TXT_DHE_DSS_DES_40_CBC_SHA "EXP-DHE-DSS-DES-CBC-SHA"
|
||||
# define SSL3_TXT_DHE_DSS_DES_64_CBC_SHA "DHE-DSS-DES-CBC-SHA"
|
||||
# define SSL3_TXT_DHE_DSS_DES_192_CBC3_SHA "DHE-DSS-DES-CBC3-SHA"
|
||||
# define SSL3_TXT_DHE_RSA_DES_40_CBC_SHA "EXP-DHE-RSA-DES-CBC-SHA"
|
||||
# define SSL3_TXT_DHE_RSA_DES_64_CBC_SHA "DHE-RSA-DES-CBC-SHA"
|
||||
# define SSL3_TXT_DHE_RSA_DES_192_CBC3_SHA "DHE-RSA-DES-CBC3-SHA"
|
||||
|
||||
/*
|
||||
* This next block of six "EDH" labels is for backward compatibility with
|
||||
* older versions of OpenSSL. New code should use the six "DHE" labels above
|
||||
* instead:
|
||||
*/
|
||||
# define SSL3_TXT_EDH_DSS_DES_40_CBC_SHA "EXP-EDH-DSS-DES-CBC-SHA"
|
||||
# define SSL3_TXT_EDH_DSS_DES_64_CBC_SHA "EDH-DSS-DES-CBC-SHA"
|
||||
# define SSL3_TXT_EDH_DSS_DES_192_CBC3_SHA "EDH-DSS-DES-CBC3-SHA"
|
||||
# define SSL3_TXT_EDH_RSA_DES_40_CBC_SHA "EXP-EDH-RSA-DES-CBC-SHA"
|
||||
# define SSL3_TXT_EDH_RSA_DES_64_CBC_SHA "EDH-RSA-DES-CBC-SHA"
|
||||
# define SSL3_TXT_EDH_RSA_DES_192_CBC3_SHA "EDH-RSA-DES-CBC3-SHA"
|
||||
|
||||
# define SSL3_TXT_ADH_RC4_40_MD5 "EXP-ADH-RC4-MD5"
|
||||
# define SSL3_TXT_ADH_RC4_128_MD5 "ADH-RC4-MD5"
|
||||
# define SSL3_TXT_ADH_DES_40_CBC_SHA "EXP-ADH-DES-CBC-SHA"
|
||||
# define SSL3_TXT_ADH_DES_64_CBC_SHA "ADH-DES-CBC-SHA"
|
||||
# define SSL3_TXT_ADH_DES_192_CBC_SHA "ADH-DES-CBC3-SHA"
|
||||
|
||||
# define SSL3_SSL_SESSION_ID_LENGTH 32
|
||||
# define SSL3_MAX_SSL_SESSION_ID_LENGTH 32
|
||||
|
||||
# define SSL3_MASTER_SECRET_SIZE 48
|
||||
# define SSL3_RANDOM_SIZE 32
|
||||
# define SSL3_SESSION_ID_SIZE 32
|
||||
# define SSL3_RT_HEADER_LENGTH 5
|
||||
|
||||
# define SSL3_HM_HEADER_LENGTH 4
|
||||
|
||||
# ifndef SSL3_ALIGN_PAYLOAD
|
||||
/*
|
||||
* Some will argue that this increases memory footprint, but it's not
|
||||
* actually true. Point is that malloc has to return at least 64-bit aligned
|
||||
* pointers, meaning that allocating 5 bytes wastes 3 bytes in either case.
|
||||
* Suggested pre-gaping simply moves these wasted bytes from the end of
|
||||
* allocated region to its front, but makes data payload aligned, which
|
||||
* improves performance:-)
|
||||
*/
|
||||
# define SSL3_ALIGN_PAYLOAD 8
|
||||
# else
|
||||
# if (SSL3_ALIGN_PAYLOAD&(SSL3_ALIGN_PAYLOAD-1))!=0
|
||||
# error "insane SSL3_ALIGN_PAYLOAD"
|
||||
# undef SSL3_ALIGN_PAYLOAD
|
||||
# endif
|
||||
# endif
|
||||
|
||||
/*
|
||||
* This is the maximum MAC (digest) size used by the SSL library. Currently
|
||||
* maximum of 20 is used by SHA1, but we reserve for future extension for
|
||||
* 512-bit hashes.
|
||||
*/
|
||||
|
||||
# define SSL3_RT_MAX_MD_SIZE 64
|
||||
|
||||
/*
|
||||
* Maximum block size used in all ciphersuites. Currently 16 for AES.
|
||||
*/
|
||||
|
||||
# define SSL_RT_MAX_CIPHER_BLOCK_SIZE 16
|
||||
|
||||
# define SSL3_RT_MAX_EXTRA (16384)
|
||||
|
||||
/* Maximum plaintext length: defined by SSL/TLS standards */
|
||||
# define SSL3_RT_MAX_PLAIN_LENGTH 16384
|
||||
/* Maximum compression overhead: defined by SSL/TLS standards */
|
||||
# define SSL3_RT_MAX_COMPRESSED_OVERHEAD 1024
|
||||
|
||||
/*
|
||||
* The standards give a maximum encryption overhead of 1024 bytes. In
|
||||
* practice the value is lower than this. The overhead is the maximum number
|
||||
* of padding bytes (256) plus the mac size.
|
||||
*/
|
||||
# define SSL3_RT_MAX_ENCRYPTED_OVERHEAD (256 + SSL3_RT_MAX_MD_SIZE)
|
||||
|
||||
/*
|
||||
* OpenSSL currently only uses a padding length of at most one block so the
|
||||
* send overhead is smaller.
|
||||
*/
|
||||
|
||||
# define SSL3_RT_SEND_MAX_ENCRYPTED_OVERHEAD \
|
||||
(SSL_RT_MAX_CIPHER_BLOCK_SIZE + SSL3_RT_MAX_MD_SIZE)
|
||||
|
||||
/* If compression isn't used don't include the compression overhead */
|
||||
|
||||
# ifdef OPENSSL_NO_COMP
|
||||
# define SSL3_RT_MAX_COMPRESSED_LENGTH SSL3_RT_MAX_PLAIN_LENGTH
|
||||
# else
|
||||
# define SSL3_RT_MAX_COMPRESSED_LENGTH \
|
||||
(SSL3_RT_MAX_PLAIN_LENGTH+SSL3_RT_MAX_COMPRESSED_OVERHEAD)
|
||||
# endif
|
||||
# define SSL3_RT_MAX_ENCRYPTED_LENGTH \
|
||||
(SSL3_RT_MAX_ENCRYPTED_OVERHEAD+SSL3_RT_MAX_COMPRESSED_LENGTH)
|
||||
# define SSL3_RT_MAX_PACKET_SIZE \
|
||||
(SSL3_RT_MAX_ENCRYPTED_LENGTH+SSL3_RT_HEADER_LENGTH)
|
||||
|
||||
# define SSL3_MD_CLIENT_FINISHED_CONST "\x43\x4C\x4E\x54"
|
||||
# define SSL3_MD_SERVER_FINISHED_CONST "\x53\x52\x56\x52"
|
||||
|
||||
# define SSL3_VERSION 0x0300
|
||||
# define SSL3_VERSION_MAJOR 0x03
|
||||
# define SSL3_VERSION_MINOR 0x00
|
||||
|
||||
# define SSL3_RT_CHANGE_CIPHER_SPEC 20
|
||||
# define SSL3_RT_ALERT 21
|
||||
# define SSL3_RT_HANDSHAKE 22
|
||||
# define SSL3_RT_APPLICATION_DATA 23
|
||||
# define DTLS1_RT_HEARTBEAT 24
|
||||
|
||||
/* Pseudo content types to indicate additional parameters */
|
||||
# define TLS1_RT_CRYPTO 0x1000
|
||||
# define TLS1_RT_CRYPTO_PREMASTER (TLS1_RT_CRYPTO | 0x1)
|
||||
# define TLS1_RT_CRYPTO_CLIENT_RANDOM (TLS1_RT_CRYPTO | 0x2)
|
||||
# define TLS1_RT_CRYPTO_SERVER_RANDOM (TLS1_RT_CRYPTO | 0x3)
|
||||
# define TLS1_RT_CRYPTO_MASTER (TLS1_RT_CRYPTO | 0x4)
|
||||
|
||||
# define TLS1_RT_CRYPTO_READ 0x0000
|
||||
# define TLS1_RT_CRYPTO_WRITE 0x0100
|
||||
# define TLS1_RT_CRYPTO_MAC (TLS1_RT_CRYPTO | 0x5)
|
||||
# define TLS1_RT_CRYPTO_KEY (TLS1_RT_CRYPTO | 0x6)
|
||||
# define TLS1_RT_CRYPTO_IV (TLS1_RT_CRYPTO | 0x7)
|
||||
# define TLS1_RT_CRYPTO_FIXED_IV (TLS1_RT_CRYPTO | 0x8)
|
||||
|
||||
/* Pseudo content type for SSL/TLS header info */
|
||||
# define SSL3_RT_HEADER 0x100
|
||||
|
||||
# define SSL3_AL_WARNING 1
|
||||
# define SSL3_AL_FATAL 2
|
||||
|
||||
# define SSL3_AD_CLOSE_NOTIFY 0
|
||||
# define SSL3_AD_UNEXPECTED_MESSAGE 10/* fatal */
|
||||
# define SSL3_AD_BAD_RECORD_MAC 20/* fatal */
|
||||
# define SSL3_AD_DECOMPRESSION_FAILURE 30/* fatal */
|
||||
# define SSL3_AD_HANDSHAKE_FAILURE 40/* fatal */
|
||||
# define SSL3_AD_NO_CERTIFICATE 41
|
||||
# define SSL3_AD_BAD_CERTIFICATE 42
|
||||
# define SSL3_AD_UNSUPPORTED_CERTIFICATE 43
|
||||
# define SSL3_AD_CERTIFICATE_REVOKED 44
|
||||
# define SSL3_AD_CERTIFICATE_EXPIRED 45
|
||||
# define SSL3_AD_CERTIFICATE_UNKNOWN 46
|
||||
# define SSL3_AD_ILLEGAL_PARAMETER 47/* fatal */
|
||||
|
||||
# define TLS1_HB_REQUEST 1
|
||||
# define TLS1_HB_RESPONSE 2
|
||||
|
||||
|
||||
# define SSL3_CT_RSA_SIGN 1
|
||||
# define SSL3_CT_DSS_SIGN 2
|
||||
# define SSL3_CT_RSA_FIXED_DH 3
|
||||
# define SSL3_CT_DSS_FIXED_DH 4
|
||||
# define SSL3_CT_RSA_EPHEMERAL_DH 5
|
||||
# define SSL3_CT_DSS_EPHEMERAL_DH 6
|
||||
# define SSL3_CT_FORTEZZA_DMS 20
|
||||
/*
|
||||
* SSL3_CT_NUMBER is used to size arrays and it must be large enough to
|
||||
* contain all of the cert types defined either for SSLv3 and TLSv1.
|
||||
*/
|
||||
# define SSL3_CT_NUMBER 9
|
||||
|
||||
# define SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS 0x0001
|
||||
|
||||
/* Removed from OpenSSL 1.1.0 */
|
||||
# define TLS1_FLAGS_TLS_PADDING_BUG 0x0
|
||||
|
||||
# define TLS1_FLAGS_SKIP_CERT_VERIFY 0x0010
|
||||
|
||||
/* Set if we encrypt then mac instead of usual mac then encrypt */
|
||||
# define TLS1_FLAGS_ENCRYPT_THEN_MAC 0x0100
|
||||
|
||||
/* Set if extended master secret extension received from peer */
|
||||
# define TLS1_FLAGS_RECEIVED_EXTMS 0x0200
|
||||
|
||||
# define SSL3_MT_HELLO_REQUEST 0
|
||||
# define SSL3_MT_CLIENT_HELLO 1
|
||||
# define SSL3_MT_SERVER_HELLO 2
|
||||
# define SSL3_MT_NEWSESSION_TICKET 4
|
||||
# define SSL3_MT_CERTIFICATE 11
|
||||
# define SSL3_MT_SERVER_KEY_EXCHANGE 12
|
||||
# define SSL3_MT_CERTIFICATE_REQUEST 13
|
||||
# define SSL3_MT_SERVER_DONE 14
|
||||
# define SSL3_MT_CERTIFICATE_VERIFY 15
|
||||
# define SSL3_MT_CLIENT_KEY_EXCHANGE 16
|
||||
# define SSL3_MT_FINISHED 20
|
||||
# define SSL3_MT_CERTIFICATE_STATUS 22
|
||||
# ifndef OPENSSL_NO_NEXTPROTONEG
|
||||
# define SSL3_MT_NEXT_PROTO 67
|
||||
# endif
|
||||
# define DTLS1_MT_HELLO_VERIFY_REQUEST 3
|
||||
|
||||
/* Dummy message type for handling CCS like a normal handshake message */
|
||||
# define SSL3_MT_CHANGE_CIPHER_SPEC 0x0101
|
||||
|
||||
# define SSL3_MT_CCS 1
|
||||
|
||||
/* These are used when changing over to a new cipher */
|
||||
# define SSL3_CC_READ 0x01
|
||||
# define SSL3_CC_WRITE 0x02
|
||||
# define SSL3_CC_CLIENT 0x10
|
||||
# define SSL3_CC_SERVER 0x20
|
||||
# define SSL3_CHANGE_CIPHER_CLIENT_WRITE (SSL3_CC_CLIENT|SSL3_CC_WRITE)
|
||||
# define SSL3_CHANGE_CIPHER_SERVER_READ (SSL3_CC_SERVER|SSL3_CC_READ)
|
||||
# define SSL3_CHANGE_CIPHER_CLIENT_READ (SSL3_CC_CLIENT|SSL3_CC_READ)
|
||||
# define SSL3_CHANGE_CIPHER_SERVER_WRITE (SSL3_CC_SERVER|SSL3_CC_WRITE)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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_STACK_H
|
||||
# define HEADER_STACK_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct stack_st OPENSSL_STACK; /* Use STACK_OF(...) instead */
|
||||
|
||||
typedef int (*OPENSSL_sk_compfunc)(const void *, const void *);
|
||||
typedef void (*OPENSSL_sk_freefunc)(void *);
|
||||
typedef void *(*OPENSSL_sk_copyfunc)(const void *);
|
||||
|
||||
int OPENSSL_sk_num(const OPENSSL_STACK *);
|
||||
void *OPENSSL_sk_value(const OPENSSL_STACK *, int);
|
||||
|
||||
void *OPENSSL_sk_set(OPENSSL_STACK *st, int i, const void *data);
|
||||
|
||||
OPENSSL_STACK *OPENSSL_sk_new(OPENSSL_sk_compfunc cmp);
|
||||
OPENSSL_STACK *OPENSSL_sk_new_null(void);
|
||||
void OPENSSL_sk_free(OPENSSL_STACK *);
|
||||
void OPENSSL_sk_pop_free(OPENSSL_STACK *st, void (*func) (void *));
|
||||
OPENSSL_STACK *OPENSSL_sk_deep_copy(const OPENSSL_STACK *, OPENSSL_sk_copyfunc c, OPENSSL_sk_freefunc f);
|
||||
int OPENSSL_sk_insert(OPENSSL_STACK *sk, const void *data, int where);
|
||||
void *OPENSSL_sk_delete(OPENSSL_STACK *st, int loc);
|
||||
void *OPENSSL_sk_delete_ptr(OPENSSL_STACK *st, const void *p);
|
||||
int OPENSSL_sk_find(OPENSSL_STACK *st, const void *data);
|
||||
int OPENSSL_sk_find_ex(OPENSSL_STACK *st, const void *data);
|
||||
int OPENSSL_sk_push(OPENSSL_STACK *st, const void *data);
|
||||
int OPENSSL_sk_unshift(OPENSSL_STACK *st, const void *data);
|
||||
void *OPENSSL_sk_shift(OPENSSL_STACK *st);
|
||||
void *OPENSSL_sk_pop(OPENSSL_STACK *st);
|
||||
void OPENSSL_sk_zero(OPENSSL_STACK *st);
|
||||
OPENSSL_sk_compfunc OPENSSL_sk_set_cmp_func(OPENSSL_STACK *sk, OPENSSL_sk_compfunc cmp);
|
||||
OPENSSL_STACK *OPENSSL_sk_dup(const OPENSSL_STACK *st);
|
||||
void OPENSSL_sk_sort(OPENSSL_STACK *st);
|
||||
int OPENSSL_sk_is_sorted(const OPENSSL_STACK *st);
|
||||
|
||||
# if OPENSSL_API_COMPAT < 0x10100000L
|
||||
# define _STACK OPENSSL_STACK
|
||||
# define sk_num OPENSSL_sk_num
|
||||
# define sk_value OPENSSL_sk_value
|
||||
# define sk_set OPENSSL_sk_set
|
||||
# define sk_new OPENSSL_sk_new
|
||||
# define sk_new_null OPENSSL_sk_new_null
|
||||
# define sk_free OPENSSL_sk_free
|
||||
# define sk_pop_free OPENSSL_sk_pop_free
|
||||
# define sk_deep_copy OPENSSL_sk_deep_copy
|
||||
# define sk_insert OPENSSL_sk_insert
|
||||
# define sk_delete OPENSSL_sk_delete
|
||||
# define sk_delete_ptr OPENSSL_sk_delete_ptr
|
||||
# define sk_find OPENSSL_sk_find
|
||||
# define sk_find_ex OPENSSL_sk_find_ex
|
||||
# define sk_push OPENSSL_sk_push
|
||||
# define sk_unshift OPENSSL_sk_unshift
|
||||
# define sk_shift OPENSSL_sk_shift
|
||||
# define sk_pop OPENSSL_sk_pop
|
||||
# define sk_zero OPENSSL_sk_zero
|
||||
# define sk_set_cmp_func OPENSSL_sk_set_cmp_func
|
||||
# define sk_dup OPENSSL_sk_dup
|
||||
# define sk_sort OPENSSL_sk_sort
|
||||
# define sk_is_sorted OPENSSL_sk_is_sorted
|
||||
# endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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_SYMHACKS_H
|
||||
# define HEADER_SYMHACKS_H
|
||||
|
||||
# include <openssl/e_os2.h>
|
||||
|
||||
/* Case insensitive linking causes problems.... */
|
||||
# if defined(OPENSSL_SYS_VMS)
|
||||
# undef ERR_load_CRYPTO_strings
|
||||
# define ERR_load_CRYPTO_strings ERR_load_CRYPTOlib_strings
|
||||
# undef OCSP_crlID_new
|
||||
# define OCSP_crlID_new OCSP_crlID2_new
|
||||
|
||||
# undef d2i_ECPARAMETERS
|
||||
# define d2i_ECPARAMETERS d2i_UC_ECPARAMETERS
|
||||
# undef i2d_ECPARAMETERS
|
||||
# define i2d_ECPARAMETERS i2d_UC_ECPARAMETERS
|
||||
# undef d2i_ECPKPARAMETERS
|
||||
# define d2i_ECPKPARAMETERS d2i_UC_ECPKPARAMETERS
|
||||
# undef i2d_ECPKPARAMETERS
|
||||
# define i2d_ECPKPARAMETERS i2d_UC_ECPKPARAMETERS
|
||||
|
||||
/*
|
||||
* These functions do not seem to exist! However, I'm paranoid... Original
|
||||
* command in x509v3.h: These functions are being redefined in another
|
||||
* directory, and clash when the linker is case-insensitive, so let's hide
|
||||
* them a little, by giving them an extra 'o' at the beginning of the name...
|
||||
*/
|
||||
# undef X509v3_cleanup_extensions
|
||||
# define X509v3_cleanup_extensions oX509v3_cleanup_extensions
|
||||
# undef X509v3_add_extension
|
||||
# define X509v3_add_extension oX509v3_add_extension
|
||||
# undef X509v3_add_netscape_extensions
|
||||
# define X509v3_add_netscape_extensions oX509v3_add_netscape_extensions
|
||||
# undef X509v3_add_standard_extensions
|
||||
# define X509v3_add_standard_extensions oX509v3_add_standard_extensions
|
||||
|
||||
/* This one clashes with CMS_data_create */
|
||||
# undef cms_Data_create
|
||||
# define cms_Data_create priv_cms_Data_create
|
||||
|
||||
# endif
|
||||
|
||||
#endif /* ! defined HEADER_VMS_IDHACKS_H */
|
||||
|
|
@ -0,0 +1,972 @@
|
|||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
|
||||
*
|
||||
* Portions of the attached software ("Contribution") are developed by
|
||||
* SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project.
|
||||
*
|
||||
* The Contribution is licensed pursuant to the OpenSSL open source
|
||||
* license provided above.
|
||||
*
|
||||
* ECC cipher suite support in OpenSSL originally written by
|
||||
* Vipul Gupta and Sumit Gupta of Sun Microsystems Laboratories.
|
||||
*
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright 2005 Nokia. All rights reserved.
|
||||
*
|
||||
* The portions of the attached software ("Contribution") is developed by
|
||||
* Nokia Corporation and is licensed pursuant to the OpenSSL open source
|
||||
* license.
|
||||
*
|
||||
* The Contribution, originally written by Mika Kousa and Pasi Eronen of
|
||||
* Nokia Corporation, consists of the "PSK" (Pre-Shared Key) ciphersuites
|
||||
* support (see RFC 4279) to OpenSSL.
|
||||
*
|
||||
* No patent licenses or other rights except those expressly stated in
|
||||
* the OpenSSL open source license shall be deemed granted or received
|
||||
* expressly, by implication, estoppel, or otherwise.
|
||||
*
|
||||
* No assurances are provided by Nokia that the Contribution does not
|
||||
* infringe the patent or other intellectual property rights of any third
|
||||
* party or that the license provides you with all the necessary rights
|
||||
* to make use of the Contribution.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. IN
|
||||
* ADDITION TO THE DISCLAIMERS INCLUDED IN THE LICENSE, NOKIA
|
||||
* SPECIFICALLY DISCLAIMS ANY LIABILITY FOR CLAIMS BROUGHT BY YOU OR ANY
|
||||
* OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OR
|
||||
* OTHERWISE.
|
||||
*/
|
||||
|
||||
#ifndef HEADER_TLS1_H
|
||||
# define HEADER_TLS1_H
|
||||
|
||||
# include <openssl/buffer.h>
|
||||
# include <openssl/x509.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Default security level if not overridden at config time */
|
||||
# ifndef OPENSSL_TLS_SECURITY_LEVEL
|
||||
# define OPENSSL_TLS_SECURITY_LEVEL 1
|
||||
# endif
|
||||
|
||||
# define TLS1_VERSION 0x0301
|
||||
# define TLS1_1_VERSION 0x0302
|
||||
# define TLS1_2_VERSION 0x0303
|
||||
# define TLS_MAX_VERSION TLS1_2_VERSION
|
||||
|
||||
/* Special value for method supporting multiple versions */
|
||||
# define TLS_ANY_VERSION 0x10000
|
||||
|
||||
# define TLS1_VERSION_MAJOR 0x03
|
||||
# define TLS1_VERSION_MINOR 0x01
|
||||
|
||||
# define TLS1_1_VERSION_MAJOR 0x03
|
||||
# define TLS1_1_VERSION_MINOR 0x02
|
||||
|
||||
# define TLS1_2_VERSION_MAJOR 0x03
|
||||
# define TLS1_2_VERSION_MINOR 0x03
|
||||
|
||||
# define TLS1_get_version(s) \
|
||||
((SSL_version(s) >> 8) == TLS1_VERSION_MAJOR ? SSL_version(s) : 0)
|
||||
|
||||
# define TLS1_get_client_version(s) \
|
||||
((SSL_client_version(s) >> 8) == TLS1_VERSION_MAJOR ? SSL_client_version(s) : 0)
|
||||
|
||||
# define TLS1_AD_DECRYPTION_FAILED 21
|
||||
# define TLS1_AD_RECORD_OVERFLOW 22
|
||||
# define TLS1_AD_UNKNOWN_CA 48/* fatal */
|
||||
# define TLS1_AD_ACCESS_DENIED 49/* fatal */
|
||||
# define TLS1_AD_DECODE_ERROR 50/* fatal */
|
||||
# define TLS1_AD_DECRYPT_ERROR 51
|
||||
# define TLS1_AD_EXPORT_RESTRICTION 60/* fatal */
|
||||
# define TLS1_AD_PROTOCOL_VERSION 70/* fatal */
|
||||
# define TLS1_AD_INSUFFICIENT_SECURITY 71/* fatal */
|
||||
# define TLS1_AD_INTERNAL_ERROR 80/* fatal */
|
||||
# define TLS1_AD_INAPPROPRIATE_FALLBACK 86/* fatal */
|
||||
# define TLS1_AD_USER_CANCELLED 90
|
||||
# define TLS1_AD_NO_RENEGOTIATION 100
|
||||
/* codes 110-114 are from RFC3546 */
|
||||
# define TLS1_AD_UNSUPPORTED_EXTENSION 110
|
||||
# define TLS1_AD_CERTIFICATE_UNOBTAINABLE 111
|
||||
# define TLS1_AD_UNRECOGNIZED_NAME 112
|
||||
# define TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE 113
|
||||
# define TLS1_AD_BAD_CERTIFICATE_HASH_VALUE 114
|
||||
# define TLS1_AD_UNKNOWN_PSK_IDENTITY 115/* fatal */
|
||||
# define TLS1_AD_NO_APPLICATION_PROTOCOL 120 /* fatal */
|
||||
|
||||
/* ExtensionType values from RFC3546 / RFC4366 / RFC6066 */
|
||||
# define TLSEXT_TYPE_server_name 0
|
||||
# define TLSEXT_TYPE_max_fragment_length 1
|
||||
# define TLSEXT_TYPE_client_certificate_url 2
|
||||
# define TLSEXT_TYPE_trusted_ca_keys 3
|
||||
# define TLSEXT_TYPE_truncated_hmac 4
|
||||
# define TLSEXT_TYPE_status_request 5
|
||||
/* ExtensionType values from RFC4681 */
|
||||
# define TLSEXT_TYPE_user_mapping 6
|
||||
/* ExtensionType values from RFC5878 */
|
||||
# define TLSEXT_TYPE_client_authz 7
|
||||
# define TLSEXT_TYPE_server_authz 8
|
||||
/* ExtensionType values from RFC6091 */
|
||||
# define TLSEXT_TYPE_cert_type 9
|
||||
|
||||
/* ExtensionType values from RFC4492 */
|
||||
# define TLSEXT_TYPE_elliptic_curves 10
|
||||
# define TLSEXT_TYPE_ec_point_formats 11
|
||||
|
||||
/* ExtensionType value from RFC5054 */
|
||||
# define TLSEXT_TYPE_srp 12
|
||||
|
||||
/* ExtensionType values from RFC5246 */
|
||||
# define TLSEXT_TYPE_signature_algorithms 13
|
||||
|
||||
/* ExtensionType value from RFC5764 */
|
||||
# define TLSEXT_TYPE_use_srtp 14
|
||||
|
||||
/* ExtensionType value from RFC5620 */
|
||||
# define TLSEXT_TYPE_heartbeat 15
|
||||
|
||||
/* ExtensionType value from RFC7301 */
|
||||
# define TLSEXT_TYPE_application_layer_protocol_negotiation 16
|
||||
|
||||
/*
|
||||
* Extension type for Certificate Transparency
|
||||
* https://tools.ietf.org/html/rfc6962#section-3.3.1
|
||||
*/
|
||||
# define TLSEXT_TYPE_signed_certificate_timestamp 18
|
||||
|
||||
/*
|
||||
* ExtensionType value for TLS padding extension.
|
||||
* http://tools.ietf.org/html/draft-agl-tls-padding
|
||||
*/
|
||||
# define TLSEXT_TYPE_padding 21
|
||||
|
||||
/* ExtensionType value from RFC7366 */
|
||||
# define TLSEXT_TYPE_encrypt_then_mac 22
|
||||
|
||||
/* ExtensionType value from RFC7627 */
|
||||
# define TLSEXT_TYPE_extended_master_secret 23
|
||||
|
||||
/* ExtensionType value from RFC4507 */
|
||||
# define TLSEXT_TYPE_session_ticket 35
|
||||
|
||||
/* Temporary extension type */
|
||||
# define TLSEXT_TYPE_renegotiate 0xff01
|
||||
|
||||
# ifndef OPENSSL_NO_NEXTPROTONEG
|
||||
/* This is not an IANA defined extension number */
|
||||
# define TLSEXT_TYPE_next_proto_neg 13172
|
||||
# endif
|
||||
|
||||
/* NameType value from RFC3546 */
|
||||
# define TLSEXT_NAMETYPE_host_name 0
|
||||
/* status request value from RFC3546 */
|
||||
# define TLSEXT_STATUSTYPE_ocsp 1
|
||||
|
||||
/* ECPointFormat values from RFC4492 */
|
||||
# define TLSEXT_ECPOINTFORMAT_first 0
|
||||
# define TLSEXT_ECPOINTFORMAT_uncompressed 0
|
||||
# define TLSEXT_ECPOINTFORMAT_ansiX962_compressed_prime 1
|
||||
# define TLSEXT_ECPOINTFORMAT_ansiX962_compressed_char2 2
|
||||
# define TLSEXT_ECPOINTFORMAT_last 2
|
||||
|
||||
/* Signature and hash algorithms from RFC5246 */
|
||||
# define TLSEXT_signature_anonymous 0
|
||||
# define TLSEXT_signature_rsa 1
|
||||
# define TLSEXT_signature_dsa 2
|
||||
# define TLSEXT_signature_ecdsa 3
|
||||
# define TLSEXT_signature_gostr34102001 237
|
||||
# define TLSEXT_signature_gostr34102012_256 238
|
||||
# define TLSEXT_signature_gostr34102012_512 239
|
||||
|
||||
/* Total number of different signature algorithms */
|
||||
# define TLSEXT_signature_num 7
|
||||
|
||||
# define TLSEXT_hash_none 0
|
||||
# define TLSEXT_hash_md5 1
|
||||
# define TLSEXT_hash_sha1 2
|
||||
# define TLSEXT_hash_sha224 3
|
||||
# define TLSEXT_hash_sha256 4
|
||||
# define TLSEXT_hash_sha384 5
|
||||
# define TLSEXT_hash_sha512 6
|
||||
# define TLSEXT_hash_gostr3411 237
|
||||
# define TLSEXT_hash_gostr34112012_256 238
|
||||
# define TLSEXT_hash_gostr34112012_512 239
|
||||
|
||||
/* Total number of different digest algorithms */
|
||||
|
||||
# define TLSEXT_hash_num 10
|
||||
|
||||
/* Flag set for unrecognised algorithms */
|
||||
# define TLSEXT_nid_unknown 0x1000000
|
||||
|
||||
/* ECC curves */
|
||||
|
||||
# define TLSEXT_curve_P_256 23
|
||||
# define TLSEXT_curve_P_384 24
|
||||
|
||||
# define TLSEXT_MAXLEN_host_name 255
|
||||
|
||||
__owur const char *SSL_get_servername(const SSL *s, const int type);
|
||||
__owur int SSL_get_servername_type(const SSL *s);
|
||||
/*
|
||||
* SSL_export_keying_material exports a value derived from the master secret,
|
||||
* as specified in RFC 5705. It writes |olen| bytes to |out| given a label and
|
||||
* optional context. (Since a zero length context is allowed, the |use_context|
|
||||
* flag controls whether a context is included.) It returns 1 on success and
|
||||
* zero otherwise.
|
||||
*/
|
||||
__owur int SSL_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);
|
||||
|
||||
int SSL_get_sigalgs(SSL *s, int idx,
|
||||
int *psign, int *phash, int *psignandhash,
|
||||
unsigned char *rsig, unsigned char *rhash);
|
||||
|
||||
int SSL_get_shared_sigalgs(SSL *s, int idx,
|
||||
int *psign, int *phash, int *psignandhash,
|
||||
unsigned char *rsig, unsigned char *rhash);
|
||||
|
||||
__owur int SSL_check_chain(SSL *s, X509 *x, EVP_PKEY *pk, STACK_OF(X509) *chain);
|
||||
|
||||
# define SSL_set_tlsext_host_name(s,name) \
|
||||
SSL_ctrl(s,SSL_CTRL_SET_TLSEXT_HOSTNAME,TLSEXT_NAMETYPE_host_name,(char *)name)
|
||||
|
||||
# define SSL_set_tlsext_debug_callback(ssl, cb) \
|
||||
SSL_callback_ctrl(ssl,SSL_CTRL_SET_TLSEXT_DEBUG_CB,(void (*)(void))cb)
|
||||
|
||||
# define SSL_set_tlsext_debug_arg(ssl, arg) \
|
||||
SSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_DEBUG_ARG,0, (void *)arg)
|
||||
|
||||
# define SSL_get_tlsext_status_type(ssl) \
|
||||
SSL_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_TYPE,0, NULL)
|
||||
|
||||
# define SSL_set_tlsext_status_type(ssl, type) \
|
||||
SSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE,type, NULL)
|
||||
|
||||
# define SSL_get_tlsext_status_exts(ssl, arg) \
|
||||
SSL_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_EXTS,0, (void *)arg)
|
||||
|
||||
# define SSL_set_tlsext_status_exts(ssl, arg) \
|
||||
SSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_EXTS,0, (void *)arg)
|
||||
|
||||
# define SSL_get_tlsext_status_ids(ssl, arg) \
|
||||
SSL_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_IDS,0, (void *)arg)
|
||||
|
||||
# define SSL_set_tlsext_status_ids(ssl, arg) \
|
||||
SSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_IDS,0, (void *)arg)
|
||||
|
||||
# define SSL_get_tlsext_status_ocsp_resp(ssl, arg) \
|
||||
SSL_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_OCSP_RESP,0, (void *)arg)
|
||||
|
||||
# define SSL_set_tlsext_status_ocsp_resp(ssl, arg, arglen) \
|
||||
SSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_OCSP_RESP,arglen, (void *)arg)
|
||||
|
||||
# define SSL_CTX_set_tlsext_servername_callback(ctx, cb) \
|
||||
SSL_CTX_callback_ctrl(ctx,SSL_CTRL_SET_TLSEXT_SERVERNAME_CB,(void (*)(void))cb)
|
||||
|
||||
# define SSL_TLSEXT_ERR_OK 0
|
||||
# define SSL_TLSEXT_ERR_ALERT_WARNING 1
|
||||
# define SSL_TLSEXT_ERR_ALERT_FATAL 2
|
||||
# define SSL_TLSEXT_ERR_NOACK 3
|
||||
|
||||
# define SSL_CTX_set_tlsext_servername_arg(ctx, arg) \
|
||||
SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG,0, (void *)arg)
|
||||
|
||||
# define SSL_CTX_get_tlsext_ticket_keys(ctx, keys, keylen) \
|
||||
SSL_CTX_ctrl((ctx),SSL_CTRL_GET_TLSEXT_TICKET_KEYS,(keylen),(keys))
|
||||
# define SSL_CTX_set_tlsext_ticket_keys(ctx, keys, keylen) \
|
||||
SSL_CTX_ctrl((ctx),SSL_CTRL_SET_TLSEXT_TICKET_KEYS,(keylen),(keys))
|
||||
|
||||
# define SSL_CTX_get_tlsext_status_cb(ssl, cb) \
|
||||
SSL_CTX_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_CB,0, (void (**)(void))cb)
|
||||
# define SSL_CTX_set_tlsext_status_cb(ssl, cb) \
|
||||
SSL_CTX_callback_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB,(void (*)(void))cb)
|
||||
|
||||
# define SSL_CTX_get_tlsext_status_arg(ssl, arg) \
|
||||
SSL_CTX_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_CB_ARG,0, (void *)arg
|
||||
# define SSL_CTX_set_tlsext_status_arg(ssl, arg) \
|
||||
SSL_CTX_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB_ARG,0, (void *)arg)
|
||||
|
||||
#define SSL_CTX_set_tlsext_status_type(ssl, type) \
|
||||
SSL_CTX_ctrl(ssl, SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE, type, NULL)
|
||||
|
||||
#define SSL_CTX_get_tlsext_status_type(ssl) \
|
||||
SSL_CTX_ctrl(ssl, SSL_CTRL_GET_TLSEXT_STATUS_REQ_TYPE, 0, NULL)
|
||||
|
||||
# define SSL_CTX_set_tlsext_ticket_key_cb(ssl, cb) \
|
||||
SSL_CTX_callback_ctrl(ssl,SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB,(void (*)(void))cb)
|
||||
|
||||
# ifndef OPENSSL_NO_HEARTBEATS
|
||||
# define SSL_DTLSEXT_HB_ENABLED 0x01
|
||||
# define SSL_DTLSEXT_HB_DONT_SEND_REQUESTS 0x02
|
||||
# define SSL_DTLSEXT_HB_DONT_RECV_REQUESTS 0x04
|
||||
# define SSL_get_dtlsext_heartbeat_pending(ssl) \
|
||||
SSL_ctrl((ssl),SSL_CTRL_GET_DTLS_EXT_HEARTBEAT_PENDING,0,NULL)
|
||||
# define SSL_set_dtlsext_heartbeat_no_requests(ssl, arg) \
|
||||
SSL_ctrl((ssl),SSL_CTRL_SET_DTLS_EXT_HEARTBEAT_NO_REQUESTS,arg,NULL)
|
||||
|
||||
# if OPENSSL_API_COMPAT < 0x10100000L
|
||||
# define SSL_CTRL_TLS_EXT_SEND_HEARTBEAT \
|
||||
SSL_CTRL_DTLS_EXT_SEND_HEARTBEAT
|
||||
# define SSL_CTRL_GET_TLS_EXT_HEARTBEAT_PENDING \
|
||||
SSL_CTRL_GET_DTLS_EXT_HEARTBEAT_PENDING
|
||||
# define SSL_CTRL_SET_TLS_EXT_HEARTBEAT_NO_REQUESTS \
|
||||
SSL_CTRL_SET_DTLS_EXT_HEARTBEAT_NO_REQUESTS
|
||||
# define SSL_TLSEXT_HB_ENABLED \
|
||||
SSL_DTLSEXT_HB_ENABLED
|
||||
# define SSL_TLSEXT_HB_DONT_SEND_REQUESTS \
|
||||
SSL_DTLSEXT_HB_DONT_SEND_REQUESTS
|
||||
# define SSL_TLSEXT_HB_DONT_RECV_REQUESTS \
|
||||
SSL_DTLSEXT_HB_DONT_RECV_REQUESTS
|
||||
# define SSL_get_tlsext_heartbeat_pending(ssl) \
|
||||
SSL_get_dtlsext_heartbeat_pending(ssl)
|
||||
# define SSL_set_tlsext_heartbeat_no_requests(ssl, arg) \
|
||||
SSL_set_dtlsext_heartbeat_no_requests(ssl, arg)
|
||||
# endif
|
||||
# endif
|
||||
|
||||
/* PSK ciphersuites from 4279 */
|
||||
# define TLS1_CK_PSK_WITH_RC4_128_SHA 0x0300008A
|
||||
# define TLS1_CK_PSK_WITH_3DES_EDE_CBC_SHA 0x0300008B
|
||||
# define TLS1_CK_PSK_WITH_AES_128_CBC_SHA 0x0300008C
|
||||
# define TLS1_CK_PSK_WITH_AES_256_CBC_SHA 0x0300008D
|
||||
|
||||
# define TLS1_CK_DHE_PSK_WITH_RC4_128_SHA 0x0300008E
|
||||
# define TLS1_CK_DHE_PSK_WITH_3DES_EDE_CBC_SHA 0x0300008F
|
||||
# define TLS1_CK_DHE_PSK_WITH_AES_128_CBC_SHA 0x03000090
|
||||
# define TLS1_CK_DHE_PSK_WITH_AES_256_CBC_SHA 0x03000091
|
||||
|
||||
# define TLS1_CK_RSA_PSK_WITH_RC4_128_SHA 0x03000092
|
||||
# define TLS1_CK_RSA_PSK_WITH_3DES_EDE_CBC_SHA 0x03000093
|
||||
# define TLS1_CK_RSA_PSK_WITH_AES_128_CBC_SHA 0x03000094
|
||||
# define TLS1_CK_RSA_PSK_WITH_AES_256_CBC_SHA 0x03000095
|
||||
|
||||
/* PSK ciphersuites from 5487 */
|
||||
# define TLS1_CK_PSK_WITH_AES_128_GCM_SHA256 0x030000A8
|
||||
# define TLS1_CK_PSK_WITH_AES_256_GCM_SHA384 0x030000A9
|
||||
# define TLS1_CK_DHE_PSK_WITH_AES_128_GCM_SHA256 0x030000AA
|
||||
# define TLS1_CK_DHE_PSK_WITH_AES_256_GCM_SHA384 0x030000AB
|
||||
# define TLS1_CK_RSA_PSK_WITH_AES_128_GCM_SHA256 0x030000AC
|
||||
# define TLS1_CK_RSA_PSK_WITH_AES_256_GCM_SHA384 0x030000AD
|
||||
|
||||
# define TLS1_CK_PSK_WITH_AES_128_CBC_SHA256 0x030000AE
|
||||
# define TLS1_CK_PSK_WITH_AES_256_CBC_SHA384 0x030000AF
|
||||
# define TLS1_CK_PSK_WITH_NULL_SHA256 0x030000B0
|
||||
# define TLS1_CK_PSK_WITH_NULL_SHA384 0x030000B1
|
||||
|
||||
# define TLS1_CK_DHE_PSK_WITH_AES_128_CBC_SHA256 0x030000B2
|
||||
# define TLS1_CK_DHE_PSK_WITH_AES_256_CBC_SHA384 0x030000B3
|
||||
# define TLS1_CK_DHE_PSK_WITH_NULL_SHA256 0x030000B4
|
||||
# define TLS1_CK_DHE_PSK_WITH_NULL_SHA384 0x030000B5
|
||||
|
||||
# define TLS1_CK_RSA_PSK_WITH_AES_128_CBC_SHA256 0x030000B6
|
||||
# define TLS1_CK_RSA_PSK_WITH_AES_256_CBC_SHA384 0x030000B7
|
||||
# define TLS1_CK_RSA_PSK_WITH_NULL_SHA256 0x030000B8
|
||||
# define TLS1_CK_RSA_PSK_WITH_NULL_SHA384 0x030000B9
|
||||
|
||||
/* NULL PSK ciphersuites from RFC4785 */
|
||||
# define TLS1_CK_PSK_WITH_NULL_SHA 0x0300002C
|
||||
# define TLS1_CK_DHE_PSK_WITH_NULL_SHA 0x0300002D
|
||||
# define TLS1_CK_RSA_PSK_WITH_NULL_SHA 0x0300002E
|
||||
|
||||
/* AES ciphersuites from RFC3268 */
|
||||
# define TLS1_CK_RSA_WITH_AES_128_SHA 0x0300002F
|
||||
# define TLS1_CK_DH_DSS_WITH_AES_128_SHA 0x03000030
|
||||
# define TLS1_CK_DH_RSA_WITH_AES_128_SHA 0x03000031
|
||||
# define TLS1_CK_DHE_DSS_WITH_AES_128_SHA 0x03000032
|
||||
# define TLS1_CK_DHE_RSA_WITH_AES_128_SHA 0x03000033
|
||||
# define TLS1_CK_ADH_WITH_AES_128_SHA 0x03000034
|
||||
|
||||
# define TLS1_CK_RSA_WITH_AES_256_SHA 0x03000035
|
||||
# define TLS1_CK_DH_DSS_WITH_AES_256_SHA 0x03000036
|
||||
# define TLS1_CK_DH_RSA_WITH_AES_256_SHA 0x03000037
|
||||
# define TLS1_CK_DHE_DSS_WITH_AES_256_SHA 0x03000038
|
||||
# define TLS1_CK_DHE_RSA_WITH_AES_256_SHA 0x03000039
|
||||
# define TLS1_CK_ADH_WITH_AES_256_SHA 0x0300003A
|
||||
|
||||
/* TLS v1.2 ciphersuites */
|
||||
# define TLS1_CK_RSA_WITH_NULL_SHA256 0x0300003B
|
||||
# define TLS1_CK_RSA_WITH_AES_128_SHA256 0x0300003C
|
||||
# define TLS1_CK_RSA_WITH_AES_256_SHA256 0x0300003D
|
||||
# define TLS1_CK_DH_DSS_WITH_AES_128_SHA256 0x0300003E
|
||||
# define TLS1_CK_DH_RSA_WITH_AES_128_SHA256 0x0300003F
|
||||
# define TLS1_CK_DHE_DSS_WITH_AES_128_SHA256 0x03000040
|
||||
|
||||
/* Camellia ciphersuites from RFC4132 */
|
||||
# define TLS1_CK_RSA_WITH_CAMELLIA_128_CBC_SHA 0x03000041
|
||||
# define TLS1_CK_DH_DSS_WITH_CAMELLIA_128_CBC_SHA 0x03000042
|
||||
# define TLS1_CK_DH_RSA_WITH_CAMELLIA_128_CBC_SHA 0x03000043
|
||||
# define TLS1_CK_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA 0x03000044
|
||||
# define TLS1_CK_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA 0x03000045
|
||||
# define TLS1_CK_ADH_WITH_CAMELLIA_128_CBC_SHA 0x03000046
|
||||
|
||||
/* TLS v1.2 ciphersuites */
|
||||
# define TLS1_CK_DHE_RSA_WITH_AES_128_SHA256 0x03000067
|
||||
# define TLS1_CK_DH_DSS_WITH_AES_256_SHA256 0x03000068
|
||||
# define TLS1_CK_DH_RSA_WITH_AES_256_SHA256 0x03000069
|
||||
# define TLS1_CK_DHE_DSS_WITH_AES_256_SHA256 0x0300006A
|
||||
# define TLS1_CK_DHE_RSA_WITH_AES_256_SHA256 0x0300006B
|
||||
# define TLS1_CK_ADH_WITH_AES_128_SHA256 0x0300006C
|
||||
# define TLS1_CK_ADH_WITH_AES_256_SHA256 0x0300006D
|
||||
|
||||
/* Camellia ciphersuites from RFC4132 */
|
||||
# define TLS1_CK_RSA_WITH_CAMELLIA_256_CBC_SHA 0x03000084
|
||||
# define TLS1_CK_DH_DSS_WITH_CAMELLIA_256_CBC_SHA 0x03000085
|
||||
# define TLS1_CK_DH_RSA_WITH_CAMELLIA_256_CBC_SHA 0x03000086
|
||||
# define TLS1_CK_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA 0x03000087
|
||||
# define TLS1_CK_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA 0x03000088
|
||||
# define TLS1_CK_ADH_WITH_CAMELLIA_256_CBC_SHA 0x03000089
|
||||
|
||||
/* SEED ciphersuites from RFC4162 */
|
||||
# define TLS1_CK_RSA_WITH_SEED_SHA 0x03000096
|
||||
# define TLS1_CK_DH_DSS_WITH_SEED_SHA 0x03000097
|
||||
# define TLS1_CK_DH_RSA_WITH_SEED_SHA 0x03000098
|
||||
# define TLS1_CK_DHE_DSS_WITH_SEED_SHA 0x03000099
|
||||
# define TLS1_CK_DHE_RSA_WITH_SEED_SHA 0x0300009A
|
||||
# define TLS1_CK_ADH_WITH_SEED_SHA 0x0300009B
|
||||
|
||||
/* TLS v1.2 GCM ciphersuites from RFC5288 */
|
||||
# define TLS1_CK_RSA_WITH_AES_128_GCM_SHA256 0x0300009C
|
||||
# define TLS1_CK_RSA_WITH_AES_256_GCM_SHA384 0x0300009D
|
||||
# define TLS1_CK_DHE_RSA_WITH_AES_128_GCM_SHA256 0x0300009E
|
||||
# define TLS1_CK_DHE_RSA_WITH_AES_256_GCM_SHA384 0x0300009F
|
||||
# define TLS1_CK_DH_RSA_WITH_AES_128_GCM_SHA256 0x030000A0
|
||||
# define TLS1_CK_DH_RSA_WITH_AES_256_GCM_SHA384 0x030000A1
|
||||
# define TLS1_CK_DHE_DSS_WITH_AES_128_GCM_SHA256 0x030000A2
|
||||
# define TLS1_CK_DHE_DSS_WITH_AES_256_GCM_SHA384 0x030000A3
|
||||
# define TLS1_CK_DH_DSS_WITH_AES_128_GCM_SHA256 0x030000A4
|
||||
# define TLS1_CK_DH_DSS_WITH_AES_256_GCM_SHA384 0x030000A5
|
||||
# define TLS1_CK_ADH_WITH_AES_128_GCM_SHA256 0x030000A6
|
||||
# define TLS1_CK_ADH_WITH_AES_256_GCM_SHA384 0x030000A7
|
||||
|
||||
/* CCM ciphersuites from RFC6655 */
|
||||
# define TLS1_CK_RSA_WITH_AES_128_CCM 0x0300C09C
|
||||
# define TLS1_CK_RSA_WITH_AES_256_CCM 0x0300C09D
|
||||
# define TLS1_CK_DHE_RSA_WITH_AES_128_CCM 0x0300C09E
|
||||
# define TLS1_CK_DHE_RSA_WITH_AES_256_CCM 0x0300C09F
|
||||
# define TLS1_CK_RSA_WITH_AES_128_CCM_8 0x0300C0A0
|
||||
# define TLS1_CK_RSA_WITH_AES_256_CCM_8 0x0300C0A1
|
||||
# define TLS1_CK_DHE_RSA_WITH_AES_128_CCM_8 0x0300C0A2
|
||||
# define TLS1_CK_DHE_RSA_WITH_AES_256_CCM_8 0x0300C0A3
|
||||
# define TLS1_CK_PSK_WITH_AES_128_CCM 0x0300C0A4
|
||||
# define TLS1_CK_PSK_WITH_AES_256_CCM 0x0300C0A5
|
||||
# define TLS1_CK_DHE_PSK_WITH_AES_128_CCM 0x0300C0A6
|
||||
# define TLS1_CK_DHE_PSK_WITH_AES_256_CCM 0x0300C0A7
|
||||
# define TLS1_CK_PSK_WITH_AES_128_CCM_8 0x0300C0A8
|
||||
# define TLS1_CK_PSK_WITH_AES_256_CCM_8 0x0300C0A9
|
||||
# define TLS1_CK_DHE_PSK_WITH_AES_128_CCM_8 0x0300C0AA
|
||||
# define TLS1_CK_DHE_PSK_WITH_AES_256_CCM_8 0x0300C0AB
|
||||
|
||||
/* CCM ciphersuites from RFC7251 */
|
||||
# define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_CCM 0x0300C0AC
|
||||
# define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_CCM 0x0300C0AD
|
||||
# define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_CCM_8 0x0300C0AE
|
||||
# define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_CCM_8 0x0300C0AF
|
||||
|
||||
/* TLS 1.2 Camellia SHA-256 ciphersuites from RFC5932 */
|
||||
# define TLS1_CK_RSA_WITH_CAMELLIA_128_CBC_SHA256 0x030000BA
|
||||
# define TLS1_CK_DH_DSS_WITH_CAMELLIA_128_CBC_SHA256 0x030000BB
|
||||
# define TLS1_CK_DH_RSA_WITH_CAMELLIA_128_CBC_SHA256 0x030000BC
|
||||
# define TLS1_CK_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256 0x030000BD
|
||||
# define TLS1_CK_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 0x030000BE
|
||||
# define TLS1_CK_ADH_WITH_CAMELLIA_128_CBC_SHA256 0x030000BF
|
||||
|
||||
# define TLS1_CK_RSA_WITH_CAMELLIA_256_CBC_SHA256 0x030000C0
|
||||
# define TLS1_CK_DH_DSS_WITH_CAMELLIA_256_CBC_SHA256 0x030000C1
|
||||
# define TLS1_CK_DH_RSA_WITH_CAMELLIA_256_CBC_SHA256 0x030000C2
|
||||
# define TLS1_CK_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256 0x030000C3
|
||||
# define TLS1_CK_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 0x030000C4
|
||||
# define TLS1_CK_ADH_WITH_CAMELLIA_256_CBC_SHA256 0x030000C5
|
||||
|
||||
/* ECC ciphersuites from RFC4492 */
|
||||
# define TLS1_CK_ECDH_ECDSA_WITH_NULL_SHA 0x0300C001
|
||||
# define TLS1_CK_ECDH_ECDSA_WITH_RC4_128_SHA 0x0300C002
|
||||
# define TLS1_CK_ECDH_ECDSA_WITH_DES_192_CBC3_SHA 0x0300C003
|
||||
# define TLS1_CK_ECDH_ECDSA_WITH_AES_128_CBC_SHA 0x0300C004
|
||||
# define TLS1_CK_ECDH_ECDSA_WITH_AES_256_CBC_SHA 0x0300C005
|
||||
|
||||
# define TLS1_CK_ECDHE_ECDSA_WITH_NULL_SHA 0x0300C006
|
||||
# define TLS1_CK_ECDHE_ECDSA_WITH_RC4_128_SHA 0x0300C007
|
||||
# define TLS1_CK_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA 0x0300C008
|
||||
# define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_CBC_SHA 0x0300C009
|
||||
# define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_CBC_SHA 0x0300C00A
|
||||
|
||||
# define TLS1_CK_ECDH_RSA_WITH_NULL_SHA 0x0300C00B
|
||||
# define TLS1_CK_ECDH_RSA_WITH_RC4_128_SHA 0x0300C00C
|
||||
# define TLS1_CK_ECDH_RSA_WITH_DES_192_CBC3_SHA 0x0300C00D
|
||||
# define TLS1_CK_ECDH_RSA_WITH_AES_128_CBC_SHA 0x0300C00E
|
||||
# define TLS1_CK_ECDH_RSA_WITH_AES_256_CBC_SHA 0x0300C00F
|
||||
|
||||
# define TLS1_CK_ECDHE_RSA_WITH_NULL_SHA 0x0300C010
|
||||
# define TLS1_CK_ECDHE_RSA_WITH_RC4_128_SHA 0x0300C011
|
||||
# define TLS1_CK_ECDHE_RSA_WITH_DES_192_CBC3_SHA 0x0300C012
|
||||
# define TLS1_CK_ECDHE_RSA_WITH_AES_128_CBC_SHA 0x0300C013
|
||||
# define TLS1_CK_ECDHE_RSA_WITH_AES_256_CBC_SHA 0x0300C014
|
||||
|
||||
# define TLS1_CK_ECDH_anon_WITH_NULL_SHA 0x0300C015
|
||||
# define TLS1_CK_ECDH_anon_WITH_RC4_128_SHA 0x0300C016
|
||||
# define TLS1_CK_ECDH_anon_WITH_DES_192_CBC3_SHA 0x0300C017
|
||||
# define TLS1_CK_ECDH_anon_WITH_AES_128_CBC_SHA 0x0300C018
|
||||
# define TLS1_CK_ECDH_anon_WITH_AES_256_CBC_SHA 0x0300C019
|
||||
|
||||
/* SRP ciphersuites from RFC 5054 */
|
||||
# define TLS1_CK_SRP_SHA_WITH_3DES_EDE_CBC_SHA 0x0300C01A
|
||||
# define TLS1_CK_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA 0x0300C01B
|
||||
# define TLS1_CK_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA 0x0300C01C
|
||||
# define TLS1_CK_SRP_SHA_WITH_AES_128_CBC_SHA 0x0300C01D
|
||||
# define TLS1_CK_SRP_SHA_RSA_WITH_AES_128_CBC_SHA 0x0300C01E
|
||||
# define TLS1_CK_SRP_SHA_DSS_WITH_AES_128_CBC_SHA 0x0300C01F
|
||||
# define TLS1_CK_SRP_SHA_WITH_AES_256_CBC_SHA 0x0300C020
|
||||
# define TLS1_CK_SRP_SHA_RSA_WITH_AES_256_CBC_SHA 0x0300C021
|
||||
# define TLS1_CK_SRP_SHA_DSS_WITH_AES_256_CBC_SHA 0x0300C022
|
||||
|
||||
/* ECDH HMAC based ciphersuites from RFC5289 */
|
||||
|
||||
# define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_SHA256 0x0300C023
|
||||
# define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_SHA384 0x0300C024
|
||||
# define TLS1_CK_ECDH_ECDSA_WITH_AES_128_SHA256 0x0300C025
|
||||
# define TLS1_CK_ECDH_ECDSA_WITH_AES_256_SHA384 0x0300C026
|
||||
# define TLS1_CK_ECDHE_RSA_WITH_AES_128_SHA256 0x0300C027
|
||||
# define TLS1_CK_ECDHE_RSA_WITH_AES_256_SHA384 0x0300C028
|
||||
# define TLS1_CK_ECDH_RSA_WITH_AES_128_SHA256 0x0300C029
|
||||
# define TLS1_CK_ECDH_RSA_WITH_AES_256_SHA384 0x0300C02A
|
||||
|
||||
/* ECDH GCM based ciphersuites from RFC5289 */
|
||||
# define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 0x0300C02B
|
||||
# define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 0x0300C02C
|
||||
# define TLS1_CK_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 0x0300C02D
|
||||
# define TLS1_CK_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 0x0300C02E
|
||||
# define TLS1_CK_ECDHE_RSA_WITH_AES_128_GCM_SHA256 0x0300C02F
|
||||
# define TLS1_CK_ECDHE_RSA_WITH_AES_256_GCM_SHA384 0x0300C030
|
||||
# define TLS1_CK_ECDH_RSA_WITH_AES_128_GCM_SHA256 0x0300C031
|
||||
# define TLS1_CK_ECDH_RSA_WITH_AES_256_GCM_SHA384 0x0300C032
|
||||
|
||||
/* ECDHE PSK ciphersuites from RFC5489 */
|
||||
# define TLS1_CK_ECDHE_PSK_WITH_RC4_128_SHA 0x0300C033
|
||||
# define TLS1_CK_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA 0x0300C034
|
||||
# define TLS1_CK_ECDHE_PSK_WITH_AES_128_CBC_SHA 0x0300C035
|
||||
# define TLS1_CK_ECDHE_PSK_WITH_AES_256_CBC_SHA 0x0300C036
|
||||
|
||||
# define TLS1_CK_ECDHE_PSK_WITH_AES_128_CBC_SHA256 0x0300C037
|
||||
# define TLS1_CK_ECDHE_PSK_WITH_AES_256_CBC_SHA384 0x0300C038
|
||||
|
||||
/* NULL PSK ciphersuites from RFC4785 */
|
||||
|
||||
# define TLS1_CK_ECDHE_PSK_WITH_NULL_SHA 0x0300C039
|
||||
# define TLS1_CK_ECDHE_PSK_WITH_NULL_SHA256 0x0300C03A
|
||||
# define TLS1_CK_ECDHE_PSK_WITH_NULL_SHA384 0x0300C03B
|
||||
|
||||
/* Camellia-CBC ciphersuites from RFC6367 */
|
||||
# define TLS1_CK_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 0x0300C072
|
||||
# define TLS1_CK_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 0x0300C073
|
||||
# define TLS1_CK_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 0x0300C074
|
||||
# define TLS1_CK_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 0x0300C075
|
||||
# define TLS1_CK_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 0x0300C076
|
||||
# define TLS1_CK_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384 0x0300C077
|
||||
# define TLS1_CK_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256 0x0300C078
|
||||
# define TLS1_CK_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384 0x0300C079
|
||||
|
||||
# define TLS1_CK_PSK_WITH_CAMELLIA_128_CBC_SHA256 0x0300C094
|
||||
# define TLS1_CK_PSK_WITH_CAMELLIA_256_CBC_SHA384 0x0300C095
|
||||
# define TLS1_CK_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 0x0300C096
|
||||
# define TLS1_CK_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 0x0300C097
|
||||
# define TLS1_CK_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256 0x0300C098
|
||||
# define TLS1_CK_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384 0x0300C099
|
||||
# define TLS1_CK_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 0x0300C09A
|
||||
# define TLS1_CK_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 0x0300C09B
|
||||
|
||||
/* draft-ietf-tls-chacha20-poly1305-03 */
|
||||
# define TLS1_CK_ECDHE_RSA_WITH_CHACHA20_POLY1305 0x0300CCA8
|
||||
# define TLS1_CK_ECDHE_ECDSA_WITH_CHACHA20_POLY1305 0x0300CCA9
|
||||
# define TLS1_CK_DHE_RSA_WITH_CHACHA20_POLY1305 0x0300CCAA
|
||||
# define TLS1_CK_PSK_WITH_CHACHA20_POLY1305 0x0300CCAB
|
||||
# define TLS1_CK_ECDHE_PSK_WITH_CHACHA20_POLY1305 0x0300CCAC
|
||||
# define TLS1_CK_DHE_PSK_WITH_CHACHA20_POLY1305 0x0300CCAD
|
||||
# define TLS1_CK_RSA_PSK_WITH_CHACHA20_POLY1305 0x0300CCAE
|
||||
|
||||
/*
|
||||
* XXX Backward compatibility alert: Older versions of OpenSSL gave some DHE
|
||||
* ciphers names with "EDH" instead of "DHE". Going forward, we should be
|
||||
* using DHE everywhere, though we may indefinitely maintain aliases for
|
||||
* users or configurations that used "EDH"
|
||||
*/
|
||||
# define TLS1_TXT_DHE_DSS_WITH_RC4_128_SHA "DHE-DSS-RC4-SHA"
|
||||
|
||||
# define TLS1_TXT_PSK_WITH_NULL_SHA "PSK-NULL-SHA"
|
||||
# define TLS1_TXT_DHE_PSK_WITH_NULL_SHA "DHE-PSK-NULL-SHA"
|
||||
# define TLS1_TXT_RSA_PSK_WITH_NULL_SHA "RSA-PSK-NULL-SHA"
|
||||
|
||||
/* AES ciphersuites from RFC3268 */
|
||||
# define TLS1_TXT_RSA_WITH_AES_128_SHA "AES128-SHA"
|
||||
# define TLS1_TXT_DH_DSS_WITH_AES_128_SHA "DH-DSS-AES128-SHA"
|
||||
# define TLS1_TXT_DH_RSA_WITH_AES_128_SHA "DH-RSA-AES128-SHA"
|
||||
# define TLS1_TXT_DHE_DSS_WITH_AES_128_SHA "DHE-DSS-AES128-SHA"
|
||||
# define TLS1_TXT_DHE_RSA_WITH_AES_128_SHA "DHE-RSA-AES128-SHA"
|
||||
# define TLS1_TXT_ADH_WITH_AES_128_SHA "ADH-AES128-SHA"
|
||||
|
||||
# define TLS1_TXT_RSA_WITH_AES_256_SHA "AES256-SHA"
|
||||
# define TLS1_TXT_DH_DSS_WITH_AES_256_SHA "DH-DSS-AES256-SHA"
|
||||
# define TLS1_TXT_DH_RSA_WITH_AES_256_SHA "DH-RSA-AES256-SHA"
|
||||
# define TLS1_TXT_DHE_DSS_WITH_AES_256_SHA "DHE-DSS-AES256-SHA"
|
||||
# define TLS1_TXT_DHE_RSA_WITH_AES_256_SHA "DHE-RSA-AES256-SHA"
|
||||
# define TLS1_TXT_ADH_WITH_AES_256_SHA "ADH-AES256-SHA"
|
||||
|
||||
/* ECC ciphersuites from RFC4492 */
|
||||
# define TLS1_TXT_ECDH_ECDSA_WITH_NULL_SHA "ECDH-ECDSA-NULL-SHA"
|
||||
# define TLS1_TXT_ECDH_ECDSA_WITH_RC4_128_SHA "ECDH-ECDSA-RC4-SHA"
|
||||
# define TLS1_TXT_ECDH_ECDSA_WITH_DES_192_CBC3_SHA "ECDH-ECDSA-DES-CBC3-SHA"
|
||||
# define TLS1_TXT_ECDH_ECDSA_WITH_AES_128_CBC_SHA "ECDH-ECDSA-AES128-SHA"
|
||||
# define TLS1_TXT_ECDH_ECDSA_WITH_AES_256_CBC_SHA "ECDH-ECDSA-AES256-SHA"
|
||||
|
||||
# define TLS1_TXT_ECDHE_ECDSA_WITH_NULL_SHA "ECDHE-ECDSA-NULL-SHA"
|
||||
# define TLS1_TXT_ECDHE_ECDSA_WITH_RC4_128_SHA "ECDHE-ECDSA-RC4-SHA"
|
||||
# define TLS1_TXT_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA "ECDHE-ECDSA-DES-CBC3-SHA"
|
||||
# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_CBC_SHA "ECDHE-ECDSA-AES128-SHA"
|
||||
# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_CBC_SHA "ECDHE-ECDSA-AES256-SHA"
|
||||
|
||||
# define TLS1_TXT_ECDH_RSA_WITH_NULL_SHA "ECDH-RSA-NULL-SHA"
|
||||
# define TLS1_TXT_ECDH_RSA_WITH_RC4_128_SHA "ECDH-RSA-RC4-SHA"
|
||||
# define TLS1_TXT_ECDH_RSA_WITH_DES_192_CBC3_SHA "ECDH-RSA-DES-CBC3-SHA"
|
||||
# define TLS1_TXT_ECDH_RSA_WITH_AES_128_CBC_SHA "ECDH-RSA-AES128-SHA"
|
||||
# define TLS1_TXT_ECDH_RSA_WITH_AES_256_CBC_SHA "ECDH-RSA-AES256-SHA"
|
||||
|
||||
# define TLS1_TXT_ECDHE_RSA_WITH_NULL_SHA "ECDHE-RSA-NULL-SHA"
|
||||
# define TLS1_TXT_ECDHE_RSA_WITH_RC4_128_SHA "ECDHE-RSA-RC4-SHA"
|
||||
# define TLS1_TXT_ECDHE_RSA_WITH_DES_192_CBC3_SHA "ECDHE-RSA-DES-CBC3-SHA"
|
||||
# define TLS1_TXT_ECDHE_RSA_WITH_AES_128_CBC_SHA "ECDHE-RSA-AES128-SHA"
|
||||
# define TLS1_TXT_ECDHE_RSA_WITH_AES_256_CBC_SHA "ECDHE-RSA-AES256-SHA"
|
||||
|
||||
# define TLS1_TXT_ECDH_anon_WITH_NULL_SHA "AECDH-NULL-SHA"
|
||||
# define TLS1_TXT_ECDH_anon_WITH_RC4_128_SHA "AECDH-RC4-SHA"
|
||||
# define TLS1_TXT_ECDH_anon_WITH_DES_192_CBC3_SHA "AECDH-DES-CBC3-SHA"
|
||||
# define TLS1_TXT_ECDH_anon_WITH_AES_128_CBC_SHA "AECDH-AES128-SHA"
|
||||
# define TLS1_TXT_ECDH_anon_WITH_AES_256_CBC_SHA "AECDH-AES256-SHA"
|
||||
|
||||
/* PSK ciphersuites from RFC 4279 */
|
||||
# define TLS1_TXT_PSK_WITH_RC4_128_SHA "PSK-RC4-SHA"
|
||||
# define TLS1_TXT_PSK_WITH_3DES_EDE_CBC_SHA "PSK-3DES-EDE-CBC-SHA"
|
||||
# define TLS1_TXT_PSK_WITH_AES_128_CBC_SHA "PSK-AES128-CBC-SHA"
|
||||
# define TLS1_TXT_PSK_WITH_AES_256_CBC_SHA "PSK-AES256-CBC-SHA"
|
||||
|
||||
# define TLS1_TXT_DHE_PSK_WITH_RC4_128_SHA "DHE-PSK-RC4-SHA"
|
||||
# define TLS1_TXT_DHE_PSK_WITH_3DES_EDE_CBC_SHA "DHE-PSK-3DES-EDE-CBC-SHA"
|
||||
# define TLS1_TXT_DHE_PSK_WITH_AES_128_CBC_SHA "DHE-PSK-AES128-CBC-SHA"
|
||||
# define TLS1_TXT_DHE_PSK_WITH_AES_256_CBC_SHA "DHE-PSK-AES256-CBC-SHA"
|
||||
# define TLS1_TXT_RSA_PSK_WITH_RC4_128_SHA "RSA-PSK-RC4-SHA"
|
||||
# define TLS1_TXT_RSA_PSK_WITH_3DES_EDE_CBC_SHA "RSA-PSK-3DES-EDE-CBC-SHA"
|
||||
# define TLS1_TXT_RSA_PSK_WITH_AES_128_CBC_SHA "RSA-PSK-AES128-CBC-SHA"
|
||||
# define TLS1_TXT_RSA_PSK_WITH_AES_256_CBC_SHA "RSA-PSK-AES256-CBC-SHA"
|
||||
|
||||
/* PSK ciphersuites from RFC 5487 */
|
||||
# define TLS1_TXT_PSK_WITH_AES_128_GCM_SHA256 "PSK-AES128-GCM-SHA256"
|
||||
# define TLS1_TXT_PSK_WITH_AES_256_GCM_SHA384 "PSK-AES256-GCM-SHA384"
|
||||
# define TLS1_TXT_DHE_PSK_WITH_AES_128_GCM_SHA256 "DHE-PSK-AES128-GCM-SHA256"
|
||||
# define TLS1_TXT_DHE_PSK_WITH_AES_256_GCM_SHA384 "DHE-PSK-AES256-GCM-SHA384"
|
||||
# define TLS1_TXT_RSA_PSK_WITH_AES_128_GCM_SHA256 "RSA-PSK-AES128-GCM-SHA256"
|
||||
# define TLS1_TXT_RSA_PSK_WITH_AES_256_GCM_SHA384 "RSA-PSK-AES256-GCM-SHA384"
|
||||
|
||||
# define TLS1_TXT_PSK_WITH_AES_128_CBC_SHA256 "PSK-AES128-CBC-SHA256"
|
||||
# define TLS1_TXT_PSK_WITH_AES_256_CBC_SHA384 "PSK-AES256-CBC-SHA384"
|
||||
# define TLS1_TXT_PSK_WITH_NULL_SHA256 "PSK-NULL-SHA256"
|
||||
# define TLS1_TXT_PSK_WITH_NULL_SHA384 "PSK-NULL-SHA384"
|
||||
|
||||
# define TLS1_TXT_DHE_PSK_WITH_AES_128_CBC_SHA256 "DHE-PSK-AES128-CBC-SHA256"
|
||||
# define TLS1_TXT_DHE_PSK_WITH_AES_256_CBC_SHA384 "DHE-PSK-AES256-CBC-SHA384"
|
||||
# define TLS1_TXT_DHE_PSK_WITH_NULL_SHA256 "DHE-PSK-NULL-SHA256"
|
||||
# define TLS1_TXT_DHE_PSK_WITH_NULL_SHA384 "DHE-PSK-NULL-SHA384"
|
||||
|
||||
# define TLS1_TXT_RSA_PSK_WITH_AES_128_CBC_SHA256 "RSA-PSK-AES128-CBC-SHA256"
|
||||
# define TLS1_TXT_RSA_PSK_WITH_AES_256_CBC_SHA384 "RSA-PSK-AES256-CBC-SHA384"
|
||||
# define TLS1_TXT_RSA_PSK_WITH_NULL_SHA256 "RSA-PSK-NULL-SHA256"
|
||||
# define TLS1_TXT_RSA_PSK_WITH_NULL_SHA384 "RSA-PSK-NULL-SHA384"
|
||||
|
||||
/* SRP ciphersuite from RFC 5054 */
|
||||
# define TLS1_TXT_SRP_SHA_WITH_3DES_EDE_CBC_SHA "SRP-3DES-EDE-CBC-SHA"
|
||||
# define TLS1_TXT_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA "SRP-RSA-3DES-EDE-CBC-SHA"
|
||||
# define TLS1_TXT_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA "SRP-DSS-3DES-EDE-CBC-SHA"
|
||||
# define TLS1_TXT_SRP_SHA_WITH_AES_128_CBC_SHA "SRP-AES-128-CBC-SHA"
|
||||
# define TLS1_TXT_SRP_SHA_RSA_WITH_AES_128_CBC_SHA "SRP-RSA-AES-128-CBC-SHA"
|
||||
# define TLS1_TXT_SRP_SHA_DSS_WITH_AES_128_CBC_SHA "SRP-DSS-AES-128-CBC-SHA"
|
||||
# define TLS1_TXT_SRP_SHA_WITH_AES_256_CBC_SHA "SRP-AES-256-CBC-SHA"
|
||||
# define TLS1_TXT_SRP_SHA_RSA_WITH_AES_256_CBC_SHA "SRP-RSA-AES-256-CBC-SHA"
|
||||
# define TLS1_TXT_SRP_SHA_DSS_WITH_AES_256_CBC_SHA "SRP-DSS-AES-256-CBC-SHA"
|
||||
|
||||
/* Camellia ciphersuites from RFC4132 */
|
||||
# define TLS1_TXT_RSA_WITH_CAMELLIA_128_CBC_SHA "CAMELLIA128-SHA"
|
||||
# define TLS1_TXT_DH_DSS_WITH_CAMELLIA_128_CBC_SHA "DH-DSS-CAMELLIA128-SHA"
|
||||
# define TLS1_TXT_DH_RSA_WITH_CAMELLIA_128_CBC_SHA "DH-RSA-CAMELLIA128-SHA"
|
||||
# define TLS1_TXT_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA "DHE-DSS-CAMELLIA128-SHA"
|
||||
# define TLS1_TXT_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA "DHE-RSA-CAMELLIA128-SHA"
|
||||
# define TLS1_TXT_ADH_WITH_CAMELLIA_128_CBC_SHA "ADH-CAMELLIA128-SHA"
|
||||
|
||||
# define TLS1_TXT_RSA_WITH_CAMELLIA_256_CBC_SHA "CAMELLIA256-SHA"
|
||||
# define TLS1_TXT_DH_DSS_WITH_CAMELLIA_256_CBC_SHA "DH-DSS-CAMELLIA256-SHA"
|
||||
# define TLS1_TXT_DH_RSA_WITH_CAMELLIA_256_CBC_SHA "DH-RSA-CAMELLIA256-SHA"
|
||||
# define TLS1_TXT_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA "DHE-DSS-CAMELLIA256-SHA"
|
||||
# define TLS1_TXT_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA "DHE-RSA-CAMELLIA256-SHA"
|
||||
# define TLS1_TXT_ADH_WITH_CAMELLIA_256_CBC_SHA "ADH-CAMELLIA256-SHA"
|
||||
|
||||
/* TLS 1.2 Camellia SHA-256 ciphersuites from RFC5932 */
|
||||
# define TLS1_TXT_RSA_WITH_CAMELLIA_128_CBC_SHA256 "CAMELLIA128-SHA256"
|
||||
# define TLS1_TXT_DH_DSS_WITH_CAMELLIA_128_CBC_SHA256 "DH-DSS-CAMELLIA128-SHA256"
|
||||
# define TLS1_TXT_DH_RSA_WITH_CAMELLIA_128_CBC_SHA256 "DH-RSA-CAMELLIA128-SHA256"
|
||||
# define TLS1_TXT_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256 "DHE-DSS-CAMELLIA128-SHA256"
|
||||
# define TLS1_TXT_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 "DHE-RSA-CAMELLIA128-SHA256"
|
||||
# define TLS1_TXT_ADH_WITH_CAMELLIA_128_CBC_SHA256 "ADH-CAMELLIA128-SHA256"
|
||||
|
||||
# define TLS1_TXT_RSA_WITH_CAMELLIA_256_CBC_SHA256 "CAMELLIA256-SHA256"
|
||||
# define TLS1_TXT_DH_DSS_WITH_CAMELLIA_256_CBC_SHA256 "DH-DSS-CAMELLIA256-SHA256"
|
||||
# define TLS1_TXT_DH_RSA_WITH_CAMELLIA_256_CBC_SHA256 "DH-RSA-CAMELLIA256-SHA256"
|
||||
# define TLS1_TXT_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256 "DHE-DSS-CAMELLIA256-SHA256"
|
||||
# define TLS1_TXT_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 "DHE-RSA-CAMELLIA256-SHA256"
|
||||
# define TLS1_TXT_ADH_WITH_CAMELLIA_256_CBC_SHA256 "ADH-CAMELLIA256-SHA256"
|
||||
|
||||
# define TLS1_TXT_PSK_WITH_CAMELLIA_128_CBC_SHA256 "PSK-CAMELLIA128-SHA256"
|
||||
# define TLS1_TXT_PSK_WITH_CAMELLIA_256_CBC_SHA384 "PSK-CAMELLIA256-SHA384"
|
||||
# define TLS1_TXT_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 "DHE-PSK-CAMELLIA128-SHA256"
|
||||
# define TLS1_TXT_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 "DHE-PSK-CAMELLIA256-SHA384"
|
||||
# define TLS1_TXT_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256 "RSA-PSK-CAMELLIA128-SHA256"
|
||||
# define TLS1_TXT_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384 "RSA-PSK-CAMELLIA256-SHA384"
|
||||
# define TLS1_TXT_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 "ECDHE-PSK-CAMELLIA128-SHA256"
|
||||
# define TLS1_TXT_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 "ECDHE-PSK-CAMELLIA256-SHA384"
|
||||
|
||||
/* SEED ciphersuites from RFC4162 */
|
||||
# define TLS1_TXT_RSA_WITH_SEED_SHA "SEED-SHA"
|
||||
# define TLS1_TXT_DH_DSS_WITH_SEED_SHA "DH-DSS-SEED-SHA"
|
||||
# define TLS1_TXT_DH_RSA_WITH_SEED_SHA "DH-RSA-SEED-SHA"
|
||||
# define TLS1_TXT_DHE_DSS_WITH_SEED_SHA "DHE-DSS-SEED-SHA"
|
||||
# define TLS1_TXT_DHE_RSA_WITH_SEED_SHA "DHE-RSA-SEED-SHA"
|
||||
# define TLS1_TXT_ADH_WITH_SEED_SHA "ADH-SEED-SHA"
|
||||
|
||||
/* TLS v1.2 ciphersuites */
|
||||
# define TLS1_TXT_RSA_WITH_NULL_SHA256 "NULL-SHA256"
|
||||
# define TLS1_TXT_RSA_WITH_AES_128_SHA256 "AES128-SHA256"
|
||||
# define TLS1_TXT_RSA_WITH_AES_256_SHA256 "AES256-SHA256"
|
||||
# define TLS1_TXT_DH_DSS_WITH_AES_128_SHA256 "DH-DSS-AES128-SHA256"
|
||||
# define TLS1_TXT_DH_RSA_WITH_AES_128_SHA256 "DH-RSA-AES128-SHA256"
|
||||
# define TLS1_TXT_DHE_DSS_WITH_AES_128_SHA256 "DHE-DSS-AES128-SHA256"
|
||||
# define TLS1_TXT_DHE_RSA_WITH_AES_128_SHA256 "DHE-RSA-AES128-SHA256"
|
||||
# define TLS1_TXT_DH_DSS_WITH_AES_256_SHA256 "DH-DSS-AES256-SHA256"
|
||||
# define TLS1_TXT_DH_RSA_WITH_AES_256_SHA256 "DH-RSA-AES256-SHA256"
|
||||
# define TLS1_TXT_DHE_DSS_WITH_AES_256_SHA256 "DHE-DSS-AES256-SHA256"
|
||||
# define TLS1_TXT_DHE_RSA_WITH_AES_256_SHA256 "DHE-RSA-AES256-SHA256"
|
||||
# define TLS1_TXT_ADH_WITH_AES_128_SHA256 "ADH-AES128-SHA256"
|
||||
# define TLS1_TXT_ADH_WITH_AES_256_SHA256 "ADH-AES256-SHA256"
|
||||
|
||||
/* TLS v1.2 GCM ciphersuites from RFC5288 */
|
||||
# define TLS1_TXT_RSA_WITH_AES_128_GCM_SHA256 "AES128-GCM-SHA256"
|
||||
# define TLS1_TXT_RSA_WITH_AES_256_GCM_SHA384 "AES256-GCM-SHA384"
|
||||
# define TLS1_TXT_DHE_RSA_WITH_AES_128_GCM_SHA256 "DHE-RSA-AES128-GCM-SHA256"
|
||||
# define TLS1_TXT_DHE_RSA_WITH_AES_256_GCM_SHA384 "DHE-RSA-AES256-GCM-SHA384"
|
||||
# define TLS1_TXT_DH_RSA_WITH_AES_128_GCM_SHA256 "DH-RSA-AES128-GCM-SHA256"
|
||||
# define TLS1_TXT_DH_RSA_WITH_AES_256_GCM_SHA384 "DH-RSA-AES256-GCM-SHA384"
|
||||
# define TLS1_TXT_DHE_DSS_WITH_AES_128_GCM_SHA256 "DHE-DSS-AES128-GCM-SHA256"
|
||||
# define TLS1_TXT_DHE_DSS_WITH_AES_256_GCM_SHA384 "DHE-DSS-AES256-GCM-SHA384"
|
||||
# define TLS1_TXT_DH_DSS_WITH_AES_128_GCM_SHA256 "DH-DSS-AES128-GCM-SHA256"
|
||||
# define TLS1_TXT_DH_DSS_WITH_AES_256_GCM_SHA384 "DH-DSS-AES256-GCM-SHA384"
|
||||
# define TLS1_TXT_ADH_WITH_AES_128_GCM_SHA256 "ADH-AES128-GCM-SHA256"
|
||||
# define TLS1_TXT_ADH_WITH_AES_256_GCM_SHA384 "ADH-AES256-GCM-SHA384"
|
||||
|
||||
/* CCM ciphersuites from RFC6655 */
|
||||
|
||||
# define TLS1_TXT_RSA_WITH_AES_128_CCM "AES128-CCM"
|
||||
# define TLS1_TXT_RSA_WITH_AES_256_CCM "AES256-CCM"
|
||||
# define TLS1_TXT_DHE_RSA_WITH_AES_128_CCM "DHE-RSA-AES128-CCM"
|
||||
# define TLS1_TXT_DHE_RSA_WITH_AES_256_CCM "DHE-RSA-AES256-CCM"
|
||||
|
||||
# define TLS1_TXT_RSA_WITH_AES_128_CCM_8 "AES128-CCM8"
|
||||
# define TLS1_TXT_RSA_WITH_AES_256_CCM_8 "AES256-CCM8"
|
||||
# define TLS1_TXT_DHE_RSA_WITH_AES_128_CCM_8 "DHE-RSA-AES128-CCM8"
|
||||
# define TLS1_TXT_DHE_RSA_WITH_AES_256_CCM_8 "DHE-RSA-AES256-CCM8"
|
||||
|
||||
# define TLS1_TXT_PSK_WITH_AES_128_CCM "PSK-AES128-CCM"
|
||||
# define TLS1_TXT_PSK_WITH_AES_256_CCM "PSK-AES256-CCM"
|
||||
# define TLS1_TXT_DHE_PSK_WITH_AES_128_CCM "DHE-PSK-AES128-CCM"
|
||||
# define TLS1_TXT_DHE_PSK_WITH_AES_256_CCM "DHE-PSK-AES256-CCM"
|
||||
|
||||
# define TLS1_TXT_PSK_WITH_AES_128_CCM_8 "PSK-AES128-CCM8"
|
||||
# define TLS1_TXT_PSK_WITH_AES_256_CCM_8 "PSK-AES256-CCM8"
|
||||
# define TLS1_TXT_DHE_PSK_WITH_AES_128_CCM_8 "DHE-PSK-AES128-CCM8"
|
||||
# define TLS1_TXT_DHE_PSK_WITH_AES_256_CCM_8 "DHE-PSK-AES256-CCM8"
|
||||
|
||||
/* CCM ciphersuites from RFC7251 */
|
||||
|
||||
# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_CCM "ECDHE-ECDSA-AES128-CCM"
|
||||
# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_CCM "ECDHE-ECDSA-AES256-CCM"
|
||||
# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_CCM_8 "ECDHE-ECDSA-AES128-CCM8"
|
||||
# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_CCM_8 "ECDHE-ECDSA-AES256-CCM8"
|
||||
|
||||
/* ECDH HMAC based ciphersuites from RFC5289 */
|
||||
|
||||
# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_SHA256 "ECDHE-ECDSA-AES128-SHA256"
|
||||
# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_SHA384 "ECDHE-ECDSA-AES256-SHA384"
|
||||
# define TLS1_TXT_ECDH_ECDSA_WITH_AES_128_SHA256 "ECDH-ECDSA-AES128-SHA256"
|
||||
# define TLS1_TXT_ECDH_ECDSA_WITH_AES_256_SHA384 "ECDH-ECDSA-AES256-SHA384"
|
||||
# define TLS1_TXT_ECDHE_RSA_WITH_AES_128_SHA256 "ECDHE-RSA-AES128-SHA256"
|
||||
# define TLS1_TXT_ECDHE_RSA_WITH_AES_256_SHA384 "ECDHE-RSA-AES256-SHA384"
|
||||
# define TLS1_TXT_ECDH_RSA_WITH_AES_128_SHA256 "ECDH-RSA-AES128-SHA256"
|
||||
# define TLS1_TXT_ECDH_RSA_WITH_AES_256_SHA384 "ECDH-RSA-AES256-SHA384"
|
||||
|
||||
/* ECDH GCM based ciphersuites from RFC5289 */
|
||||
# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 "ECDHE-ECDSA-AES128-GCM-SHA256"
|
||||
# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 "ECDHE-ECDSA-AES256-GCM-SHA384"
|
||||
# define TLS1_TXT_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 "ECDH-ECDSA-AES128-GCM-SHA256"
|
||||
# define TLS1_TXT_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 "ECDH-ECDSA-AES256-GCM-SHA384"
|
||||
# define TLS1_TXT_ECDHE_RSA_WITH_AES_128_GCM_SHA256 "ECDHE-RSA-AES128-GCM-SHA256"
|
||||
# define TLS1_TXT_ECDHE_RSA_WITH_AES_256_GCM_SHA384 "ECDHE-RSA-AES256-GCM-SHA384"
|
||||
# define TLS1_TXT_ECDH_RSA_WITH_AES_128_GCM_SHA256 "ECDH-RSA-AES128-GCM-SHA256"
|
||||
# define TLS1_TXT_ECDH_RSA_WITH_AES_256_GCM_SHA384 "ECDH-RSA-AES256-GCM-SHA384"
|
||||
|
||||
/* TLS v1.2 PSK GCM ciphersuites from RFC5487 */
|
||||
# define TLS1_TXT_PSK_WITH_AES_128_GCM_SHA256 "PSK-AES128-GCM-SHA256"
|
||||
# define TLS1_TXT_PSK_WITH_AES_256_GCM_SHA384 "PSK-AES256-GCM-SHA384"
|
||||
|
||||
/* ECDHE PSK ciphersuites from RFC 5489 */
|
||||
# define TLS1_TXT_ECDHE_PSK_WITH_RC4_128_SHA "ECDHE-PSK-RC4-SHA"
|
||||
# define TLS1_TXT_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA "ECDHE-PSK-3DES-EDE-CBC-SHA"
|
||||
# define TLS1_TXT_ECDHE_PSK_WITH_AES_128_CBC_SHA "ECDHE-PSK-AES128-CBC-SHA"
|
||||
# define TLS1_TXT_ECDHE_PSK_WITH_AES_256_CBC_SHA "ECDHE-PSK-AES256-CBC-SHA"
|
||||
|
||||
# define TLS1_TXT_ECDHE_PSK_WITH_AES_128_CBC_SHA256 "ECDHE-PSK-AES128-CBC-SHA256"
|
||||
# define TLS1_TXT_ECDHE_PSK_WITH_AES_256_CBC_SHA384 "ECDHE-PSK-AES256-CBC-SHA384"
|
||||
|
||||
# define TLS1_TXT_ECDHE_PSK_WITH_NULL_SHA "ECDHE-PSK-NULL-SHA"
|
||||
# define TLS1_TXT_ECDHE_PSK_WITH_NULL_SHA256 "ECDHE-PSK-NULL-SHA256"
|
||||
# define TLS1_TXT_ECDHE_PSK_WITH_NULL_SHA384 "ECDHE-PSK-NULL-SHA384"
|
||||
|
||||
/* Camellia-CBC ciphersuites from RFC6367 */
|
||||
# define TLS1_TXT_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 "ECDHE-ECDSA-CAMELLIA128-SHA256"
|
||||
# define TLS1_TXT_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 "ECDHE-ECDSA-CAMELLIA256-SHA384"
|
||||
# define TLS1_TXT_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 "ECDH-ECDSA-CAMELLIA128-SHA256"
|
||||
# define TLS1_TXT_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 "ECDH-ECDSA-CAMELLIA256-SHA384"
|
||||
# define TLS1_TXT_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 "ECDHE-RSA-CAMELLIA128-SHA256"
|
||||
# define TLS1_TXT_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384 "ECDHE-RSA-CAMELLIA256-SHA384"
|
||||
# define TLS1_TXT_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256 "ECDH-RSA-CAMELLIA128-SHA256"
|
||||
# define TLS1_TXT_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384 "ECDH-RSA-CAMELLIA256-SHA384"
|
||||
|
||||
/* draft-ietf-tls-chacha20-poly1305-03 */
|
||||
# define TLS1_TXT_ECDHE_RSA_WITH_CHACHA20_POLY1305 "ECDHE-RSA-CHACHA20-POLY1305"
|
||||
# define TLS1_TXT_ECDHE_ECDSA_WITH_CHACHA20_POLY1305 "ECDHE-ECDSA-CHACHA20-POLY1305"
|
||||
# define TLS1_TXT_DHE_RSA_WITH_CHACHA20_POLY1305 "DHE-RSA-CHACHA20-POLY1305"
|
||||
# define TLS1_TXT_PSK_WITH_CHACHA20_POLY1305 "PSK-CHACHA20-POLY1305"
|
||||
# define TLS1_TXT_ECDHE_PSK_WITH_CHACHA20_POLY1305 "ECDHE-PSK-CHACHA20-POLY1305"
|
||||
# define TLS1_TXT_DHE_PSK_WITH_CHACHA20_POLY1305 "DHE-PSK-CHACHA20-POLY1305"
|
||||
# define TLS1_TXT_RSA_PSK_WITH_CHACHA20_POLY1305 "RSA-PSK-CHACHA20-POLY1305"
|
||||
|
||||
# define TLS_CT_RSA_SIGN 1
|
||||
# define TLS_CT_DSS_SIGN 2
|
||||
# define TLS_CT_RSA_FIXED_DH 3
|
||||
# define TLS_CT_DSS_FIXED_DH 4
|
||||
# define TLS_CT_ECDSA_SIGN 64
|
||||
# define TLS_CT_RSA_FIXED_ECDH 65
|
||||
# define TLS_CT_ECDSA_FIXED_ECDH 66
|
||||
# define TLS_CT_GOST01_SIGN 22
|
||||
# define TLS_CT_GOST12_SIGN 238
|
||||
# define TLS_CT_GOST12_512_SIGN 239
|
||||
|
||||
/*
|
||||
* when correcting this number, correct also SSL3_CT_NUMBER in ssl3.h (see
|
||||
* comment there)
|
||||
*/
|
||||
# define TLS_CT_NUMBER 9
|
||||
|
||||
# define TLS1_FINISH_MAC_LENGTH 12
|
||||
|
||||
# define TLS_MD_MAX_CONST_SIZE 22
|
||||
# define TLS_MD_CLIENT_FINISH_CONST "client finished"
|
||||
# define TLS_MD_CLIENT_FINISH_CONST_SIZE 15
|
||||
# define TLS_MD_SERVER_FINISH_CONST "server finished"
|
||||
# define TLS_MD_SERVER_FINISH_CONST_SIZE 15
|
||||
# define TLS_MD_KEY_EXPANSION_CONST "key expansion"
|
||||
# define TLS_MD_KEY_EXPANSION_CONST_SIZE 13
|
||||
# define TLS_MD_CLIENT_WRITE_KEY_CONST "client write key"
|
||||
# define TLS_MD_CLIENT_WRITE_KEY_CONST_SIZE 16
|
||||
# define TLS_MD_SERVER_WRITE_KEY_CONST "server write key"
|
||||
# define TLS_MD_SERVER_WRITE_KEY_CONST_SIZE 16
|
||||
# define TLS_MD_IV_BLOCK_CONST "IV block"
|
||||
# define TLS_MD_IV_BLOCK_CONST_SIZE 8
|
||||
# define TLS_MD_MASTER_SECRET_CONST "master secret"
|
||||
# define TLS_MD_MASTER_SECRET_CONST_SIZE 13
|
||||
# define TLS_MD_EXTENDED_MASTER_SECRET_CONST "extended master secret"
|
||||
# define TLS_MD_EXTENDED_MASTER_SECRET_CONST_SIZE 22
|
||||
|
||||
# ifdef CHARSET_EBCDIC
|
||||
# undef TLS_MD_CLIENT_FINISH_CONST
|
||||
/*
|
||||
* client finished
|
||||
*/
|
||||
# define TLS_MD_CLIENT_FINISH_CONST "\x63\x6c\x69\x65\x6e\x74\x20\x66\x69\x6e\x69\x73\x68\x65\x64"
|
||||
|
||||
# undef TLS_MD_SERVER_FINISH_CONST
|
||||
/*
|
||||
* server finished
|
||||
*/
|
||||
# define TLS_MD_SERVER_FINISH_CONST "\x73\x65\x72\x76\x65\x72\x20\x66\x69\x6e\x69\x73\x68\x65\x64"
|
||||
|
||||
# undef TLS_MD_SERVER_WRITE_KEY_CONST
|
||||
/*
|
||||
* server write key
|
||||
*/
|
||||
# define TLS_MD_SERVER_WRITE_KEY_CONST "\x73\x65\x72\x76\x65\x72\x20\x77\x72\x69\x74\x65\x20\x6b\x65\x79"
|
||||
|
||||
# undef TLS_MD_KEY_EXPANSION_CONST
|
||||
/*
|
||||
* key expansion
|
||||
*/
|
||||
# define TLS_MD_KEY_EXPANSION_CONST "\x6b\x65\x79\x20\x65\x78\x70\x61\x6e\x73\x69\x6f\x6e"
|
||||
|
||||
# undef TLS_MD_CLIENT_WRITE_KEY_CONST
|
||||
/*
|
||||
* client write key
|
||||
*/
|
||||
# define TLS_MD_CLIENT_WRITE_KEY_CONST "\x63\x6c\x69\x65\x6e\x74\x20\x77\x72\x69\x74\x65\x20\x6b\x65\x79"
|
||||
|
||||
# undef TLS_MD_SERVER_WRITE_KEY_CONST
|
||||
/*
|
||||
* server write key
|
||||
*/
|
||||
# define TLS_MD_SERVER_WRITE_KEY_CONST "\x73\x65\x72\x76\x65\x72\x20\x77\x72\x69\x74\x65\x20\x6b\x65\x79"
|
||||
|
||||
# undef TLS_MD_IV_BLOCK_CONST
|
||||
/*
|
||||
* IV block
|
||||
*/
|
||||
# define TLS_MD_IV_BLOCK_CONST "\x49\x56\x20\x62\x6c\x6f\x63\x6b"
|
||||
|
||||
# undef TLS_MD_MASTER_SECRET_CONST
|
||||
/*
|
||||
* master secret
|
||||
*/
|
||||
# define TLS_MD_MASTER_SECRET_CONST "\x6d\x61\x73\x74\x65\x72\x20\x73\x65\x63\x72\x65\x74"
|
||||
# undef TLS_MD_EXTENDED_MASTER_SECRET_CONST
|
||||
/*
|
||||
* extended master secret
|
||||
*/
|
||||
# define TLS_MD_EXTENDED_MASTER_SECRET_CONST "\x65\x78\x74\x65\x63\x64\x65\x64\x20\x6d\x61\x73\x74\x65\x72\x20\x73\x65\x63\x72\x65\x74"
|
||||
# endif
|
||||
|
||||
/* TLS Session Ticket extension struct */
|
||||
struct tls_session_ticket_ext_st {
|
||||
unsigned short length;
|
||||
void *data;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -0,0 +1,643 @@
|
|||
/*
|
||||
* Copyright 2006-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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_TS_H
|
||||
# define HEADER_TS_H
|
||||
|
||||
# include <openssl/opensslconf.h>
|
||||
|
||||
# ifndef OPENSSL_NO_TS
|
||||
# include <openssl/symhacks.h>
|
||||
# include <openssl/buffer.h>
|
||||
# include <openssl/evp.h>
|
||||
# include <openssl/bio.h>
|
||||
# include <openssl/stack.h>
|
||||
# include <openssl/asn1.h>
|
||||
# include <openssl/safestack.h>
|
||||
# include <openssl/rsa.h>
|
||||
# include <openssl/dsa.h>
|
||||
# include <openssl/dh.h>
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
# endif
|
||||
|
||||
# include <openssl/x509.h>
|
||||
# include <openssl/x509v3.h>
|
||||
|
||||
typedef struct TS_msg_imprint_st TS_MSG_IMPRINT;
|
||||
typedef struct TS_req_st TS_REQ;
|
||||
typedef struct TS_accuracy_st TS_ACCURACY;
|
||||
typedef struct TS_tst_info_st TS_TST_INFO;
|
||||
|
||||
/* Possible values for status. */
|
||||
# define TS_STATUS_GRANTED 0
|
||||
# define TS_STATUS_GRANTED_WITH_MODS 1
|
||||
# define TS_STATUS_REJECTION 2
|
||||
# define TS_STATUS_WAITING 3
|
||||
# define TS_STATUS_REVOCATION_WARNING 4
|
||||
# define TS_STATUS_REVOCATION_NOTIFICATION 5
|
||||
|
||||
/* Possible values for failure_info. */
|
||||
# define TS_INFO_BAD_ALG 0
|
||||
# define TS_INFO_BAD_REQUEST 2
|
||||
# define TS_INFO_BAD_DATA_FORMAT 5
|
||||
# define TS_INFO_TIME_NOT_AVAILABLE 14
|
||||
# define TS_INFO_UNACCEPTED_POLICY 15
|
||||
# define TS_INFO_UNACCEPTED_EXTENSION 16
|
||||
# define TS_INFO_ADD_INFO_NOT_AVAILABLE 17
|
||||
# define TS_INFO_SYSTEM_FAILURE 25
|
||||
|
||||
|
||||
typedef struct TS_status_info_st TS_STATUS_INFO;
|
||||
typedef struct ESS_issuer_serial ESS_ISSUER_SERIAL;
|
||||
typedef struct ESS_cert_id ESS_CERT_ID;
|
||||
typedef struct ESS_signing_cert ESS_SIGNING_CERT;
|
||||
|
||||
DEFINE_STACK_OF(ESS_CERT_ID)
|
||||
|
||||
typedef struct TS_resp_st TS_RESP;
|
||||
|
||||
TS_REQ *TS_REQ_new(void);
|
||||
void TS_REQ_free(TS_REQ *a);
|
||||
int i2d_TS_REQ(const TS_REQ *a, unsigned char **pp);
|
||||
TS_REQ *d2i_TS_REQ(TS_REQ **a, const unsigned char **pp, long length);
|
||||
|
||||
TS_REQ *TS_REQ_dup(TS_REQ *a);
|
||||
|
||||
#ifndef OPENSSL_NO_STDIO
|
||||
TS_REQ *d2i_TS_REQ_fp(FILE *fp, TS_REQ **a);
|
||||
int i2d_TS_REQ_fp(FILE *fp, TS_REQ *a);
|
||||
#endif
|
||||
TS_REQ *d2i_TS_REQ_bio(BIO *fp, TS_REQ **a);
|
||||
int i2d_TS_REQ_bio(BIO *fp, TS_REQ *a);
|
||||
|
||||
TS_MSG_IMPRINT *TS_MSG_IMPRINT_new(void);
|
||||
void TS_MSG_IMPRINT_free(TS_MSG_IMPRINT *a);
|
||||
int i2d_TS_MSG_IMPRINT(const TS_MSG_IMPRINT *a, unsigned char **pp);
|
||||
TS_MSG_IMPRINT *d2i_TS_MSG_IMPRINT(TS_MSG_IMPRINT **a,
|
||||
const unsigned char **pp, long length);
|
||||
|
||||
TS_MSG_IMPRINT *TS_MSG_IMPRINT_dup(TS_MSG_IMPRINT *a);
|
||||
|
||||
#ifndef OPENSSL_NO_STDIO
|
||||
TS_MSG_IMPRINT *d2i_TS_MSG_IMPRINT_fp(FILE *fp, TS_MSG_IMPRINT **a);
|
||||
int i2d_TS_MSG_IMPRINT_fp(FILE *fp, TS_MSG_IMPRINT *a);
|
||||
#endif
|
||||
TS_MSG_IMPRINT *d2i_TS_MSG_IMPRINT_bio(BIO *bio, TS_MSG_IMPRINT **a);
|
||||
int i2d_TS_MSG_IMPRINT_bio(BIO *bio, TS_MSG_IMPRINT *a);
|
||||
|
||||
TS_RESP *TS_RESP_new(void);
|
||||
void TS_RESP_free(TS_RESP *a);
|
||||
int i2d_TS_RESP(const TS_RESP *a, unsigned char **pp);
|
||||
TS_RESP *d2i_TS_RESP(TS_RESP **a, const unsigned char **pp, long length);
|
||||
TS_TST_INFO *PKCS7_to_TS_TST_INFO(PKCS7 *token);
|
||||
TS_RESP *TS_RESP_dup(TS_RESP *a);
|
||||
|
||||
#ifndef OPENSSL_NO_STDIO
|
||||
TS_RESP *d2i_TS_RESP_fp(FILE *fp, TS_RESP **a);
|
||||
int i2d_TS_RESP_fp(FILE *fp, TS_RESP *a);
|
||||
#endif
|
||||
TS_RESP *d2i_TS_RESP_bio(BIO *bio, TS_RESP **a);
|
||||
int i2d_TS_RESP_bio(BIO *bio, TS_RESP *a);
|
||||
|
||||
TS_STATUS_INFO *TS_STATUS_INFO_new(void);
|
||||
void TS_STATUS_INFO_free(TS_STATUS_INFO *a);
|
||||
int i2d_TS_STATUS_INFO(const TS_STATUS_INFO *a, unsigned char **pp);
|
||||
TS_STATUS_INFO *d2i_TS_STATUS_INFO(TS_STATUS_INFO **a,
|
||||
const unsigned char **pp, long length);
|
||||
TS_STATUS_INFO *TS_STATUS_INFO_dup(TS_STATUS_INFO *a);
|
||||
|
||||
TS_TST_INFO *TS_TST_INFO_new(void);
|
||||
void TS_TST_INFO_free(TS_TST_INFO *a);
|
||||
int i2d_TS_TST_INFO(const TS_TST_INFO *a, unsigned char **pp);
|
||||
TS_TST_INFO *d2i_TS_TST_INFO(TS_TST_INFO **a, const unsigned char **pp,
|
||||
long length);
|
||||
TS_TST_INFO *TS_TST_INFO_dup(TS_TST_INFO *a);
|
||||
|
||||
#ifndef OPENSSL_NO_STDIO
|
||||
TS_TST_INFO *d2i_TS_TST_INFO_fp(FILE *fp, TS_TST_INFO **a);
|
||||
int i2d_TS_TST_INFO_fp(FILE *fp, TS_TST_INFO *a);
|
||||
#endif
|
||||
TS_TST_INFO *d2i_TS_TST_INFO_bio(BIO *bio, TS_TST_INFO **a);
|
||||
int i2d_TS_TST_INFO_bio(BIO *bio, TS_TST_INFO *a);
|
||||
|
||||
TS_ACCURACY *TS_ACCURACY_new(void);
|
||||
void TS_ACCURACY_free(TS_ACCURACY *a);
|
||||
int i2d_TS_ACCURACY(const TS_ACCURACY *a, unsigned char **pp);
|
||||
TS_ACCURACY *d2i_TS_ACCURACY(TS_ACCURACY **a, const unsigned char **pp,
|
||||
long length);
|
||||
TS_ACCURACY *TS_ACCURACY_dup(TS_ACCURACY *a);
|
||||
|
||||
ESS_ISSUER_SERIAL *ESS_ISSUER_SERIAL_new(void);
|
||||
void ESS_ISSUER_SERIAL_free(ESS_ISSUER_SERIAL *a);
|
||||
int i2d_ESS_ISSUER_SERIAL(const ESS_ISSUER_SERIAL *a, unsigned char **pp);
|
||||
ESS_ISSUER_SERIAL *d2i_ESS_ISSUER_SERIAL(ESS_ISSUER_SERIAL **a,
|
||||
const unsigned char **pp,
|
||||
long length);
|
||||
ESS_ISSUER_SERIAL *ESS_ISSUER_SERIAL_dup(ESS_ISSUER_SERIAL *a);
|
||||
|
||||
ESS_CERT_ID *ESS_CERT_ID_new(void);
|
||||
void ESS_CERT_ID_free(ESS_CERT_ID *a);
|
||||
int i2d_ESS_CERT_ID(const ESS_CERT_ID *a, unsigned char **pp);
|
||||
ESS_CERT_ID *d2i_ESS_CERT_ID(ESS_CERT_ID **a, const unsigned char **pp,
|
||||
long length);
|
||||
ESS_CERT_ID *ESS_CERT_ID_dup(ESS_CERT_ID *a);
|
||||
|
||||
ESS_SIGNING_CERT *ESS_SIGNING_CERT_new(void);
|
||||
void ESS_SIGNING_CERT_free(ESS_SIGNING_CERT *a);
|
||||
int i2d_ESS_SIGNING_CERT(const ESS_SIGNING_CERT *a, unsigned char **pp);
|
||||
ESS_SIGNING_CERT *d2i_ESS_SIGNING_CERT(ESS_SIGNING_CERT **a,
|
||||
const unsigned char **pp, long length);
|
||||
ESS_SIGNING_CERT *ESS_SIGNING_CERT_dup(ESS_SIGNING_CERT *a);
|
||||
|
||||
int TS_REQ_set_version(TS_REQ *a, long version);
|
||||
long TS_REQ_get_version(const TS_REQ *a);
|
||||
|
||||
int TS_STATUS_INFO_set_status(TS_STATUS_INFO *a, int i);
|
||||
const ASN1_INTEGER *TS_STATUS_INFO_get0_status(const TS_STATUS_INFO *a);
|
||||
|
||||
const STACK_OF(ASN1_UTF8STRING) *
|
||||
TS_STATUS_INFO_get0_text(const TS_STATUS_INFO *a);
|
||||
|
||||
const ASN1_BIT_STRING *
|
||||
TS_STATUS_INFO_get0_failure_info(const TS_STATUS_INFO *a);
|
||||
|
||||
int TS_REQ_set_msg_imprint(TS_REQ *a, TS_MSG_IMPRINT *msg_imprint);
|
||||
TS_MSG_IMPRINT *TS_REQ_get_msg_imprint(TS_REQ *a);
|
||||
|
||||
int TS_MSG_IMPRINT_set_algo(TS_MSG_IMPRINT *a, X509_ALGOR *alg);
|
||||
X509_ALGOR *TS_MSG_IMPRINT_get_algo(TS_MSG_IMPRINT *a);
|
||||
|
||||
int TS_MSG_IMPRINT_set_msg(TS_MSG_IMPRINT *a, unsigned char *d, int len);
|
||||
ASN1_OCTET_STRING *TS_MSG_IMPRINT_get_msg(TS_MSG_IMPRINT *a);
|
||||
|
||||
int TS_REQ_set_policy_id(TS_REQ *a, const ASN1_OBJECT *policy);
|
||||
ASN1_OBJECT *TS_REQ_get_policy_id(TS_REQ *a);
|
||||
|
||||
int TS_REQ_set_nonce(TS_REQ *a, const ASN1_INTEGER *nonce);
|
||||
const ASN1_INTEGER *TS_REQ_get_nonce(const TS_REQ *a);
|
||||
|
||||
int TS_REQ_set_cert_req(TS_REQ *a, int cert_req);
|
||||
int TS_REQ_get_cert_req(const TS_REQ *a);
|
||||
|
||||
STACK_OF(X509_EXTENSION) *TS_REQ_get_exts(TS_REQ *a);
|
||||
void TS_REQ_ext_free(TS_REQ *a);
|
||||
int TS_REQ_get_ext_count(TS_REQ *a);
|
||||
int TS_REQ_get_ext_by_NID(TS_REQ *a, int nid, int lastpos);
|
||||
int TS_REQ_get_ext_by_OBJ(TS_REQ *a, const ASN1_OBJECT *obj, int lastpos);
|
||||
int TS_REQ_get_ext_by_critical(TS_REQ *a, int crit, int lastpos);
|
||||
X509_EXTENSION *TS_REQ_get_ext(TS_REQ *a, int loc);
|
||||
X509_EXTENSION *TS_REQ_delete_ext(TS_REQ *a, int loc);
|
||||
int TS_REQ_add_ext(TS_REQ *a, X509_EXTENSION *ex, int loc);
|
||||
void *TS_REQ_get_ext_d2i(TS_REQ *a, int nid, int *crit, int *idx);
|
||||
|
||||
/* Function declarations for TS_REQ defined in ts/ts_req_print.c */
|
||||
|
||||
int TS_REQ_print_bio(BIO *bio, TS_REQ *a);
|
||||
|
||||
/* Function declarations for TS_RESP defined in ts/ts_resp_utils.c */
|
||||
|
||||
int TS_RESP_set_status_info(TS_RESP *a, TS_STATUS_INFO *info);
|
||||
TS_STATUS_INFO *TS_RESP_get_status_info(TS_RESP *a);
|
||||
|
||||
/* Caller loses ownership of PKCS7 and TS_TST_INFO objects. */
|
||||
void TS_RESP_set_tst_info(TS_RESP *a, PKCS7 *p7, TS_TST_INFO *tst_info);
|
||||
PKCS7 *TS_RESP_get_token(TS_RESP *a);
|
||||
TS_TST_INFO *TS_RESP_get_tst_info(TS_RESP *a);
|
||||
|
||||
int TS_TST_INFO_set_version(TS_TST_INFO *a, long version);
|
||||
long TS_TST_INFO_get_version(const TS_TST_INFO *a);
|
||||
|
||||
int TS_TST_INFO_set_policy_id(TS_TST_INFO *a, ASN1_OBJECT *policy_id);
|
||||
ASN1_OBJECT *TS_TST_INFO_get_policy_id(TS_TST_INFO *a);
|
||||
|
||||
int TS_TST_INFO_set_msg_imprint(TS_TST_INFO *a, TS_MSG_IMPRINT *msg_imprint);
|
||||
TS_MSG_IMPRINT *TS_TST_INFO_get_msg_imprint(TS_TST_INFO *a);
|
||||
|
||||
int TS_TST_INFO_set_serial(TS_TST_INFO *a, const ASN1_INTEGER *serial);
|
||||
const ASN1_INTEGER *TS_TST_INFO_get_serial(const TS_TST_INFO *a);
|
||||
|
||||
int TS_TST_INFO_set_time(TS_TST_INFO *a, const ASN1_GENERALIZEDTIME *gtime);
|
||||
const ASN1_GENERALIZEDTIME *TS_TST_INFO_get_time(const TS_TST_INFO *a);
|
||||
|
||||
int TS_TST_INFO_set_accuracy(TS_TST_INFO *a, TS_ACCURACY *accuracy);
|
||||
TS_ACCURACY *TS_TST_INFO_get_accuracy(TS_TST_INFO *a);
|
||||
|
||||
int TS_ACCURACY_set_seconds(TS_ACCURACY *a, const ASN1_INTEGER *seconds);
|
||||
const ASN1_INTEGER *TS_ACCURACY_get_seconds(const TS_ACCURACY *a);
|
||||
|
||||
int TS_ACCURACY_set_millis(TS_ACCURACY *a, const ASN1_INTEGER *millis);
|
||||
const ASN1_INTEGER *TS_ACCURACY_get_millis(const TS_ACCURACY *a);
|
||||
|
||||
int TS_ACCURACY_set_micros(TS_ACCURACY *a, const ASN1_INTEGER *micros);
|
||||
const ASN1_INTEGER *TS_ACCURACY_get_micros(const TS_ACCURACY *a);
|
||||
|
||||
int TS_TST_INFO_set_ordering(TS_TST_INFO *a, int ordering);
|
||||
int TS_TST_INFO_get_ordering(const TS_TST_INFO *a);
|
||||
|
||||
int TS_TST_INFO_set_nonce(TS_TST_INFO *a, const ASN1_INTEGER *nonce);
|
||||
const ASN1_INTEGER *TS_TST_INFO_get_nonce(const TS_TST_INFO *a);
|
||||
|
||||
int TS_TST_INFO_set_tsa(TS_TST_INFO *a, GENERAL_NAME *tsa);
|
||||
GENERAL_NAME *TS_TST_INFO_get_tsa(TS_TST_INFO *a);
|
||||
|
||||
STACK_OF(X509_EXTENSION) *TS_TST_INFO_get_exts(TS_TST_INFO *a);
|
||||
void TS_TST_INFO_ext_free(TS_TST_INFO *a);
|
||||
int TS_TST_INFO_get_ext_count(TS_TST_INFO *a);
|
||||
int TS_TST_INFO_get_ext_by_NID(TS_TST_INFO *a, int nid, int lastpos);
|
||||
int TS_TST_INFO_get_ext_by_OBJ(TS_TST_INFO *a, const ASN1_OBJECT *obj,
|
||||
int lastpos);
|
||||
int TS_TST_INFO_get_ext_by_critical(TS_TST_INFO *a, int crit, int lastpos);
|
||||
X509_EXTENSION *TS_TST_INFO_get_ext(TS_TST_INFO *a, int loc);
|
||||
X509_EXTENSION *TS_TST_INFO_delete_ext(TS_TST_INFO *a, int loc);
|
||||
int TS_TST_INFO_add_ext(TS_TST_INFO *a, X509_EXTENSION *ex, int loc);
|
||||
void *TS_TST_INFO_get_ext_d2i(TS_TST_INFO *a, int nid, int *crit, int *idx);
|
||||
|
||||
/*
|
||||
* Declarations related to response generation, defined in ts/ts_resp_sign.c.
|
||||
*/
|
||||
|
||||
/* Optional flags for response generation. */
|
||||
|
||||
/* Don't include the TSA name in response. */
|
||||
# define TS_TSA_NAME 0x01
|
||||
|
||||
/* Set ordering to true in response. */
|
||||
# define TS_ORDERING 0x02
|
||||
|
||||
/*
|
||||
* Include the signer certificate and the other specified certificates in
|
||||
* the ESS signing certificate attribute beside the PKCS7 signed data.
|
||||
* Only the signer certificates is included by default.
|
||||
*/
|
||||
# define TS_ESS_CERT_ID_CHAIN 0x04
|
||||
|
||||
/* Forward declaration. */
|
||||
struct TS_resp_ctx;
|
||||
|
||||
/* This must return a unique number less than 160 bits long. */
|
||||
typedef ASN1_INTEGER *(*TS_serial_cb) (struct TS_resp_ctx *, void *);
|
||||
|
||||
/*
|
||||
* This must return the seconds and microseconds since Jan 1, 1970 in the sec
|
||||
* and usec variables allocated by the caller. Return non-zero for success
|
||||
* and zero for failure.
|
||||
*/
|
||||
typedef int (*TS_time_cb) (struct TS_resp_ctx *, void *, long *sec,
|
||||
long *usec);
|
||||
|
||||
/*
|
||||
* This must process the given extension. It can modify the TS_TST_INFO
|
||||
* object of the context. Return values: !0 (processed), 0 (error, it must
|
||||
* set the status info/failure info of the response).
|
||||
*/
|
||||
typedef int (*TS_extension_cb) (struct TS_resp_ctx *, X509_EXTENSION *,
|
||||
void *);
|
||||
|
||||
typedef struct TS_resp_ctx TS_RESP_CTX;
|
||||
|
||||
DEFINE_STACK_OF_CONST(EVP_MD)
|
||||
|
||||
/* Creates a response context that can be used for generating responses. */
|
||||
TS_RESP_CTX *TS_RESP_CTX_new(void);
|
||||
void TS_RESP_CTX_free(TS_RESP_CTX *ctx);
|
||||
|
||||
/* This parameter must be set. */
|
||||
int TS_RESP_CTX_set_signer_cert(TS_RESP_CTX *ctx, X509 *signer);
|
||||
|
||||
/* This parameter must be set. */
|
||||
int TS_RESP_CTX_set_signer_key(TS_RESP_CTX *ctx, EVP_PKEY *key);
|
||||
|
||||
int TS_RESP_CTX_set_signer_digest(TS_RESP_CTX *ctx,
|
||||
const EVP_MD *signer_digest);
|
||||
|
||||
/* This parameter must be set. */
|
||||
int TS_RESP_CTX_set_def_policy(TS_RESP_CTX *ctx, const ASN1_OBJECT *def_policy);
|
||||
|
||||
/* No additional certs are included in the response by default. */
|
||||
int TS_RESP_CTX_set_certs(TS_RESP_CTX *ctx, STACK_OF(X509) *certs);
|
||||
|
||||
/*
|
||||
* Adds a new acceptable policy, only the default policy is accepted by
|
||||
* default.
|
||||
*/
|
||||
int TS_RESP_CTX_add_policy(TS_RESP_CTX *ctx, const ASN1_OBJECT *policy);
|
||||
|
||||
/*
|
||||
* Adds a new acceptable message digest. Note that no message digests are
|
||||
* accepted by default. The md argument is shared with the caller.
|
||||
*/
|
||||
int TS_RESP_CTX_add_md(TS_RESP_CTX *ctx, const EVP_MD *md);
|
||||
|
||||
/* Accuracy is not included by default. */
|
||||
int TS_RESP_CTX_set_accuracy(TS_RESP_CTX *ctx,
|
||||
int secs, int millis, int micros);
|
||||
|
||||
/*
|
||||
* Clock precision digits, i.e. the number of decimal digits: '0' means sec,
|
||||
* '3' msec, '6' usec, and so on. Default is 0.
|
||||
*/
|
||||
int TS_RESP_CTX_set_clock_precision_digits(TS_RESP_CTX *ctx,
|
||||
unsigned clock_precision_digits);
|
||||
/* At most we accept usec precision. */
|
||||
# define TS_MAX_CLOCK_PRECISION_DIGITS 6
|
||||
|
||||
/* Maximum status message length */
|
||||
# define TS_MAX_STATUS_LENGTH (1024 * 1024)
|
||||
|
||||
/* No flags are set by default. */
|
||||
void TS_RESP_CTX_add_flags(TS_RESP_CTX *ctx, int flags);
|
||||
|
||||
/* Default callback always returns a constant. */
|
||||
void TS_RESP_CTX_set_serial_cb(TS_RESP_CTX *ctx, TS_serial_cb cb, void *data);
|
||||
|
||||
/* Default callback uses the gettimeofday() and gmtime() system calls. */
|
||||
void TS_RESP_CTX_set_time_cb(TS_RESP_CTX *ctx, TS_time_cb cb, void *data);
|
||||
|
||||
/*
|
||||
* Default callback rejects all extensions. The extension callback is called
|
||||
* when the TS_TST_INFO object is already set up and not signed yet.
|
||||
*/
|
||||
/* FIXME: extension handling is not tested yet. */
|
||||
void TS_RESP_CTX_set_extension_cb(TS_RESP_CTX *ctx,
|
||||
TS_extension_cb cb, void *data);
|
||||
|
||||
/* The following methods can be used in the callbacks. */
|
||||
int TS_RESP_CTX_set_status_info(TS_RESP_CTX *ctx,
|
||||
int status, const char *text);
|
||||
|
||||
/* Sets the status info only if it is still TS_STATUS_GRANTED. */
|
||||
int TS_RESP_CTX_set_status_info_cond(TS_RESP_CTX *ctx,
|
||||
int status, const char *text);
|
||||
|
||||
int TS_RESP_CTX_add_failure_info(TS_RESP_CTX *ctx, int failure);
|
||||
|
||||
/* The get methods below can be used in the extension callback. */
|
||||
TS_REQ *TS_RESP_CTX_get_request(TS_RESP_CTX *ctx);
|
||||
|
||||
TS_TST_INFO *TS_RESP_CTX_get_tst_info(TS_RESP_CTX *ctx);
|
||||
|
||||
/*
|
||||
* Creates the signed TS_TST_INFO and puts it in TS_RESP.
|
||||
* In case of errors it sets the status info properly.
|
||||
* Returns NULL only in case of memory allocation/fatal error.
|
||||
*/
|
||||
TS_RESP *TS_RESP_create_response(TS_RESP_CTX *ctx, BIO *req_bio);
|
||||
|
||||
/*
|
||||
* Declarations related to response verification,
|
||||
* they are defined in ts/ts_resp_verify.c.
|
||||
*/
|
||||
|
||||
int TS_RESP_verify_signature(PKCS7 *token, STACK_OF(X509) *certs,
|
||||
X509_STORE *store, X509 **signer_out);
|
||||
|
||||
/* Context structure for the generic verify method. */
|
||||
|
||||
/* Verify the signer's certificate and the signature of the response. */
|
||||
# define TS_VFY_SIGNATURE (1u << 0)
|
||||
/* Verify the version number of the response. */
|
||||
# define TS_VFY_VERSION (1u << 1)
|
||||
/* Verify if the policy supplied by the user matches the policy of the TSA. */
|
||||
# define TS_VFY_POLICY (1u << 2)
|
||||
/*
|
||||
* Verify the message imprint provided by the user. This flag should not be
|
||||
* specified with TS_VFY_DATA.
|
||||
*/
|
||||
# define TS_VFY_IMPRINT (1u << 3)
|
||||
/*
|
||||
* Verify the message imprint computed by the verify method from the user
|
||||
* provided data and the MD algorithm of the response. This flag should not
|
||||
* be specified with TS_VFY_IMPRINT.
|
||||
*/
|
||||
# define TS_VFY_DATA (1u << 4)
|
||||
/* Verify the nonce value. */
|
||||
# define TS_VFY_NONCE (1u << 5)
|
||||
/* Verify if the TSA name field matches the signer certificate. */
|
||||
# define TS_VFY_SIGNER (1u << 6)
|
||||
/* Verify if the TSA name field equals to the user provided name. */
|
||||
# define TS_VFY_TSA_NAME (1u << 7)
|
||||
|
||||
/* You can use the following convenience constants. */
|
||||
# define TS_VFY_ALL_IMPRINT (TS_VFY_SIGNATURE \
|
||||
| TS_VFY_VERSION \
|
||||
| TS_VFY_POLICY \
|
||||
| TS_VFY_IMPRINT \
|
||||
| TS_VFY_NONCE \
|
||||
| TS_VFY_SIGNER \
|
||||
| TS_VFY_TSA_NAME)
|
||||
# define TS_VFY_ALL_DATA (TS_VFY_SIGNATURE \
|
||||
| TS_VFY_VERSION \
|
||||
| TS_VFY_POLICY \
|
||||
| TS_VFY_DATA \
|
||||
| TS_VFY_NONCE \
|
||||
| TS_VFY_SIGNER \
|
||||
| TS_VFY_TSA_NAME)
|
||||
|
||||
typedef struct TS_verify_ctx TS_VERIFY_CTX;
|
||||
|
||||
int TS_RESP_verify_response(TS_VERIFY_CTX *ctx, TS_RESP *response);
|
||||
int TS_RESP_verify_token(TS_VERIFY_CTX *ctx, PKCS7 *token);
|
||||
|
||||
/*
|
||||
* Declarations related to response verification context,
|
||||
*/
|
||||
TS_VERIFY_CTX *TS_VERIFY_CTX_new(void);
|
||||
void TS_VERIFY_CTX_init(TS_VERIFY_CTX *ctx);
|
||||
void TS_VERIFY_CTX_free(TS_VERIFY_CTX *ctx);
|
||||
void TS_VERIFY_CTX_cleanup(TS_VERIFY_CTX *ctx);
|
||||
int TS_VERIFY_CTX_set_flags(TS_VERIFY_CTX *ctx, int f);
|
||||
int TS_VERIFY_CTX_add_flags(TS_VERIFY_CTX *ctx, int f);
|
||||
BIO *TS_VERIFY_CTX_set_data(TS_VERIFY_CTX *ctx, BIO *b);
|
||||
unsigned char *TS_VERIFY_CTX_set_imprint(TS_VERIFY_CTX *ctx,
|
||||
unsigned char *hexstr, long len);
|
||||
X509_STORE *TS_VERIFY_CTX_set_store(TS_VERIFY_CTX *ctx, X509_STORE *s);
|
||||
STACK_OF(X509) *TS_VERIFY_CTS_set_certs(TS_VERIFY_CTX *ctx, STACK_OF(X509) *certs);
|
||||
|
||||
/*-
|
||||
* If ctx is NULL, it allocates and returns a new object, otherwise
|
||||
* it returns ctx. It initialises all the members as follows:
|
||||
* flags = TS_VFY_ALL_IMPRINT & ~(TS_VFY_TSA_NAME | TS_VFY_SIGNATURE)
|
||||
* certs = NULL
|
||||
* store = NULL
|
||||
* policy = policy from the request or NULL if absent (in this case
|
||||
* TS_VFY_POLICY is cleared from flags as well)
|
||||
* md_alg = MD algorithm from request
|
||||
* imprint, imprint_len = imprint from request
|
||||
* data = NULL
|
||||
* nonce, nonce_len = nonce from the request or NULL if absent (in this case
|
||||
* TS_VFY_NONCE is cleared from flags as well)
|
||||
* tsa_name = NULL
|
||||
* Important: after calling this method TS_VFY_SIGNATURE should be added!
|
||||
*/
|
||||
TS_VERIFY_CTX *TS_REQ_to_TS_VERIFY_CTX(TS_REQ *req, TS_VERIFY_CTX *ctx);
|
||||
|
||||
/* Function declarations for TS_RESP defined in ts/ts_resp_print.c */
|
||||
|
||||
int TS_RESP_print_bio(BIO *bio, TS_RESP *a);
|
||||
int TS_STATUS_INFO_print_bio(BIO *bio, TS_STATUS_INFO *a);
|
||||
int TS_TST_INFO_print_bio(BIO *bio, TS_TST_INFO *a);
|
||||
|
||||
/* Common utility functions defined in ts/ts_lib.c */
|
||||
|
||||
int TS_ASN1_INTEGER_print_bio(BIO *bio, const ASN1_INTEGER *num);
|
||||
int TS_OBJ_print_bio(BIO *bio, const ASN1_OBJECT *obj);
|
||||
int TS_ext_print_bio(BIO *bio, const STACK_OF(X509_EXTENSION) *extensions);
|
||||
int TS_X509_ALGOR_print_bio(BIO *bio, const X509_ALGOR *alg);
|
||||
int TS_MSG_IMPRINT_print_bio(BIO *bio, TS_MSG_IMPRINT *msg);
|
||||
|
||||
/*
|
||||
* Function declarations for handling configuration options, defined in
|
||||
* ts/ts_conf.c
|
||||
*/
|
||||
|
||||
X509 *TS_CONF_load_cert(const char *file);
|
||||
STACK_OF(X509) *TS_CONF_load_certs(const char *file);
|
||||
EVP_PKEY *TS_CONF_load_key(const char *file, const char *pass);
|
||||
const char *TS_CONF_get_tsa_section(CONF *conf, const char *section);
|
||||
int TS_CONF_set_serial(CONF *conf, const char *section, TS_serial_cb cb,
|
||||
TS_RESP_CTX *ctx);
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
int TS_CONF_set_crypto_device(CONF *conf, const char *section,
|
||||
const char *device);
|
||||
int TS_CONF_set_default_engine(const char *name);
|
||||
#endif
|
||||
int TS_CONF_set_signer_cert(CONF *conf, const char *section,
|
||||
const char *cert, TS_RESP_CTX *ctx);
|
||||
int TS_CONF_set_certs(CONF *conf, const char *section, const char *certs,
|
||||
TS_RESP_CTX *ctx);
|
||||
int TS_CONF_set_signer_key(CONF *conf, const char *section,
|
||||
const char *key, const char *pass,
|
||||
TS_RESP_CTX *ctx);
|
||||
int TS_CONF_set_signer_digest(CONF *conf, const char *section,
|
||||
const char *md, TS_RESP_CTX *ctx);
|
||||
int TS_CONF_set_def_policy(CONF *conf, const char *section,
|
||||
const char *policy, TS_RESP_CTX *ctx);
|
||||
int TS_CONF_set_policies(CONF *conf, const char *section, TS_RESP_CTX *ctx);
|
||||
int TS_CONF_set_digests(CONF *conf, const char *section, TS_RESP_CTX *ctx);
|
||||
int TS_CONF_set_accuracy(CONF *conf, const char *section, TS_RESP_CTX *ctx);
|
||||
int TS_CONF_set_clock_precision_digits(CONF *conf, const char *section,
|
||||
TS_RESP_CTX *ctx);
|
||||
int TS_CONF_set_ordering(CONF *conf, const char *section, TS_RESP_CTX *ctx);
|
||||
int TS_CONF_set_tsa_name(CONF *conf, const char *section, TS_RESP_CTX *ctx);
|
||||
int TS_CONF_set_ess_cert_id_chain(CONF *conf, const char *section,
|
||||
TS_RESP_CTX *ctx);
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
/* BEGIN ERROR CODES */
|
||||
/*
|
||||
* The following lines are auto generated by the script mkerr.pl. Any changes
|
||||
* made after this point may be overwritten when the script is next run.
|
||||
*/
|
||||
|
||||
int ERR_load_TS_strings(void);
|
||||
|
||||
/* Error codes for the TS functions. */
|
||||
|
||||
/* Function codes. */
|
||||
# define TS_F_DEF_SERIAL_CB 110
|
||||
# define TS_F_DEF_TIME_CB 111
|
||||
# define TS_F_ESS_ADD_SIGNING_CERT 112
|
||||
# define TS_F_ESS_CERT_ID_NEW_INIT 113
|
||||
# define TS_F_ESS_SIGNING_CERT_NEW_INIT 114
|
||||
# define TS_F_INT_TS_RESP_VERIFY_TOKEN 149
|
||||
# define TS_F_PKCS7_TO_TS_TST_INFO 148
|
||||
# define TS_F_TS_ACCURACY_SET_MICROS 115
|
||||
# define TS_F_TS_ACCURACY_SET_MILLIS 116
|
||||
# define TS_F_TS_ACCURACY_SET_SECONDS 117
|
||||
# define TS_F_TS_CHECK_IMPRINTS 100
|
||||
# define TS_F_TS_CHECK_NONCES 101
|
||||
# define TS_F_TS_CHECK_POLICY 102
|
||||
# define TS_F_TS_CHECK_SIGNING_CERTS 103
|
||||
# define TS_F_TS_CHECK_STATUS_INFO 104
|
||||
# define TS_F_TS_COMPUTE_IMPRINT 145
|
||||
# define TS_F_TS_CONF_INVALID 151
|
||||
# define TS_F_TS_CONF_LOAD_CERT 153
|
||||
# define TS_F_TS_CONF_LOAD_CERTS 154
|
||||
# define TS_F_TS_CONF_LOAD_KEY 155
|
||||
# define TS_F_TS_CONF_LOOKUP_FAIL 152
|
||||
# define TS_F_TS_CONF_SET_DEFAULT_ENGINE 146
|
||||
# define TS_F_TS_GET_STATUS_TEXT 105
|
||||
# define TS_F_TS_MSG_IMPRINT_SET_ALGO 118
|
||||
# define TS_F_TS_REQ_SET_MSG_IMPRINT 119
|
||||
# define TS_F_TS_REQ_SET_NONCE 120
|
||||
# define TS_F_TS_REQ_SET_POLICY_ID 121
|
||||
# define TS_F_TS_RESP_CREATE_RESPONSE 122
|
||||
# define TS_F_TS_RESP_CREATE_TST_INFO 123
|
||||
# define TS_F_TS_RESP_CTX_ADD_FAILURE_INFO 124
|
||||
# define TS_F_TS_RESP_CTX_ADD_MD 125
|
||||
# define TS_F_TS_RESP_CTX_ADD_POLICY 126
|
||||
# define TS_F_TS_RESP_CTX_NEW 127
|
||||
# define TS_F_TS_RESP_CTX_SET_ACCURACY 128
|
||||
# define TS_F_TS_RESP_CTX_SET_CERTS 129
|
||||
# define TS_F_TS_RESP_CTX_SET_DEF_POLICY 130
|
||||
# define TS_F_TS_RESP_CTX_SET_SIGNER_CERT 131
|
||||
# define TS_F_TS_RESP_CTX_SET_STATUS_INFO 132
|
||||
# define TS_F_TS_RESP_GET_POLICY 133
|
||||
# define TS_F_TS_RESP_SET_GENTIME_WITH_PRECISION 134
|
||||
# define TS_F_TS_RESP_SET_STATUS_INFO 135
|
||||
# define TS_F_TS_RESP_SET_TST_INFO 150
|
||||
# define TS_F_TS_RESP_SIGN 136
|
||||
# define TS_F_TS_RESP_VERIFY_SIGNATURE 106
|
||||
# define TS_F_TS_TST_INFO_SET_ACCURACY 137
|
||||
# define TS_F_TS_TST_INFO_SET_MSG_IMPRINT 138
|
||||
# define TS_F_TS_TST_INFO_SET_NONCE 139
|
||||
# define TS_F_TS_TST_INFO_SET_POLICY_ID 140
|
||||
# define TS_F_TS_TST_INFO_SET_SERIAL 141
|
||||
# define TS_F_TS_TST_INFO_SET_TIME 142
|
||||
# define TS_F_TS_TST_INFO_SET_TSA 143
|
||||
# define TS_F_TS_VERIFY 108
|
||||
# define TS_F_TS_VERIFY_CERT 109
|
||||
# define TS_F_TS_VERIFY_CTX_NEW 144
|
||||
|
||||
/* Reason codes. */
|
||||
# define TS_R_BAD_PKCS7_TYPE 132
|
||||
# define TS_R_BAD_TYPE 133
|
||||
# define TS_R_CANNOT_LOAD_CERT 137
|
||||
# define TS_R_CANNOT_LOAD_KEY 138
|
||||
# define TS_R_CERTIFICATE_VERIFY_ERROR 100
|
||||
# define TS_R_COULD_NOT_SET_ENGINE 127
|
||||
# define TS_R_COULD_NOT_SET_TIME 115
|
||||
# define TS_R_DETACHED_CONTENT 134
|
||||
# define TS_R_ESS_ADD_SIGNING_CERT_ERROR 116
|
||||
# define TS_R_ESS_SIGNING_CERTIFICATE_ERROR 101
|
||||
# define TS_R_INVALID_NULL_POINTER 102
|
||||
# define TS_R_INVALID_SIGNER_CERTIFICATE_PURPOSE 117
|
||||
# define TS_R_MESSAGE_IMPRINT_MISMATCH 103
|
||||
# define TS_R_NONCE_MISMATCH 104
|
||||
# define TS_R_NONCE_NOT_RETURNED 105
|
||||
# define TS_R_NO_CONTENT 106
|
||||
# define TS_R_NO_TIME_STAMP_TOKEN 107
|
||||
# define TS_R_PKCS7_ADD_SIGNATURE_ERROR 118
|
||||
# define TS_R_PKCS7_ADD_SIGNED_ATTR_ERROR 119
|
||||
# define TS_R_PKCS7_TO_TS_TST_INFO_FAILED 129
|
||||
# define TS_R_POLICY_MISMATCH 108
|
||||
# define TS_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE 120
|
||||
# define TS_R_RESPONSE_SETUP_ERROR 121
|
||||
# define TS_R_SIGNATURE_FAILURE 109
|
||||
# define TS_R_THERE_MUST_BE_ONE_SIGNER 110
|
||||
# define TS_R_TIME_SYSCALL_ERROR 122
|
||||
# define TS_R_TOKEN_NOT_PRESENT 130
|
||||
# define TS_R_TOKEN_PRESENT 131
|
||||
# define TS_R_TSA_NAME_MISMATCH 111
|
||||
# define TS_R_TSA_UNTRUSTED 112
|
||||
# define TS_R_TST_INFO_SETUP_ERROR 123
|
||||
# define TS_R_TS_DATASIGN 124
|
||||
# define TS_R_UNACCEPTABLE_POLICY 125
|
||||
# define TS_R_UNSUPPORTED_MD_ALGORITHM 126
|
||||
# define TS_R_UNSUPPORTED_VERSION 113
|
||||
# define TS_R_VAR_BAD_VALUE 135
|
||||
# define TS_R_VAR_LOOKUP_FAILURE 136
|
||||
# define TS_R_WRONG_CONTENT_TYPE 114
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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_TXT_DB_H
|
||||
# define HEADER_TXT_DB_H
|
||||
|
||||
# include <openssl/opensslconf.h>
|
||||
# include <openssl/bio.h>
|
||||
# include <openssl/stack.h>
|
||||
# include <openssl/lhash.h>
|
||||
|
||||
# define DB_ERROR_OK 0
|
||||
# define DB_ERROR_MALLOC 1
|
||||
# define DB_ERROR_INDEX_CLASH 2
|
||||
# define DB_ERROR_INDEX_OUT_OF_RANGE 3
|
||||
# define DB_ERROR_NO_INDEX 4
|
||||
# define DB_ERROR_INSERT_INDEX_CLASH 5
|
||||
# define DB_ERROR_WRONG_NUM_FIELDS 6
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef OPENSSL_STRING *OPENSSL_PSTRING;
|
||||
DEFINE_SPECIAL_STACK_OF(OPENSSL_PSTRING, OPENSSL_STRING)
|
||||
|
||||
typedef struct txt_db_st {
|
||||
int num_fields;
|
||||
STACK_OF(OPENSSL_PSTRING) *data;
|
||||
LHASH_OF(OPENSSL_STRING) **index;
|
||||
int (**qual) (OPENSSL_STRING *);
|
||||
long error;
|
||||
long arg1;
|
||||
long arg2;
|
||||
OPENSSL_STRING *arg_row;
|
||||
} TXT_DB;
|
||||
|
||||
TXT_DB *TXT_DB_read(BIO *in, int num);
|
||||
long TXT_DB_write(BIO *out, TXT_DB *db);
|
||||
int TXT_DB_create_index(TXT_DB *db, int field, int (*qual) (OPENSSL_STRING *),
|
||||
OPENSSL_LH_HASHFUNC hash, OPENSSL_LH_COMPFUNC cmp);
|
||||
void TXT_DB_free(TXT_DB *db);
|
||||
OPENSSL_STRING *TXT_DB_get_by_index(TXT_DB *db, int idx,
|
||||
OPENSSL_STRING *value);
|
||||
int TXT_DB_insert(TXT_DB *db, OPENSSL_STRING *value);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,368 @@
|
|||
/*
|
||||
* Copyright 2001-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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_H
|
||||
# define HEADER_UI_H
|
||||
|
||||
# include <openssl/opensslconf.h>
|
||||
|
||||
# ifndef OPENSSL_NO_UI
|
||||
|
||||
# if OPENSSL_API_COMPAT < 0x10100000L
|
||||
# include <openssl/crypto.h>
|
||||
# endif
|
||||
# include <openssl/safestack.h>
|
||||
# include <openssl/ossl_typ.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* All the following functions return -1 or NULL on error and in some cases
|
||||
* (UI_process()) -2 if interrupted or in some other way cancelled. When
|
||||
* everything is fine, they return 0, a positive value or a non-NULL pointer,
|
||||
* all depending on their purpose.
|
||||
*/
|
||||
|
||||
/* Creators and destructor. */
|
||||
UI *UI_new(void);
|
||||
UI *UI_new_method(const UI_METHOD *method);
|
||||
void UI_free(UI *ui);
|
||||
|
||||
/*-
|
||||
The following functions are used to add strings to be printed and prompt
|
||||
strings to prompt for data. The names are UI_{add,dup}_<function>_string
|
||||
and UI_{add,dup}_input_boolean.
|
||||
|
||||
UI_{add,dup}_<function>_string have the following meanings:
|
||||
add add a text or prompt string. The pointers given to these
|
||||
functions are used verbatim, no copying is done.
|
||||
dup make a copy of the text or prompt string, then add the copy
|
||||
to the collection of strings in the user interface.
|
||||
<function>
|
||||
The function is a name for the functionality that the given
|
||||
string shall be used for. It can be one of:
|
||||
input use the string as data prompt.
|
||||
verify use the string as verification prompt. This
|
||||
is used to verify a previous input.
|
||||
info use the string for informational output.
|
||||
error use the string for error output.
|
||||
Honestly, there's currently no difference between info and error for the
|
||||
moment.
|
||||
|
||||
UI_{add,dup}_input_boolean have the same semantics for "add" and "dup",
|
||||
and are typically used when one wants to prompt for a yes/no response.
|
||||
|
||||
All of the functions in this group take a UI and a prompt string.
|
||||
The string input and verify addition functions also take a flag argument,
|
||||
a buffer for the result to end up with, a minimum input size and a maximum
|
||||
input size (the result buffer MUST be large enough to be able to contain
|
||||
the maximum number of characters). Additionally, the verify addition
|
||||
functions takes another buffer to compare the result against.
|
||||
The boolean input functions take an action description string (which should
|
||||
be safe to ignore if the expected user action is obvious, for example with
|
||||
a dialog box with an OK button and a Cancel button), a string of acceptable
|
||||
characters to mean OK and to mean Cancel. The two last strings are checked
|
||||
to make sure they don't have common characters. Additionally, the same
|
||||
flag argument as for the string input is taken, as well as a result buffer.
|
||||
The result buffer is required to be at least one byte long. Depending on
|
||||
the answer, the first character from the OK or the Cancel character strings
|
||||
will be stored in the first byte of the result buffer. No NUL will be
|
||||
added, so the result is *not* a string.
|
||||
|
||||
On success, the all return an index of the added information. That index
|
||||
is useful when retrieving results with UI_get0_result(). */
|
||||
int UI_add_input_string(UI *ui, const char *prompt, int flags,
|
||||
char *result_buf, int minsize, int maxsize);
|
||||
int UI_dup_input_string(UI *ui, const char *prompt, int flags,
|
||||
char *result_buf, int minsize, int maxsize);
|
||||
int UI_add_verify_string(UI *ui, const char *prompt, int flags,
|
||||
char *result_buf, int minsize, int maxsize,
|
||||
const char *test_buf);
|
||||
int UI_dup_verify_string(UI *ui, const char *prompt, int flags,
|
||||
char *result_buf, int minsize, int maxsize,
|
||||
const char *test_buf);
|
||||
int UI_add_input_boolean(UI *ui, const char *prompt, const char *action_desc,
|
||||
const char *ok_chars, const char *cancel_chars,
|
||||
int flags, char *result_buf);
|
||||
int UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc,
|
||||
const char *ok_chars, const char *cancel_chars,
|
||||
int flags, char *result_buf);
|
||||
int UI_add_info_string(UI *ui, const char *text);
|
||||
int UI_dup_info_string(UI *ui, const char *text);
|
||||
int UI_add_error_string(UI *ui, const char *text);
|
||||
int UI_dup_error_string(UI *ui, const char *text);
|
||||
|
||||
/* These are the possible flags. They can be or'ed together. */
|
||||
/* Use to have echoing of input */
|
||||
# define UI_INPUT_FLAG_ECHO 0x01
|
||||
/*
|
||||
* Use a default password. Where that password is found is completely up to
|
||||
* the application, it might for example be in the user data set with
|
||||
* UI_add_user_data(). It is not recommended to have more than one input in
|
||||
* each UI being marked with this flag, or the application might get
|
||||
* confused.
|
||||
*/
|
||||
# define UI_INPUT_FLAG_DEFAULT_PWD 0x02
|
||||
|
||||
/*-
|
||||
* The user of these routines may want to define flags of their own. The core
|
||||
* UI won't look at those, but will pass them on to the method routines. They
|
||||
* must use higher bits so they don't get confused with the UI bits above.
|
||||
* UI_INPUT_FLAG_USER_BASE tells which is the lowest bit to use. A good
|
||||
* example of use is this:
|
||||
*
|
||||
* #define MY_UI_FLAG1 (0x01 << UI_INPUT_FLAG_USER_BASE)
|
||||
*
|
||||
*/
|
||||
# define UI_INPUT_FLAG_USER_BASE 16
|
||||
|
||||
/*-
|
||||
* The following function helps construct a prompt. 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().
|
||||
*
|
||||
* If the ui_method doesn't contain a pointer to a user-defined prompt
|
||||
* constructor, a default string is built, looking like this:
|
||||
*
|
||||
* "Enter {object_desc} for {object_name}:"
|
||||
*
|
||||
* So, if object_desc has the value "pass phrase" and object_name has
|
||||
* the value "foo.key", the resulting string is:
|
||||
*
|
||||
* "Enter pass phrase for foo.key:"
|
||||
*/
|
||||
char *UI_construct_prompt(UI *ui_method,
|
||||
const char *object_desc, const char *object_name);
|
||||
|
||||
/*
|
||||
* The following function is used to store a pointer to user-specific data.
|
||||
* Any previous such pointer will be returned and replaced.
|
||||
*
|
||||
* For callback purposes, this function makes a lot more sense than using
|
||||
* ex_data, since the latter requires that different parts of OpenSSL or
|
||||
* applications share the same ex_data index.
|
||||
*
|
||||
* Note that the UI_OpenSSL() method completely ignores the user data. Other
|
||||
* methods may not, however.
|
||||
*/
|
||||
void *UI_add_user_data(UI *ui, void *user_data);
|
||||
/* We need a user data retrieving function as well. */
|
||||
void *UI_get0_user_data(UI *ui);
|
||||
|
||||
/* Return the result associated with a prompt given with the index i. */
|
||||
const char *UI_get0_result(UI *ui, int i);
|
||||
|
||||
/* When all strings have been added, process the whole thing. */
|
||||
int UI_process(UI *ui);
|
||||
|
||||
/*
|
||||
* Give a user interface parametrised control commands. This can be used to
|
||||
* send down an integer, a data pointer or a function pointer, as well as be
|
||||
* used to get information from a UI.
|
||||
*/
|
||||
int UI_ctrl(UI *ui, int cmd, long i, void *p, void (*f) (void));
|
||||
|
||||
/* The commands */
|
||||
/*
|
||||
* Use UI_CONTROL_PRINT_ERRORS with the value 1 to have UI_process print the
|
||||
* OpenSSL error stack before printing any info or added error messages and
|
||||
* before any prompting.
|
||||
*/
|
||||
# define UI_CTRL_PRINT_ERRORS 1
|
||||
/*
|
||||
* Check if a UI_process() is possible to do again with the same instance of
|
||||
* a user interface. This makes UI_ctrl() return 1 if it is redoable, and 0
|
||||
* if not.
|
||||
*/
|
||||
# define UI_CTRL_IS_REDOABLE 2
|
||||
|
||||
/* Some methods may use extra data */
|
||||
# define UI_set_app_data(s,arg) UI_set_ex_data(s,0,arg)
|
||||
# define UI_get_app_data(s) UI_get_ex_data(s,0)
|
||||
|
||||
#define UI_get_ex_new_index(l, p, newf, dupf, freef) \
|
||||
CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_UI, l, p, newf, dupf, freef)
|
||||
int UI_set_ex_data(UI *r, int idx, void *arg);
|
||||
void *UI_get_ex_data(UI *r, int idx);
|
||||
|
||||
/* Use specific methods instead of the built-in one */
|
||||
void UI_set_default_method(const UI_METHOD *meth);
|
||||
const UI_METHOD *UI_get_default_method(void);
|
||||
const UI_METHOD *UI_get_method(UI *ui);
|
||||
const UI_METHOD *UI_set_method(UI *ui, const UI_METHOD *meth);
|
||||
|
||||
/* The method with all the built-in thingies */
|
||||
UI_METHOD *UI_OpenSSL(void);
|
||||
|
||||
/* ---------- For method writers ---------- */
|
||||
/*-
|
||||
A method contains a number of functions that implement the low level
|
||||
of the User Interface. The functions are:
|
||||
|
||||
an opener This function starts a session, maybe by opening
|
||||
a channel to a tty, or by opening a window.
|
||||
a writer This function is called to write a given string,
|
||||
maybe to the tty, maybe as a field label in a
|
||||
window.
|
||||
a flusher This function is called to flush everything that
|
||||
has been output so far. It can be used to actually
|
||||
display a dialog box after it has been built.
|
||||
a reader This function is called to read a given prompt,
|
||||
maybe from the tty, maybe from a field in a
|
||||
window. Note that it's called with all string
|
||||
structures, not only the prompt ones, so it must
|
||||
check such things itself.
|
||||
a closer This function closes the session, maybe by closing
|
||||
the channel to the tty, or closing the window.
|
||||
|
||||
All these functions are expected to return:
|
||||
|
||||
0 on error.
|
||||
1 on success.
|
||||
-1 on out-of-band events, for example if some prompting has
|
||||
been canceled (by pressing Ctrl-C, for example). This is
|
||||
only checked when returned by the flusher or the reader.
|
||||
|
||||
The way this is used, the opener is first called, then the writer for all
|
||||
strings, then the flusher, then the reader for all strings and finally the
|
||||
closer. Note that if you want to prompt from a terminal or other command
|
||||
line interface, the best is to have the reader also write the prompts
|
||||
instead of having the writer do it. If you want to prompt from a dialog
|
||||
box, the writer can be used to build up the contents of the box, and the
|
||||
flusher to actually display the box and run the event loop until all data
|
||||
has been given, after which the reader only grabs the given data and puts
|
||||
them back into the UI strings.
|
||||
|
||||
All method functions take a UI as argument. Additionally, the writer and
|
||||
the reader take a UI_STRING.
|
||||
*/
|
||||
|
||||
/*
|
||||
* The UI_STRING type is the data structure that contains all the needed info
|
||||
* about a string or a prompt, including test data for a verification prompt.
|
||||
*/
|
||||
typedef struct ui_string_st UI_STRING;
|
||||
DEFINE_STACK_OF(UI_STRING)
|
||||
|
||||
/*
|
||||
* The different types of strings that are currently supported. This is only
|
||||
* needed by method authors.
|
||||
*/
|
||||
enum UI_string_types {
|
||||
UIT_NONE = 0,
|
||||
UIT_PROMPT, /* Prompt for a string */
|
||||
UIT_VERIFY, /* Prompt for a string and verify */
|
||||
UIT_BOOLEAN, /* Prompt for a yes/no response */
|
||||
UIT_INFO, /* Send info to the user */
|
||||
UIT_ERROR /* Send an error message to the user */
|
||||
};
|
||||
|
||||
/* Create and manipulate methods */
|
||||
UI_METHOD *UI_create_method(const char *name);
|
||||
void UI_destroy_method(UI_METHOD *ui_method);
|
||||
int UI_method_set_opener(UI_METHOD *method, int (*opener) (UI *ui));
|
||||
int UI_method_set_writer(UI_METHOD *method,
|
||||
int (*writer) (UI *ui, UI_STRING *uis));
|
||||
int UI_method_set_flusher(UI_METHOD *method, int (*flusher) (UI *ui));
|
||||
int UI_method_set_reader(UI_METHOD *method,
|
||||
int (*reader) (UI *ui, UI_STRING *uis));
|
||||
int UI_method_set_closer(UI_METHOD *method, int (*closer) (UI *ui));
|
||||
int UI_method_set_prompt_constructor(UI_METHOD *method,
|
||||
char *(*prompt_constructor) (UI *ui,
|
||||
const char
|
||||
*object_desc,
|
||||
const char
|
||||
*object_name));
|
||||
int (*UI_method_get_opener(UI_METHOD *method)) (UI *);
|
||||
int (*UI_method_get_writer(UI_METHOD *method)) (UI *, UI_STRING *);
|
||||
int (*UI_method_get_flusher(UI_METHOD *method)) (UI *);
|
||||
int (*UI_method_get_reader(UI_METHOD *method)) (UI *, UI_STRING *);
|
||||
int (*UI_method_get_closer(UI_METHOD *method)) (UI *);
|
||||
char *(*UI_method_get_prompt_constructor(UI_METHOD *method)) (UI *,
|
||||
const char *,
|
||||
const char *);
|
||||
|
||||
/*
|
||||
* The following functions are helpers for method writers to access relevant
|
||||
* data from a UI_STRING.
|
||||
*/
|
||||
|
||||
/* Return type of the UI_STRING */
|
||||
enum UI_string_types UI_get_string_type(UI_STRING *uis);
|
||||
/* Return input flags of the UI_STRING */
|
||||
int UI_get_input_flags(UI_STRING *uis);
|
||||
/* Return the actual string to output (the prompt, info or error) */
|
||||
const char *UI_get0_output_string(UI_STRING *uis);
|
||||
/*
|
||||
* Return the optional action string to output (the boolean prompt
|
||||
* instruction)
|
||||
*/
|
||||
const char *UI_get0_action_string(UI_STRING *uis);
|
||||
/* Return the result of a prompt */
|
||||
const char *UI_get0_result_string(UI_STRING *uis);
|
||||
/*
|
||||
* Return the string to test the result against. Only useful with verifies.
|
||||
*/
|
||||
const char *UI_get0_test_string(UI_STRING *uis);
|
||||
/* Return the required minimum size of the result */
|
||||
int UI_get_result_minsize(UI_STRING *uis);
|
||||
/* Return the required maximum size of the result */
|
||||
int UI_get_result_maxsize(UI_STRING *uis);
|
||||
/* Set the result of a UI_STRING. */
|
||||
int UI_set_result(UI *ui, UI_STRING *uis, const char *result);
|
||||
|
||||
/* A couple of popular utility functions */
|
||||
int UI_UTIL_read_pw_string(char *buf, int length, const char *prompt,
|
||||
int verify);
|
||||
int UI_UTIL_read_pw(char *buf, char *buff, int size, const char *prompt,
|
||||
int verify);
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
/*
|
||||
* The following lines are auto generated by the script mkerr.pl. Any changes
|
||||
* made after this point may be overwritten when the script is next run.
|
||||
*/
|
||||
|
||||
int ERR_load_UI_strings(void);
|
||||
|
||||
/* Error codes for the UI functions. */
|
||||
|
||||
/* Function codes. */
|
||||
# define UI_F_GENERAL_ALLOCATE_BOOLEAN 108
|
||||
# define UI_F_GENERAL_ALLOCATE_PROMPT 109
|
||||
# define UI_F_UI_CREATE_METHOD 112
|
||||
# define UI_F_UI_CTRL 111
|
||||
# define UI_F_UI_DUP_ERROR_STRING 101
|
||||
# define UI_F_UI_DUP_INFO_STRING 102
|
||||
# define UI_F_UI_DUP_INPUT_BOOLEAN 110
|
||||
# define UI_F_UI_DUP_INPUT_STRING 103
|
||||
# define UI_F_UI_DUP_VERIFY_STRING 106
|
||||
# define UI_F_UI_GET0_RESULT 107
|
||||
# define UI_F_UI_NEW_METHOD 104
|
||||
# define UI_F_UI_SET_RESULT 105
|
||||
|
||||
/* Reason codes. */
|
||||
# define UI_R_COMMON_OK_AND_CANCEL_CHARACTERS 104
|
||||
# define UI_R_INDEX_TOO_LARGE 102
|
||||
# define UI_R_INDEX_TOO_SMALL 103
|
||||
# define UI_R_NO_RESULT_BUFFER 105
|
||||
# define UI_R_RESULT_TOO_LARGE 100
|
||||
# define UI_R_RESULT_TOO_SMALL 101
|
||||
# define UI_R_UNKNOWN_CONTROL_COMMAND 106
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Copyright 2005-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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_WHRLPOOL_H
|
||||
# define HEADER_WHRLPOOL_H
|
||||
|
||||
#include <openssl/opensslconf.h>
|
||||
|
||||
# ifndef OPENSSL_NO_WHIRLPOOL
|
||||
# include <openssl/e_os2.h>
|
||||
# include <stddef.h>
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
# endif
|
||||
|
||||
# define WHIRLPOOL_DIGEST_LENGTH (512/8)
|
||||
# define WHIRLPOOL_BBLOCK 512
|
||||
# define WHIRLPOOL_COUNTER (256/8)
|
||||
|
||||
typedef struct {
|
||||
union {
|
||||
unsigned char c[WHIRLPOOL_DIGEST_LENGTH];
|
||||
/* double q is here to ensure 64-bit alignment */
|
||||
double q[WHIRLPOOL_DIGEST_LENGTH / sizeof(double)];
|
||||
} H;
|
||||
unsigned char data[WHIRLPOOL_BBLOCK / 8];
|
||||
unsigned int bitoff;
|
||||
size_t bitlen[WHIRLPOOL_COUNTER / sizeof(size_t)];
|
||||
} WHIRLPOOL_CTX;
|
||||
|
||||
int WHIRLPOOL_Init(WHIRLPOOL_CTX *c);
|
||||
int WHIRLPOOL_Update(WHIRLPOOL_CTX *c, const void *inp, size_t bytes);
|
||||
void WHIRLPOOL_BitUpdate(WHIRLPOOL_CTX *c, const void *inp, size_t bits);
|
||||
int WHIRLPOOL_Final(unsigned char *md, WHIRLPOOL_CTX *c);
|
||||
unsigned char *WHIRLPOOL(const void *inp, size_t bytes, unsigned char *md);
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
# endif
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,539 @@
|
|||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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_X509_VFY_H
|
||||
# define HEADER_X509_VFY_H
|
||||
|
||||
/*
|
||||
* Protect against recursion, x509.h and x509_vfy.h each include the other.
|
||||
*/
|
||||
# ifndef HEADER_X509_H
|
||||
# include <openssl/x509.h>
|
||||
# endif
|
||||
|
||||
# include <openssl/opensslconf.h>
|
||||
# include <openssl/lhash.h>
|
||||
# include <openssl/bio.h>
|
||||
# include <openssl/crypto.h>
|
||||
# include <openssl/symhacks.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*-
|
||||
SSL_CTX -> X509_STORE
|
||||
-> X509_LOOKUP
|
||||
->X509_LOOKUP_METHOD
|
||||
-> X509_LOOKUP
|
||||
->X509_LOOKUP_METHOD
|
||||
|
||||
SSL -> X509_STORE_CTX
|
||||
->X509_STORE
|
||||
|
||||
The X509_STORE holds the tables etc for verification stuff.
|
||||
A X509_STORE_CTX is used while validating a single certificate.
|
||||
The X509_STORE has X509_LOOKUPs for looking up certs.
|
||||
The X509_STORE then calls a function to actually verify the
|
||||
certificate chain.
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
X509_LU_NONE = 0,
|
||||
X509_LU_X509, X509_LU_CRL
|
||||
} X509_LOOKUP_TYPE;
|
||||
|
||||
#if OPENSSL_API_COMPAT < 0x10100000L
|
||||
#define X509_LU_RETRY -1
|
||||
#define X509_LU_FAIL 0
|
||||
#endif
|
||||
|
||||
DEFINE_STACK_OF(X509_LOOKUP)
|
||||
DEFINE_STACK_OF(X509_OBJECT)
|
||||
DEFINE_STACK_OF(X509_VERIFY_PARAM)
|
||||
|
||||
int X509_STORE_set_depth(X509_STORE *store, int depth);
|
||||
|
||||
typedef int (*X509_STORE_CTX_verify_cb)(int, X509_STORE_CTX *);
|
||||
typedef int (*X509_STORE_CTX_verify_fn)(X509_STORE_CTX *);
|
||||
typedef int (*X509_STORE_CTX_get_issuer_fn)(X509 **issuer,
|
||||
X509_STORE_CTX *ctx, X509 *x);
|
||||
typedef int (*X509_STORE_CTX_check_issued_fn)(X509_STORE_CTX *ctx,
|
||||
X509 *x, X509 *issuer);
|
||||
typedef int (*X509_STORE_CTX_check_revocation_fn)(X509_STORE_CTX *ctx);
|
||||
typedef int (*X509_STORE_CTX_get_crl_fn)(X509_STORE_CTX *ctx,
|
||||
X509_CRL **crl, X509 *x);
|
||||
typedef int (*X509_STORE_CTX_check_crl_fn)(X509_STORE_CTX *ctx, X509_CRL *crl);
|
||||
typedef int (*X509_STORE_CTX_cert_crl_fn)(X509_STORE_CTX *ctx,
|
||||
X509_CRL *crl, X509 *x);
|
||||
typedef int (*X509_STORE_CTX_check_policy_fn)(X509_STORE_CTX *ctx);
|
||||
typedef STACK_OF(X509) *(*X509_STORE_CTX_lookup_certs_fn)(X509_STORE_CTX *ctx,
|
||||
X509_NAME *nm);
|
||||
typedef STACK_OF(X509_CRL) *(*X509_STORE_CTX_lookup_crls_fn)(X509_STORE_CTX *ctx,
|
||||
X509_NAME *nm);
|
||||
typedef int (*X509_STORE_CTX_cleanup_fn)(X509_STORE_CTX *ctx);
|
||||
|
||||
|
||||
void X509_STORE_CTX_set_depth(X509_STORE_CTX *ctx, int depth);
|
||||
|
||||
# define X509_STORE_CTX_set_app_data(ctx,data) \
|
||||
X509_STORE_CTX_set_ex_data(ctx,0,data)
|
||||
# define X509_STORE_CTX_get_app_data(ctx) \
|
||||
X509_STORE_CTX_get_ex_data(ctx,0)
|
||||
|
||||
# define X509_L_FILE_LOAD 1
|
||||
# define X509_L_ADD_DIR 2
|
||||
|
||||
# define X509_LOOKUP_load_file(x,name,type) \
|
||||
X509_LOOKUP_ctrl((x),X509_L_FILE_LOAD,(name),(long)(type),NULL)
|
||||
|
||||
# define X509_LOOKUP_add_dir(x,name,type) \
|
||||
X509_LOOKUP_ctrl((x),X509_L_ADD_DIR,(name),(long)(type),NULL)
|
||||
|
||||
# define X509_V_OK 0
|
||||
# define X509_V_ERR_UNSPECIFIED 1
|
||||
# define X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT 2
|
||||
# define X509_V_ERR_UNABLE_TO_GET_CRL 3
|
||||
# define X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE 4
|
||||
# define X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE 5
|
||||
# define X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY 6
|
||||
# define X509_V_ERR_CERT_SIGNATURE_FAILURE 7
|
||||
# define X509_V_ERR_CRL_SIGNATURE_FAILURE 8
|
||||
# define X509_V_ERR_CERT_NOT_YET_VALID 9
|
||||
# define X509_V_ERR_CERT_HAS_EXPIRED 10
|
||||
# define X509_V_ERR_CRL_NOT_YET_VALID 11
|
||||
# define X509_V_ERR_CRL_HAS_EXPIRED 12
|
||||
# define X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD 13
|
||||
# define X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD 14
|
||||
# define X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD 15
|
||||
# define X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD 16
|
||||
# define X509_V_ERR_OUT_OF_MEM 17
|
||||
# define X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT 18
|
||||
# define X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN 19
|
||||
# define X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY 20
|
||||
# define X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE 21
|
||||
# define X509_V_ERR_CERT_CHAIN_TOO_LONG 22
|
||||
# define X509_V_ERR_CERT_REVOKED 23
|
||||
# define X509_V_ERR_INVALID_CA 24
|
||||
# define X509_V_ERR_PATH_LENGTH_EXCEEDED 25
|
||||
# define X509_V_ERR_INVALID_PURPOSE 26
|
||||
# define X509_V_ERR_CERT_UNTRUSTED 27
|
||||
# define X509_V_ERR_CERT_REJECTED 28
|
||||
/* These are 'informational' when looking for issuer cert */
|
||||
# define X509_V_ERR_SUBJECT_ISSUER_MISMATCH 29
|
||||
# define X509_V_ERR_AKID_SKID_MISMATCH 30
|
||||
# define X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH 31
|
||||
# define X509_V_ERR_KEYUSAGE_NO_CERTSIGN 32
|
||||
# define X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER 33
|
||||
# define X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION 34
|
||||
# define X509_V_ERR_KEYUSAGE_NO_CRL_SIGN 35
|
||||
# define X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION 36
|
||||
# define X509_V_ERR_INVALID_NON_CA 37
|
||||
# define X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDED 38
|
||||
# define X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE 39
|
||||
# define X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED 40
|
||||
# define X509_V_ERR_INVALID_EXTENSION 41
|
||||
# define X509_V_ERR_INVALID_POLICY_EXTENSION 42
|
||||
# define X509_V_ERR_NO_EXPLICIT_POLICY 43
|
||||
# define X509_V_ERR_DIFFERENT_CRL_SCOPE 44
|
||||
# define X509_V_ERR_UNSUPPORTED_EXTENSION_FEATURE 45
|
||||
# define X509_V_ERR_UNNESTED_RESOURCE 46
|
||||
# define X509_V_ERR_PERMITTED_VIOLATION 47
|
||||
# define X509_V_ERR_EXCLUDED_VIOLATION 48
|
||||
# define X509_V_ERR_SUBTREE_MINMAX 49
|
||||
/* The application is not happy */
|
||||
# define X509_V_ERR_APPLICATION_VERIFICATION 50
|
||||
# define X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPE 51
|
||||
# define X509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX 52
|
||||
# define X509_V_ERR_UNSUPPORTED_NAME_SYNTAX 53
|
||||
# define X509_V_ERR_CRL_PATH_VALIDATION_ERROR 54
|
||||
/* Another issuer check debug option */
|
||||
# define X509_V_ERR_PATH_LOOP 55
|
||||
/* Suite B mode algorithm violation */
|
||||
# define X509_V_ERR_SUITE_B_INVALID_VERSION 56
|
||||
# define X509_V_ERR_SUITE_B_INVALID_ALGORITHM 57
|
||||
# define X509_V_ERR_SUITE_B_INVALID_CURVE 58
|
||||
# define X509_V_ERR_SUITE_B_INVALID_SIGNATURE_ALGORITHM 59
|
||||
# define X509_V_ERR_SUITE_B_LOS_NOT_ALLOWED 60
|
||||
# define X509_V_ERR_SUITE_B_CANNOT_SIGN_P_384_WITH_P_256 61
|
||||
/* Host, email and IP check errors */
|
||||
# define X509_V_ERR_HOSTNAME_MISMATCH 62
|
||||
# define X509_V_ERR_EMAIL_MISMATCH 63
|
||||
# define X509_V_ERR_IP_ADDRESS_MISMATCH 64
|
||||
/* DANE TLSA errors */
|
||||
# define X509_V_ERR_DANE_NO_MATCH 65
|
||||
/* security level errors */
|
||||
# define X509_V_ERR_EE_KEY_TOO_SMALL 66
|
||||
# define X509_V_ERR_CA_KEY_TOO_SMALL 67
|
||||
# define X509_V_ERR_CA_MD_TOO_WEAK 68
|
||||
/* Caller error */
|
||||
# define X509_V_ERR_INVALID_CALL 69
|
||||
/* Issuer lookup error */
|
||||
# define X509_V_ERR_STORE_LOOKUP 70
|
||||
/* Certificate transparency */
|
||||
# define X509_V_ERR_NO_VALID_SCTS 71
|
||||
|
||||
# define X509_V_ERR_PROXY_SUBJECT_NAME_VIOLATION 72
|
||||
|
||||
/* Certificate verify flags */
|
||||
|
||||
# if OPENSSL_API_COMPAT < 0x10100000L
|
||||
# define X509_V_FLAG_CB_ISSUER_CHECK 0x0 /* Deprecated */
|
||||
# endif
|
||||
/* Use check time instead of current time */
|
||||
# define X509_V_FLAG_USE_CHECK_TIME 0x2
|
||||
/* Lookup CRLs */
|
||||
# define X509_V_FLAG_CRL_CHECK 0x4
|
||||
/* Lookup CRLs for whole chain */
|
||||
# define X509_V_FLAG_CRL_CHECK_ALL 0x8
|
||||
/* Ignore unhandled critical extensions */
|
||||
# define X509_V_FLAG_IGNORE_CRITICAL 0x10
|
||||
/* Disable workarounds for broken certificates */
|
||||
# define X509_V_FLAG_X509_STRICT 0x20
|
||||
/* Enable proxy certificate validation */
|
||||
# define X509_V_FLAG_ALLOW_PROXY_CERTS 0x40
|
||||
/* Enable policy checking */
|
||||
# define X509_V_FLAG_POLICY_CHECK 0x80
|
||||
/* Policy variable require-explicit-policy */
|
||||
# define X509_V_FLAG_EXPLICIT_POLICY 0x100
|
||||
/* Policy variable inhibit-any-policy */
|
||||
# define X509_V_FLAG_INHIBIT_ANY 0x200
|
||||
/* Policy variable inhibit-policy-mapping */
|
||||
# define X509_V_FLAG_INHIBIT_MAP 0x400
|
||||
/* Notify callback that policy is OK */
|
||||
# define X509_V_FLAG_NOTIFY_POLICY 0x800
|
||||
/* Extended CRL features such as indirect CRLs, alternate CRL signing keys */
|
||||
# define X509_V_FLAG_EXTENDED_CRL_SUPPORT 0x1000
|
||||
/* Delta CRL support */
|
||||
# define X509_V_FLAG_USE_DELTAS 0x2000
|
||||
/* Check self-signed CA signature */
|
||||
# define X509_V_FLAG_CHECK_SS_SIGNATURE 0x4000
|
||||
/* Use trusted store first */
|
||||
# define X509_V_FLAG_TRUSTED_FIRST 0x8000
|
||||
/* Suite B 128 bit only mode: not normally used */
|
||||
# define X509_V_FLAG_SUITEB_128_LOS_ONLY 0x10000
|
||||
/* Suite B 192 bit only mode */
|
||||
# define X509_V_FLAG_SUITEB_192_LOS 0x20000
|
||||
/* Suite B 128 bit mode allowing 192 bit algorithms */
|
||||
# define X509_V_FLAG_SUITEB_128_LOS 0x30000
|
||||
/* Allow partial chains if at least one certificate is in trusted store */
|
||||
# define X509_V_FLAG_PARTIAL_CHAIN 0x80000
|
||||
/*
|
||||
* If the initial chain is not trusted, do not attempt to build an alternative
|
||||
* chain. Alternate chain checking was introduced in 1.1.0. Setting this flag
|
||||
* will force the behaviour to match that of previous versions.
|
||||
*/
|
||||
# define X509_V_FLAG_NO_ALT_CHAINS 0x100000
|
||||
/* Do not check certificate/CRL validity against current time */
|
||||
# define X509_V_FLAG_NO_CHECK_TIME 0x200000
|
||||
|
||||
# define X509_VP_FLAG_DEFAULT 0x1
|
||||
# define X509_VP_FLAG_OVERWRITE 0x2
|
||||
# define X509_VP_FLAG_RESET_FLAGS 0x4
|
||||
# define X509_VP_FLAG_LOCKED 0x8
|
||||
# define X509_VP_FLAG_ONCE 0x10
|
||||
|
||||
/* Internal use: mask of policy related options */
|
||||
# define X509_V_FLAG_POLICY_MASK (X509_V_FLAG_POLICY_CHECK \
|
||||
| X509_V_FLAG_EXPLICIT_POLICY \
|
||||
| X509_V_FLAG_INHIBIT_ANY \
|
||||
| X509_V_FLAG_INHIBIT_MAP)
|
||||
|
||||
int X509_OBJECT_idx_by_subject(STACK_OF(X509_OBJECT) *h, X509_LOOKUP_TYPE type,
|
||||
X509_NAME *name);
|
||||
X509_OBJECT *X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h,
|
||||
X509_LOOKUP_TYPE type,
|
||||
X509_NAME *name);
|
||||
X509_OBJECT *X509_OBJECT_retrieve_match(STACK_OF(X509_OBJECT) *h,
|
||||
X509_OBJECT *x);
|
||||
int X509_OBJECT_up_ref_count(X509_OBJECT *a);
|
||||
X509_OBJECT *X509_OBJECT_new(void);
|
||||
void X509_OBJECT_free(X509_OBJECT *a);
|
||||
X509_LOOKUP_TYPE X509_OBJECT_get_type(const X509_OBJECT *a);
|
||||
X509 *X509_OBJECT_get0_X509(const X509_OBJECT *a);
|
||||
X509_CRL *X509_OBJECT_get0_X509_CRL(X509_OBJECT *a);
|
||||
X509_STORE *X509_STORE_new(void);
|
||||
void X509_STORE_free(X509_STORE *v);
|
||||
int X509_STORE_lock(X509_STORE *ctx);
|
||||
int X509_STORE_unlock(X509_STORE *ctx);
|
||||
int X509_STORE_up_ref(X509_STORE *v);
|
||||
STACK_OF(X509_OBJECT) *X509_STORE_get0_objects(X509_STORE *v);
|
||||
|
||||
STACK_OF(X509) *X509_STORE_CTX_get1_certs(X509_STORE_CTX *st, X509_NAME *nm);
|
||||
STACK_OF(X509_CRL) *X509_STORE_CTX_get1_crls(X509_STORE_CTX *st, X509_NAME *nm);
|
||||
int X509_STORE_set_flags(X509_STORE *ctx, unsigned long flags);
|
||||
int X509_STORE_set_purpose(X509_STORE *ctx, int purpose);
|
||||
int X509_STORE_set_trust(X509_STORE *ctx, int trust);
|
||||
int X509_STORE_set1_param(X509_STORE *ctx, X509_VERIFY_PARAM *pm);
|
||||
X509_VERIFY_PARAM *X509_STORE_get0_param(X509_STORE *ctx);
|
||||
|
||||
void X509_STORE_set_verify(X509_STORE *ctx, X509_STORE_CTX_verify_fn verify);
|
||||
#define X509_STORE_set_verify_func(ctx, func) \
|
||||
X509_STORE_set_verify((ctx),(func))
|
||||
void X509_STORE_CTX_set_verify(X509_STORE_CTX *ctx,
|
||||
X509_STORE_CTX_verify_fn verify);
|
||||
X509_STORE_CTX_verify_fn X509_STORE_get_verify(X509_STORE *ctx);
|
||||
void X509_STORE_set_verify_cb(X509_STORE *ctx,
|
||||
X509_STORE_CTX_verify_cb verify_cb);
|
||||
# define X509_STORE_set_verify_cb_func(ctx,func) \
|
||||
X509_STORE_set_verify_cb((ctx),(func))
|
||||
X509_STORE_CTX_verify_cb X509_STORE_get_verify_cb(X509_STORE *ctx);
|
||||
void X509_STORE_set_get_issuer(X509_STORE *ctx,
|
||||
X509_STORE_CTX_get_issuer_fn get_issuer);
|
||||
X509_STORE_CTX_get_issuer_fn X509_STORE_get_get_issuer(X509_STORE *ctx);
|
||||
void X509_STORE_set_check_issued(X509_STORE *ctx,
|
||||
X509_STORE_CTX_check_issued_fn check_issued);
|
||||
X509_STORE_CTX_check_issued_fn X509_STORE_get_check_issued(X509_STORE *ctx);
|
||||
void X509_STORE_set_check_revocation(X509_STORE *ctx,
|
||||
X509_STORE_CTX_check_revocation_fn check_revocation);
|
||||
X509_STORE_CTX_check_revocation_fn X509_STORE_get_check_revocation(X509_STORE *ctx);
|
||||
void X509_STORE_set_get_crl(X509_STORE *ctx,
|
||||
X509_STORE_CTX_get_crl_fn get_crl);
|
||||
X509_STORE_CTX_get_crl_fn X509_STORE_get_get_crl(X509_STORE *ctx);
|
||||
void X509_STORE_set_check_crl(X509_STORE *ctx,
|
||||
X509_STORE_CTX_check_crl_fn check_crl);
|
||||
X509_STORE_CTX_check_crl_fn X509_STORE_get_check_crl(X509_STORE *ctx);
|
||||
void X509_STORE_set_cert_crl(X509_STORE *ctx,
|
||||
X509_STORE_CTX_cert_crl_fn cert_crl);
|
||||
X509_STORE_CTX_cert_crl_fn X509_STORE_get_cert_crl(X509_STORE *ctx);
|
||||
void X509_STORE_set_check_policy(X509_STORE *ctx,
|
||||
X509_STORE_CTX_check_policy_fn check_policy);
|
||||
X509_STORE_CTX_check_policy_fn X509_STORE_get_check_policy(X509_STORE *ctx);
|
||||
void X509_STORE_set_lookup_certs(X509_STORE *ctx,
|
||||
X509_STORE_CTX_lookup_certs_fn lookup_certs);
|
||||
X509_STORE_CTX_lookup_certs_fn X509_STORE_get_lookup_certs(X509_STORE *ctx);
|
||||
void X509_STORE_set_lookup_crls(X509_STORE *ctx,
|
||||
X509_STORE_CTX_lookup_crls_fn lookup_crls);
|
||||
#define X509_STORE_set_lookup_crls_cb(ctx, func) \
|
||||
X509_STORE_set_lookup_crls((ctx), (func))
|
||||
X509_STORE_CTX_lookup_crls_fn X509_STORE_get_lookup_crls(X509_STORE *ctx);
|
||||
void X509_STORE_set_cleanup(X509_STORE *ctx,
|
||||
X509_STORE_CTX_cleanup_fn cleanup);
|
||||
X509_STORE_CTX_cleanup_fn X509_STORE_get_cleanup(X509_STORE *ctx);
|
||||
|
||||
#define X509_STORE_get_ex_new_index(l, p, newf, dupf, freef) \
|
||||
CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_X509_STORE, l, p, newf, dupf, freef)
|
||||
int X509_STORE_set_ex_data(X509_STORE *ctx, int idx, void *data);
|
||||
void *X509_STORE_get_ex_data(X509_STORE *ctx, int idx);
|
||||
|
||||
X509_STORE_CTX *X509_STORE_CTX_new(void);
|
||||
|
||||
int X509_STORE_CTX_get1_issuer(X509 **issuer, X509_STORE_CTX *ctx, X509 *x);
|
||||
|
||||
void X509_STORE_CTX_free(X509_STORE_CTX *ctx);
|
||||
int X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store,
|
||||
X509 *x509, STACK_OF(X509) *chain);
|
||||
void X509_STORE_CTX_set0_trusted_stack(X509_STORE_CTX *ctx, STACK_OF(X509) *sk);
|
||||
void X509_STORE_CTX_cleanup(X509_STORE_CTX *ctx);
|
||||
|
||||
X509_STORE *X509_STORE_CTX_get0_store(X509_STORE_CTX *ctx);
|
||||
X509 *X509_STORE_CTX_get0_cert(X509_STORE_CTX *ctx);
|
||||
STACK_OF(X509)* X509_STORE_CTX_get0_untrusted(X509_STORE_CTX *ctx);
|
||||
void X509_STORE_CTX_set0_untrusted(X509_STORE_CTX *ctx, STACK_OF(X509) *sk);
|
||||
void X509_STORE_CTX_set_verify_cb(X509_STORE_CTX *ctx,
|
||||
X509_STORE_CTX_verify_cb verify);
|
||||
X509_STORE_CTX_verify_cb X509_STORE_CTX_get_verify_cb(X509_STORE_CTX *ctx);
|
||||
X509_STORE_CTX_verify_fn X509_STORE_CTX_get_verify(X509_STORE_CTX *ctx);
|
||||
X509_STORE_CTX_get_issuer_fn X509_STORE_CTX_get_get_issuer(X509_STORE_CTX *ctx);
|
||||
X509_STORE_CTX_check_issued_fn X509_STORE_CTX_get_check_issued(X509_STORE_CTX *ctx);
|
||||
X509_STORE_CTX_check_revocation_fn X509_STORE_CTX_get_check_revocation(X509_STORE_CTX *ctx);
|
||||
X509_STORE_CTX_get_crl_fn X509_STORE_CTX_get_get_crl(X509_STORE_CTX *ctx);
|
||||
X509_STORE_CTX_check_crl_fn X509_STORE_CTX_get_check_crl(X509_STORE_CTX *ctx);
|
||||
X509_STORE_CTX_cert_crl_fn X509_STORE_CTX_get_cert_crl(X509_STORE_CTX *ctx);
|
||||
X509_STORE_CTX_check_policy_fn X509_STORE_CTX_get_check_policy(X509_STORE_CTX *ctx);
|
||||
X509_STORE_CTX_lookup_certs_fn X509_STORE_CTX_get_lookup_certs(X509_STORE_CTX *ctx);
|
||||
X509_STORE_CTX_lookup_crls_fn X509_STORE_CTX_get_lookup_crls(X509_STORE_CTX *ctx);
|
||||
X509_STORE_CTX_cleanup_fn X509_STORE_CTX_get_cleanup(X509_STORE_CTX *ctx);
|
||||
|
||||
#if OPENSSL_API_COMPAT < 0x10100000L
|
||||
# define X509_STORE_CTX_get_chain X509_STORE_CTX_get0_chain
|
||||
# define X509_STORE_CTX_set_chain X509_STORE_CTX_set0_untrusted
|
||||
# define X509_STORE_CTX_trusted_stack X509_STORE_CTX_set0_trusted_stack
|
||||
# define X509_STORE_get_by_subject X509_STORE_CTX_get_by_subject
|
||||
# define X509_STORE_get1_cert X509_STORE_CTX_get1_certs
|
||||
# define X509_STORE_get1_crl X509_STORE_CTX_get1_crls
|
||||
#endif
|
||||
|
||||
X509_LOOKUP *X509_STORE_add_lookup(X509_STORE *v, X509_LOOKUP_METHOD *m);
|
||||
X509_LOOKUP_METHOD *X509_LOOKUP_hash_dir(void);
|
||||
X509_LOOKUP_METHOD *X509_LOOKUP_file(void);
|
||||
|
||||
int X509_STORE_add_cert(X509_STORE *ctx, X509 *x);
|
||||
int X509_STORE_add_crl(X509_STORE *ctx, X509_CRL *x);
|
||||
|
||||
int X509_STORE_CTX_get_by_subject(X509_STORE_CTX *vs, X509_LOOKUP_TYPE type,
|
||||
X509_NAME *name, X509_OBJECT *ret);
|
||||
X509_OBJECT *X509_STORE_CTX_get_obj_by_subject(X509_STORE_CTX *vs,
|
||||
X509_LOOKUP_TYPE type,
|
||||
X509_NAME *name);
|
||||
|
||||
int X509_LOOKUP_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc,
|
||||
long argl, char **ret);
|
||||
|
||||
int X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type);
|
||||
int X509_load_crl_file(X509_LOOKUP *ctx, const char *file, int type);
|
||||
int X509_load_cert_crl_file(X509_LOOKUP *ctx, const char *file, int type);
|
||||
|
||||
X509_LOOKUP *X509_LOOKUP_new(X509_LOOKUP_METHOD *method);
|
||||
void X509_LOOKUP_free(X509_LOOKUP *ctx);
|
||||
int X509_LOOKUP_init(X509_LOOKUP *ctx);
|
||||
int X509_LOOKUP_by_subject(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
|
||||
X509_NAME *name, X509_OBJECT *ret);
|
||||
int X509_LOOKUP_by_issuer_serial(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
|
||||
X509_NAME *name, ASN1_INTEGER *serial,
|
||||
X509_OBJECT *ret);
|
||||
int X509_LOOKUP_by_fingerprint(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
|
||||
const unsigned char *bytes, int len,
|
||||
X509_OBJECT *ret);
|
||||
int X509_LOOKUP_by_alias(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
|
||||
const char *str, int len, X509_OBJECT *ret);
|
||||
int X509_LOOKUP_shutdown(X509_LOOKUP *ctx);
|
||||
|
||||
int X509_STORE_load_locations(X509_STORE *ctx,
|
||||
const char *file, const char *dir);
|
||||
int X509_STORE_set_default_paths(X509_STORE *ctx);
|
||||
|
||||
#define X509_STORE_CTX_get_ex_new_index(l, p, newf, dupf, freef) \
|
||||
CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_X509_STORE_CTX, l, p, newf, dupf, freef)
|
||||
int X509_STORE_CTX_set_ex_data(X509_STORE_CTX *ctx, int idx, void *data);
|
||||
void *X509_STORE_CTX_get_ex_data(X509_STORE_CTX *ctx, int idx);
|
||||
int X509_STORE_CTX_get_error(X509_STORE_CTX *ctx);
|
||||
void X509_STORE_CTX_set_error(X509_STORE_CTX *ctx, int s);
|
||||
int X509_STORE_CTX_get_error_depth(X509_STORE_CTX *ctx);
|
||||
void X509_STORE_CTX_set_error_depth(X509_STORE_CTX *ctx, int depth);
|
||||
X509 *X509_STORE_CTX_get_current_cert(X509_STORE_CTX *ctx);
|
||||
void X509_STORE_CTX_set_current_cert(X509_STORE_CTX *ctx, X509 *x);
|
||||
X509 *X509_STORE_CTX_get0_current_issuer(X509_STORE_CTX *ctx);
|
||||
X509_CRL *X509_STORE_CTX_get0_current_crl(X509_STORE_CTX *ctx);
|
||||
X509_STORE_CTX *X509_STORE_CTX_get0_parent_ctx(X509_STORE_CTX *ctx);
|
||||
STACK_OF(X509) *X509_STORE_CTX_get0_chain(X509_STORE_CTX *ctx);
|
||||
STACK_OF(X509) *X509_STORE_CTX_get1_chain(X509_STORE_CTX *ctx);
|
||||
void X509_STORE_CTX_set_cert(X509_STORE_CTX *c, X509 *x);
|
||||
void X509_STORE_CTX_set0_verified_chain(X509_STORE_CTX *c, STACK_OF(X509) *sk);
|
||||
void X509_STORE_CTX_set0_crls(X509_STORE_CTX *c, STACK_OF(X509_CRL) *sk);
|
||||
int X509_STORE_CTX_set_purpose(X509_STORE_CTX *ctx, int purpose);
|
||||
int X509_STORE_CTX_set_trust(X509_STORE_CTX *ctx, int trust);
|
||||
int X509_STORE_CTX_purpose_inherit(X509_STORE_CTX *ctx, int def_purpose,
|
||||
int purpose, int trust);
|
||||
void X509_STORE_CTX_set_flags(X509_STORE_CTX *ctx, unsigned long flags);
|
||||
void X509_STORE_CTX_set_time(X509_STORE_CTX *ctx, unsigned long flags,
|
||||
time_t t);
|
||||
|
||||
X509_POLICY_TREE *X509_STORE_CTX_get0_policy_tree(X509_STORE_CTX *ctx);
|
||||
int X509_STORE_CTX_get_explicit_policy(X509_STORE_CTX *ctx);
|
||||
int X509_STORE_CTX_get_num_untrusted(X509_STORE_CTX *ctx);
|
||||
|
||||
X509_VERIFY_PARAM *X509_STORE_CTX_get0_param(X509_STORE_CTX *ctx);
|
||||
void X509_STORE_CTX_set0_param(X509_STORE_CTX *ctx, X509_VERIFY_PARAM *param);
|
||||
int X509_STORE_CTX_set_default(X509_STORE_CTX *ctx, const char *name);
|
||||
|
||||
/*
|
||||
* Bridge opacity barrier between libcrypt and libssl, also needed to support
|
||||
* offline testing in test/danetest.c
|
||||
*/
|
||||
void X509_STORE_CTX_set0_dane(X509_STORE_CTX *ctx, SSL_DANE *dane);
|
||||
#define DANE_FLAG_NO_DANE_EE_NAMECHECKS (1L << 0)
|
||||
|
||||
/* X509_VERIFY_PARAM functions */
|
||||
|
||||
X509_VERIFY_PARAM *X509_VERIFY_PARAM_new(void);
|
||||
void X509_VERIFY_PARAM_free(X509_VERIFY_PARAM *param);
|
||||
int X509_VERIFY_PARAM_inherit(X509_VERIFY_PARAM *to,
|
||||
const X509_VERIFY_PARAM *from);
|
||||
int X509_VERIFY_PARAM_set1(X509_VERIFY_PARAM *to,
|
||||
const X509_VERIFY_PARAM *from);
|
||||
int X509_VERIFY_PARAM_set1_name(X509_VERIFY_PARAM *param, const char *name);
|
||||
int X509_VERIFY_PARAM_set_flags(X509_VERIFY_PARAM *param,
|
||||
unsigned long flags);
|
||||
int X509_VERIFY_PARAM_clear_flags(X509_VERIFY_PARAM *param,
|
||||
unsigned long flags);
|
||||
unsigned long X509_VERIFY_PARAM_get_flags(X509_VERIFY_PARAM *param);
|
||||
int X509_VERIFY_PARAM_set_purpose(X509_VERIFY_PARAM *param, int purpose);
|
||||
int X509_VERIFY_PARAM_set_trust(X509_VERIFY_PARAM *param, int trust);
|
||||
void X509_VERIFY_PARAM_set_depth(X509_VERIFY_PARAM *param, int depth);
|
||||
void X509_VERIFY_PARAM_set_auth_level(X509_VERIFY_PARAM *param, int auth_level);
|
||||
void X509_VERIFY_PARAM_set_time(X509_VERIFY_PARAM *param, time_t t);
|
||||
int X509_VERIFY_PARAM_add0_policy(X509_VERIFY_PARAM *param,
|
||||
ASN1_OBJECT *policy);
|
||||
int X509_VERIFY_PARAM_set1_policies(X509_VERIFY_PARAM *param,
|
||||
STACK_OF(ASN1_OBJECT) *policies);
|
||||
|
||||
int X509_VERIFY_PARAM_set1_host(X509_VERIFY_PARAM *param,
|
||||
const char *name, size_t namelen);
|
||||
int X509_VERIFY_PARAM_add1_host(X509_VERIFY_PARAM *param,
|
||||
const char *name, size_t namelen);
|
||||
void X509_VERIFY_PARAM_set_hostflags(X509_VERIFY_PARAM *param,
|
||||
unsigned int flags);
|
||||
char *X509_VERIFY_PARAM_get0_peername(X509_VERIFY_PARAM *);
|
||||
void X509_VERIFY_PARAM_move_peername(X509_VERIFY_PARAM *, X509_VERIFY_PARAM *);
|
||||
int X509_VERIFY_PARAM_set1_email(X509_VERIFY_PARAM *param,
|
||||
const char *email, size_t emaillen);
|
||||
int X509_VERIFY_PARAM_set1_ip(X509_VERIFY_PARAM *param,
|
||||
const unsigned char *ip, size_t iplen);
|
||||
int X509_VERIFY_PARAM_set1_ip_asc(X509_VERIFY_PARAM *param,
|
||||
const char *ipasc);
|
||||
|
||||
int X509_VERIFY_PARAM_get_depth(const X509_VERIFY_PARAM *param);
|
||||
int X509_VERIFY_PARAM_get_auth_level(const X509_VERIFY_PARAM *param);
|
||||
const char *X509_VERIFY_PARAM_get0_name(const X509_VERIFY_PARAM *param);
|
||||
|
||||
int X509_VERIFY_PARAM_add0_table(X509_VERIFY_PARAM *param);
|
||||
int X509_VERIFY_PARAM_get_count(void);
|
||||
const X509_VERIFY_PARAM *X509_VERIFY_PARAM_get0(int id);
|
||||
const X509_VERIFY_PARAM *X509_VERIFY_PARAM_lookup(const char *name);
|
||||
void X509_VERIFY_PARAM_table_cleanup(void);
|
||||
|
||||
/* Non positive return values are errors */
|
||||
#define X509_PCY_TREE_FAILURE -2 /* Failure to satisfy explicit policy */
|
||||
#define X509_PCY_TREE_INVALID -1 /* Inconsistent or invalid extensions */
|
||||
#define X509_PCY_TREE_INTERNAL 0 /* Internal error, most likely malloc */
|
||||
|
||||
/*
|
||||
* Positive return values form a bit mask, all but the first are internal to
|
||||
* the library and don't appear in results from X509_policy_check().
|
||||
*/
|
||||
#define X509_PCY_TREE_VALID 1 /* The policy tree is valid */
|
||||
#define X509_PCY_TREE_EMPTY 2 /* The policy tree is empty */
|
||||
#define X509_PCY_TREE_EXPLICIT 4 /* Explicit policy required */
|
||||
|
||||
int X509_policy_check(X509_POLICY_TREE **ptree, int *pexplicit_policy,
|
||||
STACK_OF(X509) *certs,
|
||||
STACK_OF(ASN1_OBJECT) *policy_oids, unsigned int flags);
|
||||
|
||||
void X509_policy_tree_free(X509_POLICY_TREE *tree);
|
||||
|
||||
int X509_policy_tree_level_count(const X509_POLICY_TREE *tree);
|
||||
X509_POLICY_LEVEL *X509_policy_tree_get0_level(const X509_POLICY_TREE *tree,
|
||||
int i);
|
||||
|
||||
STACK_OF(X509_POLICY_NODE) *X509_policy_tree_get0_policies(const
|
||||
X509_POLICY_TREE
|
||||
*tree);
|
||||
|
||||
STACK_OF(X509_POLICY_NODE) *X509_policy_tree_get0_user_policies(const
|
||||
X509_POLICY_TREE
|
||||
*tree);
|
||||
|
||||
int X509_policy_level_node_count(X509_POLICY_LEVEL *level);
|
||||
|
||||
X509_POLICY_NODE *X509_policy_level_get0_node(X509_POLICY_LEVEL *level,
|
||||
int i);
|
||||
|
||||
const ASN1_OBJECT *X509_policy_node_get0_policy(const X509_POLICY_NODE *node);
|
||||
|
||||
STACK_OF(POLICYQUALINFO) *X509_policy_node_get0_qualifiers(const
|
||||
X509_POLICY_NODE
|
||||
*node);
|
||||
const X509_POLICY_NODE *X509_policy_node_get0_parent(const X509_POLICY_NODE
|
||||
*node);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* ====================================================
|
||||
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
* Developed at SunPro, a Sun Microsystems, Inc. business.
|
||||
* Permission to use, copy, modify, and distribute this
|
||||
* software is freely granted, provided that this notice
|
||||
* is preserved.
|
||||
* ====================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
* from: @(#)fdlibm.h 5.1 93/09/24
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef mozilla_imported_fdlibm_h
|
||||
#define mozilla_imported_fdlibm_h
|
||||
|
||||
namespace fdlibm {
|
||||
|
||||
double acos(double);
|
||||
double asin(double);
|
||||
double atan(double);
|
||||
double atan2(double, double);
|
||||
|
||||
double cosh(double);
|
||||
double sinh(double);
|
||||
double tanh(double);
|
||||
|
||||
double exp(double);
|
||||
double log(double);
|
||||
double log10(double);
|
||||
|
||||
double pow(double, double);
|
||||
double sqrt(double);
|
||||
double fabs(double);
|
||||
|
||||
double floor(double);
|
||||
double trunc(double);
|
||||
double ceil(double);
|
||||
|
||||
double acosh(double);
|
||||
double asinh(double);
|
||||
double atanh(double);
|
||||
double cbrt(double);
|
||||
double expm1(double);
|
||||
double hypot(double, double);
|
||||
double log1p(double);
|
||||
double log2(double);
|
||||
double rint(double);
|
||||
double copysign(double, double);
|
||||
double nearbyint(double);
|
||||
double scalbn(double, int);
|
||||
|
||||
float ceilf(float);
|
||||
float floorf(float);
|
||||
|
||||
float nearbyintf(float);
|
||||
float rintf(float);
|
||||
float truncf(float);
|
||||
|
||||
} /* namespace fdlibm */
|
||||
|
||||
#endif /* mozilla_imported_fdlibm_h */
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
/* -*- Mode: C; tab-width: 8; c-basic-offset: 8 -*- */
|
||||
/* vim:set softtabstop=8 shiftwidth=8: */
|
||||
/*-
|
||||
* Copyright (C) 2006-2008 Jason Evans <jasone@FreeBSD.org>.
|
||||
* 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(s), this list of conditions and the following disclaimer as
|
||||
* the first lines of this file unmodified other than the possible
|
||||
* addition of one or more copyright notices.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice(s), this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``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 THE COPYRIGHT HOLDER(S) 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 _JEMALLOC_TYPES_H_
|
||||
#define _JEMALLOC_TYPES_H_
|
||||
|
||||
/* grab size_t */
|
||||
#ifdef _MSC_VER
|
||||
#include <crtdefs.h>
|
||||
#else
|
||||
#include <stddef.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef unsigned char jemalloc_bool;
|
||||
|
||||
/*
|
||||
* jemalloc_stats() is not a stable interface. When using jemalloc_stats_t, be
|
||||
* sure that the compiled results of jemalloc.c are in sync with this header
|
||||
* file.
|
||||
*/
|
||||
typedef struct {
|
||||
/*
|
||||
* Run-time configuration settings.
|
||||
*/
|
||||
jemalloc_bool opt_abort; /* abort(3) on error? */
|
||||
jemalloc_bool opt_junk; /* Fill allocated memory with 0xe4? */
|
||||
jemalloc_bool opt_poison; /* Fill free memory with 0xe5? */
|
||||
jemalloc_bool opt_utrace; /* Trace all allocation events? */
|
||||
jemalloc_bool opt_sysv; /* SysV semantics? */
|
||||
jemalloc_bool opt_xmalloc; /* abort(3) on OOM? */
|
||||
jemalloc_bool opt_zero; /* Fill allocated memory with 0x0? */
|
||||
size_t narenas; /* Number of arenas. */
|
||||
size_t balance_threshold; /* Arena contention rebalance threshold. */
|
||||
size_t quantum; /* Allocation quantum. */
|
||||
size_t small_max; /* Max quantum-spaced allocation size. */
|
||||
size_t large_max; /* Max sub-chunksize allocation size. */
|
||||
size_t chunksize; /* Size of each virtual memory mapping. */
|
||||
size_t dirty_max; /* Max dirty pages per arena. */
|
||||
|
||||
/*
|
||||
* Current memory usage statistics.
|
||||
*/
|
||||
size_t mapped; /* Bytes mapped (not necessarily committed). */
|
||||
size_t allocated; /* Bytes allocated (committed, in use by application). */
|
||||
size_t waste; /* Bytes committed, not in use by the
|
||||
application, and not intentionally left
|
||||
unused (i.e., not dirty). */
|
||||
size_t page_cache; /* Committed, unused pages kept around as a
|
||||
cache. (jemalloc calls these "dirty".) */
|
||||
size_t bookkeeping; /* Committed bytes used internally by the
|
||||
allocator. */
|
||||
size_t bin_unused; /* Bytes committed to a bin but currently unused. */
|
||||
} jemalloc_stats_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* _JEMALLOC_TYPES_H_ */
|
||||
|
|
@ -15,6 +15,20 @@
|
|||
/* Define to 1 if SpiderMonkey is in debug mode. */
|
||||
/* #undef JS_DEBUG */
|
||||
|
||||
/*
|
||||
* NB: We have a special case for rust-bindgen, which wants to be able to
|
||||
* generate both debug and release bindings on a single objdir.
|
||||
*/
|
||||
#ifdef JS_DEBUG
|
||||
#if !defined(DEBUG) && !defined(RUST_BINDGEN)
|
||||
# error "SpiderMonkey was configured with --enable-debug, so DEBUG must be defined when including this header"
|
||||
# endif
|
||||
#else
|
||||
# if defined(DEBUG) && !defined(RUST_BINDGEN)
|
||||
# error "SpiderMonkey was configured with --disable-debug, so DEBUG must be not defined when including this header"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Define to 1 if SpiderMonkey should not use struct types in debug builds. */
|
||||
/* #undef JS_NO_JSVAL_JSID_STRUCT_TYPES */
|
||||
|
||||
|
|
@ -28,26 +42,20 @@
|
|||
entirely too much GC. */
|
||||
/* #undef JS_GC_ZEAL */
|
||||
|
||||
/* Define to 1 if the <endian.h> header is present and
|
||||
useable. See jscpucfg.h. */
|
||||
#define JS_HAVE_ENDIAN_H 1
|
||||
/* Define to 1 if SpiderMonkey should use small chunks. */
|
||||
/* #undef JS_GC_SMALL_CHUNK_SIZE */
|
||||
|
||||
/* Define to 1 if the <machine/endian.h> header is present and
|
||||
useable. See jscpucfg.h. */
|
||||
#define JS_HAVE_MACHINE_ENDIAN_H 1
|
||||
|
||||
/* Define to 1 if the <sys/isa_defs.h> header is present and
|
||||
useable. See jscpucfg.h. */
|
||||
/* #undef JS_HAVE_SYS_ISA_DEFS_H */
|
||||
/* Define to 1 to perform extra assertions and heap poisoning. */
|
||||
/* #undef JS_CRASH_DIAGNOSTICS */
|
||||
|
||||
/* Define to 1 if SpiderMonkey is in NUNBOX32 mode. */
|
||||
/* #undef JS_NUNBOX32 */
|
||||
#define JS_NUNBOX32 1
|
||||
|
||||
/* Define to 1 if SpiderMonkey is in PUNBOX64 mode. */
|
||||
#define JS_PUNBOX64 1
|
||||
/* #undef JS_PUNBOX64 */
|
||||
|
||||
/* MOZILLA JSAPI version number components */
|
||||
#define MOZJS_MAJOR_VERSION 33
|
||||
#define MOZJS_MINOR_VERSION 1
|
||||
#define MOZJS_MAJOR_VERSION 52
|
||||
#define MOZJS_MINOR_VERSION 0
|
||||
|
||||
#endif /* js_config_h */
|
||||
|
|
|
|||
|
|
@ -9,15 +9,13 @@
|
|||
*
|
||||
* The format for each JS error message is:
|
||||
*
|
||||
* MSG_DEF(<SYMBOLIC_NAME>, <ERROR_NUMBER>, <ARGUMENT_COUNT>, <EXCEPTION_NAME>,
|
||||
* MSG_DEF(<SYMBOLIC_NAME>, <ARGUMENT_COUNT>, <EXCEPTION_NAME>,
|
||||
* <FORMAT_STRING>)
|
||||
*
|
||||
* where ;
|
||||
* <SYMBOLIC_NAME> is a legal C identifer that will be used in the
|
||||
* JS engine source.
|
||||
*
|
||||
* <ERROR_NUMBER> is an unique integral value identifying this error.
|
||||
*
|
||||
* <ARGUMENT_COUNT> is an integer literal specifying the total number of
|
||||
* replaceable arguments in the following format string.
|
||||
*
|
||||
|
|
@ -31,413 +29,553 @@
|
|||
*
|
||||
* e.g.
|
||||
*
|
||||
* MSG_DEF(JSMSG_NOT_A_SUBSPECIES, 73, JSEXN_NONE, 2,
|
||||
* MSG_DEF(JSMSG_NOT_A_SUBSPECIES, 2, JSEXN_NONE,
|
||||
* "{0} is not a member of the {1} family")
|
||||
*
|
||||
* can be used:
|
||||
*
|
||||
* JS_ReportErrorNumber(JSMSG_NOT_A_SUBSPECIES, "Rhino", "Monkey");
|
||||
* JS_ReportErrorNumberASCII(JSMSG_NOT_A_SUBSPECIES, "Rhino", "Monkey");
|
||||
*
|
||||
* to report:
|
||||
*
|
||||
* "Rhino is not a member of the Monkey family"
|
||||
*
|
||||
* When removing MSG_DEFs, convert them to JSMSG_UNUSED<n> placeholders:
|
||||
*
|
||||
* MSG_DEF(JSMSG_UNUSED7, 7, 0, JSEXN_NONE, "")
|
||||
*
|
||||
* Before adding a new MSG_DEF at the end, look for existing JSMSG_UNUSED<n>
|
||||
* free index placeholders in the middle of the list.
|
||||
*/
|
||||
|
||||
MSG_DEF(JSMSG_NOT_AN_ERROR, 0, 0, JSEXN_NONE, "<Error #0 is reserved>")
|
||||
MSG_DEF(JSMSG_NOT_DEFINED, 1, 1, JSEXN_REFERENCEERR, "{0} is not defined")
|
||||
MSG_DEF(JSMSG_INACTIVE, 2, 0, JSEXN_INTERNALERR, "nothing active on context")
|
||||
MSG_DEF(JSMSG_MORE_ARGS_NEEDED, 3, 3, JSEXN_TYPEERR, "{0} requires more than {1} argument{2}")
|
||||
MSG_DEF(JSMSG_BAD_CHAR, 4, 1, JSEXN_INTERNALERR, "invalid format character {0}")
|
||||
MSG_DEF(JSMSG_BAD_TYPE, 5, 1, JSEXN_TYPEERR, "unknown type {0}")
|
||||
MSG_DEF(JSMSG_ALLOC_OVERFLOW, 6, 0, JSEXN_INTERNALERR, "allocation size overflow")
|
||||
MSG_DEF(JSMSG_MISSING_HEXDIGITS, 7, 0, JSEXN_SYNTAXERR, "missing hexadecimal digits after '0x'")
|
||||
MSG_DEF(JSMSG_INCOMPATIBLE_PROTO, 8, 3, JSEXN_TYPEERR, "{0}.prototype.{1} called on incompatible {2}")
|
||||
MSG_DEF(JSMSG_NO_CONSTRUCTOR, 9, 1, JSEXN_TYPEERR, "{0} has no constructor")
|
||||
MSG_DEF(JSMSG_CANT_ALIAS, 10, 3, JSEXN_TYPEERR, "can't alias {0} to {1} in class {2}")
|
||||
MSG_DEF(JSMSG_NOT_SCRIPTED_FUNCTION, 11, 1, JSEXN_TYPEERR, "{0} is not a scripted function")
|
||||
MSG_DEF(JSMSG_BAD_SORT_ARG, 12, 0, JSEXN_TYPEERR, "invalid Array.prototype.sort argument")
|
||||
MSG_DEF(JSMSG_BAD_ATOMIC_NUMBER, 13, 1, JSEXN_INTERNALERR, "internal error: no index for atom {0}")
|
||||
MSG_DEF(JSMSG_TOO_MANY_LITERALS, 14, 0, JSEXN_INTERNALERR, "too many literals")
|
||||
MSG_DEF(JSMSG_CANT_WATCH, 15, 1, JSEXN_TYPEERR, "can't watch non-native objects of class {0}")
|
||||
MSG_DEF(JSMSG_STACK_UNDERFLOW, 16, 2, JSEXN_INTERNALERR, "internal error compiling {0}: stack underflow at pc {1}")
|
||||
MSG_DEF(JSMSG_NEED_DIET, 17, 1, JSEXN_INTERNALERR, "{0} too large")
|
||||
MSG_DEF(JSMSG_TOO_MANY_LOCAL_ROOTS, 18, 0, JSEXN_ERR, "out of local root space")
|
||||
MSG_DEF(JSMSG_READ_ONLY, 19, 1, JSEXN_TYPEERR, "{0} is read-only")
|
||||
MSG_DEF(JSMSG_BAD_FORMAL, 20, 0, JSEXN_SYNTAXERR, "malformed formal parameter")
|
||||
MSG_DEF(JSMSG_CANT_DELETE, 21, 1, JSEXN_TYPEERR, "property {0} is non-configurable and can't be deleted")
|
||||
MSG_DEF(JSMSG_NOT_FUNCTION, 22, 1, JSEXN_TYPEERR, "{0} is not a function")
|
||||
MSG_DEF(JSMSG_NOT_CONSTRUCTOR, 23, 1, JSEXN_TYPEERR, "{0} is not a constructor")
|
||||
MSG_DEF(JSMSG_INVALID_DATE, 24, 0, JSEXN_RANGEERR, "invalid date")
|
||||
MSG_DEF(JSMSG_TOO_DEEP, 25, 1, JSEXN_INTERNALERR, "{0} nested too deeply")
|
||||
MSG_DEF(JSMSG_OVER_RECURSED, 26, 0, JSEXN_INTERNALERR, "too much recursion")
|
||||
MSG_DEF(JSMSG_IN_NOT_OBJECT, 27, 1, JSEXN_TYPEERR, "invalid 'in' operand {0}")
|
||||
MSG_DEF(JSMSG_BAD_NEW_RESULT, 28, 1, JSEXN_TYPEERR, "invalid new expression result {0}")
|
||||
MSG_DEF(JSMSG_OBJECT_ACCESS_DENIED, 29, 0, JSEXN_ERR, "Permission denied to access object")
|
||||
MSG_DEF(JSMSG_PROPERTY_ACCESS_DENIED, 30, 1, JSEXN_ERR, "Permission denied to access property '{0}'")
|
||||
MSG_DEF(JSMSG_BAD_INSTANCEOF_RHS, 31, 1, JSEXN_TYPEERR, "invalid 'instanceof' operand {0}")
|
||||
MSG_DEF(JSMSG_BAD_BYTECODE, 32, 1, JSEXN_INTERNALERR, "unimplemented JavaScript bytecode {0}")
|
||||
MSG_DEF(JSMSG_BAD_RADIX, 33, 0, JSEXN_RANGEERR, "radix must be an integer at least 2 and no greater than 36")
|
||||
MSG_DEF(JSMSG_PAREN_BEFORE_LET, 34, 0, JSEXN_SYNTAXERR, "missing ( before let head")
|
||||
MSG_DEF(JSMSG_CANT_CONVERT, 35, 1, JSEXN_ERR, "can't convert {0} to an integer")
|
||||
MSG_DEF(JSMSG_CYCLIC_VALUE, 36, 1, JSEXN_TYPEERR, "cyclic {0} value")
|
||||
MSG_DEF(JSMSG_COMPILE_EXECED_SCRIPT, 37, 0, JSEXN_TYPEERR, "can't compile over a script that is currently executing")
|
||||
MSG_DEF(JSMSG_CANT_CONVERT_TO, 38, 2, JSEXN_TYPEERR, "can't convert {0} to {1}")
|
||||
MSG_DEF(JSMSG_NO_PROPERTIES, 39, 1, JSEXN_TYPEERR, "{0} has no properties")
|
||||
MSG_DEF(JSMSG_CANT_FIND_CLASS, 40, 1, JSEXN_TYPEERR, "can't find class id {0}")
|
||||
MSG_DEF(JSMSG_DEAD_OBJECT, 41, 0, JSEXN_TYPEERR, "can't access dead object")
|
||||
MSG_DEF(JSMSG_BYTECODE_TOO_BIG, 42, 2, JSEXN_INTERNALERR, "bytecode {0} too large (limit {1})")
|
||||
MSG_DEF(JSMSG_UNKNOWN_FORMAT, 43, 1, JSEXN_INTERNALERR, "unknown bytecode format {0}")
|
||||
MSG_DEF(JSMSG_TOO_MANY_CON_ARGS, 44, 0, JSEXN_SYNTAXERR, "too many constructor arguments")
|
||||
MSG_DEF(JSMSG_TOO_MANY_FUN_ARGS, 45, 0, JSEXN_SYNTAXERR, "too many function arguments")
|
||||
MSG_DEF(JSMSG_BAD_QUANTIFIER, 46, 0, JSEXN_SYNTAXERR, "invalid quantifier")
|
||||
MSG_DEF(JSMSG_MIN_TOO_BIG, 47, 1, JSEXN_SYNTAXERR, "overlarge minimum {0}")
|
||||
MSG_DEF(JSMSG_MAX_TOO_BIG, 48, 1, JSEXN_SYNTAXERR, "overlarge maximum {0}")
|
||||
MSG_DEF(JSMSG_OUT_OF_ORDER, 49, 1, JSEXN_SYNTAXERR, "maximum {0} less than minimum")
|
||||
MSG_DEF(JSMSG_BAD_DESTRUCT_DECL, 50, 0, JSEXN_SYNTAXERR, "missing = in destructuring declaration")
|
||||
MSG_DEF(JSMSG_BAD_DESTRUCT_ASS, 51, 0, JSEXN_REFERENCEERR, "invalid destructuring assignment operator")
|
||||
MSG_DEF(JSMSG_PAREN_AFTER_LET, 52, 0, JSEXN_SYNTAXERR, "missing ) after let head")
|
||||
MSG_DEF(JSMSG_CURLY_AFTER_LET, 53, 0, JSEXN_SYNTAXERR, "missing } after let block")
|
||||
MSG_DEF(JSMSG_MISSING_PAREN, 54, 0, JSEXN_SYNTAXERR, "unterminated parenthetical")
|
||||
MSG_DEF(JSMSG_UNTERM_CLASS, 55, 0, JSEXN_SYNTAXERR, "unterminated character class")
|
||||
MSG_DEF(JSMSG_TRAILING_SLASH, 56, 0, JSEXN_SYNTAXERR, "trailing \\ in regular expression")
|
||||
MSG_DEF(JSMSG_BAD_CLASS_RANGE, 57, 0, JSEXN_SYNTAXERR, "invalid range in character class")
|
||||
MSG_DEF(JSMSG_BAD_REGEXP_FLAG, 58, 1, JSEXN_SYNTAXERR, "invalid regular expression flag {0}")
|
||||
MSG_DEF(JSMSG_NO_INPUT, 59, 5, JSEXN_SYNTAXERR, "no input for /{0}/{1}{2}{3}{4}")
|
||||
MSG_DEF(JSMSG_CANT_OPEN, 60, 2, JSEXN_ERR, "can't open {0}: {1}")
|
||||
MSG_DEF(JSMSG_TOO_MANY_FUN_APPLY_ARGS, 61, 0, JSEXN_RANGEERR, "arguments array passed to Function.prototype.apply is too large")
|
||||
MSG_DEF(JSMSG_UNMATCHED_RIGHT_PAREN, 62, 0, JSEXN_SYNTAXERR, "unmatched ) in regular expression")
|
||||
MSG_DEF(JSMSG_TOO_BIG_TO_ENCODE, 63, 0, JSEXN_INTERNALERR, "data are to big to encode")
|
||||
MSG_DEF(JSMSG_ARG_INDEX_OUT_OF_RANGE, 64, 1, JSEXN_RANGEERR, "argument {0} accesses an index that is out of range")
|
||||
MSG_DEF(JSMSG_SPREAD_TOO_LARGE, 65, 0, JSEXN_RANGEERR, "array too large due to spread operand(s)")
|
||||
MSG_DEF(JSMSG_SOURCE_TOO_LONG, 66, 0, JSEXN_RANGEERR, "source is too long")
|
||||
MSG_DEF(JSMSG_BAD_WEAKMAP_KEY, 67, 0, JSEXN_TYPEERR, "cannot use the given object as a weak map key")
|
||||
MSG_DEF(JSMSG_BAD_SCRIPT_MAGIC, 68, 0, JSEXN_INTERNALERR, "bad script XDR magic number")
|
||||
MSG_DEF(JSMSG_PAREN_BEFORE_FORMAL, 69, 0, JSEXN_SYNTAXERR, "missing ( before formal parameters")
|
||||
MSG_DEF(JSMSG_MISSING_FORMAL, 70, 0, JSEXN_SYNTAXERR, "missing formal parameter")
|
||||
MSG_DEF(JSMSG_PAREN_AFTER_FORMAL, 71, 0, JSEXN_SYNTAXERR, "missing ) after formal parameters")
|
||||
MSG_DEF(JSMSG_CURLY_BEFORE_BODY, 72, 0, JSEXN_SYNTAXERR, "missing { before function body")
|
||||
MSG_DEF(JSMSG_CURLY_AFTER_BODY, 73, 0, JSEXN_SYNTAXERR, "missing } after function body")
|
||||
MSG_DEF(JSMSG_PAREN_BEFORE_COND, 74, 0, JSEXN_SYNTAXERR, "missing ( before condition")
|
||||
MSG_DEF(JSMSG_PAREN_AFTER_COND, 75, 0, JSEXN_SYNTAXERR, "missing ) after condition")
|
||||
MSG_DEF(JSMSG_BAD_DUP_ARGS, 76, 0, JSEXN_SYNTAXERR, "duplicate argument names not allowed in this context")
|
||||
MSG_DEF(JSMSG_NAME_AFTER_DOT, 77, 0, JSEXN_SYNTAXERR, "missing name after . operator")
|
||||
MSG_DEF(JSMSG_BRACKET_IN_INDEX, 78, 0, JSEXN_SYNTAXERR, "missing ] in index expression")
|
||||
MSG_DEF(JSMSG_ACCESSOR_DEF_DENIED, 79, 1, JSEXN_ERR, "Permission denied to define accessor property '{0}'")
|
||||
MSG_DEF(JSMSG_PAREN_BEFORE_SWITCH, 80, 0, JSEXN_SYNTAXERR, "missing ( before switch expression")
|
||||
MSG_DEF(JSMSG_PAREN_AFTER_SWITCH, 81, 0, JSEXN_SYNTAXERR, "missing ) after switch expression")
|
||||
MSG_DEF(JSMSG_CURLY_BEFORE_SWITCH, 82, 0, JSEXN_SYNTAXERR, "missing { before switch body")
|
||||
MSG_DEF(JSMSG_COLON_AFTER_CASE, 83, 0, JSEXN_SYNTAXERR, "missing : after case label")
|
||||
MSG_DEF(JSMSG_WHILE_AFTER_DO, 84, 0, JSEXN_SYNTAXERR, "missing while after do-loop body")
|
||||
MSG_DEF(JSMSG_PAREN_AFTER_FOR, 85, 0, JSEXN_SYNTAXERR, "missing ( after for")
|
||||
MSG_DEF(JSMSG_SEMI_AFTER_FOR_INIT, 86, 0, JSEXN_SYNTAXERR, "missing ; after for-loop initializer")
|
||||
MSG_DEF(JSMSG_SEMI_AFTER_FOR_COND, 87, 0, JSEXN_SYNTAXERR, "missing ; after for-loop condition")
|
||||
MSG_DEF(JSMSG_PAREN_AFTER_FOR_CTRL, 88, 0, JSEXN_SYNTAXERR, "missing ) after for-loop control")
|
||||
MSG_DEF(JSMSG_CURLY_BEFORE_TRY, 89, 0, JSEXN_SYNTAXERR, "missing { before try block")
|
||||
MSG_DEF(JSMSG_CURLY_AFTER_TRY, 90, 0, JSEXN_SYNTAXERR, "missing } after try block")
|
||||
MSG_DEF(JSMSG_PAREN_BEFORE_CATCH, 91, 0, JSEXN_SYNTAXERR, "missing ( before catch")
|
||||
MSG_DEF(JSMSG_CATCH_IDENTIFIER, 92, 0, JSEXN_SYNTAXERR, "missing identifier in catch")
|
||||
MSG_DEF(JSMSG_PAREN_AFTER_CATCH, 93, 0, JSEXN_SYNTAXERR, "missing ) after catch")
|
||||
MSG_DEF(JSMSG_CURLY_BEFORE_CATCH, 94, 0, JSEXN_SYNTAXERR, "missing { before catch block")
|
||||
MSG_DEF(JSMSG_CURLY_AFTER_CATCH, 95, 0, JSEXN_SYNTAXERR, "missing } after catch block")
|
||||
MSG_DEF(JSMSG_CURLY_BEFORE_FINALLY, 96, 0, JSEXN_SYNTAXERR, "missing { before finally block")
|
||||
MSG_DEF(JSMSG_CURLY_AFTER_FINALLY, 97, 0, JSEXN_SYNTAXERR, "missing } after finally block")
|
||||
MSG_DEF(JSMSG_CATCH_OR_FINALLY, 98, 0, JSEXN_SYNTAXERR, "missing catch or finally after try")
|
||||
MSG_DEF(JSMSG_PAREN_BEFORE_WITH, 99, 0, JSEXN_SYNTAXERR, "missing ( before with-statement object")
|
||||
MSG_DEF(JSMSG_PAREN_AFTER_WITH, 100, 0, JSEXN_SYNTAXERR, "missing ) after with-statement object")
|
||||
MSG_DEF(JSMSG_CURLY_IN_COMPOUND, 101, 0, JSEXN_SYNTAXERR, "missing } in compound statement")
|
||||
MSG_DEF(JSMSG_NO_VARIABLE_NAME, 102, 0, JSEXN_SYNTAXERR, "missing variable name")
|
||||
MSG_DEF(JSMSG_COLON_IN_COND, 103, 0, JSEXN_SYNTAXERR, "missing : in conditional expression")
|
||||
MSG_DEF(JSMSG_PAREN_AFTER_ARGS, 104, 0, JSEXN_SYNTAXERR, "missing ) after argument list")
|
||||
MSG_DEF(JSMSG_BRACKET_AFTER_LIST, 105, 0, JSEXN_SYNTAXERR, "missing ] after element list")
|
||||
MSG_DEF(JSMSG_COLON_AFTER_ID, 106, 0, JSEXN_SYNTAXERR, "missing : after property id")
|
||||
MSG_DEF(JSMSG_CURLY_AFTER_LIST, 107, 0, JSEXN_SYNTAXERR, "missing } after property list")
|
||||
MSG_DEF(JSMSG_PAREN_IN_PAREN, 108, 0, JSEXN_SYNTAXERR, "missing ) in parenthetical")
|
||||
MSG_DEF(JSMSG_SEMI_BEFORE_STMNT, 109, 0, JSEXN_SYNTAXERR, "missing ; before statement")
|
||||
MSG_DEF(JSMSG_NO_RETURN_VALUE, 110, 1, JSEXN_TYPEERR, "function {0} does not always return a value")
|
||||
MSG_DEF(JSMSG_DUPLICATE_FORMAL, 111, 1, JSEXN_SYNTAXERR, "duplicate formal argument {0}")
|
||||
MSG_DEF(JSMSG_EQUAL_AS_ASSIGN, 112, 0, JSEXN_SYNTAXERR, "test for equality (==) mistyped as assignment (=)?")
|
||||
MSG_DEF(JSMSG_OPTIMIZED_CLOSURE_LEAK, 113, 0, JSEXN_INTERNALERR, "can't access optimized closure")
|
||||
MSG_DEF(JSMSG_TOO_MANY_DEFAULTS, 114, 0, JSEXN_SYNTAXERR, "more than one switch default")
|
||||
MSG_DEF(JSMSG_TOO_MANY_CASES, 115, 0, JSEXN_INTERNALERR, "too many switch cases")
|
||||
MSG_DEF(JSMSG_BAD_SWITCH, 116, 0, JSEXN_SYNTAXERR, "invalid switch statement")
|
||||
MSG_DEF(JSMSG_BAD_FOR_LEFTSIDE, 117, 0, JSEXN_SYNTAXERR, "invalid for/in left-hand side")
|
||||
MSG_DEF(JSMSG_CATCH_AFTER_GENERAL, 118, 0, JSEXN_SYNTAXERR, "catch after unconditional catch")
|
||||
MSG_DEF(JSMSG_CATCH_WITHOUT_TRY, 119, 0, JSEXN_SYNTAXERR, "catch without try")
|
||||
MSG_DEF(JSMSG_FINALLY_WITHOUT_TRY, 120, 0, JSEXN_SYNTAXERR, "finally without try")
|
||||
MSG_DEF(JSMSG_LABEL_NOT_FOUND, 121, 0, JSEXN_SYNTAXERR, "label not found")
|
||||
MSG_DEF(JSMSG_TOUGH_BREAK, 122, 0, JSEXN_SYNTAXERR, "unlabeled break must be inside loop or switch")
|
||||
MSG_DEF(JSMSG_BAD_CONTINUE, 123, 0, JSEXN_SYNTAXERR, "continue must be inside loop")
|
||||
MSG_DEF(JSMSG_BAD_RETURN_OR_YIELD, 124, 1, JSEXN_SYNTAXERR, "{0} not in function")
|
||||
MSG_DEF(JSMSG_BAD_LABEL, 125, 0, JSEXN_SYNTAXERR, "invalid label")
|
||||
MSG_DEF(JSMSG_DUPLICATE_LABEL, 126, 0, JSEXN_SYNTAXERR, "duplicate label")
|
||||
MSG_DEF(JSMSG_VAR_HIDES_ARG, 127, 1, JSEXN_TYPEERR, "variable {0} redeclares argument")
|
||||
MSG_DEF(JSMSG_BAD_VAR_INIT, 128, 0, JSEXN_SYNTAXERR, "invalid variable initialization")
|
||||
MSG_DEF(JSMSG_BAD_LEFTSIDE_OF_ASS, 129, 0, JSEXN_REFERENCEERR, "invalid assignment left-hand side")
|
||||
MSG_DEF(JSMSG_BAD_OPERAND, 130, 1, JSEXN_SYNTAXERR, "invalid {0} operand")
|
||||
MSG_DEF(JSMSG_BAD_PROP_ID, 131, 0, JSEXN_SYNTAXERR, "invalid property id")
|
||||
MSG_DEF(JSMSG_RESERVED_ID, 132, 1, JSEXN_SYNTAXERR, "{0} is a reserved identifier")
|
||||
MSG_DEF(JSMSG_SYNTAX_ERROR, 133, 0, JSEXN_SYNTAXERR, "syntax error")
|
||||
MSG_DEF(JSMSG_MISSING_BINARY_DIGITS, 134, 0, JSEXN_SYNTAXERR, "missing binary digits after '0b'")
|
||||
MSG_DEF(JSMSG_BAD_PROTOTYPE, 135, 1, JSEXN_TYPEERR, "'prototype' property of {0} is not an object")
|
||||
MSG_DEF(JSMSG_MISSING_EXPONENT, 136, 0, JSEXN_SYNTAXERR, "missing exponent")
|
||||
MSG_DEF(JSMSG_OUT_OF_MEMORY, 137, 0, JSEXN_ERR, "out of memory")
|
||||
MSG_DEF(JSMSG_UNTERMINATED_STRING, 138, 0, JSEXN_SYNTAXERR, "unterminated string literal")
|
||||
MSG_DEF(JSMSG_TOO_MANY_PARENS, 139, 0, JSEXN_INTERNALERR, "too many parentheses in regular expression")
|
||||
MSG_DEF(JSMSG_UNTERMINATED_COMMENT, 140, 0, JSEXN_SYNTAXERR, "unterminated comment")
|
||||
MSG_DEF(JSMSG_UNTERMINATED_REGEXP, 141, 0, JSEXN_SYNTAXERR, "unterminated regular expression literal")
|
||||
MSG_DEF(JSMSG_BAD_CLONE_FUNOBJ_SCOPE, 142, 0, JSEXN_TYPEERR, "bad cloned function scope chain")
|
||||
MSG_DEF(JSMSG_MISSING_OCTAL_DIGITS, 143, 0, JSEXN_SYNTAXERR, "missing octal digits after '0o'")
|
||||
MSG_DEF(JSMSG_ILLEGAL_CHARACTER, 144, 0, JSEXN_SYNTAXERR, "illegal character")
|
||||
MSG_DEF(JSMSG_BAD_OCTAL, 145, 1, JSEXN_SYNTAXERR, "{0} is not a legal ECMA-262 octal constant")
|
||||
MSG_DEF(JSMSG_RESULTING_STRING_TOO_LARGE, 146, 0, JSEXN_RANGEERR, "repeat count must be less than infinity and not overflow maximum string size")
|
||||
MSG_DEF(JSMSG_UNCAUGHT_EXCEPTION, 147, 1, JSEXN_INTERNALERR, "uncaught exception: {0}")
|
||||
MSG_DEF(JSMSG_INVALID_BACKREF, 148, 0, JSEXN_SYNTAXERR, "non-octal digit in an escape sequence that doesn't match a back-reference")
|
||||
MSG_DEF(JSMSG_BAD_BACKREF, 149, 0, JSEXN_SYNTAXERR, "back-reference exceeds number of capturing parentheses")
|
||||
MSG_DEF(JSMSG_PRECISION_RANGE, 150, 1, JSEXN_RANGEERR, "precision {0} out of range")
|
||||
MSG_DEF(JSMSG_BAD_GETTER_OR_SETTER, 151, 1, JSEXN_TYPEERR, "invalid {0} usage")
|
||||
MSG_DEF(JSMSG_BAD_ARRAY_LENGTH, 152, 0, JSEXN_RANGEERR, "invalid array length")
|
||||
MSG_DEF(JSMSG_CANT_DESCRIBE_PROPS, 153, 1, JSEXN_TYPEERR, "can't describe non-native properties of class {0}")
|
||||
MSG_DEF(JSMSG_BAD_APPLY_ARGS, 154, 1, JSEXN_TYPEERR, "second argument to Function.prototype.{0} must be an array")
|
||||
MSG_DEF(JSMSG_REDECLARED_VAR, 155, 2, JSEXN_TYPEERR, "redeclaration of {0} {1}")
|
||||
MSG_DEF(JSMSG_UNDECLARED_VAR, 156, 1, JSEXN_REFERENCEERR, "assignment to undeclared variable {0}")
|
||||
MSG_DEF(JSMSG_ANON_NO_RETURN_VALUE, 157, 0, JSEXN_TYPEERR, "anonymous function does not always return a value")
|
||||
MSG_DEF(JSMSG_DEPRECATED_USAGE, 158, 1, JSEXN_REFERENCEERR, "deprecated {0} usage")
|
||||
MSG_DEF(JSMSG_BAD_URI, 159, 0, JSEXN_URIERR, "malformed URI sequence")
|
||||
MSG_DEF(JSMSG_GETTER_ONLY, 160, 0, JSEXN_TYPEERR, "setting a property that has only a getter")
|
||||
MSG_DEF(JSMSG_IDSTART_AFTER_NUMBER, 161, 0, JSEXN_SYNTAXERR, "identifier starts immediately after numeric literal")
|
||||
MSG_DEF(JSMSG_UNDEFINED_PROP, 162, 1, JSEXN_REFERENCEERR, "reference to undefined property {0}")
|
||||
MSG_DEF(JSMSG_USELESS_EXPR, 163, 0, JSEXN_TYPEERR, "useless expression")
|
||||
MSG_DEF(JSMSG_REDECLARED_PARAM, 164, 1, JSEXN_TYPEERR, "redeclaration of formal parameter {0}")
|
||||
MSG_DEF(JSMSG_NEWREGEXP_FLAGGED, 165, 0, JSEXN_TYPEERR, "can't supply flags when constructing one RegExp from another")
|
||||
MSG_DEF(JSMSG_RESERVED_SLOT_RANGE, 166, 0, JSEXN_RANGEERR, "reserved slot index out of range")
|
||||
MSG_DEF(JSMSG_CANT_DECODE_PRINCIPALS, 167, 0, JSEXN_INTERNALERR, "can't decode JSPrincipals")
|
||||
MSG_DEF(JSMSG_CANT_SEAL_OBJECT, 168, 1, JSEXN_ERR, "can't seal {0} objects")
|
||||
MSG_DEF(JSMSG_TOO_MANY_CATCH_VARS, 169, 0, JSEXN_SYNTAXERR, "too many catch variables")
|
||||
MSG_DEF(JSMSG_NEGATIVE_REPETITION_COUNT, 170, 0, JSEXN_RANGEERR, "repeat count must be non-negative")
|
||||
MSG_DEF(JSMSG_INVALID_FOR_OF_INIT, 171, 0, JSEXN_SYNTAXERR, "for-of loop variable declaration may not have an initializer")
|
||||
MSG_DEF(JSMSG_INVALID_MAP_ITERABLE, 172, 0, JSEXN_TYPEERR, "iterable for map should have array-like objects")
|
||||
MSG_DEF(JSMSG_NOT_A_CODEPOINT, 173, 1, JSEXN_RANGEERR, "{0} is not a valid code point")
|
||||
MSG_DEF(JSMSG_BRACKET_AFTER_ARRAY_COMPREHENSION, 174, 0, JSEXN_SYNTAXERR, "missing ] after array comprehension")
|
||||
MSG_DEF(JSMSG_NESTING_GENERATOR, 175, 0, JSEXN_TYPEERR, "already executing generator")
|
||||
MSG_DEF(JSMSG_PAREN_AFTER_FOR_OF_ITERABLE, 176, 0, JSEXN_SYNTAXERR, "missing ) after for-of iterable")
|
||||
MSG_DEF(JSMSG_INVALID_NORMALIZE_FORM, 177, 0, JSEXN_RANGEERR, "form must be one of 'NFC', 'NFD', 'NFKC', or 'NFKD'")
|
||||
MSG_DEF(JSMSG_NOTHING_TO_REPEAT, 178, 0, JSEXN_SYNTAXERR, "nothing to repeat")
|
||||
MSG_DEF(JSMSG_INVALID_GROUP, 179, 0, JSEXN_SYNTAXERR, "invalid regexp group")
|
||||
MSG_DEF(JSMSG_ESCAPE_AT_END_OF_REGEXP, 180, 0, JSEXN_SYNTAXERR, "\\ at end of pattern")
|
||||
MSG_DEF(JSMSG_NUMBERS_OUT_OF_ORDER, 181, 0, JSEXN_SYNTAXERR, "numbers out of order in {} quantifier.")
|
||||
MSG_DEF(JSMSG_BAD_GENERATOR_SEND, 182, 1, JSEXN_TYPEERR, "attempt to send {0} to newborn generator")
|
||||
MSG_DEF(JSMSG_SC_NOT_TRANSFERABLE, 183, 0, JSEXN_TYPEERR, "invalid transferable array for structured clone")
|
||||
MSG_DEF(JSMSG_SC_DUP_TRANSFERABLE, 184, 0, JSEXN_TYPEERR, "duplicate transferable for structured clone")
|
||||
MSG_DEF(JSMSG_CANT_REPORT_AS_NON_EXTENSIBLE, 185, 0, JSEXN_TYPEERR, "proxy can't report an extensible object as non-extensible")
|
||||
MSG_DEF(JSMSG_SYMBOL_TO_STRING, 186, 0, JSEXN_TYPEERR, "can't convert symbol to string")
|
||||
MSG_DEF(JSMSG_UNUSED187, 187, 0, JSEXN_NONE, "")
|
||||
MSG_DEF(JSMSG_INCOMPATIBLE_METHOD, 188, 3, JSEXN_TYPEERR, "{0} {1} called on incompatible {2}")
|
||||
MSG_DEF(JSMSG_SYMBOL_TO_PRIMITIVE, 189, 0, JSEXN_TYPEERR, "can't convert symbol object to primitive")
|
||||
MSG_DEF(JSMSG_UNUSED190, 190, 0, JSEXN_NONE, "")
|
||||
MSG_DEF(JSMSG_BAD_INDEX, 191, 0, JSEXN_RANGEERR, "invalid or out-of-range index")
|
||||
MSG_DEF(JSMSG_SELFHOSTED_TOP_LEVEL_LET,192,0, JSEXN_SYNTAXERR, "self-hosted code cannot contain top-level 'let' declarations")
|
||||
MSG_DEF(JSMSG_BAD_FOR_EACH_LOOP, 193, 0, JSEXN_SYNTAXERR, "invalid for each loop")
|
||||
MSG_DEF(JSMSG_OBJECT_WATCH_DEPRECATED,194, 0, JSEXN_NONE, "Object.prototype.watch and unwatch are very slow, non-standard, and deprecated; use a getter/setter instead")
|
||||
MSG_DEF(JSMSG_TYPE_ERR_BAD_ARGS, 195, 0, JSEXN_TYPEERR, "invalid arguments")
|
||||
MSG_DEF(JSMSG_REDECLARED_CATCH_IDENTIFIER, 196, 1, JSEXN_TYPEERR, "redeclaration of identifier '{0}' in catch")
|
||||
MSG_DEF(JSMSG_INTERNAL_INTL_ERROR, 197, 0, JSEXN_ERR, "internal error while computing Intl data")
|
||||
MSG_DEF(JSMSG_DEFAULT_LOCALE_ERROR, 198, 0, JSEXN_ERR, "internal error getting the default locale")
|
||||
MSG_DEF(JSMSG_TOO_MANY_LOCALS, 199, 0, JSEXN_SYNTAXERR, "too many local variables")
|
||||
MSG_DEF(JSMSG_ARRAY_INIT_TOO_BIG, 200, 0, JSEXN_INTERNALERR, "array initialiser too large")
|
||||
MSG_DEF(JSMSG_REGEXP_TOO_COMPLEX, 201, 0, JSEXN_INTERNALERR, "regular expression too complex")
|
||||
MSG_DEF(JSMSG_BUFFER_TOO_SMALL, 202, 0, JSEXN_INTERNALERR, "buffer too small")
|
||||
MSG_DEF(JSMSG_BAD_SURROGATE_CHAR, 203, 1, JSEXN_TYPEERR, "bad surrogate character {0}")
|
||||
MSG_DEF(JSMSG_UTF8_CHAR_TOO_LARGE, 204, 1, JSEXN_TYPEERR, "UTF-8 character {0} too large")
|
||||
MSG_DEF(JSMSG_MALFORMED_UTF8_CHAR, 205, 1, JSEXN_TYPEERR, "malformed UTF-8 character sequence at offset {0}")
|
||||
MSG_DEF(JSMSG_USER_DEFINED_ERROR, 206, 0, JSEXN_ERR, "JS_ReportError was called")
|
||||
MSG_DEF(JSMSG_WRONG_CONSTRUCTOR, 207, 1, JSEXN_TYPEERR, "wrong constructor called for {0}")
|
||||
MSG_DEF(JSMSG_BAD_GENERATOR_RETURN, 208, 1, JSEXN_TYPEERR, "generator function {0} returns a value")
|
||||
MSG_DEF(JSMSG_BAD_ANON_GENERATOR_RETURN, 209, 0, JSEXN_TYPEERR, "anonymous generator function returns a value")
|
||||
MSG_DEF(JSMSG_PROTO_SETTING_SLOW, 210, 0, JSEXN_NONE, "mutating the [[Prototype]] of an object will cause your code to run very slowly; instead create the object with the correct initial [[Prototype]] value using Object.create")
|
||||
MSG_DEF(JSMSG_IN_AFTER_FOR_NAME, 211, 0, JSEXN_SYNTAXERR, "missing 'in' or 'of' after for")
|
||||
MSG_DEF(JSMSG_BAD_TRAP_RETURN_VALUE, 212, 2, JSEXN_TYPEERR,"trap {1} for {0} returned a primitive value")
|
||||
MSG_DEF(JSMSG_OF_AFTER_FOR_NAME, 213, 0, JSEXN_SYNTAXERR, "missing 'of' after for")
|
||||
MSG_DEF(JSMSG_BAD_GENERATOR_YIELD, 214, 1, JSEXN_TYPEERR, "yield from closing generator {0}")
|
||||
MSG_DEF(JSMSG_BAD_GENERATOR_SYNTAX, 215, 1, JSEXN_SYNTAXERR, "{0} expression must be parenthesized")
|
||||
MSG_DEF(JSMSG_ARRAY_COMP_LEFTSIDE, 216, 0, JSEXN_SYNTAXERR, "invalid array comprehension left-hand side")
|
||||
MSG_DEF(JSMSG_LET_COMP_BINDING, 217, 0, JSEXN_SYNTAXERR, "'let' is not a valid name for a comprehension variable")
|
||||
MSG_DEF(JSMSG_EMPTY_ARRAY_REDUCE, 218, 0, JSEXN_TYPEERR, "reduce of empty array with no initial value")
|
||||
MSG_DEF(JSMSG_BAD_SYMBOL, 219, 1, JSEXN_TYPEERR, "{0} is not a well-known @@-symbol")
|
||||
MSG_DEF(JSMSG_BAD_DELETE_OPERAND, 220, 0, JSEXN_REFERENCEERR, "invalid delete operand")
|
||||
MSG_DEF(JSMSG_BAD_INCOP_OPERAND, 221, 0, JSEXN_REFERENCEERR, "invalid increment/decrement operand")
|
||||
MSG_DEF(JSMSG_UNEXPECTED_TYPE, 222, 2, JSEXN_TYPEERR, "{0} is {1}")
|
||||
MSG_DEF(JSMSG_LET_DECL_NOT_IN_BLOCK, 223, 0, JSEXN_SYNTAXERR, "let declaration not directly within block")
|
||||
MSG_DEF(JSMSG_UNUSED224, 224, 0, JSEXN_NONE, "")
|
||||
MSG_DEF(JSMSG_CANT_SET_ARRAY_ATTRS, 225, 0, JSEXN_INTERNALERR, "can't set attributes on indexed array properties")
|
||||
MSG_DEF(JSMSG_EVAL_ARITY, 226, 0, JSEXN_TYPEERR, "eval accepts only one parameter")
|
||||
MSG_DEF(JSMSG_MISSING_FUN_ARG, 227, 2, JSEXN_TYPEERR, "missing argument {0} when calling function {1}")
|
||||
MSG_DEF(JSMSG_JSON_BAD_PARSE, 228, 3, JSEXN_SYNTAXERR, "JSON.parse: {0} at line {1} column {2} of the JSON data")
|
||||
MSG_DEF(JSMSG_JSON_BAD_STRINGIFY, 229, 0, JSEXN_ERR, "JSON.stringify")
|
||||
MSG_DEF(JSMSG_NOT_CALLABLE_OR_UNDEFINED, 230, 0, JSEXN_TYPEERR, "value is not a function or undefined")
|
||||
MSG_DEF(JSMSG_NOT_NONNULL_OBJECT, 231, 0, JSEXN_TYPEERR, "value is not a non-null object")
|
||||
MSG_DEF(JSMSG_DEPRECATED_OCTAL, 232, 0, JSEXN_SYNTAXERR, "octal literals and octal escape sequences are deprecated")
|
||||
MSG_DEF(JSMSG_STRICT_CODE_WITH, 233, 0, JSEXN_SYNTAXERR, "strict mode code may not contain 'with' statements")
|
||||
MSG_DEF(JSMSG_DUPLICATE_PROPERTY, 234, 1, JSEXN_SYNTAXERR, "property name {0} appears more than once in object literal")
|
||||
MSG_DEF(JSMSG_DEPRECATED_DELETE_OPERAND, 235, 0, JSEXN_SYNTAXERR, "applying the 'delete' operator to an unqualified name is deprecated")
|
||||
MSG_DEF(JSMSG_BAD_STRICT_ASSIGN, 236, 1, JSEXN_SYNTAXERR, "can't assign to {0} in strict mode")
|
||||
MSG_DEF(JSMSG_BAD_BINDING, 237, 1, JSEXN_SYNTAXERR, "redefining {0} is deprecated")
|
||||
MSG_DEF(JSMSG_INVALID_DESCRIPTOR, 238, 0, JSEXN_TYPEERR, "property descriptors must not specify a value or be writable when a getter or setter has been specified")
|
||||
MSG_DEF(JSMSG_OBJECT_NOT_EXTENSIBLE, 239, 1, JSEXN_TYPEERR, "{0} is not extensible")
|
||||
MSG_DEF(JSMSG_CANT_REDEFINE_PROP, 240, 1, JSEXN_TYPEERR, "can't redefine non-configurable property '{0}'")
|
||||
MSG_DEF(JSMSG_CANT_APPEND_TO_ARRAY, 241, 0, JSEXN_TYPEERR, "can't add elements past the end of an array if its length property is unwritable")
|
||||
MSG_DEF(JSMSG_CANT_REDEFINE_ARRAY_LENGTH,242, 0, JSEXN_TYPEERR, "can't redefine array length")
|
||||
MSG_DEF(JSMSG_CANT_DEFINE_PAST_ARRAY_LENGTH,243, 0, JSEXN_TYPEERR, "can't define array index property past the end of an array with non-writable length")
|
||||
MSG_DEF(JSMSG_TYPED_ARRAY_BAD_INDEX, 244, 0, JSEXN_ERR, "invalid or out-of-range index")
|
||||
MSG_DEF(JSMSG_TYPED_ARRAY_NEGATIVE_ARG, 245, 1, JSEXN_ERR, "argument {0} must be >= 0")
|
||||
MSG_DEF(JSMSG_TYPED_ARRAY_BAD_ARGS, 246, 0, JSEXN_ERR, "invalid arguments")
|
||||
MSG_DEF(JSMSG_CSP_BLOCKED_FUNCTION, 247, 0, JSEXN_ERR, "call to Function() blocked by CSP")
|
||||
MSG_DEF(JSMSG_BAD_GET_SET_FIELD, 248, 1, JSEXN_TYPEERR, "property descriptor's {0} field is neither undefined nor a function")
|
||||
MSG_DEF(JSMSG_BAD_PROXY_FIX, 249, 0, JSEXN_TYPEERR, "proxy was fixed while executing the handler")
|
||||
MSG_DEF(JSMSG_INVALID_EVAL_SCOPE_ARG, 250, 0, JSEXN_EVALERR, "invalid eval scope argument")
|
||||
MSG_DEF(JSMSG_ACCESSOR_WRONG_ARGS, 251, 3, JSEXN_SYNTAXERR, "{0} functions must have {1} argument{2}")
|
||||
MSG_DEF(JSMSG_THROW_TYPE_ERROR, 252, 0, JSEXN_TYPEERR, "'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them")
|
||||
MSG_DEF(JSMSG_BAD_TOISOSTRING_PROP, 253, 0, JSEXN_TYPEERR, "toISOString property is not callable")
|
||||
MSG_DEF(JSMSG_BAD_PARSE_NODE, 254, 0, JSEXN_INTERNALERR, "bad parse node")
|
||||
MSG_DEF(JSMSG_NOT_EXPECTED_TYPE, 255, 3, JSEXN_TYPEERR, "{0}: expected {1}, got {2}")
|
||||
MSG_DEF(JSMSG_CALLER_IS_STRICT, 256, 0, JSEXN_TYPEERR, "access to strict mode caller function is censored")
|
||||
MSG_DEF(JSMSG_NEED_DEBUG_MODE, 257, 0, JSEXN_ERR, "function can be called only in debug mode")
|
||||
MSG_DEF(JSMSG_STRICT_CODE_LET_EXPR_STMT, 258, 0, JSEXN_ERR, "strict mode code may not contain unparenthesized let expression statements")
|
||||
MSG_DEF(JSMSG_CANT_CHANGE_EXTENSIBILITY, 259, 0, JSEXN_TYPEERR, "can't change object's extensibility")
|
||||
MSG_DEF(JSMSG_SC_BAD_SERIALIZED_DATA, 260, 1, JSEXN_INTERNALERR, "bad serialized structured data ({0})")
|
||||
MSG_DEF(JSMSG_SC_UNSUPPORTED_TYPE, 261, 0, JSEXN_TYPEERR, "unsupported type for structured data")
|
||||
MSG_DEF(JSMSG_SC_RECURSION, 262, 0, JSEXN_INTERNALERR, "recursive object")
|
||||
MSG_DEF(JSMSG_DEBUG_CANT_DEBUG_GLOBAL, 263, 0, JSEXN_ERR, "passing non-debuggable global to addDebuggee")
|
||||
MSG_DEF(JSMSG_BAD_CLONE_VERSION, 264, 0, JSEXN_ERR, "unsupported structured clone version")
|
||||
MSG_DEF(JSMSG_CANT_CLONE_OBJECT, 265, 0, JSEXN_TYPEERR, "can't clone object")
|
||||
MSG_DEF(JSMSG_DEBUG_RESUMPTION_VALUE_DISALLOWED, 266, 0, JSEXN_TYPEERR, "resumption values are disallowed in this hook")
|
||||
MSG_DEF(JSMSG_STRICT_FUNCTION_STATEMENT, 267, 0, JSEXN_SYNTAXERR, "in strict mode code, functions may be declared only at top level or immediately within another function")
|
||||
MSG_DEF(JSMSG_INVALID_FOR_IN_INIT, 268, 0, JSEXN_SYNTAXERR, "for-in loop let declaration may not have an initializer")
|
||||
MSG_DEF(JSMSG_CLEARED_SCOPE, 269, 0, JSEXN_TYPEERR, "attempt to run compile-and-go script on a cleared scope")
|
||||
MSG_DEF(JSMSG_MALFORMED_ESCAPE, 270, 1, JSEXN_SYNTAXERR, "malformed {0} character escape sequence")
|
||||
MSG_DEF(JSMSG_BAD_GENEXP_BODY, 271, 1, JSEXN_SYNTAXERR, "illegal use of {0} in generator expression")
|
||||
MSG_DEF(JSMSG_YIELD_WITHOUT_OPERAND, 272, 0, JSEXN_SYNTAXERR, "yield without a value is deprecated, and illegal in ES6 (use 'yield undefined' instead)")
|
||||
MSG_DEF(JSMSG_UNNAMED_FUNCTION_STMT, 273, 0, JSEXN_SYNTAXERR, "function statement requires a name")
|
||||
MSG_DEF(JSMSG_CCW_REQUIRED, 274, 1, JSEXN_TYPEERR, "{0}: argument must be an object from a different compartment")
|
||||
MSG_DEF(JSMSG_DEBUG_BAD_RESUMPTION, 275, 0, JSEXN_TYPEERR, "debugger resumption value must be undefined, {throw: val}, {return: val}, or null")
|
||||
MSG_DEF(JSMSG_ASSIGN_FUNCTION_OR_NULL, 276, 1, JSEXN_TYPEERR, "value assigned to {0} must be a function or null")
|
||||
MSG_DEF(JSMSG_DEBUG_NOT_LIVE, 277, 1, JSEXN_ERR, "{0} is not live")
|
||||
MSG_DEF(JSMSG_DEBUG_OBJECT_WRONG_OWNER, 278, 0, JSEXN_TYPEERR, "Debugger.Object belongs to a different Debugger")
|
||||
MSG_DEF(JSMSG_DEBUG_OBJECT_PROTO, 279, 0, JSEXN_TYPEERR, "Debugger.Object.prototype is not a valid Debugger.Object")
|
||||
MSG_DEF(JSMSG_DEBUG_LOOP, 280, 0, JSEXN_TYPEERR, "cannot debug an object in same compartment as debugger or a compartment that is already debugging the debugger")
|
||||
MSG_DEF(JSMSG_DEBUG_NOT_IDLE, 281, 0, JSEXN_ERR, "can't start debugging: a debuggee script is on the stack")
|
||||
MSG_DEF(JSMSG_DEBUG_BAD_OFFSET, 282, 0, JSEXN_TYPEERR, "invalid script offset")
|
||||
MSG_DEF(JSMSG_DEBUG_BAD_LINE, 283, 0, JSEXN_TYPEERR, "invalid line number")
|
||||
MSG_DEF(JSMSG_DEBUG_NOT_DEBUGGING, 284, 0, JSEXN_ERR, "can't set breakpoint: script global is not a debuggee")
|
||||
MSG_DEF(JSMSG_DEBUG_COMPARTMENT_MISMATCH, 285, 2, JSEXN_TYPEERR, "{0}: descriptor .{1} property is an object in a different compartment than the target object")
|
||||
MSG_DEF(JSMSG_DEBUG_NOT_SCRIPT_FRAME, 286, 0, JSEXN_ERR, "stack frame is not running JavaScript code")
|
||||
MSG_DEF(JSMSG_CANT_WATCH_PROP, 287, 0, JSEXN_TYPEERR, "properties whose names are objects can't be watched")
|
||||
MSG_DEF(JSMSG_CSP_BLOCKED_EVAL, 288, 0, JSEXN_ERR, "call to eval() blocked by CSP")
|
||||
MSG_DEF(JSMSG_DEBUG_NO_SCOPE_OBJECT, 289, 0, JSEXN_TYPEERR, "declarative Environments don't have binding objects")
|
||||
MSG_DEF(JSMSG_EMPTY_CONSEQUENT, 290, 0, JSEXN_SYNTAXERR, "mistyped ; after conditional?")
|
||||
MSG_DEF(JSMSG_NOT_ITERABLE, 291, 1, JSEXN_TYPEERR, "{0} is not iterable")
|
||||
MSG_DEF(JSMSG_QUERY_LINE_WITHOUT_URL, 292, 0, JSEXN_TYPEERR, "findScripts query object has 'line' property, but no 'url' property")
|
||||
MSG_DEF(JSMSG_QUERY_INNERMOST_WITHOUT_LINE_URL, 293, 0, JSEXN_TYPEERR, "findScripts query object has 'innermost' property without both 'url' and 'line' properties")
|
||||
MSG_DEF(JSMSG_DEBUG_VARIABLE_NOT_FOUND, 294, 0, JSEXN_TYPEERR, "variable not found in environment")
|
||||
MSG_DEF(JSMSG_PARAMETER_AFTER_REST, 295, 0, JSEXN_SYNTAXERR, "parameter after rest parameter")
|
||||
MSG_DEF(JSMSG_NO_REST_NAME, 296, 0, JSEXN_SYNTAXERR, "no parameter name after ...")
|
||||
MSG_DEF(JSMSG_ARGUMENTS_AND_REST, 297, 0, JSEXN_SYNTAXERR, "'arguments' object may not be used in conjunction with a rest parameter")
|
||||
MSG_DEF(JSMSG_FUNCTION_ARGUMENTS_AND_REST, 298, 0, JSEXN_ERR, "the 'arguments' property of a function with a rest parameter may not be used")
|
||||
MSG_DEF(JSMSG_REST_WITH_DEFAULT, 299, 0, JSEXN_SYNTAXERR, "rest parameter may not have a default")
|
||||
MSG_DEF(JSMSG_NONDEFAULT_FORMAL_AFTER_DEFAULT, 300, 0, JSEXN_SYNTAXERR, "parameter(s) with default followed by parameter without default")
|
||||
MSG_DEF(JSMSG_YIELD_IN_DEFAULT, 301, 0, JSEXN_SYNTAXERR, "yield in default expression")
|
||||
MSG_DEF(JSMSG_INTRINSIC_NOT_DEFINED, 302, 1, JSEXN_REFERENCEERR, "no intrinsic function {0}")
|
||||
MSG_DEF(JSMSG_ALREADY_HAS_PRAGMA, 303, 2, JSEXN_NONE, "{0} is being assigned a {1}, but already has one")
|
||||
MSG_DEF(JSMSG_PAR_ARRAY_BAD_ARG, 304, 0, JSEXN_RANGEERR, "invalid parallel method argument")
|
||||
MSG_DEF(JSMSG_REGEXP_RUNTIME_ERROR, 305, 0, JSEXN_INTERNALERR, "an error occurred while executing regular expression")
|
||||
MSG_DEF(JSMSG_DEBUG_OPTIMIZED_OUT, 306, 0, JSEXN_ERR, "variable has been optimized out")
|
||||
MSG_DEF(JSMSG_NEXT_RETURNED_PRIMITIVE,307, 0, JSEXN_TYPEERR, "iterator.next() returned a non-object value")
|
||||
MSG_DEF(JSMSG_PAR_ARRAY_SCATTER_CONFLICT, 308, 0, JSEXN_ERR, "no conflict resolution function provided")
|
||||
MSG_DEF(JSMSG_PAR_ARRAY_SCATTER_BOUNDS, 309, 0, JSEXN_ERR, "index in scatter vector out of bounds")
|
||||
MSG_DEF(JSMSG_CANT_REPORT_NC_AS_NE, 310, 0, JSEXN_TYPEERR, "proxy can't report a non-configurable own property as non-existent")
|
||||
MSG_DEF(JSMSG_CANT_REPORT_E_AS_NE, 311, 0, JSEXN_TYPEERR, "proxy can't report an existing own property as non-existent on a non-extensible object")
|
||||
MSG_DEF(JSMSG_CANT_REPORT_NEW, 312, 0, JSEXN_TYPEERR, "proxy can't report a new property on a non-extensible object")
|
||||
MSG_DEF(JSMSG_CANT_REPORT_INVALID, 313, 0, JSEXN_TYPEERR, "proxy can't report an incompatible property descriptor")
|
||||
MSG_DEF(JSMSG_CANT_REPORT_NE_AS_NC, 314, 0, JSEXN_TYPEERR, "proxy can't report a non-existent property as non-configurable")
|
||||
MSG_DEF(JSMSG_CANT_DEFINE_NEW, 315, 0, JSEXN_TYPEERR, "proxy can't define a new property on a non-extensible object")
|
||||
MSG_DEF(JSMSG_CANT_DEFINE_INVALID, 316, 0, JSEXN_TYPEERR, "proxy can't define an incompatible property descriptor")
|
||||
MSG_DEF(JSMSG_CANT_DEFINE_NE_AS_NC, 317, 0, JSEXN_TYPEERR, "proxy can't define a non-existent property as non-configurable")
|
||||
MSG_DEF(JSMSG_INVALID_TRAP_RESULT, 318, 2, JSEXN_TYPEERR, "trap {1} for {0} returned an invalid result")
|
||||
MSG_DEF(JSMSG_CANT_SKIP_NC, 319, 0, JSEXN_TYPEERR, "proxy can't skip a non-configurable property")
|
||||
MSG_DEF(JSMSG_MUST_REPORT_SAME_VALUE, 320, 0, JSEXN_TYPEERR, "proxy must report the same value for a non-writable, non-configurable property")
|
||||
MSG_DEF(JSMSG_MUST_REPORT_UNDEFINED, 321, 0, JSEXN_TYPEERR, "proxy must report undefined for a non-configurable accessor property without a getter")
|
||||
MSG_DEF(JSMSG_CANT_SET_NW_NC, 322, 0, JSEXN_TYPEERR, "proxy can't successfully set a non-writable, non-configurable property")
|
||||
MSG_DEF(JSMSG_CANT_SET_WO_SETTER, 323, 0, JSEXN_TYPEERR, "proxy can't succesfully set an accessor property without a setter")
|
||||
MSG_DEF(JSMSG_DEBUG_BAD_REFERENT, 324, 2, JSEXN_TYPEERR, "{0} does not refer to {1}")
|
||||
MSG_DEF(JSMSG_DEBUG_WRAPPER_IN_WAY, 325, 3, JSEXN_TYPEERR, "{0} is {1}{2}a global object, but a direct reference is required")
|
||||
MSG_DEF(JSMSG_UNWRAP_DENIED, 326, 0, JSEXN_ERR, "permission denied to unwrap object")
|
||||
MSG_DEF(JSMSG_INTL_OBJECT_NOT_INITED, 327, 3, JSEXN_TYPEERR, "Intl.{0}.prototype.{1} called on value that's not an object initialized as a {2}")
|
||||
MSG_DEF(JSMSG_INVALID_LOCALES_ELEMENT,328, 0, JSEXN_TYPEERR, "invalid element in locales argument")
|
||||
MSG_DEF(JSMSG_INVALID_LANGUAGE_TAG, 329, 1, JSEXN_RANGEERR, "invalid language tag: {0}")
|
||||
MSG_DEF(JSMSG_INVALID_LOCALE_MATCHER, 330, 1, JSEXN_RANGEERR, "invalid locale matcher in supportedLocalesOf(): {0}")
|
||||
MSG_DEF(JSMSG_INVALID_OPTION_VALUE, 331, 2, JSEXN_RANGEERR, "invalid value {1} for option {0}")
|
||||
MSG_DEF(JSMSG_INVALID_DIGITS_VALUE, 332, 1, JSEXN_RANGEERR, "invalid digits value: {0}")
|
||||
MSG_DEF(JSMSG_INTL_OBJECT_REINITED, 333, 0, JSEXN_TYPEERR, "can't initialize object twice as an object of an Intl constructor")
|
||||
MSG_DEF(JSMSG_INVALID_CURRENCY_CODE, 334, 1, JSEXN_RANGEERR, "invalid currency code in NumberFormat(): {0}")
|
||||
MSG_DEF(JSMSG_UNDEFINED_CURRENCY, 335, 0, JSEXN_TYPEERR, "undefined currency in NumberFormat() with currency style")
|
||||
MSG_DEF(JSMSG_INVALID_TIME_ZONE, 336, 1, JSEXN_RANGEERR, "invalid time zone in DateTimeFormat(): {0}")
|
||||
MSG_DEF(JSMSG_DATE_NOT_FINITE, 337, 0, JSEXN_RANGEERR, "date value is not finite in DateTimeFormat.format()")
|
||||
MSG_DEF(JSMSG_USE_ASM_DIRECTIVE_FAIL, 338, 0, JSEXN_SYNTAXERR, "\"use asm\" is only meaningful in the Directive Prologue of a function body")
|
||||
MSG_DEF(JSMSG_USE_ASM_TYPE_FAIL, 339, 1, JSEXN_TYPEERR, "asm.js type error: {0}")
|
||||
MSG_DEF(JSMSG_USE_ASM_LINK_FAIL, 340, 1, JSEXN_TYPEERR, "asm.js link error: {0}")
|
||||
MSG_DEF(JSMSG_USE_ASM_TYPE_OK, 341, 1, JSEXN_NONE, "Successfully compiled asm.js code ({0})")
|
||||
MSG_DEF(JSMSG_BAD_ARROW_ARGS, 342, 0, JSEXN_SYNTAXERR, "invalid arrow-function arguments (parentheses around the arrow-function may help)")
|
||||
MSG_DEF(JSMSG_YIELD_IN_ARROW, 343, 0, JSEXN_SYNTAXERR, "arrow function may not contain yield")
|
||||
MSG_DEF(JSMSG_WRONG_VALUE, 344, 2, JSEXN_ERR, "expected {0} but found {1}")
|
||||
MSG_DEF(JSMSG_PAR_ARRAY_SCATTER_BAD_TARGET, 345, 1, JSEXN_ERR, "target for index {0} is not an integer")
|
||||
MSG_DEF(JSMSG_SELFHOSTED_UNBOUND_NAME,346, 0, JSEXN_TYPEERR, "self-hosted code may not contain unbound name lookups")
|
||||
MSG_DEF(JSMSG_DEPRECATED_PRAGMA, 347, 1, JSEXN_NONE, "Using //@ to indicate {0} pragmas is deprecated. Use //# instead")
|
||||
MSG_DEF(JSMSG_BAD_DESTRUCT_ASSIGN, 348, 1, JSEXN_SYNTAXERR, "can't assign to {0} using destructuring assignment")
|
||||
MSG_DEF(JSMSG_TYPEDOBJECT_ARRAYTYPE_BAD_ARGS, 349, 0, JSEXN_ERR, "Invalid arguments")
|
||||
MSG_DEF(JSMSG_TYPEDOBJECT_BINARYARRAY_BAD_INDEX, 350, 0, JSEXN_RANGEERR, "invalid or out-of-range index")
|
||||
MSG_DEF(JSMSG_TYPEDOBJECT_STRUCTTYPE_BAD_ARGS, 351, 0, JSEXN_RANGEERR, "invalid field descriptor")
|
||||
MSG_DEF(JSMSG_TYPEDOBJECT_NOT_BINARYSTRUCT, 352, 1, JSEXN_TYPEERR, "{0} is not a BinaryStruct")
|
||||
MSG_DEF(JSMSG_TYPEDOBJECT_SUBARRAY_INTEGER_ARG, 353, 1, JSEXN_ERR, "argument {0} must be an integer")
|
||||
MSG_DEF(JSMSG_TYPEDOBJECT_STRUCTTYPE_EMPTY_DESCRIPTOR, 354, 0, JSEXN_ERR, "field descriptor cannot be empty")
|
||||
MSG_DEF(JSMSG_TYPEDOBJECT_STRUCTTYPE_BAD_FIELD, 355, 1, JSEXN_ERR, "field {0} is not a valid BinaryData Type descriptor")
|
||||
MSG_DEF(JSMSG_GENERATOR_FINISHED, 356, 0, JSEXN_TYPEERR, "generator has already finished")
|
||||
MSG_DEF(JSMSG_TYPEDOBJECT_TOO_BIG, 357, 0, JSEXN_ERR, "Type is too large to allocate")
|
||||
MSG_DEF(JSMSG_TYPEDOBJECT_NOT_TYPE_OBJECT, 358, 0, JSEXN_ERR, "Expected a type object")
|
||||
MSG_DEF(JSMSG_TOO_MANY_CON_SPREADARGS, 359, 0, JSEXN_RANGEERR, "too many constructor arguments")
|
||||
MSG_DEF(JSMSG_TOO_MANY_FUN_SPREADARGS, 360, 0, JSEXN_RANGEERR, "too many function arguments")
|
||||
MSG_DEF(JSMSG_DEBUG_NOT_DEBUGGEE, 361, 2, JSEXN_ERR, "{0} is not a debuggee {1}")
|
||||
MSG_DEF(JSMSG_TYPEDOBJECT_NOT_TYPED_OBJECT, 362, 0, JSEXN_ERR, "Expected a typed object")
|
||||
MSG_DEF(JSMSG_TYPEDOBJECT_NO_SUCH_PROP, 363, 1, JSEXN_TYPEERR, "No such property: {0}")
|
||||
MSG_DEF(JSMSG_TYPEDOBJECT_BAD_ARGS, 364, 0, JSEXN_TYPEERR, "invalid arguments")
|
||||
MSG_DEF(JSMSG_TYPEDOBJECT_HANDLE_UNATTACHED, 365, 0, JSEXN_TYPEERR, "handle unattached")
|
||||
MSG_DEF(JSMSG_TYPEDOBJECT_HANDLE_BAD_TYPE, 366, 0, JSEXN_TYPEERR, "handle moved to destination of incorrect type")
|
||||
MSG_DEF(JSMSG_NOT_AN_ERROR, 0, JSEXN_ERR, "<Error #0 is reserved>")
|
||||
MSG_DEF(JSMSG_NOT_DEFINED, 1, JSEXN_REFERENCEERR, "{0} is not defined")
|
||||
MSG_DEF(JSMSG_MORE_ARGS_NEEDED, 3, JSEXN_TYPEERR, "{0} requires more than {1} argument{2}")
|
||||
MSG_DEF(JSMSG_INCOMPATIBLE_PROTO, 3, JSEXN_TYPEERR, "{0}.prototype.{1} called on incompatible {2}")
|
||||
MSG_DEF(JSMSG_NO_CONSTRUCTOR, 1, JSEXN_TYPEERR, "{0} has no constructor")
|
||||
MSG_DEF(JSMSG_BAD_SORT_ARG, 0, JSEXN_TYPEERR, "invalid Array.prototype.sort argument")
|
||||
MSG_DEF(JSMSG_CANT_WATCH, 1, JSEXN_TYPEERR, "can't watch non-native objects of class {0}")
|
||||
MSG_DEF(JSMSG_READ_ONLY, 1, JSEXN_TYPEERR, "{0} is read-only")
|
||||
MSG_DEF(JSMSG_CANT_DELETE, 1, JSEXN_TYPEERR, "property {0} is non-configurable and can't be deleted")
|
||||
MSG_DEF(JSMSG_CANT_TRUNCATE_ARRAY, 0, JSEXN_TYPEERR, "can't delete non-configurable array element")
|
||||
MSG_DEF(JSMSG_NOT_FUNCTION, 1, JSEXN_TYPEERR, "{0} is not a function")
|
||||
MSG_DEF(JSMSG_NOT_CONSTRUCTOR, 1, JSEXN_TYPEERR, "{0} is not a constructor")
|
||||
MSG_DEF(JSMSG_CANT_CONVERT_TO, 2, JSEXN_TYPEERR, "can't convert {0} to {1}")
|
||||
MSG_DEF(JSMSG_TOPRIMITIVE_NOT_CALLABLE, 2, JSEXN_TYPEERR, "can't convert {0} to {1}: its [Symbol.toPrimitive] property is not a function")
|
||||
MSG_DEF(JSMSG_TOPRIMITIVE_RETURNED_OBJECT, 2, JSEXN_TYPEERR, "can't convert {0} to {1}: its [Symbol.toPrimitive] method returned an object")
|
||||
MSG_DEF(JSMSG_NO_PROPERTIES, 1, JSEXN_TYPEERR, "{0} has no properties")
|
||||
MSG_DEF(JSMSG_BAD_REGEXP_FLAG, 1, JSEXN_SYNTAXERR, "invalid regular expression flag {0}")
|
||||
MSG_DEF(JSMSG_ARG_INDEX_OUT_OF_RANGE, 1, JSEXN_RANGEERR, "argument {0} accesses an index that is out of range")
|
||||
MSG_DEF(JSMSG_SPREAD_TOO_LARGE, 0, JSEXN_RANGEERR, "array too large due to spread operand(s)")
|
||||
MSG_DEF(JSMSG_BAD_WEAKMAP_KEY, 0, JSEXN_TYPEERR, "cannot use the given object as a weak map key")
|
||||
MSG_DEF(JSMSG_BAD_GETTER_OR_SETTER, 1, JSEXN_TYPEERR, "invalid {0} usage")
|
||||
MSG_DEF(JSMSG_BAD_ARRAY_LENGTH, 0, JSEXN_RANGEERR, "invalid array length")
|
||||
MSG_DEF(JSMSG_REDECLARED_VAR, 2, JSEXN_SYNTAXERR, "redeclaration of {0} {1}")
|
||||
MSG_DEF(JSMSG_UNDECLARED_VAR, 1, JSEXN_REFERENCEERR, "assignment to undeclared variable {0}")
|
||||
MSG_DEF(JSMSG_GETTER_ONLY, 0, JSEXN_TYPEERR, "setting a property that has only a getter")
|
||||
MSG_DEF(JSMSG_OVERWRITING_ACCESSOR, 1, JSEXN_TYPEERR, "can't overwrite accessor property {0}")
|
||||
MSG_DEF(JSMSG_UNDEFINED_PROP, 1, JSEXN_REFERENCEERR, "reference to undefined property {0}")
|
||||
MSG_DEF(JSMSG_INVALID_MAP_ITERABLE, 1, JSEXN_TYPEERR, "iterable for {0} should have array-like objects")
|
||||
MSG_DEF(JSMSG_NESTING_GENERATOR, 0, JSEXN_TYPEERR, "already executing generator")
|
||||
MSG_DEF(JSMSG_INCOMPATIBLE_METHOD, 3, JSEXN_TYPEERR, "{0} {1} called on incompatible {2}")
|
||||
MSG_DEF(JSMSG_OBJECT_WATCH_DEPRECATED, 0, JSEXN_WARN, "Object.prototype.watch and unwatch are very slow, non-standard, and deprecated; use a getter/setter instead")
|
||||
MSG_DEF(JSMSG_ARRAYBUFFER_SLICE_DEPRECATED, 0, JSEXN_WARN, "ArrayBuffer.slice is deprecated; use ArrayBuffer.prototype.slice instead")
|
||||
MSG_DEF(JSMSG_BAD_SURROGATE_CHAR, 1, JSEXN_TYPEERR, "bad surrogate character {0}")
|
||||
MSG_DEF(JSMSG_UTF8_CHAR_TOO_LARGE, 1, JSEXN_TYPEERR, "UTF-8 character {0} too large")
|
||||
MSG_DEF(JSMSG_MALFORMED_UTF8_CHAR, 1, JSEXN_TYPEERR, "malformed UTF-8 character sequence at offset {0}")
|
||||
MSG_DEF(JSMSG_BUILTIN_CTOR_NO_NEW, 1, JSEXN_TYPEERR, "calling a builtin {0} constructor without new is forbidden")
|
||||
MSG_DEF(JSMSG_BAD_GENERATOR_YIELD, 1, JSEXN_TYPEERR, "yield from closing generator {0}")
|
||||
MSG_DEF(JSMSG_EMPTY_ARRAY_REDUCE, 0, JSEXN_TYPEERR, "reduce of empty array with no initial value")
|
||||
MSG_DEF(JSMSG_UNEXPECTED_TYPE, 2, JSEXN_TYPEERR, "{0} is {1}")
|
||||
MSG_DEF(JSMSG_MISSING_FUN_ARG, 2, JSEXN_TYPEERR, "missing argument {0} when calling function {1}")
|
||||
MSG_DEF(JSMSG_NOT_NONNULL_OBJECT, 1, JSEXN_TYPEERR, "{0} is not a non-null object")
|
||||
MSG_DEF(JSMSG_SET_NON_OBJECT_RECEIVER, 1, JSEXN_TYPEERR, "can't assign to properties of {0}: not an object")
|
||||
MSG_DEF(JSMSG_INVALID_DESCRIPTOR, 0, JSEXN_TYPEERR, "property descriptors must not specify a value or be writable when a getter or setter has been specified")
|
||||
MSG_DEF(JSMSG_OBJECT_NOT_EXTENSIBLE, 1, JSEXN_TYPEERR, "{0}: Object is not extensible")
|
||||
MSG_DEF(JSMSG_CANT_DEFINE_PROP_OBJECT_NOT_EXTENSIBLE, 2, JSEXN_TYPEERR, "can't define property {1}: {0} is not extensible")
|
||||
MSG_DEF(JSMSG_CANT_REDEFINE_PROP, 1, JSEXN_TYPEERR, "can't redefine non-configurable property {0}")
|
||||
MSG_DEF(JSMSG_CANT_REDEFINE_ARRAY_LENGTH, 0, JSEXN_TYPEERR, "can't redefine array length")
|
||||
MSG_DEF(JSMSG_CANT_DEFINE_PAST_ARRAY_LENGTH, 0, JSEXN_TYPEERR, "can't define array index property past the end of an array with non-writable length")
|
||||
MSG_DEF(JSMSG_BAD_GET_SET_FIELD, 1, JSEXN_TYPEERR, "property descriptor's {0} field is neither undefined nor a function")
|
||||
MSG_DEF(JSMSG_THROW_TYPE_ERROR, 0, JSEXN_TYPEERR, "'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them")
|
||||
MSG_DEF(JSMSG_NOT_EXPECTED_TYPE, 3, JSEXN_TYPEERR, "{0}: expected {1}, got {2}")
|
||||
MSG_DEF(JSMSG_NOT_ITERABLE, 1, JSEXN_TYPEERR, "{0} is not iterable")
|
||||
MSG_DEF(JSMSG_NOT_ITERATOR, 1, JSEXN_TYPEERR, "{0} is not iterator")
|
||||
MSG_DEF(JSMSG_ALREADY_HAS_PRAGMA, 2, JSEXN_WARN, "{0} is being assigned a {1}, but already has one")
|
||||
MSG_DEF(JSMSG_GET_ITER_RETURNED_PRIMITIVE, 0, JSEXN_TYPEERR, "[Symbol.iterator]() returned a non-object value")
|
||||
MSG_DEF(JSMSG_NEXT_RETURNED_PRIMITIVE, 0, JSEXN_TYPEERR, "iterator.next() returned a non-object value")
|
||||
MSG_DEF(JSMSG_CANT_SET_PROTO, 0, JSEXN_TYPEERR, "can't set prototype of this object")
|
||||
MSG_DEF(JSMSG_CANT_SET_PROTO_OF, 1, JSEXN_TYPEERR, "can't set prototype of {0}")
|
||||
MSG_DEF(JSMSG_CANT_SET_PROTO_CYCLE, 0, JSEXN_TYPEERR, "can't set prototype: it would cause a prototype chain cycle")
|
||||
MSG_DEF(JSMSG_INVALID_ARG_TYPE, 3, JSEXN_TYPEERR, "Invalid type: {0} can't be a{1} {2}")
|
||||
MSG_DEF(JSMSG_TERMINATED, 1, JSEXN_ERR, "Script terminated by timeout at:\n{0}")
|
||||
MSG_DEF(JSMSG_PROTO_NOT_OBJORNULL, 1, JSEXN_TYPEERR, "{0}.prototype is not an object or null")
|
||||
MSG_DEF(JSMSG_CANT_CALL_CLASS_CONSTRUCTOR, 0, JSEXN_TYPEERR, "class constructors must be invoked with |new|")
|
||||
MSG_DEF(JSMSG_UNINITIALIZED_THIS, 1, JSEXN_REFERENCEERR, "|this| used uninitialized in {0} class constructor")
|
||||
MSG_DEF(JSMSG_UNINITIALIZED_THIS_ARROW, 0, JSEXN_REFERENCEERR, "|this| used uninitialized in arrow function in class constructor")
|
||||
MSG_DEF(JSMSG_BAD_DERIVED_RETURN, 1, JSEXN_TYPEERR, "derived class constructor returned invalid value {0}")
|
||||
|
||||
MSG_DEF(JSMSG_IMPORT_DECL_AT_TOP_LEVEL, 367, 0, JSEXN_SYNTAXERR, "import declarations may only appear at top level")
|
||||
MSG_DEF(JSMSG_NO_IMPORT_NAME, 368, 0, JSEXN_SYNTAXERR, "missing import name")
|
||||
MSG_DEF(JSMSG_AS_AFTER_RESERVED_WORD, 369, 1, JSEXN_SYNTAXERR, "missing keyword 'as' after reserved word '{0}'")
|
||||
MSG_DEF(JSMSG_NO_BINDING_NAME, 370, 0, JSEXN_SYNTAXERR, "missing binding name")
|
||||
MSG_DEF(JSMSG_RC_AFTER_IMPORT_SPEC_LIST, 371, 0, JSEXN_SYNTAXERR, "missing '}' after module specifier list")
|
||||
MSG_DEF(JSMSG_FROM_AFTER_IMPORT_SPEC_SET, 372, 0, JSEXN_SYNTAXERR, "missing keyword 'from' after import specifier set")
|
||||
MSG_DEF(JSMSG_DECLARATION_AFTER_IMPORT, 373, 0, JSEXN_SYNTAXERR, "missing declaration after 'import' keyword")
|
||||
MSG_DEF(JSMSG_MODULE_SPEC_AFTER_FROM, 374, 0, JSEXN_SYNTAXERR, "missing module specifier after 'from' keyword")
|
||||
MSG_DEF(JSMSG_MODULES_NOT_IMPLEMENTED, 375, 0, JSEXN_SYNTAXERR, "modules are not implemented yet")
|
||||
MSG_DEF(JSMSG_EXPORT_DECL_AT_TOP_LEVEL, 376, 0, JSEXN_SYNTAXERR, "export declarations may only appear at top level")
|
||||
MSG_DEF(JSMSG_RC_AFTER_EXPORT_SPEC_LIST, 377, 0, JSEXN_SYNTAXERR, "missing '}' after export specifier list")
|
||||
MSG_DEF(JSMSG_NO_EXPORT_NAME, 378, 0, JSEXN_SYNTAXERR, "missing export name")
|
||||
MSG_DEF(JSMSG_DECLARATION_AFTER_EXPORT, 379, 0, JSEXN_SYNTAXERR, "missing declaration after 'export' keyword")
|
||||
MSG_DEF(JSMSG_INVALID_PROTOTYPE, 380, 0, JSEXN_TYPEERR, "prototype field is not an object")
|
||||
MSG_DEF(JSMSG_TYPEDOBJECT_HANDLE_TO_UNSIZED, 381, 0, JSEXN_TYPEERR, "cannot create a handle to an unsized type")
|
||||
MSG_DEF(JSMSG_SETPROTOTYPEOF_FAIL, 382, 1, JSEXN_TYPEERR, "[[SetPrototypeOf]] failed on {0}")
|
||||
MSG_DEF(JSMSG_INVALID_ARG_TYPE, 383, 3, JSEXN_TYPEERR, "Invalid type: {0} can't be a{1} {2}")
|
||||
MSG_DEF(JSMSG_TERMINATED, 384, 1, JSEXN_ERR, "Script terminated by timeout at:\n{0}")
|
||||
MSG_DEF(JSMSG_NO_SUCH_SELF_HOSTED_PROP, 385, 1, JSEXN_ERR, "No such property on self-hosted object: {0}")
|
||||
MSG_DEF(JSMSG_PROXY_EXTENSIBILITY, 386, 0, JSEXN_TYPEERR, "proxy must report same extensiblitity as target")
|
||||
MSG_DEF(JSMSG_PROXY_CONSTRUCT_OBJECT, 387, 0, JSEXN_TYPEERR, "proxy [[Construct]] must return an object")
|
||||
MSG_DEF(JSMSG_PROXY_GETOWN_OBJORUNDEF, 388, 0, JSEXN_TYPEERR, "proxy [[GetOwnProperty]] must return an object or undefined")
|
||||
MSG_DEF(JSMSG_CANT_REPORT_C_AS_NC, 389, 0, JSEXN_TYPEERR, "proxy can't report existing configurable property as non-configurable")
|
||||
// JSON
|
||||
MSG_DEF(JSMSG_JSON_BAD_PARSE, 3, JSEXN_SYNTAXERR, "JSON.parse: {0} at line {1} column {2} of the JSON data")
|
||||
MSG_DEF(JSMSG_JSON_CYCLIC_VALUE, 0, JSEXN_TYPEERR, "cyclic object value")
|
||||
|
||||
// Runtime errors
|
||||
MSG_DEF(JSMSG_BAD_INSTANCEOF_RHS, 1, JSEXN_TYPEERR, "invalid 'instanceof' operand {0}")
|
||||
MSG_DEF(JSMSG_BAD_LEFTSIDE_OF_ASS, 0, JSEXN_REFERENCEERR, "invalid assignment left-hand side")
|
||||
MSG_DEF(JSMSG_BAD_PROTOTYPE, 1, JSEXN_TYPEERR, "'prototype' property of {0} is not an object")
|
||||
MSG_DEF(JSMSG_IN_NOT_OBJECT, 1, JSEXN_TYPEERR, "invalid 'in' operand {0}")
|
||||
MSG_DEF(JSMSG_TOO_MANY_CON_SPREADARGS, 0, JSEXN_RANGEERR, "too many constructor arguments")
|
||||
MSG_DEF(JSMSG_TOO_MANY_FUN_SPREADARGS, 0, JSEXN_RANGEERR, "too many function arguments")
|
||||
MSG_DEF(JSMSG_UNINITIALIZED_LEXICAL, 1, JSEXN_REFERENCEERR, "can't access lexical declaration `{0}' before initialization")
|
||||
MSG_DEF(JSMSG_BAD_CONST_ASSIGN, 1, JSEXN_TYPEERR, "invalid assignment to const `{0}'")
|
||||
MSG_DEF(JSMSG_CANT_DECLARE_GLOBAL_BINDING, 2, JSEXN_TYPEERR, "cannot declare global binding `{0}': {1}")
|
||||
|
||||
// Date
|
||||
MSG_DEF(JSMSG_INVALID_DATE, 0, JSEXN_RANGEERR, "invalid date")
|
||||
MSG_DEF(JSMSG_BAD_TOISOSTRING_PROP, 0, JSEXN_TYPEERR, "toISOString property is not callable")
|
||||
|
||||
// String
|
||||
MSG_DEF(JSMSG_BAD_URI, 0, JSEXN_URIERR, "malformed URI sequence")
|
||||
MSG_DEF(JSMSG_INVALID_NORMALIZE_FORM, 0, JSEXN_RANGEERR, "form must be one of 'NFC', 'NFD', 'NFKC', or 'NFKD'")
|
||||
MSG_DEF(JSMSG_NEGATIVE_REPETITION_COUNT, 0, JSEXN_RANGEERR, "repeat count must be non-negative")
|
||||
MSG_DEF(JSMSG_NOT_A_CODEPOINT, 1, JSEXN_RANGEERR, "{0} is not a valid code point")
|
||||
MSG_DEF(JSMSG_RESULTING_STRING_TOO_LARGE, 0, JSEXN_RANGEERR, "repeat count must be less than infinity and not overflow maximum string size")
|
||||
|
||||
// Number
|
||||
MSG_DEF(JSMSG_BAD_RADIX, 0, JSEXN_RANGEERR, "radix must be an integer at least 2 and no greater than 36")
|
||||
MSG_DEF(JSMSG_PRECISION_RANGE, 1, JSEXN_RANGEERR, "precision {0} out of range")
|
||||
|
||||
// Function
|
||||
MSG_DEF(JSMSG_BAD_APPLY_ARGS, 1, JSEXN_TYPEERR, "second argument to Function.prototype.{0} must be an array")
|
||||
MSG_DEF(JSMSG_BAD_FORMAL, 0, JSEXN_SYNTAXERR, "malformed formal parameter")
|
||||
MSG_DEF(JSMSG_CALLER_IS_STRICT, 0, JSEXN_TYPEERR, "access to strict mode caller function is censored")
|
||||
MSG_DEF(JSMSG_DEPRECATED_USAGE, 1, JSEXN_REFERENCEERR, "deprecated {0} usage")
|
||||
MSG_DEF(JSMSG_NOT_SCRIPTED_FUNCTION, 1, JSEXN_TYPEERR, "{0} is not a scripted function")
|
||||
MSG_DEF(JSMSG_NO_REST_NAME, 0, JSEXN_SYNTAXERR, "no parameter name after ...")
|
||||
MSG_DEF(JSMSG_PARAMETER_AFTER_REST, 0, JSEXN_SYNTAXERR, "parameter after rest parameter")
|
||||
MSG_DEF(JSMSG_TOO_MANY_ARGUMENTS, 0, JSEXN_RANGEERR, "too many arguments provided for a function call")
|
||||
|
||||
// CSP
|
||||
MSG_DEF(JSMSG_CSP_BLOCKED_EVAL, 0, JSEXN_ERR, "call to eval() blocked by CSP")
|
||||
MSG_DEF(JSMSG_CSP_BLOCKED_FUNCTION, 0, JSEXN_ERR, "call to Function() blocked by CSP")
|
||||
|
||||
// Wrappers
|
||||
MSG_DEF(JSMSG_ACCESSOR_DEF_DENIED, 1, JSEXN_ERR, "Permission denied to define accessor property {0}")
|
||||
MSG_DEF(JSMSG_DEAD_OBJECT, 0, JSEXN_TYPEERR, "can't access dead object")
|
||||
MSG_DEF(JSMSG_UNWRAP_DENIED, 0, JSEXN_ERR, "permission denied to unwrap object")
|
||||
|
||||
// JSAPI-only (Not thrown as JS exceptions)
|
||||
MSG_DEF(JSMSG_BAD_CLONE_FUNOBJ_SCOPE, 0, JSEXN_TYPEERR, "bad cloned function scope chain")
|
||||
MSG_DEF(JSMSG_CANT_CLONE_OBJECT, 0, JSEXN_TYPEERR, "can't clone object")
|
||||
MSG_DEF(JSMSG_CANT_OPEN, 2, JSEXN_ERR, "can't open {0}: {1}")
|
||||
MSG_DEF(JSMSG_USER_DEFINED_ERROR, 0, JSEXN_ERR, "JS_ReportError was called")
|
||||
|
||||
// Internal errors
|
||||
MSG_DEF(JSMSG_ALLOC_OVERFLOW, 0, JSEXN_INTERNALERR, "allocation size overflow")
|
||||
MSG_DEF(JSMSG_BAD_BYTECODE, 1, JSEXN_INTERNALERR, "unimplemented JavaScript bytecode {0}")
|
||||
MSG_DEF(JSMSG_BUFFER_TOO_SMALL, 0, JSEXN_INTERNALERR, "buffer too small")
|
||||
MSG_DEF(JSMSG_BUILD_ID_NOT_AVAILABLE, 0, JSEXN_INTERNALERR, "build ID is not available")
|
||||
MSG_DEF(JSMSG_BYTECODE_TOO_BIG, 2, JSEXN_INTERNALERR, "bytecode {0} too large (limit {1})")
|
||||
MSG_DEF(JSMSG_ERR_DURING_THROW, 0, JSEXN_INTERNALERR, "an internal error occurred while throwing an exception")
|
||||
MSG_DEF(JSMSG_NEED_DIET, 1, JSEXN_INTERNALERR, "{0} too large")
|
||||
MSG_DEF(JSMSG_OUT_OF_MEMORY, 0, JSEXN_INTERNALERR, "out of memory")
|
||||
MSG_DEF(JSMSG_OVER_RECURSED, 0, JSEXN_INTERNALERR, "too much recursion")
|
||||
MSG_DEF(JSMSG_TOO_BIG_TO_ENCODE, 0, JSEXN_INTERNALERR, "data are to big to encode")
|
||||
MSG_DEF(JSMSG_TOO_DEEP, 1, JSEXN_INTERNALERR, "{0} nested too deeply")
|
||||
MSG_DEF(JSMSG_UNCAUGHT_EXCEPTION, 1, JSEXN_INTERNALERR, "uncaught exception: {0}")
|
||||
MSG_DEF(JSMSG_UNKNOWN_FORMAT, 1, JSEXN_INTERNALERR, "unknown bytecode format {0}")
|
||||
|
||||
// Frontend
|
||||
MSG_DEF(JSMSG_ACCESSOR_WRONG_ARGS, 3, JSEXN_SYNTAXERR, "{0} functions must have {1} argument{2}")
|
||||
MSG_DEF(JSMSG_ARRAY_COMP_LEFTSIDE, 0, JSEXN_SYNTAXERR, "invalid array comprehension left-hand side")
|
||||
MSG_DEF(JSMSG_ARRAY_INIT_TOO_BIG, 0, JSEXN_INTERNALERR, "array initializer too large")
|
||||
MSG_DEF(JSMSG_AS_AFTER_IMPORT_STAR, 0, JSEXN_SYNTAXERR, "missing keyword 'as' after import *")
|
||||
MSG_DEF(JSMSG_AS_AFTER_RESERVED_WORD, 1, JSEXN_SYNTAXERR, "missing keyword 'as' after reserved word '{0}'")
|
||||
MSG_DEF(JSMSG_ASYNC_GENERATOR, 0, JSEXN_SYNTAXERR, "generator function or method can't be async")
|
||||
MSG_DEF(JSMSG_AWAIT_IN_DEFAULT, 0, JSEXN_SYNTAXERR, "await can't be used in default expression")
|
||||
MSG_DEF(JSMSG_BAD_ANON_GENERATOR_RETURN, 0, JSEXN_TYPEERR, "anonymous generator function returns a value")
|
||||
MSG_DEF(JSMSG_BAD_ARROW_ARGS, 0, JSEXN_SYNTAXERR, "invalid arrow-function arguments (parentheses around the arrow-function may help)")
|
||||
MSG_DEF(JSMSG_BAD_BINDING, 1, JSEXN_SYNTAXERR, "redefining {0} is deprecated")
|
||||
MSG_DEF(JSMSG_BAD_CONST_DECL, 0, JSEXN_SYNTAXERR, "missing = in const declaration")
|
||||
MSG_DEF(JSMSG_BAD_CONTINUE, 0, JSEXN_SYNTAXERR, "continue must be inside loop")
|
||||
MSG_DEF(JSMSG_BAD_DESTRUCT_ASS, 0, JSEXN_REFERENCEERR, "invalid destructuring assignment operator")
|
||||
MSG_DEF(JSMSG_BAD_DESTRUCT_TARGET, 0, JSEXN_SYNTAXERR, "invalid destructuring target")
|
||||
MSG_DEF(JSMSG_BAD_DESTRUCT_PARENS, 0, JSEXN_SYNTAXERR, "destructuring patterns in assignments can't be parenthesized")
|
||||
MSG_DEF(JSMSG_BAD_DESTRUCT_DECL, 0, JSEXN_SYNTAXERR, "missing = in destructuring declaration")
|
||||
MSG_DEF(JSMSG_BAD_DUP_ARGS, 0, JSEXN_SYNTAXERR, "duplicate argument names not allowed in this context")
|
||||
MSG_DEF(JSMSG_BAD_FOR_EACH_LOOP, 0, JSEXN_SYNTAXERR, "invalid for each loop")
|
||||
MSG_DEF(JSMSG_BAD_FOR_LEFTSIDE, 0, JSEXN_SYNTAXERR, "invalid for-in/of left-hand side")
|
||||
MSG_DEF(JSMSG_LEXICAL_DECL_DEFINES_LET,0, JSEXN_SYNTAXERR, "a lexical declaration can't define a 'let' binding")
|
||||
MSG_DEF(JSMSG_LET_STARTING_FOROF_LHS, 0, JSEXN_SYNTAXERR, "an expression X in 'for (X of Y)' must not start with 'let'")
|
||||
MSG_DEF(JSMSG_BAD_GENERATOR_RETURN, 1, JSEXN_TYPEERR, "generator function {0} returns a value")
|
||||
MSG_DEF(JSMSG_BAD_GENEXP_BODY, 1, JSEXN_SYNTAXERR, "illegal use of {0} in generator expression")
|
||||
MSG_DEF(JSMSG_BAD_INCOP_OPERAND, 0, JSEXN_REFERENCEERR, "invalid increment/decrement operand")
|
||||
MSG_DEF(JSMSG_BAD_METHOD_DEF, 0, JSEXN_SYNTAXERR, "bad method definition")
|
||||
MSG_DEF(JSMSG_BAD_OCTAL, 1, JSEXN_SYNTAXERR, "{0} is not a legal ECMA-262 octal constant")
|
||||
MSG_DEF(JSMSG_BAD_OPERAND, 1, JSEXN_SYNTAXERR, "invalid {0} operand")
|
||||
MSG_DEF(JSMSG_BAD_POW_LEFTSIDE, 0, JSEXN_SYNTAXERR, "unparenthesized unary expression can't appear on the left-hand side of '**'")
|
||||
MSG_DEF(JSMSG_BAD_PROP_ID, 0, JSEXN_SYNTAXERR, "invalid property id")
|
||||
MSG_DEF(JSMSG_BAD_RETURN_OR_YIELD, 1, JSEXN_SYNTAXERR, "{0} not in function")
|
||||
MSG_DEF(JSMSG_BAD_STRICT_ASSIGN, 1, JSEXN_SYNTAXERR, "'{0}' can't be defined or assigned to in strict mode code")
|
||||
MSG_DEF(JSMSG_BAD_SWITCH, 0, JSEXN_SYNTAXERR, "invalid switch statement")
|
||||
MSG_DEF(JSMSG_BAD_SUPER, 0, JSEXN_SYNTAXERR, "invalid use of keyword 'super'")
|
||||
MSG_DEF(JSMSG_BAD_SUPERPROP, 1, JSEXN_SYNTAXERR, "use of super {0} accesses only valid within methods or eval code within methods")
|
||||
MSG_DEF(JSMSG_BAD_SUPERCALL, 0, JSEXN_SYNTAXERR, "super() is only valid in derived class constructors")
|
||||
MSG_DEF(JSMSG_BRACKET_AFTER_ARRAY_COMPREHENSION, 0, JSEXN_SYNTAXERR, "missing ] after array comprehension")
|
||||
MSG_DEF(JSMSG_BRACKET_AFTER_LIST, 0, JSEXN_SYNTAXERR, "missing ] after element list")
|
||||
MSG_DEF(JSMSG_BRACKET_IN_INDEX, 0, JSEXN_SYNTAXERR, "missing ] in index expression")
|
||||
MSG_DEF(JSMSG_CATCH_AFTER_GENERAL, 0, JSEXN_SYNTAXERR, "catch after unconditional catch")
|
||||
MSG_DEF(JSMSG_CATCH_IDENTIFIER, 0, JSEXN_SYNTAXERR, "missing identifier in catch")
|
||||
MSG_DEF(JSMSG_CATCH_OR_FINALLY, 0, JSEXN_SYNTAXERR, "missing catch or finally after try")
|
||||
MSG_DEF(JSMSG_CATCH_WITHOUT_TRY, 0, JSEXN_SYNTAXERR, "catch without try")
|
||||
MSG_DEF(JSMSG_COLON_AFTER_CASE, 0, JSEXN_SYNTAXERR, "missing : after case label")
|
||||
MSG_DEF(JSMSG_COLON_AFTER_ID, 0, JSEXN_SYNTAXERR, "missing : after property id")
|
||||
MSG_DEF(JSMSG_COLON_IN_COND, 0, JSEXN_SYNTAXERR, "missing : in conditional expression")
|
||||
MSG_DEF(JSMSG_COMP_PROP_UNTERM_EXPR, 0, JSEXN_SYNTAXERR, "missing ] in computed property name")
|
||||
MSG_DEF(JSMSG_CONTRARY_NONDIRECTIVE, 1, JSEXN_SYNTAXERR, "'{0}' statement won't be enforced as a directive because it isn't in directive prologue position")
|
||||
MSG_DEF(JSMSG_CURLY_AFTER_BODY, 0, JSEXN_SYNTAXERR, "missing } after function body")
|
||||
MSG_DEF(JSMSG_CURLY_AFTER_CATCH, 0, JSEXN_SYNTAXERR, "missing } after catch block")
|
||||
MSG_DEF(JSMSG_CURLY_AFTER_FINALLY, 0, JSEXN_SYNTAXERR, "missing } after finally block")
|
||||
MSG_DEF(JSMSG_CURLY_AFTER_LIST, 0, JSEXN_SYNTAXERR, "missing } after property list")
|
||||
MSG_DEF(JSMSG_CURLY_AFTER_TRY, 0, JSEXN_SYNTAXERR, "missing } after try block")
|
||||
MSG_DEF(JSMSG_CURLY_BEFORE_BODY, 0, JSEXN_SYNTAXERR, "missing { before function body")
|
||||
MSG_DEF(JSMSG_CURLY_BEFORE_CATCH, 0, JSEXN_SYNTAXERR, "missing { before catch block")
|
||||
MSG_DEF(JSMSG_CURLY_BEFORE_CLASS, 0, JSEXN_SYNTAXERR, "missing { before class body")
|
||||
MSG_DEF(JSMSG_CURLY_BEFORE_FINALLY, 0, JSEXN_SYNTAXERR, "missing { before finally block")
|
||||
MSG_DEF(JSMSG_CURLY_BEFORE_SWITCH, 0, JSEXN_SYNTAXERR, "missing { before switch body")
|
||||
MSG_DEF(JSMSG_CURLY_BEFORE_TRY, 0, JSEXN_SYNTAXERR, "missing { before try block")
|
||||
MSG_DEF(JSMSG_CURLY_IN_COMPOUND, 0, JSEXN_SYNTAXERR, "missing } in compound statement")
|
||||
MSG_DEF(JSMSG_DECLARATION_AFTER_EXPORT,0, JSEXN_SYNTAXERR, "missing declaration after 'export' keyword")
|
||||
MSG_DEF(JSMSG_DECLARATION_AFTER_IMPORT,0, JSEXN_SYNTAXERR, "missing declaration after 'import' keyword")
|
||||
MSG_DEF(JSMSG_DEPRECATED_DELETE_OPERAND, 0, JSEXN_SYNTAXERR, "applying the 'delete' operator to an unqualified name is deprecated")
|
||||
MSG_DEF(JSMSG_DEPRECATED_EXPR_CLOSURE, 0, JSEXN_WARN, "expression closures are deprecated")
|
||||
MSG_DEF(JSMSG_DEPRECATED_FOR_EACH, 0, JSEXN_WARN, "JavaScript 1.6's for-each-in loops are deprecated; consider using ES6 for-of instead")
|
||||
MSG_DEF(JSMSG_DEPRECATED_OCTAL, 0, JSEXN_SYNTAXERR, "\"0\"-prefixed octal literals and octal escape sequences are deprecated; for octal literals use the \"0o\" prefix instead")
|
||||
MSG_DEF(JSMSG_DEPRECATED_PRAGMA, 1, JSEXN_WARN, "Using //@ to indicate {0} pragmas is deprecated. Use //# instead")
|
||||
MSG_DEF(JSMSG_DEPRECATED_BLOCK_SCOPE_FUN_REDECL, 1, JSEXN_WARN, "redeclaration of block-scoped function `{0}' is deprecated")
|
||||
MSG_DEF(JSMSG_DUPLICATE_EXPORT_NAME, 1, JSEXN_SYNTAXERR, "duplicate export name '{0}'")
|
||||
MSG_DEF(JSMSG_DUPLICATE_FORMAL, 1, JSEXN_SYNTAXERR, "duplicate formal argument {0}")
|
||||
MSG_DEF(JSMSG_DUPLICATE_LABEL, 0, JSEXN_SYNTAXERR, "duplicate label")
|
||||
MSG_DEF(JSMSG_DUPLICATE_PROPERTY, 1, JSEXN_SYNTAXERR, "property name {0} appears more than once in object literal")
|
||||
MSG_DEF(JSMSG_DUPLICATE_PROTO_PROPERTY, 0, JSEXN_SYNTAXERR, "property name __proto__ appears more than once in object literal")
|
||||
MSG_DEF(JSMSG_EMPTY_CONSEQUENT, 0, JSEXN_SYNTAXERR, "mistyped ; after conditional?")
|
||||
MSG_DEF(JSMSG_EQUAL_AS_ASSIGN, 0, JSEXN_SYNTAXERR, "test for equality (==) mistyped as assignment (=)?")
|
||||
MSG_DEF(JSMSG_EXPORT_DECL_AT_TOP_LEVEL,0, JSEXN_SYNTAXERR, "export declarations may only appear at top level of a module")
|
||||
MSG_DEF(JSMSG_FINALLY_WITHOUT_TRY, 0, JSEXN_SYNTAXERR, "finally without try")
|
||||
MSG_DEF(JSMSG_FORBIDDEN_AS_STATEMENT, 1, JSEXN_SYNTAXERR, "{0} can't appear in single-statement context")
|
||||
MSG_DEF(JSMSG_FROM_AFTER_IMPORT_CLAUSE, 0, JSEXN_SYNTAXERR, "missing keyword 'from' after import clause")
|
||||
MSG_DEF(JSMSG_FROM_AFTER_EXPORT_STAR, 0, JSEXN_SYNTAXERR, "missing keyword 'from' after export *")
|
||||
MSG_DEF(JSMSG_GARBAGE_AFTER_INPUT, 2, JSEXN_SYNTAXERR, "unexpected garbage after {0}, starting with {1}")
|
||||
MSG_DEF(JSMSG_IDSTART_AFTER_NUMBER, 0, JSEXN_SYNTAXERR, "identifier starts immediately after numeric literal")
|
||||
MSG_DEF(JSMSG_ILLEGAL_CHARACTER, 0, JSEXN_SYNTAXERR, "illegal character")
|
||||
MSG_DEF(JSMSG_IMPORT_DECL_AT_TOP_LEVEL, 0, JSEXN_SYNTAXERR, "import declarations may only appear at top level of a module")
|
||||
MSG_DEF(JSMSG_INVALID_FOR_IN_DECL_WITH_INIT,0,JSEXN_SYNTAXERR,"for-in loop head declarations may not have initializers")
|
||||
MSG_DEF(JSMSG_LABEL_NOT_FOUND, 0, JSEXN_SYNTAXERR, "label not found")
|
||||
MSG_DEF(JSMSG_LET_COMP_BINDING, 0, JSEXN_SYNTAXERR, "'let' is not a valid name for a comprehension variable")
|
||||
MSG_DEF(JSMSG_LEXICAL_DECL_NOT_IN_BLOCK, 1, JSEXN_SYNTAXERR, "{0} declaration not directly within block")
|
||||
MSG_DEF(JSMSG_LEXICAL_DECL_LABEL, 1, JSEXN_SYNTAXERR, "{0} declarations cannot be labelled")
|
||||
MSG_DEF(JSMSG_GENERATOR_LABEL, 0, JSEXN_SYNTAXERR, "generator functions cannot be labelled")
|
||||
MSG_DEF(JSMSG_FUNCTION_LABEL, 0, JSEXN_SYNTAXERR, "functions cannot be labelled")
|
||||
MSG_DEF(JSMSG_SLOPPY_FUNCTION_LABEL, 0, JSEXN_SYNTAXERR, "functions can only be labelled inside blocks")
|
||||
MSG_DEF(JSMSG_LINE_BREAK_AFTER_THROW, 0, JSEXN_SYNTAXERR, "no line break is allowed between 'throw' and its expression")
|
||||
MSG_DEF(JSMSG_LINE_BREAK_BEFORE_ARROW, 0, JSEXN_SYNTAXERR, "no line break is allowed before '=>'")
|
||||
MSG_DEF(JSMSG_MALFORMED_ESCAPE, 1, JSEXN_SYNTAXERR, "malformed {0} character escape sequence")
|
||||
MSG_DEF(JSMSG_MISSING_BINARY_DIGITS, 0, JSEXN_SYNTAXERR, "missing binary digits after '0b'")
|
||||
MSG_DEF(JSMSG_MISSING_EXPONENT, 0, JSEXN_SYNTAXERR, "missing exponent")
|
||||
MSG_DEF(JSMSG_MISSING_EXPR_AFTER_THROW,0, JSEXN_SYNTAXERR, "throw statement is missing an expression")
|
||||
MSG_DEF(JSMSG_MISSING_FORMAL, 0, JSEXN_SYNTAXERR, "missing formal parameter")
|
||||
MSG_DEF(JSMSG_MISSING_HEXDIGITS, 0, JSEXN_SYNTAXERR, "missing hexadecimal digits after '0x'")
|
||||
MSG_DEF(JSMSG_MISSING_OCTAL_DIGITS, 0, JSEXN_SYNTAXERR, "missing octal digits after '0o'")
|
||||
MSG_DEF(JSMSG_MODULE_SPEC_AFTER_FROM, 0, JSEXN_SYNTAXERR, "missing module specifier after 'from' keyword")
|
||||
MSG_DEF(JSMSG_NAME_AFTER_DOT, 0, JSEXN_SYNTAXERR, "missing name after . operator")
|
||||
MSG_DEF(JSMSG_NAMED_IMPORTS_OR_NAMESPACE_IMPORT, 0, JSEXN_SYNTAXERR, "expected named imports or namespace import after comma")
|
||||
MSG_DEF(JSMSG_NO_BINDING_NAME, 0, JSEXN_SYNTAXERR, "missing binding name")
|
||||
MSG_DEF(JSMSG_NO_EXPORT_NAME, 0, JSEXN_SYNTAXERR, "missing export name")
|
||||
MSG_DEF(JSMSG_NO_IMPORT_NAME, 0, JSEXN_SYNTAXERR, "missing import name")
|
||||
MSG_DEF(JSMSG_NO_VARIABLE_NAME, 0, JSEXN_SYNTAXERR, "missing variable name")
|
||||
MSG_DEF(JSMSG_OF_AFTER_FOR_NAME, 0, JSEXN_SYNTAXERR, "missing 'of' after for")
|
||||
MSG_DEF(JSMSG_PAREN_AFTER_ARGS, 0, JSEXN_SYNTAXERR, "missing ) after argument list")
|
||||
MSG_DEF(JSMSG_PAREN_AFTER_CATCH, 0, JSEXN_SYNTAXERR, "missing ) after catch")
|
||||
MSG_DEF(JSMSG_PAREN_AFTER_COND, 0, JSEXN_SYNTAXERR, "missing ) after condition")
|
||||
MSG_DEF(JSMSG_PAREN_AFTER_FOR, 0, JSEXN_SYNTAXERR, "missing ( after for")
|
||||
MSG_DEF(JSMSG_PAREN_AFTER_FORMAL, 0, JSEXN_SYNTAXERR, "missing ) after formal parameters")
|
||||
MSG_DEF(JSMSG_PAREN_AFTER_FOR_CTRL, 0, JSEXN_SYNTAXERR, "missing ) after for-loop control")
|
||||
MSG_DEF(JSMSG_PAREN_AFTER_FOR_OF_ITERABLE, 0, JSEXN_SYNTAXERR, "missing ) after for-of iterable")
|
||||
MSG_DEF(JSMSG_PAREN_AFTER_SWITCH, 0, JSEXN_SYNTAXERR, "missing ) after switch expression")
|
||||
MSG_DEF(JSMSG_PAREN_AFTER_WITH, 0, JSEXN_SYNTAXERR, "missing ) after with-statement object")
|
||||
MSG_DEF(JSMSG_PAREN_BEFORE_CATCH, 0, JSEXN_SYNTAXERR, "missing ( before catch")
|
||||
MSG_DEF(JSMSG_PAREN_BEFORE_COND, 0, JSEXN_SYNTAXERR, "missing ( before condition")
|
||||
MSG_DEF(JSMSG_PAREN_BEFORE_FORMAL, 0, JSEXN_SYNTAXERR, "missing ( before formal parameters")
|
||||
MSG_DEF(JSMSG_PAREN_BEFORE_SWITCH, 0, JSEXN_SYNTAXERR, "missing ( before switch expression")
|
||||
MSG_DEF(JSMSG_PAREN_BEFORE_WITH, 0, JSEXN_SYNTAXERR, "missing ( before with-statement object")
|
||||
MSG_DEF(JSMSG_PAREN_IN_PAREN, 0, JSEXN_SYNTAXERR, "missing ) in parenthetical")
|
||||
MSG_DEF(JSMSG_RC_AFTER_EXPORT_SPEC_LIST, 0, JSEXN_SYNTAXERR, "missing '}' after export specifier list")
|
||||
MSG_DEF(JSMSG_RC_AFTER_IMPORT_SPEC_LIST, 0, JSEXN_SYNTAXERR, "missing '}' after module specifier list")
|
||||
MSG_DEF(JSMSG_REDECLARED_CATCH_IDENTIFIER, 1, JSEXN_SYNTAXERR, "redeclaration of identifier '{0}' in catch")
|
||||
MSG_DEF(JSMSG_RESERVED_ID, 1, JSEXN_SYNTAXERR, "{0} is a reserved identifier")
|
||||
MSG_DEF(JSMSG_REST_WITH_COMMA, 0, JSEXN_SYNTAXERR, "rest element may not have a trailing comma")
|
||||
MSG_DEF(JSMSG_REST_WITH_DEFAULT, 0, JSEXN_SYNTAXERR, "rest parameter may not have a default")
|
||||
MSG_DEF(JSMSG_SELFHOSTED_TOP_LEVEL_LEXICAL, 1, JSEXN_SYNTAXERR, "self-hosted code cannot contain top-level {0} declarations")
|
||||
MSG_DEF(JSMSG_SELFHOSTED_METHOD_CALL, 0, JSEXN_SYNTAXERR, "self-hosted code may not contain direct method calls. Use callFunction() or callContentFunction()")
|
||||
MSG_DEF(JSMSG_SELFHOSTED_UNBOUND_NAME, 0, JSEXN_TYPEERR, "self-hosted code may not contain unbound name lookups")
|
||||
MSG_DEF(JSMSG_SEMI_AFTER_FOR_COND, 0, JSEXN_SYNTAXERR, "missing ; after for-loop condition")
|
||||
MSG_DEF(JSMSG_SEMI_AFTER_FOR_INIT, 0, JSEXN_SYNTAXERR, "missing ; after for-loop initializer")
|
||||
MSG_DEF(JSMSG_SEMI_BEFORE_STMNT, 0, JSEXN_SYNTAXERR, "missing ; before statement")
|
||||
MSG_DEF(JSMSG_SOURCE_TOO_LONG, 0, JSEXN_RANGEERR, "source is too long")
|
||||
MSG_DEF(JSMSG_STMT_AFTER_RETURN, 0, JSEXN_WARN, "unreachable code after return statement")
|
||||
MSG_DEF(JSMSG_STRICT_CODE_WITH, 0, JSEXN_SYNTAXERR, "strict mode code may not contain 'with' statements")
|
||||
MSG_DEF(JSMSG_STRICT_NON_SIMPLE_PARAMS, 1, JSEXN_SYNTAXERR, "\"use strict\" not allowed in function with {0} parameter")
|
||||
MSG_DEF(JSMSG_TEMPLSTR_UNTERM_EXPR, 0, JSEXN_SYNTAXERR, "missing } in template string")
|
||||
MSG_DEF(JSMSG_SIMD_NOT_A_VECTOR, 2, JSEXN_TYPEERR, "expecting a SIMD {0} object as argument {1}")
|
||||
MSG_DEF(JSMSG_TOO_MANY_CASES, 0, JSEXN_INTERNALERR, "too many switch cases")
|
||||
MSG_DEF(JSMSG_TOO_MANY_CATCH_VARS, 0, JSEXN_SYNTAXERR, "too many catch variables")
|
||||
MSG_DEF(JSMSG_TOO_MANY_CON_ARGS, 0, JSEXN_SYNTAXERR, "too many constructor arguments")
|
||||
MSG_DEF(JSMSG_TOO_MANY_DEFAULTS, 0, JSEXN_SYNTAXERR, "more than one switch default")
|
||||
MSG_DEF(JSMSG_TOO_MANY_FUN_ARGS, 0, JSEXN_SYNTAXERR, "too many function arguments")
|
||||
MSG_DEF(JSMSG_TOO_MANY_LOCALS, 0, JSEXN_SYNTAXERR, "too many local variables")
|
||||
MSG_DEF(JSMSG_TOO_MANY_YIELDS, 0, JSEXN_SYNTAXERR, "too many yield expressions")
|
||||
MSG_DEF(JSMSG_TOUGH_BREAK, 0, JSEXN_SYNTAXERR, "unlabeled break must be inside loop or switch")
|
||||
MSG_DEF(JSMSG_UNEXPECTED_TOKEN, 2, JSEXN_SYNTAXERR, "expected {0}, got {1}")
|
||||
MSG_DEF(JSMSG_UNNAMED_CLASS_STMT, 0, JSEXN_SYNTAXERR, "class statement requires a name")
|
||||
MSG_DEF(JSMSG_UNNAMED_FUNCTION_STMT, 0, JSEXN_SYNTAXERR, "function statement requires a name")
|
||||
MSG_DEF(JSMSG_UNTERMINATED_COMMENT, 0, JSEXN_SYNTAXERR, "unterminated comment")
|
||||
MSG_DEF(JSMSG_UNTERMINATED_REGEXP, 0, JSEXN_SYNTAXERR, "unterminated regular expression literal")
|
||||
MSG_DEF(JSMSG_UNTERMINATED_STRING, 0, JSEXN_SYNTAXERR, "unterminated string literal")
|
||||
MSG_DEF(JSMSG_USELESS_EXPR, 0, JSEXN_TYPEERR, "useless expression")
|
||||
MSG_DEF(JSMSG_USE_ASM_DIRECTIVE_FAIL, 0, JSEXN_SYNTAXERR, "\"use asm\" is only meaningful in the Directive Prologue of a function body")
|
||||
MSG_DEF(JSMSG_VAR_HIDES_ARG, 1, JSEXN_TYPEERR, "variable {0} redeclares argument")
|
||||
MSG_DEF(JSMSG_WHILE_AFTER_DO, 0, JSEXN_SYNTAXERR, "missing while after do-loop body")
|
||||
MSG_DEF(JSMSG_YIELD_IN_ARROW, 0, JSEXN_SYNTAXERR, "arrow function may not contain yield")
|
||||
MSG_DEF(JSMSG_YIELD_IN_DEFAULT, 0, JSEXN_SYNTAXERR, "yield in default expression")
|
||||
MSG_DEF(JSMSG_YIELD_IN_METHOD, 0, JSEXN_SYNTAXERR, "non-generator method definitions may not contain yield")
|
||||
MSG_DEF(JSMSG_BAD_COLUMN_NUMBER, 0, JSEXN_RANGEERR, "column number out of range")
|
||||
MSG_DEF(JSMSG_COMPUTED_NAME_IN_PATTERN,0, JSEXN_SYNTAXERR, "computed property names aren't supported in this destructuring declaration")
|
||||
MSG_DEF(JSMSG_DEFAULT_IN_PATTERN, 0, JSEXN_SYNTAXERR, "destructuring defaults aren't supported in this destructuring declaration")
|
||||
MSG_DEF(JSMSG_BAD_NEWTARGET, 0, JSEXN_SYNTAXERR, "new.target only allowed within functions")
|
||||
MSG_DEF(JSMSG_ESCAPED_KEYWORD, 0, JSEXN_SYNTAXERR, "keywords must be written literally, without embedded escapes")
|
||||
|
||||
// asm.js
|
||||
MSG_DEF(JSMSG_USE_ASM_TYPE_FAIL, 1, JSEXN_TYPEERR, "asm.js type error: {0}")
|
||||
MSG_DEF(JSMSG_USE_ASM_LINK_FAIL, 1, JSEXN_TYPEERR, "asm.js link error: {0}")
|
||||
MSG_DEF(JSMSG_USE_ASM_TYPE_OK, 1, JSEXN_WARN, "Successfully compiled asm.js code ({0})")
|
||||
|
||||
// wasm
|
||||
MSG_DEF(JSMSG_WASM_COMPILE_ERROR, 1, JSEXN_WASMCOMPILEERROR, "{0}")
|
||||
MSG_DEF(JSMSG_WASM_IND_CALL_TO_NULL, 0, JSEXN_WASMRUNTIMEERROR, "indirect call to null")
|
||||
MSG_DEF(JSMSG_WASM_IND_CALL_BAD_SIG, 0, JSEXN_WASMRUNTIMEERROR, "indirect call signature mismatch")
|
||||
MSG_DEF(JSMSG_WASM_UNREACHABLE, 0, JSEXN_WASMRUNTIMEERROR, "unreachable executed")
|
||||
MSG_DEF(JSMSG_WASM_INTEGER_OVERFLOW, 0, JSEXN_WASMRUNTIMEERROR, "integer overflow")
|
||||
MSG_DEF(JSMSG_WASM_INVALID_CONVERSION, 0, JSEXN_WASMRUNTIMEERROR, "invalid conversion to integer")
|
||||
MSG_DEF(JSMSG_WASM_INT_DIVIDE_BY_ZERO, 0, JSEXN_WASMRUNTIMEERROR, "integer divide by zero")
|
||||
MSG_DEF(JSMSG_WASM_OUT_OF_BOUNDS, 0, JSEXN_WASMRUNTIMEERROR, "index out of bounds")
|
||||
MSG_DEF(JSMSG_WASM_UNALIGNED_ACCESS, 0, JSEXN_WASMRUNTIMEERROR, "unaligned memory access")
|
||||
MSG_DEF(JSMSG_WASM_BAD_UINT32, 2, JSEXN_RANGEERR, "bad {0} {1}")
|
||||
MSG_DEF(JSMSG_WASM_BAD_GROW, 1, JSEXN_RANGEERR, "failed to grow {0}")
|
||||
MSG_DEF(JSMSG_WASM_BAD_FIT, 2, JSEXN_RANGEERR, "{0} segment does not fit in {1}")
|
||||
MSG_DEF(JSMSG_WASM_BAD_BUF_ARG, 0, JSEXN_TYPEERR, "first argument must be an ArrayBuffer or typed array object")
|
||||
MSG_DEF(JSMSG_WASM_BAD_MOD_ARG, 0, JSEXN_TYPEERR, "first argument must be a WebAssembly.Module")
|
||||
MSG_DEF(JSMSG_WASM_BAD_BUF_MOD_ARG, 0, JSEXN_TYPEERR, "first argument must be a WebAssembly.Module, ArrayBuffer or typed array object")
|
||||
MSG_DEF(JSMSG_WASM_BAD_DESC_ARG, 1, JSEXN_TYPEERR, "first argument must be a {0} descriptor")
|
||||
MSG_DEF(JSMSG_WASM_BAD_IMP_SIZE, 1, JSEXN_TYPEERR, "imported {0} with incompatible size")
|
||||
MSG_DEF(JSMSG_WASM_BAD_IMP_MAX, 1, JSEXN_TYPEERR, "imported {0} with incompatible maximum size")
|
||||
MSG_DEF(JSMSG_WASM_BAD_ELEMENT, 0, JSEXN_TYPEERR, "\"element\" property of table descriptor must be \"anyfunc\"")
|
||||
MSG_DEF(JSMSG_WASM_BAD_IMPORT_ARG, 0, JSEXN_TYPEERR, "second argument must be an object")
|
||||
MSG_DEF(JSMSG_WASM_BAD_IMPORT_FIELD, 2, JSEXN_TYPEERR, "import object field '{0}' is not {1}")
|
||||
MSG_DEF(JSMSG_WASM_BAD_IMPORT_SIG, 0, JSEXN_TYPEERR, "imported function signature mismatch")
|
||||
MSG_DEF(JSMSG_WASM_BAD_TABLE_VALUE, 0, JSEXN_TYPEERR, "can only assign WebAssembly exported functions to Table")
|
||||
MSG_DEF(JSMSG_WASM_BAD_I64, 0, JSEXN_TYPEERR, "cannot pass i64 to or from JS")
|
||||
MSG_DEF(JSMSG_WASM_NO_TRANSFER, 0, JSEXN_TYPEERR, "cannot transfer WebAssembly/asm.js ArrayBuffer")
|
||||
MSG_DEF(JSMSG_WASM_TEXT_FAIL, 1, JSEXN_SYNTAXERR, "wasm text error: {0}")
|
||||
|
||||
// Proxy
|
||||
MSG_DEF(JSMSG_BAD_TRAP_RETURN_VALUE, 2, JSEXN_TYPEERR,"trap {1} for {0} returned a primitive value")
|
||||
MSG_DEF(JSMSG_BAD_GETPROTOTYPEOF_TRAP_RETURN,0,JSEXN_TYPEERR,"proxy getPrototypeOf handler returned a non-object, non-null value")
|
||||
MSG_DEF(JSMSG_INCONSISTENT_GETPROTOTYPEOF_TRAP,0,JSEXN_TYPEERR,"proxy getPrototypeOf handler didn't return the target object's prototype")
|
||||
MSG_DEF(JSMSG_PROXY_SETPROTOTYPEOF_RETURNED_FALSE, 0, JSEXN_TYPEERR, "proxy setPrototypeOf handler returned false")
|
||||
MSG_DEF(JSMSG_PROXY_ISEXTENSIBLE_RETURNED_FALSE,0,JSEXN_TYPEERR,"proxy isExtensible handler must return the same extensibility as target")
|
||||
MSG_DEF(JSMSG_INCONSISTENT_SETPROTOTYPEOF_TRAP,0,JSEXN_TYPEERR,"proxy setPrototypeOf handler returned true, even though the target's prototype is immutable because the target is non-extensible")
|
||||
MSG_DEF(JSMSG_CANT_CHANGE_EXTENSIBILITY, 0, JSEXN_TYPEERR, "can't change object's extensibility")
|
||||
MSG_DEF(JSMSG_CANT_DEFINE_INVALID, 0, JSEXN_TYPEERR, "proxy can't define an incompatible property descriptor")
|
||||
MSG_DEF(JSMSG_CANT_DEFINE_NEW, 0, JSEXN_TYPEERR, "proxy can't define a new property on a non-extensible object")
|
||||
MSG_DEF(JSMSG_CANT_DEFINE_NE_AS_NC, 0, JSEXN_TYPEERR, "proxy can't define a non-existent property as non-configurable")
|
||||
MSG_DEF(JSMSG_PROXY_DEFINE_RETURNED_FALSE, 1, JSEXN_TYPEERR, "proxy defineProperty handler returned false for property '{0}'")
|
||||
MSG_DEF(JSMSG_PROXY_DELETE_RETURNED_FALSE, 1, JSEXN_TYPEERR, "can't delete property '{0}': proxy deleteProperty handler returned false")
|
||||
MSG_DEF(JSMSG_PROXY_PREVENTEXTENSIONS_RETURNED_FALSE, 0, JSEXN_TYPEERR, "proxy preventExtensions handler returned false")
|
||||
MSG_DEF(JSMSG_PROXY_SET_RETURNED_FALSE, 1, JSEXN_TYPEERR, "proxy set handler returned false for property '{0}'")
|
||||
MSG_DEF(JSMSG_CANT_REPORT_AS_NON_EXTENSIBLE, 0, JSEXN_TYPEERR, "proxy can't report an extensible object as non-extensible")
|
||||
MSG_DEF(JSMSG_CANT_REPORT_C_AS_NC, 0, JSEXN_TYPEERR, "proxy can't report existing configurable property as non-configurable")
|
||||
MSG_DEF(JSMSG_CANT_REPORT_E_AS_NE, 0, JSEXN_TYPEERR, "proxy can't report an existing own property as non-existent on a non-extensible object")
|
||||
MSG_DEF(JSMSG_CANT_REPORT_INVALID, 0, JSEXN_TYPEERR, "proxy can't report an incompatible property descriptor")
|
||||
MSG_DEF(JSMSG_CANT_REPORT_NC_AS_NE, 0, JSEXN_TYPEERR, "proxy can't report a non-configurable own property as non-existent")
|
||||
MSG_DEF(JSMSG_CANT_REPORT_NEW, 0, JSEXN_TYPEERR, "proxy can't report a new property on a non-extensible object")
|
||||
MSG_DEF(JSMSG_CANT_REPORT_NE_AS_NC, 0, JSEXN_TYPEERR, "proxy can't report a non-existent property as non-configurable")
|
||||
MSG_DEF(JSMSG_CANT_SET_NW_NC, 0, JSEXN_TYPEERR, "proxy can't successfully set a non-writable, non-configurable property")
|
||||
MSG_DEF(JSMSG_CANT_SET_WO_SETTER, 0, JSEXN_TYPEERR, "proxy can't succesfully set an accessor property without a setter")
|
||||
MSG_DEF(JSMSG_CANT_SKIP_NC, 0, JSEXN_TYPEERR, "proxy can't skip a non-configurable property")
|
||||
MSG_DEF(JSMSG_ONWKEYS_STR_SYM, 0, JSEXN_TYPEERR, "proxy [[OwnPropertyKeys]] must return an array with only string and symbol elements")
|
||||
MSG_DEF(JSMSG_MUST_REPORT_SAME_VALUE, 0, JSEXN_TYPEERR, "proxy must report the same value for a non-writable, non-configurable property")
|
||||
MSG_DEF(JSMSG_MUST_REPORT_UNDEFINED, 0, JSEXN_TYPEERR, "proxy must report undefined for a non-configurable accessor property without a getter")
|
||||
MSG_DEF(JSMSG_OBJECT_ACCESS_DENIED, 0, JSEXN_ERR, "Permission denied to access object")
|
||||
MSG_DEF(JSMSG_PROPERTY_ACCESS_DENIED, 1, JSEXN_ERR, "Permission denied to access property {0}")
|
||||
MSG_DEF(JSMSG_PROXY_CONSTRUCT_OBJECT, 0, JSEXN_TYPEERR, "proxy [[Construct]] must return an object")
|
||||
MSG_DEF(JSMSG_PROXY_EXTENSIBILITY, 0, JSEXN_TYPEERR, "proxy must report same extensiblitity as target")
|
||||
MSG_DEF(JSMSG_PROXY_GETOWN_OBJORUNDEF, 0, JSEXN_TYPEERR, "proxy [[GetOwnProperty]] must return an object or undefined")
|
||||
MSG_DEF(JSMSG_PROXY_REVOKED, 0, JSEXN_TYPEERR, "illegal operation attempted on a revoked proxy")
|
||||
MSG_DEF(JSMSG_PROXY_ARG_REVOKED, 1, JSEXN_TYPEERR, "argument {0} cannot be a revoked proxy")
|
||||
MSG_DEF(JSMSG_BAD_TRAP, 1, JSEXN_TYPEERR, "proxy handler's {0} trap wasn't undefined, null, or callable")
|
||||
|
||||
// Structured cloning
|
||||
MSG_DEF(JSMSG_SC_BAD_CLONE_VERSION, 0, JSEXN_ERR, "unsupported structured clone version")
|
||||
MSG_DEF(JSMSG_SC_BAD_SERIALIZED_DATA, 1, JSEXN_INTERNALERR, "bad serialized structured data ({0})")
|
||||
MSG_DEF(JSMSG_SC_DUP_TRANSFERABLE, 0, JSEXN_TYPEERR, "duplicate transferable for structured clone")
|
||||
MSG_DEF(JSMSG_SC_NOT_TRANSFERABLE, 0, JSEXN_TYPEERR, "invalid transferable array for structured clone")
|
||||
MSG_DEF(JSMSG_SC_UNSUPPORTED_TYPE, 0, JSEXN_TYPEERR, "unsupported type for structured data")
|
||||
MSG_DEF(JSMSG_SC_NOT_CLONABLE, 1, JSEXN_TYPEERR, "{0} cannot be cloned in this context")
|
||||
MSG_DEF(JSMSG_SC_SAB_TRANSFER, 0, JSEXN_WARN, "SharedArrayBuffer must not be in the transfer list")
|
||||
MSG_DEF(JSMSG_SC_SAB_DISABLED, 0, JSEXN_TYPEERR, "SharedArrayBuffer not cloned - shared memory disabled in receiver")
|
||||
|
||||
// Debugger
|
||||
MSG_DEF(JSMSG_ASSIGN_FUNCTION_OR_NULL, 1, JSEXN_TYPEERR, "value assigned to {0} must be a function or null")
|
||||
MSG_DEF(JSMSG_DEBUG_BAD_AWAIT, 0, JSEXN_TYPEERR, "await expression received invalid value")
|
||||
MSG_DEF(JSMSG_DEBUG_BAD_LINE, 0, JSEXN_TYPEERR, "invalid line number")
|
||||
MSG_DEF(JSMSG_DEBUG_BAD_OFFSET, 0, JSEXN_TYPEERR, "invalid script offset")
|
||||
MSG_DEF(JSMSG_DEBUG_BAD_REFERENT, 2, JSEXN_TYPEERR, "{0} does not refer to {1}")
|
||||
MSG_DEF(JSMSG_DEBUG_BAD_RESUMPTION, 0, JSEXN_TYPEERR, "debugger resumption value must be undefined, {throw: val}, {return: val}, or null")
|
||||
MSG_DEF(JSMSG_DEBUG_BAD_YIELD, 0, JSEXN_TYPEERR, "generator yielded invalid value")
|
||||
MSG_DEF(JSMSG_DEBUG_CANT_DEBUG_GLOBAL, 0, JSEXN_TYPEERR, "passing non-debuggable global to addDebuggee")
|
||||
MSG_DEF(JSMSG_DEBUG_CCW_REQUIRED, 1, JSEXN_TYPEERR, "{0}: argument must be an object from a different compartment")
|
||||
MSG_DEF(JSMSG_DEBUG_COMPARTMENT_MISMATCH, 2, JSEXN_TYPEERR, "{0}: descriptor .{1} property is an object in a different compartment than the target object")
|
||||
MSG_DEF(JSMSG_DEBUG_LOOP, 0, JSEXN_TYPEERR, "cannot debug an object in same compartment as debugger or a compartment that is already debugging the debugger")
|
||||
MSG_DEF(JSMSG_DEBUG_NOT_DEBUGGEE, 2, JSEXN_ERR, "{0} is not a debuggee {1}")
|
||||
MSG_DEF(JSMSG_DEBUG_NOT_DEBUGGING, 0, JSEXN_ERR, "can't set breakpoint: script global is not a debuggee")
|
||||
MSG_DEF(JSMSG_DEBUG_NOT_IDLE, 0, JSEXN_ERR, "can't start debugging: a debuggee script is on the stack")
|
||||
MSG_DEF(JSMSG_DEBUG_NOT_LIVE, 1, JSEXN_ERR, "{0} is not live")
|
||||
MSG_DEF(JSMSG_DEBUG_NO_ENV_OBJECT, 0, JSEXN_TYPEERR, "declarative Environments don't have binding objects")
|
||||
MSG_DEF(JSMSG_DEBUG_PROTO, 2, JSEXN_TYPEERR, "{0}.prototype is not a valid {1} instance")
|
||||
MSG_DEF(JSMSG_DEBUG_WRONG_OWNER, 1, JSEXN_TYPEERR, "{0} belongs to a different Debugger")
|
||||
MSG_DEF(JSMSG_DEBUG_OPTIMIZED_OUT, 1, JSEXN_ERR, "variable `{0}' has been optimized out")
|
||||
MSG_DEF(JSMSG_DEBUG_RESUMPTION_VALUE_DISALLOWED, 0, JSEXN_TYPEERR, "resumption values are disallowed in this hook")
|
||||
MSG_DEF(JSMSG_DEBUG_VARIABLE_NOT_FOUND,0, JSEXN_TYPEERR, "variable not found in environment")
|
||||
MSG_DEF(JSMSG_DEBUG_WRAPPER_IN_WAY, 3, JSEXN_TYPEERR, "{0} is {1}{2}a global object, but a direct reference is required")
|
||||
MSG_DEF(JSMSG_DEBUGGEE_WOULD_RUN, 2, JSEXN_DEBUGGEEWOULDRUN, "debuggee `{0}:{1}' would run")
|
||||
MSG_DEF(JSMSG_NOT_CALLABLE_OR_UNDEFINED, 0, JSEXN_TYPEERR, "value is not a function or undefined")
|
||||
MSG_DEF(JSMSG_NOT_TRACKING_ALLOCATIONS, 1, JSEXN_ERR, "Cannot call {0} without setting trackingAllocationSites to true")
|
||||
MSG_DEF(JSMSG_OBJECT_METADATA_CALLBACK_ALREADY_SET, 0, JSEXN_ERR, "Cannot track object allocation, because other tools are already doing so")
|
||||
MSG_DEF(JSMSG_QUERY_INNERMOST_WITHOUT_LINE_URL, 0, JSEXN_TYPEERR, "findScripts query object with 'innermost' property must have 'line' and either 'displayURL', 'url', or 'source'")
|
||||
MSG_DEF(JSMSG_QUERY_LINE_WITHOUT_URL, 0, JSEXN_TYPEERR, "findScripts query object has 'line' property, but no 'displayURL', 'url', or 'source' property")
|
||||
MSG_DEF(JSMSG_DEBUG_CANT_SET_OPT_ENV, 1, JSEXN_REFERENCEERR, "can't set `{0}' in an optimized-out environment")
|
||||
MSG_DEF(JSMSG_DEBUG_INVISIBLE_COMPARTMENT, 0, JSEXN_TYPEERR, "object in compartment marked as invisible to Debugger")
|
||||
MSG_DEF(JSMSG_DEBUG_CENSUS_BREAKDOWN, 1, JSEXN_TYPEERR, "unrecognized 'by' value in takeCensus breakdown: {0}")
|
||||
MSG_DEF(JSMSG_DEBUG_PROMISE_NOT_RESOLVED, 0, JSEXN_TYPEERR, "Promise hasn't been resolved")
|
||||
MSG_DEF(JSMSG_DEBUG_PROMISE_NOT_FULFILLED, 0, JSEXN_TYPEERR, "Promise hasn't been fulfilled")
|
||||
MSG_DEF(JSMSG_DEBUG_PROMISE_NOT_REJECTED, 0, JSEXN_TYPEERR, "Promise hasn't been rejected")
|
||||
|
||||
// Tracelogger
|
||||
MSG_DEF(JSMSG_TRACELOGGER_ENABLE_FAIL, 1, JSEXN_ERR, "enabling tracelogger failed: {0}")
|
||||
|
||||
// Intl
|
||||
MSG_DEF(JSMSG_DATE_NOT_FINITE, 0, JSEXN_RANGEERR, "date value is not finite in DateTimeFormat.format()")
|
||||
MSG_DEF(JSMSG_INTERNAL_INTL_ERROR, 0, JSEXN_ERR, "internal error while computing Intl data")
|
||||
MSG_DEF(JSMSG_INTL_OBJECT_NOT_INITED, 3, JSEXN_TYPEERR, "Intl.{0}.prototype.{1} called on value that's not an object initialized as a {2}")
|
||||
MSG_DEF(JSMSG_INTL_OBJECT_REINITED, 0, JSEXN_TYPEERR, "can't initialize object twice as an object of an Intl constructor")
|
||||
MSG_DEF(JSMSG_INVALID_CURRENCY_CODE, 1, JSEXN_RANGEERR, "invalid currency code in NumberFormat(): {0}")
|
||||
MSG_DEF(JSMSG_INVALID_DIGITS_VALUE, 1, JSEXN_RANGEERR, "invalid digits value: {0}")
|
||||
MSG_DEF(JSMSG_INVALID_LANGUAGE_TAG, 1, JSEXN_RANGEERR, "invalid language tag: {0}")
|
||||
MSG_DEF(JSMSG_INVALID_LOCALES_ELEMENT, 0, JSEXN_TYPEERR, "invalid element in locales argument")
|
||||
MSG_DEF(JSMSG_INVALID_LOCALE_MATCHER, 1, JSEXN_RANGEERR, "invalid locale matcher in supportedLocalesOf(): {0}")
|
||||
MSG_DEF(JSMSG_INVALID_OPTION_VALUE, 2, JSEXN_RANGEERR, "invalid value {1} for option {0}")
|
||||
MSG_DEF(JSMSG_INVALID_TIME_ZONE, 1, JSEXN_RANGEERR, "invalid time zone in DateTimeFormat(): {0}")
|
||||
MSG_DEF(JSMSG_UNDEFINED_CURRENCY, 0, JSEXN_TYPEERR, "undefined currency in NumberFormat() with currency style")
|
||||
|
||||
// RegExp
|
||||
MSG_DEF(JSMSG_BACK_REF_OUT_OF_RANGE, 0, JSEXN_SYNTAXERR, "back reference out of range in regular expression")
|
||||
MSG_DEF(JSMSG_BAD_CLASS_RANGE, 0, JSEXN_SYNTAXERR, "invalid range in character class")
|
||||
MSG_DEF(JSMSG_ESCAPE_AT_END_OF_REGEXP, 0, JSEXN_SYNTAXERR, "\\ at end of pattern")
|
||||
MSG_DEF(JSMSG_EXEC_NOT_OBJORNULL, 0, JSEXN_TYPEERR, "RegExp exec method should return object or null")
|
||||
MSG_DEF(JSMSG_INVALID_DECIMAL_ESCAPE, 0, JSEXN_SYNTAXERR, "invalid decimal escape in regular expression")
|
||||
MSG_DEF(JSMSG_INVALID_GROUP, 0, JSEXN_SYNTAXERR, "invalid regexp group")
|
||||
MSG_DEF(JSMSG_INVALID_IDENTITY_ESCAPE, 0, JSEXN_SYNTAXERR, "invalid identity escape in regular expression")
|
||||
MSG_DEF(JSMSG_INVALID_UNICODE_ESCAPE, 0, JSEXN_SYNTAXERR, "invalid unicode escape in regular expression")
|
||||
MSG_DEF(JSMSG_MISSING_PAREN, 0, JSEXN_SYNTAXERR, "unterminated parenthetical")
|
||||
MSG_DEF(JSMSG_NEWREGEXP_FLAGGED, 0, JSEXN_TYPEERR, "can't supply flags when constructing one RegExp from another")
|
||||
MSG_DEF(JSMSG_NOTHING_TO_REPEAT, 0, JSEXN_SYNTAXERR, "nothing to repeat")
|
||||
MSG_DEF(JSMSG_NUMBERS_OUT_OF_ORDER, 0, JSEXN_SYNTAXERR, "numbers out of order in {} quantifier.")
|
||||
MSG_DEF(JSMSG_RANGE_WITH_CLASS_ESCAPE, 0, JSEXN_SYNTAXERR, "character class escape cannot be used in class range in regular expression")
|
||||
MSG_DEF(JSMSG_RAW_BRACE_IN_REGEP, 0, JSEXN_SYNTAXERR, "raw brace is not allowed in regular expression with unicode flag")
|
||||
MSG_DEF(JSMSG_RAW_BRACKET_IN_REGEP, 0, JSEXN_SYNTAXERR, "raw bracket is not allowed in regular expression with unicode flag")
|
||||
MSG_DEF(JSMSG_TOO_MANY_PARENS, 0, JSEXN_INTERNALERR, "too many parentheses in regular expression")
|
||||
MSG_DEF(JSMSG_UNICODE_OVERFLOW, 0, JSEXN_SYNTAXERR, "unicode codepoint should not be greater than 0x10FFFF in regular expression")
|
||||
MSG_DEF(JSMSG_UNMATCHED_RIGHT_PAREN, 0, JSEXN_SYNTAXERR, "unmatched ) in regular expression")
|
||||
MSG_DEF(JSMSG_UNTERM_CLASS, 0, JSEXN_SYNTAXERR, "unterminated character class")
|
||||
|
||||
// Self-hosting
|
||||
MSG_DEF(JSMSG_DEFAULT_LOCALE_ERROR, 0, JSEXN_ERR, "internal error getting the default locale")
|
||||
MSG_DEF(JSMSG_NO_SUCH_SELF_HOSTED_PROP,1, JSEXN_ERR, "No such property on self-hosted object: {0}")
|
||||
|
||||
// Typed object / SIMD
|
||||
MSG_DEF(JSMSG_INVALID_PROTOTYPE, 0, JSEXN_TYPEERR, "prototype field is not an object")
|
||||
MSG_DEF(JSMSG_TYPEDOBJECT_BAD_ARGS, 0, JSEXN_TYPEERR, "invalid arguments")
|
||||
MSG_DEF(JSMSG_TYPEDOBJECT_BINARYARRAY_BAD_INDEX, 0, JSEXN_RANGEERR, "invalid or out-of-range index")
|
||||
MSG_DEF(JSMSG_TYPEDOBJECT_HANDLE_UNATTACHED, 0, JSEXN_TYPEERR, "handle unattached")
|
||||
MSG_DEF(JSMSG_TYPEDOBJECT_STRUCTTYPE_BAD_ARGS, 0, JSEXN_RANGEERR, "invalid field descriptor")
|
||||
MSG_DEF(JSMSG_TYPEDOBJECT_TOO_BIG, 0, JSEXN_ERR, "Type is too large to allocate")
|
||||
MSG_DEF(JSMSG_SIMD_FAILED_CONVERSION, 0, JSEXN_RANGEERR, "SIMD conversion loses precision")
|
||||
MSG_DEF(JSMSG_SIMD_TO_NUMBER, 0, JSEXN_TYPEERR, "can't convert SIMD value to number")
|
||||
|
||||
// Array
|
||||
MSG_DEF(JSMSG_TOO_LONG_ARRAY, 0, JSEXN_TYPEERR, "Too long array")
|
||||
|
||||
// Typed array
|
||||
MSG_DEF(JSMSG_BAD_INDEX, 0, JSEXN_RANGEERR, "invalid or out-of-range index")
|
||||
MSG_DEF(JSMSG_NON_ARRAY_BUFFER_RETURNED, 0, JSEXN_TYPEERR, "expected ArrayBuffer, but species constructor returned non-ArrayBuffer")
|
||||
MSG_DEF(JSMSG_SAME_ARRAY_BUFFER_RETURNED, 0, JSEXN_TYPEERR, "expected different ArrayBuffer, but species constructor returned same ArrayBuffer")
|
||||
MSG_DEF(JSMSG_SHORT_ARRAY_BUFFER_RETURNED, 2, JSEXN_TYPEERR, "expected ArrayBuffer with at least {0} bytes, but species constructor returns ArrayBuffer with {1} bytes")
|
||||
MSG_DEF(JSMSG_TYPED_ARRAY_BAD_ARGS, 0, JSEXN_TYPEERR, "invalid arguments")
|
||||
MSG_DEF(JSMSG_TYPED_ARRAY_NEGATIVE_ARG,1, JSEXN_RANGEERR, "argument {0} must be >= 0")
|
||||
MSG_DEF(JSMSG_TYPED_ARRAY_DETACHED, 0, JSEXN_TYPEERR, "attempting to access detached ArrayBuffer")
|
||||
MSG_DEF(JSMSG_TYPED_ARRAY_CONSTRUCT_BOUNDS, 0, JSEXN_RANGEERR, "attempting to construct out-of-bounds TypedArray on ArrayBuffer")
|
||||
MSG_DEF(JSMSG_TYPED_ARRAY_CALL_OR_CONSTRUCT, 1, JSEXN_TYPEERR, "cannot directly {0} builtin %TypedArray%")
|
||||
MSG_DEF(JSMSG_NON_TYPED_ARRAY_RETURNED, 0, JSEXN_TYPEERR, "constructor didn't return TypedArray object")
|
||||
MSG_DEF(JSMSG_SHORT_TYPED_ARRAY_RETURNED, 2, JSEXN_TYPEERR, "expected TypedArray of at least length {0}, but constructor returned TypedArray of length {1}")
|
||||
|
||||
// Shared array buffer
|
||||
MSG_DEF(JSMSG_SHARED_ARRAY_BAD_LENGTH, 0, JSEXN_RANGEERR, "length argument out of range")
|
||||
MSG_DEF(JSMSG_NON_SHARED_ARRAY_BUFFER_RETURNED, 0, JSEXN_TYPEERR, "expected SharedArrayBuffer, but species constructor returned non-SharedArrayBuffer")
|
||||
MSG_DEF(JSMSG_SAME_SHARED_ARRAY_BUFFER_RETURNED, 0, JSEXN_TYPEERR, "expected different SharedArrayBuffer, but species constructor returned same SharedArrayBuffer")
|
||||
MSG_DEF(JSMSG_SHORT_SHARED_ARRAY_BUFFER_RETURNED, 2, JSEXN_TYPEERR, "expected SharedArrayBuffer with at least {0} bytes, but species constructor returns SharedArrayBuffer with {1} bytes")
|
||||
|
||||
// Reflect
|
||||
MSG_DEF(JSMSG_BAD_PARSE_NODE, 0, JSEXN_INTERNALERR, "bad parse node")
|
||||
|
||||
// Symbol
|
||||
MSG_DEF(JSMSG_SYMBOL_TO_STRING, 0, JSEXN_TYPEERR, "can't convert symbol to string")
|
||||
MSG_DEF(JSMSG_SYMBOL_TO_NUMBER, 0, JSEXN_TYPEERR, "can't convert symbol to number")
|
||||
|
||||
// Atomics and futexes
|
||||
MSG_DEF(JSMSG_ATOMICS_BAD_ARRAY, 0, JSEXN_TYPEERR, "invalid array type for the operation")
|
||||
MSG_DEF(JSMSG_ATOMICS_TOO_LONG, 0, JSEXN_RANGEERR, "timeout value too large")
|
||||
MSG_DEF(JSMSG_ATOMICS_WAIT_NOT_ALLOWED, 0, JSEXN_ERR, "waiting is not allowed on this thread")
|
||||
|
||||
// XPConnect wrappers and DOM bindings
|
||||
MSG_DEF(JSMSG_CANT_SET_INTERPOSED, 1, JSEXN_TYPEERR, "unable to set interposed data property '{0}'")
|
||||
MSG_DEF(JSMSG_CANT_DEFINE_WINDOW_ELEMENT, 0, JSEXN_TYPEERR, "can't define elements on a Window object")
|
||||
MSG_DEF(JSMSG_CANT_DELETE_WINDOW_ELEMENT, 0, JSEXN_TYPEERR, "can't delete elements from a Window object")
|
||||
MSG_DEF(JSMSG_CANT_DELETE_WINDOW_NAMED_PROPERTY, 1, JSEXN_TYPEERR, "can't delete property {0} from window's named properties object")
|
||||
MSG_DEF(JSMSG_CANT_PREVENT_EXTENSIONS, 0, JSEXN_TYPEERR, "can't prevent extensions on this proxy object")
|
||||
MSG_DEF(JSMSG_NO_NAMED_SETTER, 2, JSEXN_TYPEERR, "{0} doesn't have a named property setter for '{1}'")
|
||||
MSG_DEF(JSMSG_NO_INDEXED_SETTER, 2, JSEXN_TYPEERR, "{0} doesn't have an indexed property setter for '{1}'")
|
||||
|
||||
// Super
|
||||
MSG_DEF(JSMSG_CANT_DELETE_SUPER, 0, JSEXN_REFERENCEERR, "invalid delete involving 'super'")
|
||||
MSG_DEF(JSMSG_REINIT_THIS, 0, JSEXN_REFERENCEERR, "super() called twice in derived class constructor")
|
||||
|
||||
// Modules
|
||||
MSG_DEF(JSMSG_BAD_DEFAULT_EXPORT, 0, JSEXN_SYNTAXERR, "default export cannot be provided by export *")
|
||||
MSG_DEF(JSMSG_MISSING_INDIRECT_EXPORT, 1, JSEXN_SYNTAXERR, "indirect export '{0}' not found")
|
||||
MSG_DEF(JSMSG_AMBIGUOUS_INDIRECT_EXPORT, 1, JSEXN_SYNTAXERR, "ambiguous indirect export '{0}'")
|
||||
MSG_DEF(JSMSG_MISSING_IMPORT, 1, JSEXN_SYNTAXERR, "import '{0}' not found")
|
||||
MSG_DEF(JSMSG_AMBIGUOUS_IMPORT, 1, JSEXN_SYNTAXERR, "ambiguous import '{0}'")
|
||||
MSG_DEF(JSMSG_MISSING_NAMESPACE_EXPORT, 0, JSEXN_SYNTAXERR, "export not found for namespace")
|
||||
MSG_DEF(JSMSG_MISSING_EXPORT, 1, JSEXN_SYNTAXERR, "local binding for export '{0}' not found")
|
||||
MSG_DEF(JSMSG_MODULE_INSTANTIATE_FAILED, 0, JSEXN_INTERNALERR, "attempt to re-instantiate module after failure")
|
||||
MSG_DEF(JSMSG_BAD_MODULE_STATE, 0, JSEXN_INTERNALERR, "module record in unexpected state")
|
||||
|
||||
// Promise
|
||||
MSG_DEF(JSMSG_CANNOT_RESOLVE_PROMISE_WITH_ITSELF, 0, JSEXN_TYPEERR, "A promise cannot be resolved with itself.")
|
||||
MSG_DEF(JSMSG_PROMISE_CAPABILITY_HAS_SOMETHING_ALREADY, 0, JSEXN_TYPEERR, "GetCapabilitiesExecutor function already invoked with non-undefined values.")
|
||||
MSG_DEF(JSMSG_PROMISE_RESOLVE_FUNCTION_NOT_CALLABLE, 0, JSEXN_TYPEERR, "A Promise subclass passed a non-callable value as the resolve function.")
|
||||
MSG_DEF(JSMSG_PROMISE_REJECT_FUNCTION_NOT_CALLABLE, 0, JSEXN_TYPEERR, "A Promise subclass passed a non-callable value as the reject function.")
|
||||
MSG_DEF(JSMSG_PROMISE_ERROR_IN_WRAPPED_REJECTION_REASON,0, JSEXN_INTERNALERR, "Promise rejection value is a non-unwrappable cross-compartment wrapper.")
|
||||
|
|
|
|||
|
|
@ -1,174 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* vim: set ts=8 sts=4 et sw=4 tw=99:
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/* JS::Anchor implementation. */
|
||||
|
||||
#ifndef js_Anchor_h
|
||||
#define js_Anchor_h
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
|
||||
#include "js/TypeDecls.h"
|
||||
|
||||
namespace JS {
|
||||
|
||||
/*
|
||||
* Protecting non-Value, non-JSObject *, non-JSString * values from collection
|
||||
*
|
||||
* Most of the time, the garbage collector's conservative stack scanner works
|
||||
* behind the scenes, finding all live values and protecting them from being
|
||||
* collected. However, when JSAPI client code obtains a pointer to data the
|
||||
* scanner does not know about, owned by an object the scanner does know about,
|
||||
* Care Must Be Taken.
|
||||
*
|
||||
* The scanner recognizes only a select set of types: pointers to JSObjects and
|
||||
* similar things (JSFunctions, and so on), pointers to JSStrings, and Values.
|
||||
* So while the scanner finds all live |JSString| pointers, it does not notice
|
||||
* |jschar| pointers.
|
||||
*
|
||||
* So suppose we have:
|
||||
*
|
||||
* void f(JSString *str) {
|
||||
* const jschar *ch = JS_GetStringCharsZ(str);
|
||||
* ... do stuff with ch, but no uses of str ...;
|
||||
* }
|
||||
*
|
||||
* After the call to |JS_GetStringCharsZ|, there are no further uses of
|
||||
* |str|, which means that the compiler is within its rights to not store
|
||||
* it anywhere. But because the stack scanner will not notice |ch|, there
|
||||
* is no longer any live value in this frame that would keep the string
|
||||
* alive. If |str| is the last reference to that |JSString|, and the
|
||||
* collector runs while we are using |ch|, the string's array of |jschar|s
|
||||
* may be freed out from under us.
|
||||
*
|
||||
* Note that there is only an issue when 1) we extract a thing X the scanner
|
||||
* doesn't recognize from 2) a thing Y the scanner does recognize, and 3) if Y
|
||||
* gets garbage-collected, then X gets freed. If we have code like this:
|
||||
*
|
||||
* void g(JSObject *obj) {
|
||||
* JS::Value x;
|
||||
* JS_GetProperty(obj, "x", &x);
|
||||
* ... do stuff with x ...
|
||||
* }
|
||||
*
|
||||
* there's no problem, because the value we've extracted, x, is a Value, a
|
||||
* type that the conservative scanner recognizes.
|
||||
*
|
||||
* Conservative GC frees us from the obligation to explicitly root the types it
|
||||
* knows about, but when we work with derived values like |ch|, we must root
|
||||
* their owners, as the derived value alone won't keep them alive.
|
||||
*
|
||||
* A JS::Anchor is a kind of GC root that allows us to keep the owners of
|
||||
* derived values like |ch| alive throughout the Anchor's lifetime. We could
|
||||
* fix the above code as follows:
|
||||
*
|
||||
* void f(JSString *str) {
|
||||
* JS::Anchor<JSString *> a_str(str);
|
||||
* const jschar *ch = JS_GetStringCharsZ(str);
|
||||
* ... do stuff with ch, but no uses of str ...;
|
||||
* }
|
||||
*
|
||||
* This simply ensures that |str| will be live until |a_str| goes out of scope.
|
||||
* As long as we don't retain a pointer to the string's characters for longer
|
||||
* than that, we have avoided all garbage collection hazards.
|
||||
*/
|
||||
template<typename T> class AnchorPermitted;
|
||||
template<> class AnchorPermitted<JSObject *> { };
|
||||
template<> class AnchorPermitted<const JSObject *> { };
|
||||
template<> class AnchorPermitted<JSFunction *> { };
|
||||
template<> class AnchorPermitted<const JSFunction *> { };
|
||||
template<> class AnchorPermitted<JSString *> { };
|
||||
template<> class AnchorPermitted<const JSString *> { };
|
||||
template<> class AnchorPermitted<Value> { };
|
||||
template<> class AnchorPermitted<const JSScript *> { };
|
||||
template<> class AnchorPermitted<JSScript *> { };
|
||||
|
||||
template<typename T>
|
||||
class Anchor : AnchorPermitted<T>
|
||||
{
|
||||
public:
|
||||
Anchor() { }
|
||||
explicit Anchor(T t) { hold = t; }
|
||||
inline ~Anchor();
|
||||
|
||||
private:
|
||||
T hold;
|
||||
|
||||
/*
|
||||
* Rooting analysis considers use of operator= to be a use of an anchor.
|
||||
* For simplicity, Anchor is treated as if it contained a GC thing, from
|
||||
* construction. Thus if we had
|
||||
*
|
||||
* void operator=(const T &t) { hold = t; }
|
||||
*
|
||||
* and this code
|
||||
*
|
||||
* JS::Anchor<JSString*> anchor;
|
||||
* stuff that could GC, producing |str|;
|
||||
* anchor = str;
|
||||
*
|
||||
* the last line would be seen as a hazard, because the final = would "use"
|
||||
* |anchor| that is a GC thing -- which could have been moved around by the
|
||||
* GC. The workaround is to structure your code so that JS::Anchor is
|
||||
* always constructed, living for however long the corresponding value must
|
||||
* live.
|
||||
*/
|
||||
void operator=(const T &t) MOZ_DELETE;
|
||||
|
||||
Anchor(const Anchor &other) MOZ_DELETE;
|
||||
void operator=(const Anchor &other) MOZ_DELETE;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
inline Anchor<T>::~Anchor()
|
||||
{
|
||||
#ifdef __GNUC__
|
||||
/*
|
||||
* No code is generated for this. But because this is marked 'volatile', G++ will
|
||||
* assume it has important side-effects, and won't delete it. (G++ never looks at
|
||||
* the actual text and notices it's empty.) And because we have passed |hold| to
|
||||
* it, GCC will keep |hold| alive until this point.
|
||||
*
|
||||
* The "memory" clobber operand ensures that G++ will not move prior memory
|
||||
* accesses after the asm --- it's a barrier. Unfortunately, it also means that
|
||||
* G++ will assume that all memory has changed after the asm, as it would for a
|
||||
* call to an unknown function. I don't know of a way to avoid that consequence.
|
||||
*/
|
||||
asm volatile("":: "g" (hold) : "memory");
|
||||
#else
|
||||
/*
|
||||
* An adequate portable substitute, for non-structure types.
|
||||
*
|
||||
* The compiler promises that, by the end of an expression statement, the
|
||||
* last-stored value to a volatile object is the same as it would be in an
|
||||
* unoptimized, direct implementation (the "abstract machine" whose behavior the
|
||||
* language spec describes). However, the compiler is still free to reorder
|
||||
* non-volatile accesses across this store --- which is what we must prevent. So
|
||||
* assigning the held value to a volatile variable, as we do here, is not enough.
|
||||
*
|
||||
* In our case, however, garbage collection only occurs at function calls, so it
|
||||
* is sufficient to ensure that the destructor's store isn't moved earlier across
|
||||
* any function calls that could collect. It is hard to imagine the compiler
|
||||
* analyzing the program so thoroughly that it could prove that such motion was
|
||||
* safe. In practice, compilers treat calls to the collector as opaque operations
|
||||
* --- in particular, as operations which could access volatile variables, across
|
||||
* which this destructor must not be moved.
|
||||
*
|
||||
* ("Objection, your honor! *Alleged* killer whale!")
|
||||
*
|
||||
* The disadvantage of this approach is that it does generate code for the store.
|
||||
* We do need to use Anchors in some cases where cycles are tight.
|
||||
*
|
||||
* Note that there is a Anchor<Value>::~Anchor() specialization in Value.h.
|
||||
*/
|
||||
volatile T sink;
|
||||
sink = hold;
|
||||
#endif /* defined(__GNUC__) */
|
||||
}
|
||||
|
||||
} // namespace JS
|
||||
|
||||
#endif /* js_Anchor_h */
|
||||
|
|
@ -6,16 +6,51 @@
|
|||
|
||||
/*
|
||||
* Helper classes encapsulating access to the callee, |this| value, arguments,
|
||||
* and argument count for a function call.
|
||||
* and argument count for a call/construct operation.
|
||||
*
|
||||
* The intent of JS::CallArgs and JS::CallReceiver is that they be used to
|
||||
* encapsulate access to the un-abstracted |unsigned argc, Value *vp| arguments
|
||||
* to a function. It's possible (albeit deprecated) to manually index into
|
||||
* |vp| to access the callee, |this|, and arguments of a function, and to set
|
||||
* its return value. It's also possible to use the supported API of JS_CALLEE,
|
||||
* JS_THIS, JS_ARGV, JS_RVAL and JS_SET_RVAL to the same ends. But neither API
|
||||
* has the error-handling or moving-GC correctness of CallArgs or CallReceiver.
|
||||
* New code should use CallArgs and CallReceiver instead whenever possible.
|
||||
* JS::CallArgs encapsulates access to a JSNative's un-abstracted
|
||||
* |unsigned argc, Value* vp| arguments. The principal way to create a
|
||||
* JS::CallArgs is using JS::CallArgsFromVp:
|
||||
*
|
||||
* // If provided no arguments or a non-numeric first argument, return zero.
|
||||
* // Otherwise return |this| exactly as given, without boxing.
|
||||
* static bool
|
||||
* Func(JSContext* cx, unsigned argc, JS::Value* vp)
|
||||
* {
|
||||
* JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
*
|
||||
* // Guard against no arguments or a non-numeric arg0.
|
||||
* if (args.length() == 0 || !args[0].isNumber()) {
|
||||
* args.rval().setInt32(0);
|
||||
* return true;
|
||||
* }
|
||||
*
|
||||
* // Access to the callee must occur before accessing/setting
|
||||
* // the return value.
|
||||
* JSObject& callee = args.callee();
|
||||
* args.rval().setObject(callee);
|
||||
*
|
||||
* // callee() and calleev() will now assert.
|
||||
*
|
||||
* // It's always fine to access thisv().
|
||||
* HandleValue thisv = args.thisv();
|
||||
* args.rval().set(thisv);
|
||||
*
|
||||
* // As the return value was last set to |this|, returns |this|.
|
||||
* return true;
|
||||
* }
|
||||
*
|
||||
* CallArgs is exposed publicly and used internally. Not all parts of its
|
||||
* public interface are meant to be used by embedders! See inline comments to
|
||||
* for details.
|
||||
*
|
||||
* It's possible (albeit deprecated) to manually index into |vp| to access the
|
||||
* callee, |this|, and arguments of a function, and to set its return value.
|
||||
* It's also possible to use the supported API of JS_CALLEE, JS_THIS, JS_ARGV,
|
||||
* JS_RVAL, and JS_SET_RVAL to the same ends.
|
||||
*
|
||||
* But neither API has the error-handling or moving-GC correctness of CallArgs.
|
||||
* New code should use CallArgs instead whenever possible.
|
||||
*
|
||||
* The eventual plan is to change JSNative to take |const CallArgs&| directly,
|
||||
* for automatic assertion of correct use and to make calling functions more
|
||||
|
|
@ -40,142 +75,100 @@
|
|||
|
||||
/* Typedef for native functions called by the JS VM. */
|
||||
typedef bool
|
||||
(* JSNative)(JSContext *cx, unsigned argc, JS::Value *vp);
|
||||
|
||||
/* Typedef for native functions that may be called in parallel. */
|
||||
typedef bool
|
||||
(* JSParallelNative)(js::ForkJoinContext *cx, unsigned argc, JS::Value *vp);
|
||||
|
||||
/*
|
||||
* Typedef for native functions that may be called either in parallel or
|
||||
* sequential execution.
|
||||
*/
|
||||
typedef bool
|
||||
(* JSThreadSafeNative)(js::ThreadSafeContext *cx, unsigned argc, JS::Value *vp);
|
||||
|
||||
/*
|
||||
* Convenience wrappers for passing in ThreadSafeNative to places that expect
|
||||
* a JSNative or a JSParallelNative.
|
||||
*/
|
||||
template <JSThreadSafeNative threadSafeNative>
|
||||
inline bool
|
||||
JSNativeThreadSafeWrapper(JSContext *cx, unsigned argc, JS::Value *vp);
|
||||
|
||||
template <JSThreadSafeNative threadSafeNative>
|
||||
inline bool
|
||||
JSParallelNativeThreadSafeWrapper(js::ForkJoinContext *cx, unsigned argc, JS::Value *vp);
|
||||
|
||||
/*
|
||||
* Compute |this| for the |vp| inside a JSNative, either boxing primitives or
|
||||
* replacing with the global object as necessary.
|
||||
*
|
||||
* This method will go away at some point: instead use |args.thisv()|. If the
|
||||
* value is an object, no further work is required. If that value is |null| or
|
||||
* |undefined|, use |JS_GetGlobalForObject| to compute the global object. If
|
||||
* the value is some other primitive, use |JS_ValueToObject| to box it.
|
||||
*/
|
||||
extern JS_PUBLIC_API(JS::Value)
|
||||
JS_ComputeThis(JSContext *cx, JS::Value *vp);
|
||||
(* JSNative)(JSContext* cx, unsigned argc, JS::Value* vp);
|
||||
|
||||
namespace JS {
|
||||
|
||||
extern JS_PUBLIC_DATA(const HandleValue) UndefinedHandleValue;
|
||||
|
||||
/*
|
||||
* JS::CallReceiver encapsulates access to the callee, |this|, and eventual
|
||||
* return value for a function call. The principal way to create a
|
||||
* CallReceiver is using JS::CallReceiverFromVp:
|
||||
*
|
||||
* static bool
|
||||
* FunctionReturningThis(JSContext *cx, unsigned argc, JS::Value *vp)
|
||||
* {
|
||||
* JS::CallReceiver rec = JS::CallReceiverFromVp(vp);
|
||||
*
|
||||
* // Access to the callee must occur before accessing/setting
|
||||
* // the return value.
|
||||
* JSObject &callee = rec.callee();
|
||||
* rec.rval().set(JS::ObjectValue(callee));
|
||||
*
|
||||
* // callee() and calleev() will now assert.
|
||||
*
|
||||
* // It's always fine to access thisv().
|
||||
* HandleValue thisv = rec.thisv();
|
||||
* rec.rval().set(thisv);
|
||||
*
|
||||
* // As the return value was last set to |this|, returns |this|.
|
||||
* return true;
|
||||
* }
|
||||
*
|
||||
* A note on JS_ComputeThis and JS_THIS_OBJECT: these methods currently aren't
|
||||
* part of the CallReceiver interface. We will likely add them at some point.
|
||||
* Until then, you should probably continue using |vp| directly for these two
|
||||
* cases.
|
||||
*
|
||||
* CallReceiver is exposed publicly and used internally. Not all parts of its
|
||||
* public interface are meant to be used by embedders! See inline comments to
|
||||
* for details.
|
||||
*/
|
||||
|
||||
namespace detail {
|
||||
|
||||
/*
|
||||
* Compute |this| for the |vp| inside a JSNative, either boxing primitives or
|
||||
* replacing with the global object as necessary.
|
||||
*/
|
||||
extern JS_PUBLIC_API(Value)
|
||||
ComputeThis(JSContext* cx, JS::Value* vp);
|
||||
|
||||
#ifdef JS_DEBUG
|
||||
extern JS_PUBLIC_API(void)
|
||||
CheckIsValidConstructible(Value v);
|
||||
CheckIsValidConstructible(const Value& v);
|
||||
#endif
|
||||
|
||||
enum UsedRval { IncludeUsedRval, NoUsedRval };
|
||||
|
||||
template<UsedRval WantUsedRval>
|
||||
class MOZ_STACK_CLASS UsedRvalBase;
|
||||
|
||||
template<>
|
||||
class MOZ_STACK_CLASS UsedRvalBase<IncludeUsedRval>
|
||||
class MOZ_STACK_CLASS IncludeUsedRval
|
||||
{
|
||||
protected:
|
||||
#ifdef JS_DEBUG
|
||||
mutable bool usedRval_;
|
||||
void setUsedRval() const { usedRval_ = true; }
|
||||
void clearUsedRval() const { usedRval_ = false; }
|
||||
void assertUnusedRval() const { MOZ_ASSERT(!usedRval_); }
|
||||
#else
|
||||
void setUsedRval() const {}
|
||||
void clearUsedRval() const {}
|
||||
void assertUnusedRval() const {}
|
||||
#endif
|
||||
};
|
||||
|
||||
template<>
|
||||
class MOZ_STACK_CLASS UsedRvalBase<NoUsedRval>
|
||||
class MOZ_STACK_CLASS NoUsedRval
|
||||
{
|
||||
protected:
|
||||
void setUsedRval() const {}
|
||||
void clearUsedRval() const {}
|
||||
void assertUnusedRval() const {}
|
||||
};
|
||||
|
||||
template<UsedRval WantUsedRval>
|
||||
class MOZ_STACK_CLASS CallReceiverBase : public UsedRvalBase<
|
||||
#ifdef JS_DEBUG
|
||||
WantUsedRval
|
||||
#else
|
||||
NoUsedRval
|
||||
#endif
|
||||
>
|
||||
template<class WantUsedRval>
|
||||
class MOZ_STACK_CLASS CallArgsBase : public WantUsedRval
|
||||
{
|
||||
static_assert(mozilla::IsSame<WantUsedRval, IncludeUsedRval>::value ||
|
||||
mozilla::IsSame<WantUsedRval, NoUsedRval>::value,
|
||||
"WantUsedRval can only be IncludeUsedRval or NoUsedRval");
|
||||
|
||||
protected:
|
||||
Value *argv_;
|
||||
Value* argv_;
|
||||
unsigned argc_;
|
||||
bool constructing_;
|
||||
|
||||
public:
|
||||
/*
|
||||
* Returns the function being called, as an object. Must not be called
|
||||
* after rval() has been used!
|
||||
*/
|
||||
JSObject &callee() const {
|
||||
MOZ_ASSERT(!this->usedRval_);
|
||||
return argv_[-2].toObject();
|
||||
}
|
||||
// CALLEE ACCESS
|
||||
|
||||
/*
|
||||
* Returns the function being called, as a value. Must not be called after
|
||||
* rval() has been used!
|
||||
*/
|
||||
HandleValue calleev() const {
|
||||
MOZ_ASSERT(!this->usedRval_);
|
||||
this->assertUnusedRval();
|
||||
return HandleValue::fromMarkedLocation(&argv_[-2]);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the function being called, as an object. Must not be called
|
||||
* after rval() has been used!
|
||||
*/
|
||||
JSObject& callee() const {
|
||||
return calleev().toObject();
|
||||
}
|
||||
|
||||
// CALLING/CONSTRUCTING-DIFFERENTIATIONS
|
||||
|
||||
bool isConstructing() const {
|
||||
if (!argv_[-1].isMagic())
|
||||
return false;
|
||||
|
||||
#ifdef JS_DEBUG
|
||||
if (!this->usedRval_)
|
||||
CheckIsValidConstructible(calleev());
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
MutableHandleValue newTarget() const {
|
||||
MOZ_ASSERT(constructing_);
|
||||
return MutableHandleValue::fromMarkedLocation(&this->argv_[argc_]);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the |this| value passed to the function. This method must not
|
||||
* be called when the function is being called as a constructor via |new|.
|
||||
|
|
@ -189,128 +182,16 @@ class MOZ_STACK_CLASS CallReceiverBase : public UsedRvalBase<
|
|||
return HandleValue::fromMarkedLocation(&argv_[-1]);
|
||||
}
|
||||
|
||||
Value computeThis(JSContext *cx) const {
|
||||
Value computeThis(JSContext* cx) const {
|
||||
if (thisv().isObject())
|
||||
return thisv();
|
||||
|
||||
return JS_ComputeThis(cx, base());
|
||||
return ComputeThis(cx, base());
|
||||
}
|
||||
|
||||
bool isConstructing() const {
|
||||
#ifdef JS_DEBUG
|
||||
if (this->usedRval_)
|
||||
CheckIsValidConstructible(calleev());
|
||||
#endif
|
||||
return argv_[-1].isMagic();
|
||||
}
|
||||
// ARGUMENTS
|
||||
|
||||
/*
|
||||
* Returns the currently-set return value. The initial contents of this
|
||||
* value are unspecified. Once this method has been called, callee() and
|
||||
* calleev() can no longer be used. (If you're compiling against a debug
|
||||
* build of SpiderMonkey, these methods will assert to aid debugging.)
|
||||
*
|
||||
* If the method you're implementing succeeds by returning true, you *must*
|
||||
* set this. (SpiderMonkey doesn't currently assert this, but it will do
|
||||
* so eventually.) You don't need to use or change this if your method
|
||||
* fails.
|
||||
*/
|
||||
MutableHandleValue rval() const {
|
||||
this->setUsedRval();
|
||||
return MutableHandleValue::fromMarkedLocation(&argv_[-2]);
|
||||
}
|
||||
|
||||
public:
|
||||
// These methods are only intended for internal use. Embedders shouldn't
|
||||
// use them!
|
||||
|
||||
Value *base() const { return argv_ - 2; }
|
||||
|
||||
Value *spAfterCall() const {
|
||||
this->setUsedRval();
|
||||
return argv_ - 1;
|
||||
}
|
||||
|
||||
public:
|
||||
// These methods are publicly exposed, but they are *not* to be used when
|
||||
// implementing a JSNative method and encapsulating access to |vp| within
|
||||
// it. You probably don't want to use these!
|
||||
|
||||
void setCallee(Value aCalleev) const {
|
||||
this->clearUsedRval();
|
||||
argv_[-2] = aCalleev;
|
||||
}
|
||||
|
||||
void setThis(Value aThisv) const {
|
||||
argv_[-1] = aThisv;
|
||||
}
|
||||
|
||||
MutableHandleValue mutableThisv() const {
|
||||
return MutableHandleValue::fromMarkedLocation(&argv_[-1]);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
class MOZ_STACK_CLASS CallReceiver : public detail::CallReceiverBase<detail::IncludeUsedRval>
|
||||
{
|
||||
private:
|
||||
friend CallReceiver CallReceiverFromVp(Value *vp);
|
||||
friend CallReceiver CallReceiverFromArgv(Value *argv);
|
||||
};
|
||||
|
||||
MOZ_ALWAYS_INLINE CallReceiver
|
||||
CallReceiverFromArgv(Value *argv)
|
||||
{
|
||||
CallReceiver receiver;
|
||||
receiver.clearUsedRval();
|
||||
receiver.argv_ = argv;
|
||||
return receiver;
|
||||
}
|
||||
|
||||
MOZ_ALWAYS_INLINE CallReceiver
|
||||
CallReceiverFromVp(Value *vp)
|
||||
{
|
||||
return CallReceiverFromArgv(vp + 2);
|
||||
}
|
||||
|
||||
/*
|
||||
* JS::CallArgs encapsulates everything JS::CallReceiver does, plus access to
|
||||
* the function call's arguments. The principal way to create a CallArgs is
|
||||
* like so, using JS::CallArgsFromVp:
|
||||
*
|
||||
* static bool
|
||||
* FunctionReturningArgcTimesArg0(JSContext *cx, unsigned argc, JS::Value *vp)
|
||||
* {
|
||||
* JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
*
|
||||
* // Guard against no arguments or a non-numeric arg0.
|
||||
* if (args.length() == 0 || !args[0].isNumber()) {
|
||||
* args.rval().setInt32(0);
|
||||
* return true;
|
||||
* }
|
||||
*
|
||||
* args.rval().set(JS::NumberValue(args.length() * args[0].toNumber()));
|
||||
* return true;
|
||||
* }
|
||||
*
|
||||
* CallArgs is exposed publicly and used internally. Not all parts of its
|
||||
* public interface are meant to be used by embedders! See inline comments to
|
||||
* for details.
|
||||
*/
|
||||
namespace detail {
|
||||
|
||||
template<UsedRval WantUsedRval>
|
||||
class MOZ_STACK_CLASS CallArgsBase :
|
||||
public mozilla::Conditional<WantUsedRval == detail::IncludeUsedRval,
|
||||
CallReceiver,
|
||||
CallReceiverBase<NoUsedRval> >::Type
|
||||
{
|
||||
protected:
|
||||
unsigned argc_;
|
||||
|
||||
public:
|
||||
/* Returns the number of arguments. */
|
||||
/* Returns the number of arguments. */
|
||||
unsigned length() const { return argc_; }
|
||||
|
||||
/* Returns the i-th zero-indexed argument. */
|
||||
|
|
@ -337,13 +218,60 @@ class MOZ_STACK_CLASS CallArgsBase :
|
|||
return i < argc_ && !this->argv_[i].isUndefined();
|
||||
}
|
||||
|
||||
public:
|
||||
// These methods are publicly exposed, but we're less sure of the interface
|
||||
// here than we'd like (because they're hackish and drop assertions). Try
|
||||
// to avoid using these if you can.
|
||||
// RETURN VALUE
|
||||
|
||||
Value *array() const { return this->argv_; }
|
||||
Value *end() const { return this->argv_ + argc_; }
|
||||
/*
|
||||
* Returns the currently-set return value. The initial contents of this
|
||||
* value are unspecified. Once this method has been called, callee() and
|
||||
* calleev() can no longer be used. (If you're compiling against a debug
|
||||
* build of SpiderMonkey, these methods will assert to aid debugging.)
|
||||
*
|
||||
* If the method you're implementing succeeds by returning true, you *must*
|
||||
* set this. (SpiderMonkey doesn't currently assert this, but it will do
|
||||
* so eventually.) You don't need to use or change this if your method
|
||||
* fails.
|
||||
*/
|
||||
MutableHandleValue rval() const {
|
||||
this->setUsedRval();
|
||||
return MutableHandleValue::fromMarkedLocation(&argv_[-2]);
|
||||
}
|
||||
|
||||
public:
|
||||
// These methods are publicly exposed, but they are *not* to be used when
|
||||
// implementing a JSNative method and encapsulating access to |vp| within
|
||||
// it. You probably don't want to use these!
|
||||
|
||||
void setCallee(const Value& aCalleev) const {
|
||||
this->clearUsedRval();
|
||||
argv_[-2] = aCalleev;
|
||||
}
|
||||
|
||||
void setThis(const Value& aThisv) const {
|
||||
argv_[-1] = aThisv;
|
||||
}
|
||||
|
||||
MutableHandleValue mutableThisv() const {
|
||||
return MutableHandleValue::fromMarkedLocation(&argv_[-1]);
|
||||
}
|
||||
|
||||
public:
|
||||
// These methods are publicly exposed, but we're unsure of the interfaces
|
||||
// (because they're hackish and drop assertions). Avoid using these if you
|
||||
// can.
|
||||
|
||||
Value* array() const { return argv_; }
|
||||
Value* end() const { return argv_ + argc_ + constructing_; }
|
||||
|
||||
public:
|
||||
// These methods are only intended for internal use. Embedders shouldn't
|
||||
// use them!
|
||||
|
||||
Value* base() const { return argv_ - 2; }
|
||||
|
||||
Value* spAfterCall() const {
|
||||
this->setUsedRval();
|
||||
return argv_ - 1;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
|
@ -351,55 +279,78 @@ class MOZ_STACK_CLASS CallArgsBase :
|
|||
class MOZ_STACK_CLASS CallArgs : public detail::CallArgsBase<detail::IncludeUsedRval>
|
||||
{
|
||||
private:
|
||||
friend CallArgs CallArgsFromVp(unsigned argc, Value *vp);
|
||||
friend CallArgs CallArgsFromSp(unsigned argc, Value *sp);
|
||||
friend CallArgs CallArgsFromVp(unsigned argc, Value* vp);
|
||||
friend CallArgs CallArgsFromSp(unsigned stackSlots, Value* sp, bool constructing);
|
||||
|
||||
static CallArgs create(unsigned argc, Value *argv) {
|
||||
static CallArgs create(unsigned argc, Value* argv, bool constructing) {
|
||||
CallArgs args;
|
||||
args.clearUsedRval();
|
||||
args.argv_ = argv;
|
||||
args.argc_ = argc;
|
||||
args.constructing_ = constructing;
|
||||
#ifdef DEBUG
|
||||
for (unsigned i = 0; i < argc; ++i)
|
||||
MOZ_ASSERT_IF(argv[i].isMarkable(), !GCThingIsMarkedGray(GCCellPtr(argv[i])));
|
||||
#endif
|
||||
return args;
|
||||
}
|
||||
|
||||
public:
|
||||
/*
|
||||
* Returns true if there are at least |required| arguments passed in. If
|
||||
* false, it reports an error message on the context.
|
||||
*/
|
||||
bool requireAtLeast(JSContext* cx, const char* fnname, unsigned required) const;
|
||||
|
||||
};
|
||||
|
||||
MOZ_ALWAYS_INLINE CallArgs
|
||||
CallArgsFromVp(unsigned argc, Value *vp)
|
||||
CallArgsFromVp(unsigned argc, Value* vp)
|
||||
{
|
||||
return CallArgs::create(argc, vp + 2);
|
||||
return CallArgs::create(argc, vp + 2, vp[1].isMagic(JS_IS_CONSTRUCTING));
|
||||
}
|
||||
|
||||
// This method is only intended for internal use in SpiderMonkey. We may
|
||||
// eventually move it to an internal header. Embedders should use
|
||||
// JS::CallArgsFromVp!
|
||||
MOZ_ALWAYS_INLINE CallArgs
|
||||
CallArgsFromSp(unsigned argc, Value *sp)
|
||||
CallArgsFromSp(unsigned stackSlots, Value* sp, bool constructing = false)
|
||||
{
|
||||
return CallArgs::create(argc, sp - argc);
|
||||
return CallArgs::create(stackSlots - constructing, sp - stackSlots, constructing);
|
||||
}
|
||||
|
||||
} // namespace JS
|
||||
|
||||
/*
|
||||
* Macros to hide interpreter stack layout details from a JSNative using its
|
||||
* JS::Value *vp parameter. DO NOT USE THESE! Instead use JS::CallArgs and
|
||||
* JS::Value* vp parameter. DO NOT USE THESE! Instead use JS::CallArgs and
|
||||
* friends, above. These macros will be removed when we change JSNative to
|
||||
* take a const JS::CallArgs&.
|
||||
*/
|
||||
|
||||
#define JS_THIS_OBJECT(cx,vp) (JS_THIS(cx,vp).toObjectOrNull())
|
||||
|
||||
/*
|
||||
* Return |this| if |this| is an object. Otherwise, return the global object
|
||||
* if |this| is null or undefined, and finally return a boxed version of any
|
||||
* other primitive.
|
||||
*
|
||||
* Note: if this method returns null, an error has occurred and must be
|
||||
* propagated or caught.
|
||||
*/
|
||||
MOZ_ALWAYS_INLINE JS::Value
|
||||
JS_THIS(JSContext *cx, JS::Value *vp)
|
||||
JS_THIS(JSContext* cx, JS::Value* vp)
|
||||
{
|
||||
return vp[1].isPrimitive() ? JS_ComputeThis(cx, vp) : vp[1];
|
||||
return vp[1].isPrimitive() ? JS::detail::ComputeThis(cx, vp) : vp[1];
|
||||
}
|
||||
|
||||
/*
|
||||
* A note on JS_THIS_OBJECT: no equivalent method is part of the CallArgs
|
||||
* interface, and we're unlikely to add one (functions shouldn't be implicitly
|
||||
* exposing the global object to arbitrary callers). Continue using |vp|
|
||||
* directly for this case, but be aware this API will eventually be replaced
|
||||
* with a function that operates directly upon |args.thisv()|.
|
||||
*/
|
||||
#define JS_THIS_OBJECT(cx,vp) (JS_THIS(cx,vp).toObjectOrNull())
|
||||
|
||||
/*
|
||||
* |this| is passed to functions in ES5 without change. Functions themselves
|
||||
* do any post-processing they desire to box |this|, compute the global object,
|
||||
|
|
|
|||
|
|
@ -18,13 +18,13 @@ typedef bool (*IsAcceptableThis)(HandleValue v);
|
|||
|
||||
// Implements the guts of a method; guaranteed to be provided an acceptable
|
||||
// this-value, as determined by a corresponding IsAcceptableThis method.
|
||||
typedef bool (*NativeImpl)(JSContext *cx, CallArgs args);
|
||||
typedef bool (*NativeImpl)(JSContext* cx, const CallArgs& args);
|
||||
|
||||
namespace detail {
|
||||
|
||||
// DON'T CALL THIS DIRECTLY. It's for use only by CallNonGenericMethod!
|
||||
extern JS_PUBLIC_API(bool)
|
||||
CallMethodIfWrapped(JSContext *cx, IsAcceptableThis test, NativeImpl impl, CallArgs args);
|
||||
CallMethodIfWrapped(JSContext* cx, IsAcceptableThis test, NativeImpl impl, const CallArgs& args);
|
||||
|
||||
} // namespace detail
|
||||
|
||||
|
|
@ -44,7 +44,7 @@ CallMethodIfWrapped(JSContext *cx, IsAcceptableThis test, NativeImpl impl, CallA
|
|||
// static const JSClass AnswerClass = { ... };
|
||||
//
|
||||
// static bool
|
||||
// IsAnswerObject(const Value &v)
|
||||
// IsAnswerObject(const Value& v)
|
||||
// {
|
||||
// if (!v.isObject())
|
||||
// return false;
|
||||
|
|
@ -57,7 +57,7 @@ CallMethodIfWrapped(JSContext *cx, IsAcceptableThis test, NativeImpl impl, CallA
|
|||
// its interface is the same as that of JSNative.
|
||||
//
|
||||
// static bool
|
||||
// answer_getAnswer_impl(JSContext *cx, JS::CallArgs args)
|
||||
// answer_getAnswer_impl(JSContext* cx, JS::CallArgs args)
|
||||
// {
|
||||
// args.rval().setInt32(42);
|
||||
// return true;
|
||||
|
|
@ -70,7 +70,7 @@ CallMethodIfWrapped(JSContext *cx, IsAcceptableThis test, NativeImpl impl, CallA
|
|||
// declared below, passing the appropriate template and runtime arguments.
|
||||
//
|
||||
// static bool
|
||||
// answer_getAnswer(JSContext *cx, unsigned argc, JS::Value *vp)
|
||||
// answer_getAnswer(JSContext* cx, unsigned argc, JS::Value* vp)
|
||||
// {
|
||||
// JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
// return JS::CallNonGenericMethod<IsAnswerObject, answer_getAnswer_impl>(cx, args);
|
||||
|
|
@ -93,7 +93,7 @@ CallMethodIfWrapped(JSContext *cx, IsAcceptableThis test, NativeImpl impl, CallA
|
|||
//
|
||||
template<IsAcceptableThis Test, NativeImpl Impl>
|
||||
MOZ_ALWAYS_INLINE bool
|
||||
CallNonGenericMethod(JSContext *cx, CallArgs args)
|
||||
CallNonGenericMethod(JSContext* cx, const CallArgs& args)
|
||||
{
|
||||
HandleValue thisv = args.thisv();
|
||||
if (Test(thisv))
|
||||
|
|
@ -103,7 +103,7 @@ CallNonGenericMethod(JSContext *cx, CallArgs args)
|
|||
}
|
||||
|
||||
MOZ_ALWAYS_INLINE bool
|
||||
CallNonGenericMethod(JSContext *cx, IsAcceptableThis Test, NativeImpl Impl, CallArgs args)
|
||||
CallNonGenericMethod(JSContext* cx, IsAcceptableThis Test, NativeImpl Impl, const CallArgs& args)
|
||||
{
|
||||
HandleValue thisv = args.thisv();
|
||||
if (Test(thisv))
|
||||
|
|
|
|||
|
|
@ -7,15 +7,14 @@
|
|||
#ifndef js_CharacterEncoding_h
|
||||
#define js_CharacterEncoding_h
|
||||
|
||||
#include "mozilla/NullPtr.h"
|
||||
#include "mozilla/Range.h"
|
||||
|
||||
#include "js/TypeDecls.h"
|
||||
#include "js/Utility.h"
|
||||
|
||||
namespace js {
|
||||
struct ThreadSafeContext;
|
||||
}
|
||||
class ExclusiveContext;
|
||||
} // namespace js
|
||||
|
||||
class JSFlatString;
|
||||
|
||||
|
|
@ -32,13 +31,15 @@ class Latin1Chars : public mozilla::Range<Latin1Char>
|
|||
typedef mozilla::Range<Latin1Char> Base;
|
||||
|
||||
public:
|
||||
using CharT = Latin1Char;
|
||||
|
||||
Latin1Chars() : Base() {}
|
||||
Latin1Chars(char *aBytes, size_t aLength) : Base(reinterpret_cast<Latin1Char *>(aBytes), aLength) {}
|
||||
Latin1Chars(const Latin1Char *aBytes, size_t aLength)
|
||||
: Base(const_cast<Latin1Char *>(aBytes), aLength)
|
||||
Latin1Chars(char* aBytes, size_t aLength) : Base(reinterpret_cast<Latin1Char*>(aBytes), aLength) {}
|
||||
Latin1Chars(const Latin1Char* aBytes, size_t aLength)
|
||||
: Base(const_cast<Latin1Char*>(aBytes), aLength)
|
||||
{}
|
||||
Latin1Chars(const char *aBytes, size_t aLength)
|
||||
: Base(reinterpret_cast<Latin1Char *>(const_cast<char *>(aBytes)), aLength)
|
||||
Latin1Chars(const char* aBytes, size_t aLength)
|
||||
: Base(reinterpret_cast<Latin1Char*>(const_cast<char*>(aBytes)), aLength)
|
||||
{}
|
||||
};
|
||||
|
||||
|
|
@ -50,15 +51,17 @@ class Latin1CharsZ : public mozilla::RangedPtr<Latin1Char>
|
|||
typedef mozilla::RangedPtr<Latin1Char> Base;
|
||||
|
||||
public:
|
||||
using CharT = Latin1Char;
|
||||
|
||||
Latin1CharsZ() : Base(nullptr, 0) {}
|
||||
|
||||
Latin1CharsZ(char *aBytes, size_t aLength)
|
||||
: Base(reinterpret_cast<Latin1Char *>(aBytes), aLength)
|
||||
Latin1CharsZ(char* aBytes, size_t aLength)
|
||||
: Base(reinterpret_cast<Latin1Char*>(aBytes), aLength)
|
||||
{
|
||||
MOZ_ASSERT(aBytes[aLength] == '\0');
|
||||
}
|
||||
|
||||
Latin1CharsZ(Latin1Char *aBytes, size_t aLength)
|
||||
Latin1CharsZ(Latin1Char* aBytes, size_t aLength)
|
||||
: Base(aBytes, aLength)
|
||||
{
|
||||
MOZ_ASSERT(aBytes[aLength] == '\0');
|
||||
|
|
@ -66,7 +69,7 @@ class Latin1CharsZ : public mozilla::RangedPtr<Latin1Char>
|
|||
|
||||
using Base::operator=;
|
||||
|
||||
char *c_str() { return reinterpret_cast<char *>(get()); }
|
||||
char* c_str() { return reinterpret_cast<char*>(get()); }
|
||||
};
|
||||
|
||||
class UTF8Chars : public mozilla::Range<unsigned char>
|
||||
|
|
@ -74,12 +77,14 @@ class UTF8Chars : public mozilla::Range<unsigned char>
|
|||
typedef mozilla::Range<unsigned char> Base;
|
||||
|
||||
public:
|
||||
using CharT = unsigned char;
|
||||
|
||||
UTF8Chars() : Base() {}
|
||||
UTF8Chars(char *aBytes, size_t aLength)
|
||||
: Base(reinterpret_cast<unsigned char *>(aBytes), aLength)
|
||||
UTF8Chars(char* aBytes, size_t aLength)
|
||||
: Base(reinterpret_cast<unsigned char*>(aBytes), aLength)
|
||||
{}
|
||||
UTF8Chars(const char *aBytes, size_t aLength)
|
||||
: Base(reinterpret_cast<unsigned char *>(const_cast<char *>(aBytes)), aLength)
|
||||
UTF8Chars(const char* aBytes, size_t aLength)
|
||||
: Base(reinterpret_cast<unsigned char*>(const_cast<char*>(aBytes)), aLength)
|
||||
{}
|
||||
};
|
||||
|
||||
|
|
@ -91,15 +96,17 @@ class UTF8CharsZ : public mozilla::RangedPtr<unsigned char>
|
|||
typedef mozilla::RangedPtr<unsigned char> Base;
|
||||
|
||||
public:
|
||||
using CharT = unsigned char;
|
||||
|
||||
UTF8CharsZ() : Base(nullptr, 0) {}
|
||||
|
||||
UTF8CharsZ(char *aBytes, size_t aLength)
|
||||
: Base(reinterpret_cast<unsigned char *>(aBytes), aLength)
|
||||
UTF8CharsZ(char* aBytes, size_t aLength)
|
||||
: Base(reinterpret_cast<unsigned char*>(aBytes), aLength)
|
||||
{
|
||||
MOZ_ASSERT(aBytes[aLength] == '\0');
|
||||
}
|
||||
|
||||
UTF8CharsZ(unsigned char *aBytes, size_t aLength)
|
||||
UTF8CharsZ(unsigned char* aBytes, size_t aLength)
|
||||
: Base(aBytes, aLength)
|
||||
{
|
||||
MOZ_ASSERT(aBytes[aLength] == '\0');
|
||||
|
|
@ -107,7 +114,44 @@ class UTF8CharsZ : public mozilla::RangedPtr<unsigned char>
|
|||
|
||||
using Base::operator=;
|
||||
|
||||
char *c_str() { return reinterpret_cast<char *>(get()); }
|
||||
char* c_str() { return reinterpret_cast<char*>(get()); }
|
||||
};
|
||||
|
||||
/*
|
||||
* A wrapper for a "const char*" that is encoded using UTF-8.
|
||||
* This class does not manage ownership of the data; that is left
|
||||
* to others. This differs from UTF8CharsZ in that the chars are
|
||||
* const and it allows assignment.
|
||||
*/
|
||||
class ConstUTF8CharsZ
|
||||
{
|
||||
const char* data_;
|
||||
|
||||
public:
|
||||
using CharT = unsigned char;
|
||||
|
||||
ConstUTF8CharsZ() : data_(nullptr)
|
||||
{}
|
||||
|
||||
ConstUTF8CharsZ(const char* aBytes, size_t aLength)
|
||||
: data_(aBytes)
|
||||
{
|
||||
MOZ_ASSERT(aBytes[aLength] == '\0');
|
||||
#ifdef DEBUG
|
||||
validate(aLength);
|
||||
#endif
|
||||
}
|
||||
|
||||
const void* get() const { return data_; }
|
||||
|
||||
const char* c_str() const { return data_; }
|
||||
|
||||
explicit operator bool() const { return data_ != nullptr; }
|
||||
|
||||
private:
|
||||
#ifdef DEBUG
|
||||
void validate(size_t aLength);
|
||||
#endif
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
@ -118,27 +162,31 @@ class UTF8CharsZ : public mozilla::RangedPtr<unsigned char>
|
|||
* manually interpreting UTF-16 extension characters embedded in the JS
|
||||
* string.
|
||||
*/
|
||||
class TwoByteChars : public mozilla::Range<jschar>
|
||||
class TwoByteChars : public mozilla::Range<char16_t>
|
||||
{
|
||||
typedef mozilla::Range<jschar> Base;
|
||||
typedef mozilla::Range<char16_t> Base;
|
||||
|
||||
public:
|
||||
using CharT = char16_t;
|
||||
|
||||
TwoByteChars() : Base() {}
|
||||
TwoByteChars(jschar *aChars, size_t aLength) : Base(aChars, aLength) {}
|
||||
TwoByteChars(const jschar *aChars, size_t aLength) : Base(const_cast<jschar *>(aChars), aLength) {}
|
||||
TwoByteChars(char16_t* aChars, size_t aLength) : Base(aChars, aLength) {}
|
||||
TwoByteChars(const char16_t* aChars, size_t aLength) : Base(const_cast<char16_t*>(aChars), aLength) {}
|
||||
};
|
||||
|
||||
/*
|
||||
* A TwoByteChars, but \0 terminated for compatibility with JSFlatString.
|
||||
*/
|
||||
class TwoByteCharsZ : public mozilla::RangedPtr<jschar>
|
||||
class TwoByteCharsZ : public mozilla::RangedPtr<char16_t>
|
||||
{
|
||||
typedef mozilla::RangedPtr<jschar> Base;
|
||||
typedef mozilla::RangedPtr<char16_t> Base;
|
||||
|
||||
public:
|
||||
using CharT = char16_t;
|
||||
|
||||
TwoByteCharsZ() : Base(nullptr, 0) {}
|
||||
|
||||
TwoByteCharsZ(jschar *chars, size_t length)
|
||||
TwoByteCharsZ(char16_t* chars, size_t length)
|
||||
: Base(chars, length)
|
||||
{
|
||||
MOZ_ASSERT(chars[length] == '\0');
|
||||
|
|
@ -147,25 +195,22 @@ class TwoByteCharsZ : public mozilla::RangedPtr<jschar>
|
|||
using Base::operator=;
|
||||
};
|
||||
|
||||
typedef mozilla::RangedPtr<const jschar> ConstCharPtr;
|
||||
typedef mozilla::RangedPtr<const char16_t> ConstCharPtr;
|
||||
|
||||
/*
|
||||
* Like TwoByteChars, but the chars are const.
|
||||
*/
|
||||
class ConstTwoByteChars : public mozilla::RangedPtr<const jschar>
|
||||
class ConstTwoByteChars : public mozilla::Range<const char16_t>
|
||||
{
|
||||
typedef mozilla::Range<const char16_t> Base;
|
||||
|
||||
public:
|
||||
ConstTwoByteChars(const ConstTwoByteChars &s) : ConstCharPtr(s) {}
|
||||
MOZ_IMPLICIT ConstTwoByteChars(const mozilla::RangedPtr<const jschar> &s) : ConstCharPtr(s) {}
|
||||
ConstTwoByteChars(const jschar *s, size_t len) : ConstCharPtr(s, len) {}
|
||||
ConstTwoByteChars(const jschar *pos, const jschar *start, size_t len)
|
||||
: ConstCharPtr(pos, start, len)
|
||||
{}
|
||||
using CharT = char16_t;
|
||||
|
||||
using ConstCharPtr::operator=;
|
||||
ConstTwoByteChars() : Base() {}
|
||||
ConstTwoByteChars(const char16_t* aChars, size_t aLength) : Base(aChars, aLength) {}
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Convert a 2-byte character sequence to "ISO-Latin-1". This works by
|
||||
* truncating each 2-byte pair in the sequence to a 1-byte pair. If the source
|
||||
|
|
@ -177,24 +222,37 @@ class ConstTwoByteChars : public mozilla::RangedPtr<const jschar>
|
|||
* This method cannot trigger GC.
|
||||
*/
|
||||
extern Latin1CharsZ
|
||||
LossyTwoByteCharsToNewLatin1CharsZ(js::ThreadSafeContext *cx,
|
||||
const mozilla::Range<const jschar> tbchars);
|
||||
LossyTwoByteCharsToNewLatin1CharsZ(js::ExclusiveContext* cx,
|
||||
const mozilla::Range<const char16_t> tbchars);
|
||||
|
||||
inline Latin1CharsZ
|
||||
LossyTwoByteCharsToNewLatin1CharsZ(js::ExclusiveContext* cx, const char16_t* begin, size_t length)
|
||||
{
|
||||
const mozilla::Range<const char16_t> tbchars(begin, length);
|
||||
return JS::LossyTwoByteCharsToNewLatin1CharsZ(cx, tbchars);
|
||||
}
|
||||
|
||||
template <typename CharT>
|
||||
extern UTF8CharsZ
|
||||
CharsToNewUTF8CharsZ(js::ThreadSafeContext *cx, const mozilla::Range<const CharT> chars);
|
||||
CharsToNewUTF8CharsZ(js::ExclusiveContext* maybeCx, const mozilla::Range<CharT> chars);
|
||||
|
||||
uint32_t
|
||||
Utf8ToOneUcs4Char(const uint8_t *utf8Buffer, int utf8Length);
|
||||
Utf8ToOneUcs4Char(const uint8_t* utf8Buffer, int utf8Length);
|
||||
|
||||
/*
|
||||
* Inflate bytes in UTF-8 encoding to jschars.
|
||||
* Inflate bytes in UTF-8 encoding to char16_t.
|
||||
* - On error, returns an empty TwoByteCharsZ.
|
||||
* - On success, returns a malloc'd TwoByteCharsZ, and updates |outlen| to hold
|
||||
* its length; the length value excludes the trailing null.
|
||||
*/
|
||||
extern TwoByteCharsZ
|
||||
UTF8CharsToNewTwoByteCharsZ(JSContext *cx, const UTF8Chars utf8, size_t *outlen);
|
||||
UTF8CharsToNewTwoByteCharsZ(JSContext* cx, const UTF8Chars utf8, size_t* outlen);
|
||||
|
||||
/*
|
||||
* Like UTF8CharsToNewTwoByteCharsZ, but for ConstUTF8CharsZ.
|
||||
*/
|
||||
extern TwoByteCharsZ
|
||||
UTF8CharsToNewTwoByteCharsZ(JSContext* cx, const ConstUTF8CharsZ& utf8, size_t* outlen);
|
||||
|
||||
/*
|
||||
* The same as UTF8CharsToNewTwoByteCharsZ(), except that any malformed UTF-8 characters
|
||||
|
|
@ -202,25 +260,79 @@ UTF8CharsToNewTwoByteCharsZ(JSContext *cx, const UTF8Chars utf8, size_t *outlen)
|
|||
* input.
|
||||
*/
|
||||
extern TwoByteCharsZ
|
||||
LossyUTF8CharsToNewTwoByteCharsZ(JSContext *cx, const UTF8Chars utf8, size_t *outlen);
|
||||
LossyUTF8CharsToNewTwoByteCharsZ(JSContext* cx, const UTF8Chars utf8, size_t* outlen);
|
||||
|
||||
extern TwoByteCharsZ
|
||||
LossyUTF8CharsToNewTwoByteCharsZ(JSContext* cx, const ConstUTF8CharsZ& utf8, size_t* outlen);
|
||||
|
||||
/*
|
||||
* Returns the length of the char buffer required to encode |s| as UTF8.
|
||||
* Does not include the null-terminator.
|
||||
*/
|
||||
JS_PUBLIC_API(size_t)
|
||||
GetDeflatedUTF8StringLength(JSFlatString *s);
|
||||
GetDeflatedUTF8StringLength(JSFlatString* s);
|
||||
|
||||
/*
|
||||
* Encode |src| as UTF8. The caller must ensure |dst| has enough space.
|
||||
* Does not write the null terminator.
|
||||
* Encode |src| as UTF8. The caller must either ensure |dst| has enough space
|
||||
* to encode the entire string or pass the length of the buffer as |dstlenp|,
|
||||
* in which case the function will encode characters from the string until
|
||||
* the buffer is exhausted. Does not write the null terminator.
|
||||
*
|
||||
* If |dstlenp| is provided, it will be updated to hold the number of bytes
|
||||
* written to the buffer. If |numcharsp| is provided, it will be updated to hold
|
||||
* the number of Unicode characters written to the buffer (which can be less
|
||||
* than the length of the string, if the buffer is exhausted before the string
|
||||
* is fully encoded).
|
||||
*/
|
||||
JS_PUBLIC_API(void)
|
||||
DeflateStringToUTF8Buffer(JSFlatString *src, mozilla::RangedPtr<char> dst);
|
||||
DeflateStringToUTF8Buffer(JSFlatString* src, mozilla::RangedPtr<char> dst,
|
||||
size_t* dstlenp = nullptr, size_t* numcharsp = nullptr);
|
||||
|
||||
/*
|
||||
* The smallest character encoding capable of fully representing a particular
|
||||
* string.
|
||||
*/
|
||||
enum class SmallestEncoding {
|
||||
ASCII,
|
||||
Latin1,
|
||||
UTF16
|
||||
};
|
||||
|
||||
/*
|
||||
* Returns the smallest encoding possible for the given string: if all
|
||||
* codepoints are <128 then ASCII, otherwise if all codepoints are <256
|
||||
* Latin-1, else UTF16.
|
||||
*/
|
||||
JS_PUBLIC_API(SmallestEncoding)
|
||||
FindSmallestEncoding(UTF8Chars utf8);
|
||||
|
||||
/*
|
||||
* Return a null-terminated Latin-1 string copied from the input string,
|
||||
* storing its length (excluding null terminator) in |*outlen|. Fail and
|
||||
* report an error if the string contains non-Latin-1 codepoints. Returns
|
||||
* Latin1CharsZ() on failure.
|
||||
*/
|
||||
extern Latin1CharsZ
|
||||
UTF8CharsToNewLatin1CharsZ(JSContext* cx, const UTF8Chars utf8, size_t* outlen);
|
||||
|
||||
/*
|
||||
* Return a null-terminated Latin-1 string copied from the input string,
|
||||
* storing its length (excluding null terminator) in |*outlen|. Non-Latin-1
|
||||
* codepoints are replaced by '?'. Returns Latin1CharsZ() on failure.
|
||||
*/
|
||||
extern Latin1CharsZ
|
||||
LossyUTF8CharsToNewLatin1CharsZ(JSContext* cx, const UTF8Chars utf8, size_t* outlen);
|
||||
|
||||
/*
|
||||
* Returns true if all characters in the given null-terminated string are
|
||||
* ASCII, i.e. < 0x80, false otherwise.
|
||||
*/
|
||||
extern bool
|
||||
StringIsASCII(const char* s);
|
||||
|
||||
} // namespace JS
|
||||
|
||||
inline void JS_free(JS::Latin1CharsZ &ptr) { js_free((void*)ptr.get()); }
|
||||
inline void JS_free(JS::UTF8CharsZ &ptr) { js_free((void*)ptr.get()); }
|
||||
inline void JS_free(JS::Latin1CharsZ& ptr) { js_free((void*)ptr.get()); }
|
||||
inline void JS_free(JS::UTF8CharsZ& ptr) { js_free((void*)ptr.get()); }
|
||||
|
||||
#endif /* js_CharacterEncoding_h */
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,581 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* vim: set ts=8 sts=4 et sw=4 tw=99:
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/* ECMAScript conversion operations. */
|
||||
|
||||
#ifndef js_Conversions_h
|
||||
#define js_Conversions_h
|
||||
|
||||
#include "mozilla/Casting.h"
|
||||
#include "mozilla/FloatingPoint.h"
|
||||
#include "mozilla/TypeTraits.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "jspubtd.h"
|
||||
|
||||
#include "js/RootingAPI.h"
|
||||
#include "js/Value.h"
|
||||
|
||||
struct JSContext;
|
||||
|
||||
namespace js {
|
||||
|
||||
/* DO NOT CALL THIS. Use JS::ToBoolean. */
|
||||
extern JS_PUBLIC_API(bool)
|
||||
ToBooleanSlow(JS::HandleValue v);
|
||||
|
||||
/* DO NOT CALL THIS. Use JS::ToNumber. */
|
||||
extern JS_PUBLIC_API(bool)
|
||||
ToNumberSlow(JSContext* cx, JS::HandleValue v, double* dp);
|
||||
|
||||
/* DO NOT CALL THIS. Use JS::ToInt8. */
|
||||
extern JS_PUBLIC_API(bool)
|
||||
ToInt8Slow(JSContext *cx, JS::HandleValue v, int8_t *out);
|
||||
|
||||
/* DO NOT CALL THIS. Use JS::ToUint8. */
|
||||
extern JS_PUBLIC_API(bool)
|
||||
ToUint8Slow(JSContext *cx, JS::HandleValue v, uint8_t *out);
|
||||
|
||||
/* DO NOT CALL THIS. Use JS::ToInt16. */
|
||||
extern JS_PUBLIC_API(bool)
|
||||
ToInt16Slow(JSContext *cx, JS::HandleValue v, int16_t *out);
|
||||
|
||||
/* DO NOT CALL THIS. Use JS::ToInt32. */
|
||||
extern JS_PUBLIC_API(bool)
|
||||
ToInt32Slow(JSContext* cx, JS::HandleValue v, int32_t* out);
|
||||
|
||||
/* DO NOT CALL THIS. Use JS::ToUint32. */
|
||||
extern JS_PUBLIC_API(bool)
|
||||
ToUint32Slow(JSContext* cx, JS::HandleValue v, uint32_t* out);
|
||||
|
||||
/* DO NOT CALL THIS. Use JS::ToUint16. */
|
||||
extern JS_PUBLIC_API(bool)
|
||||
ToUint16Slow(JSContext* cx, JS::HandleValue v, uint16_t* out);
|
||||
|
||||
/* DO NOT CALL THIS. Use JS::ToInt64. */
|
||||
extern JS_PUBLIC_API(bool)
|
||||
ToInt64Slow(JSContext* cx, JS::HandleValue v, int64_t* out);
|
||||
|
||||
/* DO NOT CALL THIS. Use JS::ToUint64. */
|
||||
extern JS_PUBLIC_API(bool)
|
||||
ToUint64Slow(JSContext* cx, JS::HandleValue v, uint64_t* out);
|
||||
|
||||
/* DO NOT CALL THIS. Use JS::ToString. */
|
||||
extern JS_PUBLIC_API(JSString*)
|
||||
ToStringSlow(JSContext* cx, JS::HandleValue v);
|
||||
|
||||
/* DO NOT CALL THIS. Use JS::ToObject. */
|
||||
extern JS_PUBLIC_API(JSObject*)
|
||||
ToObjectSlow(JSContext* cx, JS::HandleValue v, bool reportScanStack);
|
||||
|
||||
} // namespace js
|
||||
|
||||
namespace JS {
|
||||
|
||||
namespace detail {
|
||||
|
||||
#ifdef JS_DEBUG
|
||||
/**
|
||||
* Assert that we're not doing GC on cx, that we're in a request as
|
||||
* needed, and that the compartments for cx and v are correct.
|
||||
* Also check that GC would be safe at this point.
|
||||
*/
|
||||
extern JS_PUBLIC_API(void)
|
||||
AssertArgumentsAreSane(JSContext* cx, HandleValue v);
|
||||
#else
|
||||
inline void AssertArgumentsAreSane(JSContext* cx, HandleValue v)
|
||||
{}
|
||||
#endif /* JS_DEBUG */
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/**
|
||||
* ES6 draft 20141224, 7.1.1, second algorithm.
|
||||
*
|
||||
* Most users shouldn't call this -- use JS::ToBoolean, ToNumber, or ToString
|
||||
* instead. This will typically only be called from custom convert hooks that
|
||||
* wish to fall back to the ES6 default conversion behavior shared by most
|
||||
* objects in JS, codified as OrdinaryToPrimitive.
|
||||
*/
|
||||
extern JS_PUBLIC_API(bool)
|
||||
OrdinaryToPrimitive(JSContext* cx, HandleObject obj, JSType type, MutableHandleValue vp);
|
||||
|
||||
/* ES6 draft 20141224, 7.1.2. */
|
||||
MOZ_ALWAYS_INLINE bool
|
||||
ToBoolean(HandleValue v)
|
||||
{
|
||||
if (v.isBoolean())
|
||||
return v.toBoolean();
|
||||
if (v.isInt32())
|
||||
return v.toInt32() != 0;
|
||||
if (v.isNullOrUndefined())
|
||||
return false;
|
||||
if (v.isDouble()) {
|
||||
double d = v.toDouble();
|
||||
return !mozilla::IsNaN(d) && d != 0;
|
||||
}
|
||||
if (v.isSymbol())
|
||||
return true;
|
||||
|
||||
/* The slow path handles strings and objects. */
|
||||
return js::ToBooleanSlow(v);
|
||||
}
|
||||
|
||||
/* ES6 draft 20141224, 7.1.3. */
|
||||
MOZ_ALWAYS_INLINE bool
|
||||
ToNumber(JSContext* cx, HandleValue v, double* out)
|
||||
{
|
||||
detail::AssertArgumentsAreSane(cx, v);
|
||||
|
||||
if (v.isNumber()) {
|
||||
*out = v.toNumber();
|
||||
return true;
|
||||
}
|
||||
return js::ToNumberSlow(cx, v, out);
|
||||
}
|
||||
|
||||
/* ES6 draft 20141224, ToInteger (specialized for doubles). */
|
||||
inline double
|
||||
ToInteger(double d)
|
||||
{
|
||||
if (d == 0)
|
||||
return d;
|
||||
|
||||
if (!mozilla::IsFinite(d)) {
|
||||
if (mozilla::IsNaN(d))
|
||||
return 0;
|
||||
return d;
|
||||
}
|
||||
|
||||
return d < 0 ? ceil(d) : floor(d);
|
||||
}
|
||||
|
||||
/* ES6 draft 20141224, 7.1.5. */
|
||||
MOZ_ALWAYS_INLINE bool
|
||||
ToInt32(JSContext* cx, JS::HandleValue v, int32_t* out)
|
||||
{
|
||||
detail::AssertArgumentsAreSane(cx, v);
|
||||
|
||||
if (v.isInt32()) {
|
||||
*out = v.toInt32();
|
||||
return true;
|
||||
}
|
||||
return js::ToInt32Slow(cx, v, out);
|
||||
}
|
||||
|
||||
/* ES6 draft 20141224, 7.1.6. */
|
||||
MOZ_ALWAYS_INLINE bool
|
||||
ToUint32(JSContext* cx, HandleValue v, uint32_t* out)
|
||||
{
|
||||
detail::AssertArgumentsAreSane(cx, v);
|
||||
|
||||
if (v.isInt32()) {
|
||||
*out = uint32_t(v.toInt32());
|
||||
return true;
|
||||
}
|
||||
return js::ToUint32Slow(cx, v, out);
|
||||
}
|
||||
|
||||
/* ES6 draft 20141224, 7.1.7. */
|
||||
MOZ_ALWAYS_INLINE bool
|
||||
ToInt16(JSContext *cx, JS::HandleValue v, int16_t *out)
|
||||
{
|
||||
detail::AssertArgumentsAreSane(cx, v);
|
||||
|
||||
if (v.isInt32()) {
|
||||
*out = int16_t(v.toInt32());
|
||||
return true;
|
||||
}
|
||||
return js::ToInt16Slow(cx, v, out);
|
||||
}
|
||||
|
||||
/* ES6 draft 20141224, 7.1.8. */
|
||||
MOZ_ALWAYS_INLINE bool
|
||||
ToUint16(JSContext* cx, HandleValue v, uint16_t* out)
|
||||
{
|
||||
detail::AssertArgumentsAreSane(cx, v);
|
||||
|
||||
if (v.isInt32()) {
|
||||
*out = uint16_t(v.toInt32());
|
||||
return true;
|
||||
}
|
||||
return js::ToUint16Slow(cx, v, out);
|
||||
}
|
||||
|
||||
/* ES6 draft 20141224, 7.1.9 */
|
||||
MOZ_ALWAYS_INLINE bool
|
||||
ToInt8(JSContext *cx, JS::HandleValue v, int8_t *out)
|
||||
{
|
||||
detail::AssertArgumentsAreSane(cx, v);
|
||||
|
||||
if (v.isInt32()) {
|
||||
*out = int8_t(v.toInt32());
|
||||
return true;
|
||||
}
|
||||
return js::ToInt8Slow(cx, v, out);
|
||||
}
|
||||
|
||||
/* ES6 ECMA-262, 7.1.10 */
|
||||
MOZ_ALWAYS_INLINE bool
|
||||
ToUint8(JSContext *cx, JS::HandleValue v, uint8_t *out)
|
||||
{
|
||||
detail::AssertArgumentsAreSane(cx, v);
|
||||
|
||||
if (v.isInt32()) {
|
||||
*out = uint8_t(v.toInt32());
|
||||
return true;
|
||||
}
|
||||
return js::ToUint8Slow(cx, v, out);
|
||||
}
|
||||
|
||||
/*
|
||||
* Non-standard, with behavior similar to that of ToInt32, except in its
|
||||
* producing an int64_t.
|
||||
*/
|
||||
MOZ_ALWAYS_INLINE bool
|
||||
ToInt64(JSContext* cx, HandleValue v, int64_t* out)
|
||||
{
|
||||
detail::AssertArgumentsAreSane(cx, v);
|
||||
|
||||
if (v.isInt32()) {
|
||||
*out = int64_t(v.toInt32());
|
||||
return true;
|
||||
}
|
||||
return js::ToInt64Slow(cx, v, out);
|
||||
}
|
||||
|
||||
/*
|
||||
* Non-standard, with behavior similar to that of ToUint32, except in its
|
||||
* producing a uint64_t.
|
||||
*/
|
||||
MOZ_ALWAYS_INLINE bool
|
||||
ToUint64(JSContext* cx, HandleValue v, uint64_t* out)
|
||||
{
|
||||
detail::AssertArgumentsAreSane(cx, v);
|
||||
|
||||
if (v.isInt32()) {
|
||||
*out = uint64_t(v.toInt32());
|
||||
return true;
|
||||
}
|
||||
return js::ToUint64Slow(cx, v, out);
|
||||
}
|
||||
|
||||
/* ES6 draft 20141224, 7.1.12. */
|
||||
MOZ_ALWAYS_INLINE JSString*
|
||||
ToString(JSContext* cx, HandleValue v)
|
||||
{
|
||||
detail::AssertArgumentsAreSane(cx, v);
|
||||
|
||||
if (v.isString())
|
||||
return v.toString();
|
||||
return js::ToStringSlow(cx, v);
|
||||
}
|
||||
|
||||
/* ES6 draft 20141224, 7.1.13. */
|
||||
inline JSObject*
|
||||
ToObject(JSContext* cx, HandleValue v)
|
||||
{
|
||||
detail::AssertArgumentsAreSane(cx, v);
|
||||
|
||||
if (v.isObject())
|
||||
return &v.toObject();
|
||||
return js::ToObjectSlow(cx, v, false);
|
||||
}
|
||||
|
||||
namespace detail {
|
||||
|
||||
/*
|
||||
* Convert a double value to ResultType (an unsigned integral type) using
|
||||
* ECMAScript-style semantics (that is, in like manner to how ECMAScript's
|
||||
* ToInt32 converts to int32_t).
|
||||
*
|
||||
* If d is infinite or NaN, return 0.
|
||||
* Otherwise compute d2 = sign(d) * floor(abs(d)), and return the ResultType
|
||||
* value congruent to d2 mod 2**(bit width of ResultType).
|
||||
*
|
||||
* The algorithm below is inspired by that found in
|
||||
* <http://trac.webkit.org/changeset/67825/trunk/JavaScriptCore/runtime/JSValue.cpp>
|
||||
* but has been generalized to all integer widths.
|
||||
*/
|
||||
template<typename ResultType>
|
||||
inline ResultType
|
||||
ToUintWidth(double d)
|
||||
{
|
||||
static_assert(mozilla::IsUnsigned<ResultType>::value,
|
||||
"ResultType must be an unsigned type");
|
||||
|
||||
uint64_t bits = mozilla::BitwiseCast<uint64_t>(d);
|
||||
unsigned DoubleExponentShift = mozilla::FloatingPoint<double>::kExponentShift;
|
||||
|
||||
// Extract the exponent component. (Be careful here! It's not technically
|
||||
// the exponent in NaN, infinities, and subnormals.)
|
||||
int_fast16_t exp =
|
||||
int_fast16_t((bits & mozilla::FloatingPoint<double>::kExponentBits) >> DoubleExponentShift) -
|
||||
int_fast16_t(mozilla::FloatingPoint<double>::kExponentBias);
|
||||
|
||||
// If the exponent's less than zero, abs(d) < 1, so the result is 0. (This
|
||||
// also handles subnormals.)
|
||||
if (exp < 0)
|
||||
return 0;
|
||||
|
||||
uint_fast16_t exponent = mozilla::AssertedCast<uint_fast16_t>(exp);
|
||||
|
||||
// If the exponent is greater than or equal to the bits of precision of a
|
||||
// double plus ResultType's width, the number is either infinite, NaN, or
|
||||
// too large to have lower-order bits in the congruent value. (Example:
|
||||
// 2**84 is exactly representable as a double. The next exact double is
|
||||
// 2**84 + 2**32. Thus if ResultType is int32_t, an exponent >= 84 implies
|
||||
// floor(abs(d)) == 0 mod 2**32.) Return 0 in all these cases.
|
||||
const size_t ResultWidth = CHAR_BIT * sizeof(ResultType);
|
||||
if (exponent >= DoubleExponentShift + ResultWidth)
|
||||
return 0;
|
||||
|
||||
// The significand contains the bits that will determine the final result.
|
||||
// Shift those bits left or right, according to the exponent, to their
|
||||
// locations in the unsigned binary representation of floor(abs(d)).
|
||||
static_assert(sizeof(ResultType) <= sizeof(uint64_t),
|
||||
"Left-shifting below would lose upper bits");
|
||||
ResultType result = (exponent > DoubleExponentShift)
|
||||
? ResultType(bits << (exponent - DoubleExponentShift))
|
||||
: ResultType(bits >> (DoubleExponentShift - exponent));
|
||||
|
||||
// Two further complications remain. First, |result| may contain bogus
|
||||
// sign/exponent bits. Second, IEEE-754 numbers' significands (excluding
|
||||
// subnormals, but we already handled those) have an implicit leading 1
|
||||
// which may affect the final result.
|
||||
//
|
||||
// It may appear that there's complexity here depending on how ResultWidth
|
||||
// and DoubleExponentShift relate, but it turns out there's not.
|
||||
//
|
||||
// Assume ResultWidth < DoubleExponentShift:
|
||||
// Only right-shifts leave bogus bits in |result|. For this to happen,
|
||||
// we must right-shift by > |DoubleExponentShift - ResultWidth|, implying
|
||||
// |exponent < ResultWidth|.
|
||||
// The implicit leading bit only matters if it appears in the final
|
||||
// result -- if |2**exponent mod 2**ResultWidth != 0|. This implies
|
||||
// |exponent < ResultWidth|.
|
||||
// Otherwise assume ResultWidth >= DoubleExponentShift:
|
||||
// Any left-shift less than |ResultWidth - DoubleExponentShift| leaves
|
||||
// bogus bits in |result|. This implies |exponent < ResultWidth|. Any
|
||||
// right-shift less than |ResultWidth| does too, which implies
|
||||
// |DoubleExponentShift - ResultWidth < exponent|. By assumption, then,
|
||||
// |exponent| is negative, but we excluded that above. So bogus bits
|
||||
// need only |exponent < ResultWidth|.
|
||||
// The implicit leading bit matters identically to the other case, so
|
||||
// again, |exponent < ResultWidth|.
|
||||
if (exponent < ResultWidth) {
|
||||
ResultType implicitOne = ResultType(1) << exponent;
|
||||
result &= implicitOne - 1; // remove bogus bits
|
||||
result += implicitOne; // add the implicit bit
|
||||
}
|
||||
|
||||
// Compute the congruent value in the signed range.
|
||||
return (bits & mozilla::FloatingPoint<double>::kSignBit) ? ~result + 1 : result;
|
||||
}
|
||||
|
||||
template<typename ResultType>
|
||||
inline ResultType
|
||||
ToIntWidth(double d)
|
||||
{
|
||||
static_assert(mozilla::IsSigned<ResultType>::value,
|
||||
"ResultType must be a signed type");
|
||||
|
||||
const ResultType MaxValue = (1ULL << (CHAR_BIT * sizeof(ResultType) - 1)) - 1;
|
||||
const ResultType MinValue = -MaxValue - 1;
|
||||
|
||||
typedef typename mozilla::MakeUnsigned<ResultType>::Type UnsignedResult;
|
||||
UnsignedResult u = ToUintWidth<UnsignedResult>(d);
|
||||
if (u <= UnsignedResult(MaxValue))
|
||||
return static_cast<ResultType>(u);
|
||||
return (MinValue + static_cast<ResultType>(u - MaxValue)) - 1;
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/* ES5 9.5 ToInt32 (specialized for doubles). */
|
||||
inline int32_t
|
||||
ToInt32(double d)
|
||||
{
|
||||
// clang crashes compiling this when targeting arm:
|
||||
// https://llvm.org/bugs/show_bug.cgi?id=22974
|
||||
#if defined (__arm__) && defined (__GNUC__) && !defined(__clang__)
|
||||
int32_t i;
|
||||
uint32_t tmp0;
|
||||
uint32_t tmp1;
|
||||
uint32_t tmp2;
|
||||
asm (
|
||||
// We use a pure integer solution here. In the 'softfp' ABI, the argument
|
||||
// will start in r0 and r1, and VFP can't do all of the necessary ECMA
|
||||
// conversions by itself so some integer code will be required anyway. A
|
||||
// hybrid solution is faster on A9, but this pure integer solution is
|
||||
// notably faster for A8.
|
||||
|
||||
// %0 is the result register, and may alias either of the %[QR]1 registers.
|
||||
// %Q4 holds the lower part of the mantissa.
|
||||
// %R4 holds the sign, exponent, and the upper part of the mantissa.
|
||||
// %1, %2 and %3 are used as temporary values.
|
||||
|
||||
// Extract the exponent.
|
||||
" mov %1, %R4, LSR #20\n"
|
||||
" bic %1, %1, #(1 << 11)\n" // Clear the sign.
|
||||
|
||||
// Set the implicit top bit of the mantissa. This clobbers a bit of the
|
||||
// exponent, but we have already extracted that.
|
||||
" orr %R4, %R4, #(1 << 20)\n"
|
||||
|
||||
// Special Cases
|
||||
// We should return zero in the following special cases:
|
||||
// - Exponent is 0x000 - 1023: +/-0 or subnormal.
|
||||
// - Exponent is 0x7ff - 1023: +/-INFINITY or NaN
|
||||
// - This case is implicitly handled by the standard code path anyway,
|
||||
// as shifting the mantissa up by the exponent will result in '0'.
|
||||
//
|
||||
// The result is composed of the mantissa, prepended with '1' and
|
||||
// bit-shifted left by the (decoded) exponent. Note that because the r1[20]
|
||||
// is the bit with value '1', r1 is effectively already shifted (left) by
|
||||
// 20 bits, and r0 is already shifted by 52 bits.
|
||||
|
||||
// Adjust the exponent to remove the encoding offset. If the decoded
|
||||
// exponent is negative, quickly bail out with '0' as such values round to
|
||||
// zero anyway. This also catches +/-0 and subnormals.
|
||||
" sub %1, %1, #0xff\n"
|
||||
" subs %1, %1, #0x300\n"
|
||||
" bmi 8f\n"
|
||||
|
||||
// %1 = (decoded) exponent >= 0
|
||||
// %R4 = upper mantissa and sign
|
||||
|
||||
// ---- Lower Mantissa ----
|
||||
" subs %3, %1, #52\n" // Calculate exp-52
|
||||
" bmi 1f\n"
|
||||
|
||||
// Shift r0 left by exp-52.
|
||||
// Ensure that we don't overflow ARM's 8-bit shift operand range.
|
||||
// We need to handle anything up to an 11-bit value here as we know that
|
||||
// 52 <= exp <= 1024 (0x400). Any shift beyond 31 bits results in zero
|
||||
// anyway, so as long as we don't touch the bottom 5 bits, we can use
|
||||
// a logical OR to push long shifts into the 32 <= (exp&0xff) <= 255 range.
|
||||
" bic %2, %3, #0xff\n"
|
||||
" orr %3, %3, %2, LSR #3\n"
|
||||
// We can now perform a straight shift, avoiding the need for any
|
||||
// conditional instructions or extra branches.
|
||||
" mov %Q4, %Q4, LSL %3\n"
|
||||
" b 2f\n"
|
||||
"1:\n" // Shift r0 right by 52-exp.
|
||||
// We know that 0 <= exp < 52, and we can shift up to 255 bits so 52-exp
|
||||
// will always be a valid shift and we can sk%3 the range check for this case.
|
||||
" rsb %3, %1, #52\n"
|
||||
" mov %Q4, %Q4, LSR %3\n"
|
||||
|
||||
// %1 = (decoded) exponent
|
||||
// %R4 = upper mantissa and sign
|
||||
// %Q4 = partially-converted integer
|
||||
|
||||
"2:\n"
|
||||
// ---- Upper Mantissa ----
|
||||
// This is much the same as the lower mantissa, with a few different
|
||||
// boundary checks and some masking to hide the exponent & sign bit in the
|
||||
// upper word.
|
||||
// Note that the upper mantissa is pre-shifted by 20 in %R4, but we shift
|
||||
// it left more to remove the sign and exponent so it is effectively
|
||||
// pre-shifted by 31 bits.
|
||||
" subs %3, %1, #31\n" // Calculate exp-31
|
||||
" mov %1, %R4, LSL #11\n" // Re-use %1 as a temporary register.
|
||||
" bmi 3f\n"
|
||||
|
||||
// Shift %R4 left by exp-31.
|
||||
// Avoid overflowing the 8-bit shift range, as before.
|
||||
" bic %2, %3, #0xff\n"
|
||||
" orr %3, %3, %2, LSR #3\n"
|
||||
// Perform the shift.
|
||||
" mov %2, %1, LSL %3\n"
|
||||
" b 4f\n"
|
||||
"3:\n" // Shift r1 right by 31-exp.
|
||||
// We know that 0 <= exp < 31, and we can shift up to 255 bits so 31-exp
|
||||
// will always be a valid shift and we can skip the range check for this case.
|
||||
" rsb %3, %3, #0\n" // Calculate 31-exp from -(exp-31)
|
||||
" mov %2, %1, LSR %3\n" // Thumb-2 can't do "LSR %3" in "orr".
|
||||
|
||||
// %Q4 = partially-converted integer (lower)
|
||||
// %R4 = upper mantissa and sign
|
||||
// %2 = partially-converted integer (upper)
|
||||
|
||||
"4:\n"
|
||||
// Combine the converted parts.
|
||||
" orr %Q4, %Q4, %2\n"
|
||||
// Negate the result if we have to, and move it to %0 in the process. To
|
||||
// avoid conditionals, we can do this by inverting on %R4[31], then adding
|
||||
// %R4[31]>>31.
|
||||
" eor %Q4, %Q4, %R4, ASR #31\n"
|
||||
" add %0, %Q4, %R4, LSR #31\n"
|
||||
" b 9f\n"
|
||||
"8:\n"
|
||||
// +/-INFINITY, +/-0, subnormals, NaNs, and anything else out-of-range that
|
||||
// will result in a conversion of '0'.
|
||||
" mov %0, #0\n"
|
||||
"9:\n"
|
||||
: "=r" (i), "=&r" (tmp0), "=&r" (tmp1), "=&r" (tmp2), "=&r" (d)
|
||||
: "4" (d)
|
||||
: "cc"
|
||||
);
|
||||
return i;
|
||||
#else
|
||||
return detail::ToIntWidth<int32_t>(d);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* ES5 9.6 (specialized for doubles). */
|
||||
inline uint32_t
|
||||
ToUint32(double d)
|
||||
{
|
||||
return detail::ToUintWidth<uint32_t>(d);
|
||||
}
|
||||
|
||||
/* WEBIDL 4.2.4 */
|
||||
inline int8_t
|
||||
ToInt8(double d)
|
||||
{
|
||||
return detail::ToIntWidth<int8_t>(d);
|
||||
}
|
||||
|
||||
/* ECMA-262 7.1.10 ToUInt8() specialized for doubles. */
|
||||
inline int8_t
|
||||
ToUint8(double d)
|
||||
{
|
||||
return detail::ToUintWidth<uint8_t>(d);
|
||||
}
|
||||
|
||||
/* WEBIDL 4.2.6 */
|
||||
inline int16_t
|
||||
ToInt16(double d)
|
||||
{
|
||||
return detail::ToIntWidth<int16_t>(d);
|
||||
}
|
||||
|
||||
inline uint16_t
|
||||
ToUint16(double d)
|
||||
{
|
||||
return detail::ToUintWidth<uint16_t>(d);
|
||||
}
|
||||
|
||||
/* WEBIDL 4.2.10 */
|
||||
inline int64_t
|
||||
ToInt64(double d)
|
||||
{
|
||||
return detail::ToIntWidth<int64_t>(d);
|
||||
}
|
||||
|
||||
/* WEBIDL 4.2.11 */
|
||||
inline uint64_t
|
||||
ToUint64(double d)
|
||||
{
|
||||
return detail::ToUintWidth<uint64_t>(d);
|
||||
}
|
||||
|
||||
} // namespace JS
|
||||
|
||||
#endif /* js_Conversions_h */
|
||||
|
|
@ -3,15 +3,134 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/* JavaScript date/time computation and creation functions. */
|
||||
|
||||
#ifndef js_Date_h
|
||||
#define js_Date_h
|
||||
|
||||
#include "jstypes.h"
|
||||
/*
|
||||
* Dates in JavaScript are defined by IEEE-754 double precision numbers from
|
||||
* the set:
|
||||
*
|
||||
* { t ∈ ℕ : -8.64e15 ≤ t ≤ +8.64e15 } ∪ { NaN }
|
||||
*
|
||||
* The single NaN value represents any invalid-date value. All other values
|
||||
* represent idealized durations in milliseconds since the UTC epoch. (Leap
|
||||
* seconds are ignored; leap days are not.) +0 is the only zero in this set.
|
||||
* The limit represented by 8.64e15 milliseconds is 100 million days either
|
||||
* side of 00:00 January 1, 1970 UTC.
|
||||
*
|
||||
* Dates in the above set are represented by the |ClippedTime| class. The
|
||||
* double type is a superset of the above set, so it *may* (but need not)
|
||||
* represent a date. Use ECMAScript's |TimeClip| method to produce a date from
|
||||
* a double.
|
||||
*
|
||||
* Date *objects* are simply wrappers around |TimeClip|'d numbers, with a bunch
|
||||
* of accessor methods to the various aspects of the represented date.
|
||||
*/
|
||||
|
||||
#include "mozilla/FloatingPoint.h"
|
||||
#include "mozilla/MathAlgorithms.h"
|
||||
|
||||
#include "js/Conversions.h"
|
||||
#include "js/Value.h"
|
||||
|
||||
struct JSContext;
|
||||
|
||||
namespace JS {
|
||||
|
||||
// Year is a year, month is 0-11, day is 1-based. The return value is
|
||||
// a number of milliseconds since the epoch. Can return NaN.
|
||||
/**
|
||||
* Re-query the system to determine the current time zone adjustment from UTC,
|
||||
* including any component due to DST. If the time zone has changed, this will
|
||||
* cause all Date object non-UTC methods and formatting functions to produce
|
||||
* appropriately adjusted results.
|
||||
*
|
||||
* Left to its own devices, SpiderMonkey itself may occasionally call this
|
||||
* method to attempt to keep up with system time changes. However, no
|
||||
* particular frequency of checking is guaranteed. Embedders unable to accept
|
||||
* occasional inaccuracies should call this method in response to system time
|
||||
* changes, or immediately before operations requiring instantaneous
|
||||
* correctness, to guarantee correct behavior.
|
||||
*/
|
||||
extern JS_PUBLIC_API(void)
|
||||
ResetTimeZone();
|
||||
|
||||
class ClippedTime;
|
||||
inline ClippedTime TimeClip(double time);
|
||||
|
||||
/*
|
||||
* |ClippedTime| represents the limited subset of dates/times described above.
|
||||
*
|
||||
* An invalid date/time may be created through the |ClippedTime::invalid|
|
||||
* method. Otherwise, a |ClippedTime| may be created using the |TimeClip|
|
||||
* method.
|
||||
*
|
||||
* In typical use, the user might wish to manipulate a timestamp. The user
|
||||
* performs a series of operations on it, but the final value might not be a
|
||||
* date as defined above -- it could have overflowed, acquired a fractional
|
||||
* component, &c. So as a *final* step, the user passes that value through
|
||||
* |TimeClip| to produce a number restricted to JavaScript's date range.
|
||||
*
|
||||
* APIs that accept a JavaScript date value thus accept a |ClippedTime|, not a
|
||||
* double. This ensures that date/time APIs will only ever receive acceptable
|
||||
* JavaScript dates. This also forces users to perform any desired clipping,
|
||||
* as only the user knows what behavior is desired when clipping occurs.
|
||||
*/
|
||||
class ClippedTime
|
||||
{
|
||||
double t;
|
||||
|
||||
explicit ClippedTime(double time) : t(time) {}
|
||||
friend ClippedTime TimeClip(double time);
|
||||
|
||||
public:
|
||||
// Create an invalid date.
|
||||
ClippedTime() : t(mozilla::UnspecifiedNaN<double>()) {}
|
||||
|
||||
// Create an invalid date/time, more explicitly; prefer this to the default
|
||||
// constructor.
|
||||
static ClippedTime invalid() { return ClippedTime(); }
|
||||
|
||||
double toDouble() const { return t; }
|
||||
|
||||
bool isValid() const { return !mozilla::IsNaN(t); }
|
||||
};
|
||||
|
||||
// ES6 20.3.1.15.
|
||||
//
|
||||
// Clip a double to JavaScript's date range (or to an invalid date) using the
|
||||
// ECMAScript TimeClip algorithm.
|
||||
inline ClippedTime
|
||||
TimeClip(double time)
|
||||
{
|
||||
// Steps 1-2.
|
||||
const double MaxTimeMagnitude = 8.64e15;
|
||||
if (!mozilla::IsFinite(time) || mozilla::Abs(time) > MaxTimeMagnitude)
|
||||
return ClippedTime(mozilla::UnspecifiedNaN<double>());
|
||||
|
||||
// Step 3.
|
||||
return ClippedTime(ToInteger(time) + (+0.0));
|
||||
}
|
||||
|
||||
// Produce a double Value from the given time. Because times may be NaN,
|
||||
// prefer using this to manual canonicalization.
|
||||
inline Value
|
||||
TimeValue(ClippedTime time)
|
||||
{
|
||||
return DoubleValue(JS::CanonicalizeNaN(time.toDouble()));
|
||||
}
|
||||
|
||||
// Create a new Date object whose [[DateValue]] internal slot contains the
|
||||
// clipped |time|. (Users who must represent times outside that range must use
|
||||
// another representation.)
|
||||
extern JS_PUBLIC_API(JSObject*)
|
||||
NewDateObject(JSContext* cx, ClippedTime time);
|
||||
|
||||
// Year is a year, month is 0-11, day is 1-based. The return value is a number
|
||||
// of milliseconds since the epoch.
|
||||
//
|
||||
// Consistent with the MakeDate algorithm defined in ECMAScript, this value is
|
||||
// *not* clipped! Use JS::TimeClip if you need a clipped date.
|
||||
JS_PUBLIC_API(double)
|
||||
MakeDate(double year, unsigned month, unsigned day);
|
||||
|
||||
|
|
@ -30,6 +149,22 @@ MonthFromTime(double time);
|
|||
JS_PUBLIC_API(double)
|
||||
DayFromTime(double time);
|
||||
|
||||
// Takes an integer year and returns the number of days from epoch to the given
|
||||
// year.
|
||||
// NOTE: The calculation performed by this function is literally that given in
|
||||
// the ECMAScript specification. Nonfinite years, years containing fractional
|
||||
// components, and years outside ECMAScript's date range are not handled with
|
||||
// any particular intelligence. Garbage in, garbage out.
|
||||
JS_PUBLIC_API(double)
|
||||
DayFromYear(double year);
|
||||
|
||||
// Takes an integer number of milliseconds since the epoch and an integer year,
|
||||
// returns the number of days in that year. If |time| is nonfinite, returns NaN.
|
||||
// Otherwise |time| *must* correspond to a time within the valid year |year|.
|
||||
// This should usually be ensured by computing |year| as |JS::DayFromYear(time)|.
|
||||
JS_PUBLIC_API(double)
|
||||
DayWithinYear(double time, double year);
|
||||
|
||||
} // namespace JS
|
||||
|
||||
#endif /* js_Date_h */
|
||||
|
|
|
|||
|
|
@ -0,0 +1,384 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* vim: set ts=8 sts=4 et sw=4 tw=99:
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// Interfaces by which the embedding can interact with the Debugger API.
|
||||
|
||||
#ifndef js_Debug_h
|
||||
#define js_Debug_h
|
||||
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "jspubtd.h"
|
||||
|
||||
#include "js/GCAPI.h"
|
||||
#include "js/RootingAPI.h"
|
||||
#include "js/TypeDecls.h"
|
||||
|
||||
namespace js {
|
||||
class Debugger;
|
||||
} // namespace js
|
||||
|
||||
namespace JS {
|
||||
namespace dbg {
|
||||
|
||||
// Helping embedding code build objects for Debugger
|
||||
// -------------------------------------------------
|
||||
//
|
||||
// Some Debugger API features lean on the embedding application to construct
|
||||
// their result values. For example, Debugger.Frame.prototype.scriptEntryReason
|
||||
// calls hooks provided by the embedding to construct values explaining why it
|
||||
// invoked JavaScript; if F is a frame called from a mouse click event handler,
|
||||
// F.scriptEntryReason would return an object of the form:
|
||||
//
|
||||
// { eventType: "mousedown", event: <object> }
|
||||
//
|
||||
// where <object> is a Debugger.Object whose referent is the event being
|
||||
// dispatched.
|
||||
//
|
||||
// However, Debugger implements a trust boundary. Debuggee code may be
|
||||
// considered untrusted; debugger code needs to be protected from debuggee
|
||||
// getters, setters, proxies, Object.watch watchpoints, and any other feature
|
||||
// that might accidentally cause debugger code to set the debuggee running. The
|
||||
// Debugger API tries to make it easy to write safe debugger code by only
|
||||
// offering access to debuggee objects via Debugger.Object instances, which
|
||||
// ensure that only those operations whose explicit purpose is to invoke
|
||||
// debuggee code do so. But this protective membrane is only helpful if we
|
||||
// interpose Debugger.Object instances in all the necessary spots.
|
||||
//
|
||||
// SpiderMonkey's compartment system also implements a trust boundary. The
|
||||
// debuggee and debugger are always in different compartments. Inter-compartment
|
||||
// work requires carefully tracking which compartment each JSObject or JS::Value
|
||||
// belongs to, and ensuring that is is correctly wrapped for each operation.
|
||||
//
|
||||
// It seems precarious to expect the embedding's hooks to implement these trust
|
||||
// boundaries. Instead, the JS::dbg::Builder API segregates the code which
|
||||
// constructs trusted objects from that which deals with untrusted objects.
|
||||
// Trusted objects have an entirely different C++ type, so code that improperly
|
||||
// mixes trusted and untrusted objects is caught at compile time.
|
||||
//
|
||||
// In the structure shown above, there are two trusted objects, and one
|
||||
// untrusted object:
|
||||
//
|
||||
// - The overall object, with the 'eventType' and 'event' properties, is a
|
||||
// trusted object. We're going to return it to D.F.p.scriptEntryReason's
|
||||
// caller, which will handle it directly.
|
||||
//
|
||||
// - The Debugger.Object instance appearing as the value of the 'event' property
|
||||
// is a trusted object. It belongs to the same Debugger instance as the
|
||||
// Debugger.Frame instance whose scriptEntryReason accessor was called, and
|
||||
// presents a safe reflection-oriented API for inspecting its referent, which
|
||||
// is:
|
||||
//
|
||||
// - The actual event object, an untrusted object, and the referent of the
|
||||
// Debugger.Object above. (Content can do things like replacing accessors on
|
||||
// Event.prototype.)
|
||||
//
|
||||
// Using JS::dbg::Builder, all objects and values the embedding deals with
|
||||
// directly are considered untrusted, and are assumed to be debuggee values. The
|
||||
// only way to construct trusted objects is to use Builder's own methods, which
|
||||
// return a separate Object type. The only way to set a property on a trusted
|
||||
// object is through that Object type. The actual trusted object is never
|
||||
// exposed to the embedding.
|
||||
//
|
||||
// So, for example, the embedding might use code like the following to construct
|
||||
// the object shown above, given a Builder passed to it by Debugger:
|
||||
//
|
||||
// bool
|
||||
// MyScriptEntryReason::explain(JSContext* cx,
|
||||
// Builder& builder,
|
||||
// Builder::Object& result)
|
||||
// {
|
||||
// JSObject* eventObject = ... obtain debuggee event object somehow ...;
|
||||
// if (!eventObject)
|
||||
// return false;
|
||||
// result = builder.newObject(cx);
|
||||
// return result &&
|
||||
// result.defineProperty(cx, "eventType", SafelyFetchType(eventObject)) &&
|
||||
// result.defineProperty(cx, "event", eventObject);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// Object::defineProperty also accepts an Object as the value to store on the
|
||||
// property. By its type, we know that the value is trusted, so we set it
|
||||
// directly as the property's value, without interposing a Debugger.Object
|
||||
// wrapper. This allows the embedding to builted nested structures of trusted
|
||||
// objects.
|
||||
//
|
||||
// The Builder and Builder::Object methods take care of doing whatever
|
||||
// compartment switching and wrapping are necessary to construct the trusted
|
||||
// values in the Debugger's compartment.
|
||||
//
|
||||
// The Object type is self-rooting. Construction, assignment, and destruction
|
||||
// all properly root the referent object.
|
||||
|
||||
class BuilderOrigin;
|
||||
|
||||
class Builder {
|
||||
// The Debugger instance whose client we are building a value for. We build
|
||||
// objects in this object's compartment.
|
||||
PersistentRootedObject debuggerObject;
|
||||
|
||||
// debuggerObject's Debugger structure, for convenience.
|
||||
js::Debugger* debugger;
|
||||
|
||||
// Check that |thing| is in the same compartment as our debuggerObject. Used
|
||||
// for assertions when constructing BuiltThings. We can overload this as we
|
||||
// add more instantiations of BuiltThing.
|
||||
#if DEBUG
|
||||
void assertBuilt(JSObject* obj);
|
||||
#else
|
||||
void assertBuilt(JSObject* obj) { }
|
||||
#endif
|
||||
|
||||
protected:
|
||||
// A reference to a trusted object or value. At the moment, we only use it
|
||||
// with JSObject*.
|
||||
template<typename T>
|
||||
class BuiltThing {
|
||||
friend class BuilderOrigin;
|
||||
|
||||
protected:
|
||||
// The Builder to which this trusted thing belongs.
|
||||
Builder& owner;
|
||||
|
||||
// A rooted reference to our value.
|
||||
PersistentRooted<T> value;
|
||||
|
||||
BuiltThing(JSContext* cx, Builder& owner_, T value_ = GCPolicy<T>::initial())
|
||||
: owner(owner_), value(cx, value_)
|
||||
{
|
||||
owner.assertBuilt(value_);
|
||||
}
|
||||
|
||||
// Forward some things from our owner, for convenience.
|
||||
js::Debugger* debugger() const { return owner.debugger; }
|
||||
JSObject* debuggerObject() const { return owner.debuggerObject; }
|
||||
|
||||
public:
|
||||
BuiltThing(const BuiltThing& rhs) : owner(rhs.owner), value(rhs.value) { }
|
||||
BuiltThing& operator=(const BuiltThing& rhs) {
|
||||
MOZ_ASSERT(&owner == &rhs.owner);
|
||||
owner.assertBuilt(rhs.value);
|
||||
value = rhs.value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
explicit operator bool() const {
|
||||
// If we ever instantiate BuiltThing<Value>, this might not suffice.
|
||||
return value;
|
||||
}
|
||||
|
||||
private:
|
||||
BuiltThing() = delete;
|
||||
};
|
||||
|
||||
public:
|
||||
// A reference to a trusted object, possibly null. Instances of Object are
|
||||
// always properly rooted. They can be copied and assigned, as if they were
|
||||
// pointers.
|
||||
class Object: private BuiltThing<JSObject*> {
|
||||
friend class Builder; // for construction
|
||||
friend class BuilderOrigin; // for unwrapping
|
||||
|
||||
typedef BuiltThing<JSObject*> Base;
|
||||
|
||||
// This is private, because only Builders can create Objects that
|
||||
// actually point to something (hence the 'friend' declaration).
|
||||
Object(JSContext* cx, Builder& owner_, HandleObject obj) : Base(cx, owner_, obj.get()) { }
|
||||
|
||||
bool definePropertyToTrusted(JSContext* cx, const char* name,
|
||||
JS::MutableHandleValue value);
|
||||
|
||||
public:
|
||||
Object(JSContext* cx, Builder& owner_) : Base(cx, owner_, nullptr) { }
|
||||
Object(const Object& rhs) : Base(rhs) { }
|
||||
|
||||
// Our automatically-generated assignment operator can see our base
|
||||
// class's assignment operator, so we don't need to write one out here.
|
||||
|
||||
// Set the property named |name| on this object to |value|.
|
||||
//
|
||||
// If |value| is a string or primitive, re-wrap it for the debugger's
|
||||
// compartment.
|
||||
//
|
||||
// If |value| is an object, assume it is a debuggee object and make a
|
||||
// Debugger.Object instance referring to it. Set that as the propery's
|
||||
// value.
|
||||
//
|
||||
// If |value| is another trusted object, store it directly as the
|
||||
// property's value.
|
||||
//
|
||||
// On error, report the problem on cx and return false.
|
||||
bool defineProperty(JSContext* cx, const char* name, JS::HandleValue value);
|
||||
bool defineProperty(JSContext* cx, const char* name, JS::HandleObject value);
|
||||
bool defineProperty(JSContext* cx, const char* name, Object& value);
|
||||
|
||||
using Base::operator bool;
|
||||
};
|
||||
|
||||
// Build an empty object for direct use by debugger code, owned by this
|
||||
// Builder. If an error occurs, report it on cx and return a false Object.
|
||||
Object newObject(JSContext* cx);
|
||||
|
||||
protected:
|
||||
Builder(JSContext* cx, js::Debugger* debugger);
|
||||
};
|
||||
|
||||
// Debugger itself instantiates this subclass of Builder, which can unwrap
|
||||
// BuiltThings that belong to it.
|
||||
class BuilderOrigin : public Builder {
|
||||
template<typename T>
|
||||
T unwrapAny(const BuiltThing<T>& thing) {
|
||||
MOZ_ASSERT(&thing.owner == this);
|
||||
return thing.value.get();
|
||||
}
|
||||
|
||||
public:
|
||||
BuilderOrigin(JSContext* cx, js::Debugger* debugger_)
|
||||
: Builder(cx, debugger_)
|
||||
{ }
|
||||
|
||||
JSObject* unwrap(Object& object) { return unwrapAny(object); }
|
||||
};
|
||||
|
||||
|
||||
|
||||
// Finding the size of blocks allocated with malloc
|
||||
// ------------------------------------------------
|
||||
//
|
||||
// Debugger.Memory wants to be able to report how many bytes items in memory are
|
||||
// consuming. To do this, it needs a function that accepts a pointer to a block,
|
||||
// and returns the number of bytes allocated to that block. SpiderMonkey itself
|
||||
// doesn't know which function is appropriate to use, but the embedding does.
|
||||
|
||||
// Tell Debuggers in |cx| to use |mallocSizeOf| to find the size of
|
||||
// malloc'd blocks.
|
||||
JS_PUBLIC_API(void)
|
||||
SetDebuggerMallocSizeOf(JSContext* cx, mozilla::MallocSizeOf mallocSizeOf);
|
||||
|
||||
// Get the MallocSizeOf function that the given context is using to find the
|
||||
// size of malloc'd blocks.
|
||||
JS_PUBLIC_API(mozilla::MallocSizeOf)
|
||||
GetDebuggerMallocSizeOf(JSContext* cx);
|
||||
|
||||
|
||||
|
||||
// Debugger and Garbage Collection Events
|
||||
// --------------------------------------
|
||||
//
|
||||
// The Debugger wants to report about its debuggees' GC cycles, however entering
|
||||
// JS after a GC is troublesome since SpiderMonkey will often do something like
|
||||
// force a GC and then rely on the nursery being empty. If we call into some
|
||||
// Debugger's hook after the GC, then JS runs and the nursery won't be
|
||||
// empty. Instead, we rely on embedders to call back into SpiderMonkey after a
|
||||
// GC and notify Debuggers to call their onGarbageCollection hook.
|
||||
|
||||
|
||||
// For each Debugger that observed a debuggee involved in the given GC event,
|
||||
// call its `onGarbageCollection` hook.
|
||||
JS_PUBLIC_API(bool)
|
||||
FireOnGarbageCollectionHook(JSContext* cx, GarbageCollectionEvent::Ptr&& data);
|
||||
|
||||
|
||||
|
||||
// Handlers for observing Promises
|
||||
// -------------------------------
|
||||
//
|
||||
// The Debugger wants to observe behavior of promises, which are implemented by
|
||||
// Gecko with webidl and which SpiderMonkey knows nothing about. On the other
|
||||
// hand, Gecko knows nothing about which (if any) debuggers are observing a
|
||||
// promise's global. The compromise is that Gecko is responsible for calling
|
||||
// these handlers at the appropriate times, and SpiderMonkey will handle
|
||||
// notifying any Debugger instances that are observing the given promise's
|
||||
// global.
|
||||
|
||||
// Notify any Debugger instances observing this promise's global that a new
|
||||
// promise was allocated.
|
||||
JS_PUBLIC_API(void)
|
||||
onNewPromise(JSContext* cx, HandleObject promise);
|
||||
|
||||
// Notify any Debugger instances observing this promise's global that the
|
||||
// promise has settled (ie, it has either been fulfilled or rejected). Note that
|
||||
// this is *not* equivalent to the promise resolution (ie, the promise's fate
|
||||
// getting locked in) because you can resolve a promise with another pending
|
||||
// promise, in which case neither promise has settled yet.
|
||||
//
|
||||
// It is Gecko's responsibility to ensure that this is never called on the same
|
||||
// promise more than once (because a promise can only make the transition from
|
||||
// unsettled to settled once).
|
||||
JS_PUBLIC_API(void)
|
||||
onPromiseSettled(JSContext* cx, HandleObject promise);
|
||||
|
||||
|
||||
|
||||
// Return true if the given value is a Debugger object, false otherwise.
|
||||
JS_PUBLIC_API(bool)
|
||||
IsDebugger(JSObject& obj);
|
||||
|
||||
// Append each of the debuggee global objects observed by the Debugger object
|
||||
// |dbgObj| to |vector|. Returns true on success, false on failure.
|
||||
JS_PUBLIC_API(bool)
|
||||
GetDebuggeeGlobals(JSContext* cx, JSObject& dbgObj, AutoObjectVector& vector);
|
||||
|
||||
|
||||
// Hooks for reporting where JavaScript execution began.
|
||||
//
|
||||
// Our performance tools would like to be able to label blocks of JavaScript
|
||||
// execution with the function name and source location where execution began:
|
||||
// the event handler, the callback, etc.
|
||||
//
|
||||
// Construct an instance of this class on the stack, providing a JSContext
|
||||
// belonging to the runtime in which execution will occur. Each time we enter
|
||||
// JavaScript --- specifically, each time we push a JavaScript stack frame that
|
||||
// has no older JS frames younger than this AutoEntryMonitor --- we will
|
||||
// call the appropriate |Entry| member function to indicate where we've begun
|
||||
// execution.
|
||||
|
||||
class MOZ_STACK_CLASS AutoEntryMonitor {
|
||||
JSRuntime* runtime_;
|
||||
AutoEntryMonitor* savedMonitor_;
|
||||
|
||||
public:
|
||||
explicit AutoEntryMonitor(JSContext* cx);
|
||||
~AutoEntryMonitor();
|
||||
|
||||
// SpiderMonkey reports the JavaScript entry points occuring within this
|
||||
// AutoEntryMonitor's scope to the following member functions, which the
|
||||
// embedding is expected to override.
|
||||
//
|
||||
// It is important to note that |asyncCause| is owned by the caller and its
|
||||
// lifetime must outlive the lifetime of the AutoEntryMonitor object. It is
|
||||
// strongly encouraged that |asyncCause| be a string constant or similar
|
||||
// statically allocated string.
|
||||
|
||||
// We have begun executing |function|. Note that |function| may not be the
|
||||
// actual closure we are running, but only the canonical function object to
|
||||
// which the script refers.
|
||||
virtual void Entry(JSContext* cx, JSFunction* function,
|
||||
HandleValue asyncStack,
|
||||
const char* asyncCause) = 0;
|
||||
|
||||
// Execution has begun at the entry point of |script|, which is not a
|
||||
// function body. (This is probably being executed by 'eval' or some
|
||||
// JSAPI equivalent.)
|
||||
virtual void Entry(JSContext* cx, JSScript* script,
|
||||
HandleValue asyncStack,
|
||||
const char* asyncCause) = 0;
|
||||
|
||||
// Execution of the function or script has ended.
|
||||
virtual void Exit(JSContext* cx) { }
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // namespace dbg
|
||||
} // namespace JS
|
||||
|
||||
|
||||
#endif /* js_Debug_h */
|
||||
|
|
@ -7,47 +7,67 @@
|
|||
#ifndef js_GCAPI_h
|
||||
#define js_GCAPI_h
|
||||
|
||||
#include "mozilla/NullPtr.h"
|
||||
#include "mozilla/Vector.h"
|
||||
|
||||
#include "js/GCAnnotations.h"
|
||||
#include "js/HeapAPI.h"
|
||||
#include "js/UniquePtr.h"
|
||||
|
||||
namespace js {
|
||||
namespace gc {
|
||||
class GCRuntime;
|
||||
}
|
||||
}
|
||||
} // namespace gc
|
||||
namespace gcstats {
|
||||
struct Statistics;
|
||||
} // namespace gcstats
|
||||
} // namespace js
|
||||
|
||||
typedef enum JSGCMode {
|
||||
/* Perform only global GCs. */
|
||||
/** Perform only global GCs. */
|
||||
JSGC_MODE_GLOBAL = 0,
|
||||
|
||||
/* Perform per-compartment GCs until too much garbage has accumulated. */
|
||||
JSGC_MODE_COMPARTMENT = 1,
|
||||
/** Perform per-zone GCs until too much garbage has accumulated. */
|
||||
JSGC_MODE_ZONE = 1,
|
||||
|
||||
/*
|
||||
/**
|
||||
* Collect in short time slices rather than all at once. Implies
|
||||
* JSGC_MODE_COMPARTMENT.
|
||||
* JSGC_MODE_ZONE.
|
||||
*/
|
||||
JSGC_MODE_INCREMENTAL = 2
|
||||
} JSGCMode;
|
||||
|
||||
/**
|
||||
* Kinds of js_GC invocation.
|
||||
*/
|
||||
typedef enum JSGCInvocationKind {
|
||||
/* Normal invocation. */
|
||||
GC_NORMAL = 0,
|
||||
|
||||
/* Minimize GC triggers and release empty GC chunks right away. */
|
||||
GC_SHRINK = 1
|
||||
} JSGCInvocationKind;
|
||||
|
||||
namespace JS {
|
||||
|
||||
#define GCREASONS(D) \
|
||||
/* Reasons internal to the JS engine */ \
|
||||
D(API) \
|
||||
D(MAYBEGC) \
|
||||
D(EAGER_ALLOC_TRIGGER) \
|
||||
D(DESTROY_RUNTIME) \
|
||||
D(DESTROY_CONTEXT) \
|
||||
D(UNUSED0) \
|
||||
D(LAST_DITCH) \
|
||||
D(TOO_MUCH_MALLOC) \
|
||||
D(ALLOC_TRIGGER) \
|
||||
D(DEBUG_GC) \
|
||||
D(TRANSPLANT) \
|
||||
D(COMPARTMENT_REVIVED) \
|
||||
D(RESET) \
|
||||
D(OUT_OF_NURSERY) \
|
||||
D(EVICT_NURSERY) \
|
||||
D(FULL_STORE_BUFFER) \
|
||||
D(SHARED_MEMORY_LIMIT) \
|
||||
D(UNUSED1) \
|
||||
D(INCREMENTAL_TOO_SLOW) \
|
||||
D(ABORT_GC) \
|
||||
\
|
||||
/* These are reserved for future use. */ \
|
||||
D(RESERVED0) \
|
||||
|
|
@ -66,10 +86,6 @@ namespace JS {
|
|||
D(RESERVED13) \
|
||||
D(RESERVED14) \
|
||||
D(RESERVED15) \
|
||||
D(RESERVED16) \
|
||||
D(RESERVED17) \
|
||||
D(RESERVED18) \
|
||||
D(RESERVED19) \
|
||||
\
|
||||
/* Reasons from Firefox */ \
|
||||
D(DOM_WINDOW_UTILS) \
|
||||
|
|
@ -90,7 +106,9 @@ namespace JS {
|
|||
D(REFRESH_FRAME) \
|
||||
D(FULL_GC_TIMER) \
|
||||
D(SHUTDOWN_CC) \
|
||||
D(FINISH_LARGE_EVALUTE)
|
||||
D(FINISH_LARGE_EVALUATE) \
|
||||
D(USER_INACTIVE) \
|
||||
D(XPCONNECT_SHUTDOWN)
|
||||
|
||||
namespace gcreason {
|
||||
|
||||
|
|
@ -105,12 +123,18 @@ enum Reason {
|
|||
/*
|
||||
* For telemetry, we want to keep a fixed max bucket size over time so we
|
||||
* don't have to switch histograms. 100 is conservative; as of this writing
|
||||
* there are 26. But the cost of extra buckets seems to be low while the
|
||||
* there are 52. But the cost of extra buckets seems to be low while the
|
||||
* cost of switching histograms is high.
|
||||
*/
|
||||
NUM_TELEMETRY_REASONS = 100
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a statically allocated C string explaining the given GC reason.
|
||||
*/
|
||||
extern JS_PUBLIC_API(const char*)
|
||||
ExplainReason(JS::gcreason::Reason reason);
|
||||
|
||||
} /* namespace gcreason */
|
||||
|
||||
/*
|
||||
|
|
@ -127,39 +151,39 @@ enum Reason {
|
|||
* all zones. Failing to select any zone is an error.
|
||||
*/
|
||||
|
||||
/*
|
||||
/**
|
||||
* Schedule the given zone to be collected as part of the next GC.
|
||||
*/
|
||||
extern JS_FRIEND_API(void)
|
||||
PrepareZoneForGC(Zone *zone);
|
||||
extern JS_PUBLIC_API(void)
|
||||
PrepareZoneForGC(Zone* zone);
|
||||
|
||||
/*
|
||||
/**
|
||||
* Schedule all zones to be collected in the next GC.
|
||||
*/
|
||||
extern JS_FRIEND_API(void)
|
||||
PrepareForFullGC(JSRuntime *rt);
|
||||
extern JS_PUBLIC_API(void)
|
||||
PrepareForFullGC(JSContext* cx);
|
||||
|
||||
/*
|
||||
/**
|
||||
* When performing an incremental GC, the zones that were selected for the
|
||||
* previous incremental slice must be selected in subsequent slices as well.
|
||||
* This function selects those slices automatically.
|
||||
*/
|
||||
extern JS_FRIEND_API(void)
|
||||
PrepareForIncrementalGC(JSRuntime *rt);
|
||||
extern JS_PUBLIC_API(void)
|
||||
PrepareForIncrementalGC(JSContext* cx);
|
||||
|
||||
/*
|
||||
/**
|
||||
* Returns true if any zone in the system has been scheduled for GC with one of
|
||||
* the functions above or by the JS engine.
|
||||
*/
|
||||
extern JS_FRIEND_API(bool)
|
||||
IsGCScheduled(JSRuntime *rt);
|
||||
extern JS_PUBLIC_API(bool)
|
||||
IsGCScheduled(JSContext* cx);
|
||||
|
||||
/*
|
||||
/**
|
||||
* Undoes the effect of the Prepare methods above. The given zone will not be
|
||||
* collected in the next GC.
|
||||
*/
|
||||
extern JS_FRIEND_API(void)
|
||||
SkipZoneForGC(Zone *zone);
|
||||
extern JS_PUBLIC_API(void)
|
||||
SkipZoneForGC(Zone* zone);
|
||||
|
||||
/*
|
||||
* Non-Incremental GC:
|
||||
|
|
@ -167,21 +191,17 @@ SkipZoneForGC(Zone *zone);
|
|||
* The following functions perform a non-incremental GC.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Performs a non-incremental collection of all selected zones. Some objects
|
||||
* that are unreachable from the program may still be alive afterwards because
|
||||
* of internal references.
|
||||
/**
|
||||
* Performs a non-incremental collection of all selected zones.
|
||||
*
|
||||
* If the gckind argument is GC_NORMAL, then some objects that are unreachable
|
||||
* from the program may still be alive afterwards because of internal
|
||||
* references; if GC_SHRINK is passed then caches and other temporary references
|
||||
* to objects will be cleared and all unreferenced objects will be removed from
|
||||
* the system.
|
||||
*/
|
||||
extern JS_FRIEND_API(void)
|
||||
GCForReason(JSRuntime *rt, gcreason::Reason reason);
|
||||
|
||||
/*
|
||||
* Perform a non-incremental collection after clearing caches and other
|
||||
* temporary references to objects. This will remove all unreferenced objects
|
||||
* in the system.
|
||||
*/
|
||||
extern JS_FRIEND_API(void)
|
||||
ShrinkingGC(JSRuntime *rt, gcreason::Reason reason);
|
||||
extern JS_PUBLIC_API(void)
|
||||
GCForReason(JSContext* cx, JSGCInvocationKind gckind, gcreason::Reason reason);
|
||||
|
||||
/*
|
||||
* Incremental GC:
|
||||
|
|
@ -198,34 +218,102 @@ ShrinkingGC(JSRuntime *rt, gcreason::Reason reason);
|
|||
* JS_GC().
|
||||
* - The GC mode must have been set to JSGC_MODE_INCREMENTAL with
|
||||
* JS_SetGCParameter().
|
||||
* - All native objects that have their own trace hook must indicate that they
|
||||
* implement read and write barriers with the JSCLASS_IMPLEMENTS_BARRIERS
|
||||
* flag.
|
||||
*
|
||||
* Note: Even if incremental GC is enabled and working correctly,
|
||||
* non-incremental collections can still happen when low on memory.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Begin an incremental collection and perform one slice worth of work or
|
||||
* perform a slice of an ongoing incremental collection. When this function
|
||||
* returns, the collection is not complete. This function must be called
|
||||
* repeatedly until !IsIncrementalGCInProgress(rt).
|
||||
/**
|
||||
* Begin an incremental collection and perform one slice worth of work. When
|
||||
* this function returns, the collection may not be complete.
|
||||
* IncrementalGCSlice() must be called repeatedly until
|
||||
* !IsIncrementalGCInProgress(cx).
|
||||
*
|
||||
* Note: SpiderMonkey's GC is not realtime. Slices in practice may be longer or
|
||||
* shorter than the requested interval.
|
||||
*/
|
||||
extern JS_FRIEND_API(void)
|
||||
IncrementalGC(JSRuntime *rt, gcreason::Reason reason, int64_t millis = 0);
|
||||
extern JS_PUBLIC_API(void)
|
||||
StartIncrementalGC(JSContext* cx, JSGCInvocationKind gckind, gcreason::Reason reason,
|
||||
int64_t millis = 0);
|
||||
|
||||
/*
|
||||
* If IsIncrementalGCInProgress(rt), this call finishes the ongoing collection
|
||||
* by performing an arbitrarily long slice. If !IsIncrementalGCInProgress(rt),
|
||||
* this is equivalent to GCForReason. When this function returns,
|
||||
* IsIncrementalGCInProgress(rt) will always be false.
|
||||
/**
|
||||
* Perform a slice of an ongoing incremental collection. When this function
|
||||
* returns, the collection may not be complete. It must be called repeatedly
|
||||
* until !IsIncrementalGCInProgress(cx).
|
||||
*
|
||||
* Note: SpiderMonkey's GC is not realtime. Slices in practice may be longer or
|
||||
* shorter than the requested interval.
|
||||
*/
|
||||
extern JS_FRIEND_API(void)
|
||||
FinishIncrementalGC(JSRuntime *rt, gcreason::Reason reason);
|
||||
extern JS_PUBLIC_API(void)
|
||||
IncrementalGCSlice(JSContext* cx, gcreason::Reason reason, int64_t millis = 0);
|
||||
|
||||
/**
|
||||
* If IsIncrementalGCInProgress(cx), this call finishes the ongoing collection
|
||||
* by performing an arbitrarily long slice. If !IsIncrementalGCInProgress(cx),
|
||||
* this is equivalent to GCForReason. When this function returns,
|
||||
* IsIncrementalGCInProgress(cx) will always be false.
|
||||
*/
|
||||
extern JS_PUBLIC_API(void)
|
||||
FinishIncrementalGC(JSContext* cx, gcreason::Reason reason);
|
||||
|
||||
/**
|
||||
* If IsIncrementalGCInProgress(cx), this call aborts the ongoing collection and
|
||||
* performs whatever work needs to be done to return the collector to its idle
|
||||
* state. This may take an arbitrarily long time. When this function returns,
|
||||
* IsIncrementalGCInProgress(cx) will always be false.
|
||||
*/
|
||||
extern JS_PUBLIC_API(void)
|
||||
AbortIncrementalGC(JSContext* cx);
|
||||
|
||||
namespace dbg {
|
||||
|
||||
// The `JS::dbg::GarbageCollectionEvent` class is essentially a view of the
|
||||
// `js::gcstats::Statistics` data without the uber implementation-specific bits.
|
||||
// It should generally be palatable for web developers.
|
||||
class GarbageCollectionEvent
|
||||
{
|
||||
// The major GC number of the GC cycle this data pertains to.
|
||||
uint64_t majorGCNumber_;
|
||||
|
||||
// Reference to a non-owned, statically allocated C string. This is a very
|
||||
// short reason explaining why a GC was triggered.
|
||||
const char* reason;
|
||||
|
||||
// Reference to a nullable, non-owned, statically allocated C string. If the
|
||||
// collection was forced to be non-incremental, this is a short reason of
|
||||
// why the GC could not perform an incremental collection.
|
||||
const char* nonincrementalReason;
|
||||
|
||||
// Represents a single slice of a possibly multi-slice incremental garbage
|
||||
// collection.
|
||||
struct Collection {
|
||||
double startTimestamp;
|
||||
double endTimestamp;
|
||||
};
|
||||
|
||||
// The set of garbage collection slices that made up this GC cycle.
|
||||
mozilla::Vector<Collection> collections;
|
||||
|
||||
GarbageCollectionEvent(const GarbageCollectionEvent& rhs) = delete;
|
||||
GarbageCollectionEvent& operator=(const GarbageCollectionEvent& rhs) = delete;
|
||||
|
||||
public:
|
||||
explicit GarbageCollectionEvent(uint64_t majorGCNum)
|
||||
: majorGCNumber_(majorGCNum)
|
||||
, reason(nullptr)
|
||||
, nonincrementalReason(nullptr)
|
||||
, collections()
|
||||
{ }
|
||||
|
||||
using Ptr = js::UniquePtr<GarbageCollectionEvent>;
|
||||
static Ptr Create(JSRuntime* rt, ::js::gcstats::Statistics& stats, uint64_t majorGCNumber);
|
||||
|
||||
JSObject* toJSObject(JSContext* cx) const;
|
||||
|
||||
uint64_t majorGCNumber() const { return majorGCNumber_; }
|
||||
};
|
||||
|
||||
} // namespace dbg
|
||||
|
||||
enum GCProgress {
|
||||
/*
|
||||
|
|
@ -244,37 +332,80 @@ enum GCProgress {
|
|||
GC_CYCLE_END
|
||||
};
|
||||
|
||||
struct JS_FRIEND_API(GCDescription) {
|
||||
bool isCompartment_;
|
||||
struct JS_PUBLIC_API(GCDescription) {
|
||||
bool isZone_;
|
||||
JSGCInvocationKind invocationKind_;
|
||||
gcreason::Reason reason_;
|
||||
|
||||
explicit GCDescription(bool isCompartment)
|
||||
: isCompartment_(isCompartment) {}
|
||||
GCDescription(bool isZone, JSGCInvocationKind kind, gcreason::Reason reason)
|
||||
: isZone_(isZone), invocationKind_(kind), reason_(reason) {}
|
||||
|
||||
jschar *formatMessage(JSRuntime *rt) const;
|
||||
jschar *formatJSON(JSRuntime *rt, uint64_t timestamp) const;
|
||||
char16_t* formatSliceMessage(JSContext* cx) const;
|
||||
char16_t* formatSummaryMessage(JSContext* cx) const;
|
||||
char16_t* formatJSON(JSContext* cx, uint64_t timestamp) const;
|
||||
|
||||
JS::dbg::GarbageCollectionEvent::Ptr toGCEvent(JSContext* cx) const;
|
||||
};
|
||||
|
||||
typedef void
|
||||
(* GCSliceCallback)(JSRuntime *rt, GCProgress progress, const GCDescription &desc);
|
||||
(* GCSliceCallback)(JSContext* cx, GCProgress progress, const GCDescription& desc);
|
||||
|
||||
/*
|
||||
/**
|
||||
* The GC slice callback is called at the beginning and end of each slice. This
|
||||
* callback may be used for GC notifications as well as to perform additional
|
||||
* marking.
|
||||
*/
|
||||
extern JS_FRIEND_API(GCSliceCallback)
|
||||
SetGCSliceCallback(JSRuntime *rt, GCSliceCallback callback);
|
||||
extern JS_PUBLIC_API(GCSliceCallback)
|
||||
SetGCSliceCallback(JSContext* cx, GCSliceCallback callback);
|
||||
|
||||
/*
|
||||
/**
|
||||
* Describes the progress of an observed nursery collection.
|
||||
*/
|
||||
enum class GCNurseryProgress {
|
||||
/**
|
||||
* The nursery collection is starting.
|
||||
*/
|
||||
GC_NURSERY_COLLECTION_START,
|
||||
/**
|
||||
* The nursery collection is ending.
|
||||
*/
|
||||
GC_NURSERY_COLLECTION_END
|
||||
};
|
||||
|
||||
/**
|
||||
* A nursery collection callback receives the progress of the nursery collection
|
||||
* and the reason for the collection.
|
||||
*/
|
||||
using GCNurseryCollectionCallback = void(*)(JSContext* cx, GCNurseryProgress progress,
|
||||
gcreason::Reason reason);
|
||||
|
||||
/**
|
||||
* Set the nursery collection callback for the given runtime. When set, it will
|
||||
* be called at the start and end of every nursery collection.
|
||||
*/
|
||||
extern JS_PUBLIC_API(GCNurseryCollectionCallback)
|
||||
SetGCNurseryCollectionCallback(JSContext* cx, GCNurseryCollectionCallback callback);
|
||||
|
||||
typedef void
|
||||
(* DoCycleCollectionCallback)(JSContext* cx);
|
||||
|
||||
/**
|
||||
* The purge gray callback is called after any COMPARTMENT_REVIVED GC in which
|
||||
* the majority of compartments have been marked gray.
|
||||
*/
|
||||
extern JS_PUBLIC_API(DoCycleCollectionCallback)
|
||||
SetDoCycleCollectionCallback(JSContext* cx, DoCycleCollectionCallback callback);
|
||||
|
||||
/**
|
||||
* Incremental GC defaults to enabled, but may be disabled for testing or in
|
||||
* embeddings that have not yet implemented barriers on their native classes.
|
||||
* There is not currently a way to re-enable incremental GC once it has been
|
||||
* disabled on the runtime.
|
||||
*/
|
||||
extern JS_FRIEND_API(void)
|
||||
DisableIncrementalGC(JSRuntime *rt);
|
||||
extern JS_PUBLIC_API(void)
|
||||
DisableIncrementalGC(JSContext* cx);
|
||||
|
||||
/*
|
||||
/**
|
||||
* Returns true if incremental GC is enabled. Simply having incremental GC
|
||||
* enabled is not sufficient to ensure incremental collections are happening.
|
||||
* See the comment "Incremental GC" above for reasons why incremental GC may be
|
||||
|
|
@ -282,45 +413,42 @@ DisableIncrementalGC(JSRuntime *rt);
|
|||
* GCDescription returned by GCSliceCallback may help narrow down the cause if
|
||||
* collections are not happening incrementally when expected.
|
||||
*/
|
||||
extern JS_FRIEND_API(bool)
|
||||
IsIncrementalGCEnabled(JSRuntime *rt);
|
||||
extern JS_PUBLIC_API(bool)
|
||||
IsIncrementalGCEnabled(JSContext* cx);
|
||||
|
||||
/*
|
||||
/**
|
||||
* Returns true while an incremental GC is ongoing, both when actively
|
||||
* collecting and between slices.
|
||||
*/
|
||||
JS_FRIEND_API(bool)
|
||||
IsIncrementalGCInProgress(JSRuntime *rt);
|
||||
extern JS_PUBLIC_API(bool)
|
||||
IsIncrementalGCInProgress(JSContext* cx);
|
||||
|
||||
/*
|
||||
* Returns true when writes to GC things must call an incremental (pre) barrier.
|
||||
* This is generally only true when running mutator code in-between GC slices.
|
||||
* At other times, the barrier may be elided for performance.
|
||||
*/
|
||||
extern JS_FRIEND_API(bool)
|
||||
IsIncrementalBarrierNeeded(JSRuntime *rt);
|
||||
|
||||
extern JS_FRIEND_API(bool)
|
||||
IsIncrementalBarrierNeeded(JSContext *cx);
|
||||
extern JS_PUBLIC_API(bool)
|
||||
IsIncrementalBarrierNeeded(JSContext* cx);
|
||||
|
||||
/*
|
||||
* Notify the GC that a reference to a GC thing is about to be overwritten.
|
||||
* These methods must be called if IsIncrementalBarrierNeeded.
|
||||
*/
|
||||
extern JS_FRIEND_API(void)
|
||||
IncrementalReferenceBarrier(void *ptr, JSGCTraceKind kind);
|
||||
extern JS_PUBLIC_API(void)
|
||||
IncrementalReferenceBarrier(GCCellPtr thing);
|
||||
|
||||
extern JS_FRIEND_API(void)
|
||||
IncrementalValueBarrier(const Value &v);
|
||||
extern JS_PUBLIC_API(void)
|
||||
IncrementalValueBarrier(const Value& v);
|
||||
|
||||
extern JS_FRIEND_API(void)
|
||||
IncrementalObjectBarrier(JSObject *obj);
|
||||
extern JS_PUBLIC_API(void)
|
||||
IncrementalObjectBarrier(JSObject* obj);
|
||||
|
||||
/*
|
||||
/**
|
||||
* Returns true if the most recent GC ran incrementally.
|
||||
*/
|
||||
extern JS_FRIEND_API(bool)
|
||||
WasIncrementalGC(JSRuntime *rt);
|
||||
extern JS_PUBLIC_API(bool)
|
||||
WasIncrementalGC(JSContext* cx);
|
||||
|
||||
/*
|
||||
* Generational GC:
|
||||
|
|
@ -330,75 +458,106 @@ WasIncrementalGC(JSRuntime *rt);
|
|||
* --enable-gcgenerational.
|
||||
*/
|
||||
|
||||
/* Ensure that generational GC is disabled within some scope. */
|
||||
class JS_FRIEND_API(AutoDisableGenerationalGC)
|
||||
/** Ensure that generational GC is disabled within some scope. */
|
||||
class JS_PUBLIC_API(AutoDisableGenerationalGC)
|
||||
{
|
||||
js::gc::GCRuntime *gc;
|
||||
#if defined(JSGC_GENERATIONAL) && defined(JS_GC_ZEAL)
|
||||
bool restartVerifier;
|
||||
#endif
|
||||
js::gc::GCRuntime* gc;
|
||||
|
||||
public:
|
||||
explicit AutoDisableGenerationalGC(JSRuntime *rt);
|
||||
explicit AutoDisableGenerationalGC(JSRuntime* rt);
|
||||
~AutoDisableGenerationalGC();
|
||||
};
|
||||
|
||||
/*
|
||||
/**
|
||||
* Returns true if generational allocation and collection is currently enabled
|
||||
* on the given runtime.
|
||||
*/
|
||||
extern JS_FRIEND_API(bool)
|
||||
IsGenerationalGCEnabled(JSRuntime *rt);
|
||||
extern JS_PUBLIC_API(bool)
|
||||
IsGenerationalGCEnabled(JSRuntime* rt);
|
||||
|
||||
/*
|
||||
/**
|
||||
* Returns the GC's "number". This does not correspond directly to the number
|
||||
* of GCs that have been run, but is guaranteed to be monotonically increasing
|
||||
* with GC activity.
|
||||
*/
|
||||
extern JS_FRIEND_API(size_t)
|
||||
extern JS_PUBLIC_API(size_t)
|
||||
GetGCNumber();
|
||||
|
||||
/*
|
||||
* The GC does not immediately return the unused memory freed by a collection
|
||||
* back to the system incase it is needed soon afterwards. This call forces the
|
||||
* GC to return this memory immediately.
|
||||
/**
|
||||
* Pass a subclass of this "abstract" class to callees to require that they
|
||||
* never GC. Subclasses can use assertions or the hazard analysis to ensure no
|
||||
* GC happens.
|
||||
*/
|
||||
extern JS_FRIEND_API(void)
|
||||
ShrinkGCBuffers(JSRuntime *rt);
|
||||
|
||||
/*
|
||||
* Assert if a GC occurs while this class is live. This class does not disable
|
||||
* the static rooting hazard analysis.
|
||||
*/
|
||||
class JS_PUBLIC_API(AutoAssertOnGC)
|
||||
class JS_PUBLIC_API(AutoRequireNoGC)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
js::gc::GCRuntime *gc;
|
||||
protected:
|
||||
AutoRequireNoGC() {}
|
||||
~AutoRequireNoGC() {}
|
||||
};
|
||||
|
||||
/**
|
||||
* Diagnostic assert (see MOZ_DIAGNOSTIC_ASSERT) that GC cannot occur while this
|
||||
* class is live. This class does not disable the static rooting hazard
|
||||
* analysis.
|
||||
*
|
||||
* This works by entering a GC unsafe region, which is checked on allocation and
|
||||
* on GC.
|
||||
*/
|
||||
class JS_PUBLIC_API(AutoAssertNoGC) : public AutoRequireNoGC
|
||||
{
|
||||
js::gc::GCRuntime* gc;
|
||||
size_t gcNumber;
|
||||
|
||||
public:
|
||||
AutoAssertOnGC();
|
||||
explicit AutoAssertOnGC(JSRuntime *rt);
|
||||
~AutoAssertOnGC();
|
||||
AutoAssertNoGC();
|
||||
explicit AutoAssertNoGC(JSRuntime* rt);
|
||||
explicit AutoAssertNoGC(JSContext* cx);
|
||||
~AutoAssertNoGC();
|
||||
};
|
||||
|
||||
static void VerifyIsSafeToGC(JSRuntime *rt);
|
||||
/**
|
||||
* Assert if an allocation of a GC thing occurs while this class is live. This
|
||||
* class does not disable the static rooting hazard analysis.
|
||||
*/
|
||||
class JS_PUBLIC_API(AutoAssertNoAlloc)
|
||||
{
|
||||
#ifdef JS_DEBUG
|
||||
js::gc::GCRuntime* gc;
|
||||
|
||||
public:
|
||||
AutoAssertNoAlloc() : gc(nullptr) {}
|
||||
explicit AutoAssertNoAlloc(JSContext* cx);
|
||||
void disallowAlloc(JSRuntime* rt);
|
||||
~AutoAssertNoAlloc();
|
||||
#else
|
||||
public:
|
||||
AutoAssertOnGC() {}
|
||||
explicit AutoAssertOnGC(JSRuntime *rt) {}
|
||||
~AutoAssertOnGC() {}
|
||||
|
||||
static void VerifyIsSafeToGC(JSRuntime *rt) {}
|
||||
AutoAssertNoAlloc() {}
|
||||
explicit AutoAssertNoAlloc(JSContext* cx) {}
|
||||
void disallowAlloc(JSRuntime* rt) {}
|
||||
#endif
|
||||
};
|
||||
|
||||
/*
|
||||
* Disable the static rooting hazard analysis in the live region, but assert if
|
||||
* any GC occurs while this guard object is live. This is most useful to help
|
||||
* the exact rooting hazard analysis in complex regions, since it cannot
|
||||
* understand dataflow.
|
||||
/**
|
||||
* Assert if a GC barrier is invoked while this class is live. This class does
|
||||
* not disable the static rooting hazard analysis.
|
||||
*/
|
||||
class JS_PUBLIC_API(AutoAssertOnBarrier)
|
||||
{
|
||||
JSContext* context;
|
||||
bool prev;
|
||||
|
||||
public:
|
||||
explicit AutoAssertOnBarrier(JSContext* cx);
|
||||
~AutoAssertOnBarrier();
|
||||
};
|
||||
|
||||
/**
|
||||
* Disable the static rooting hazard analysis in the live region and assert if
|
||||
* any allocation that could potentially trigger a GC occurs while this guard
|
||||
* object is live. This is most useful to help the exact rooting hazard analysis
|
||||
* in complex regions, since it cannot understand dataflow.
|
||||
*
|
||||
* Note: GC behavior is unpredictable even when deterministice and is generally
|
||||
* Note: GC behavior is unpredictable even when deterministic and is generally
|
||||
* non-deterministic in practice. The fact that this guard has not
|
||||
* asserted is not a guarantee that a GC cannot happen in the guarded
|
||||
* region. As a rule, anyone performing a GC unsafe action should
|
||||
|
|
@ -406,36 +565,115 @@ class JS_PUBLIC_API(AutoAssertOnGC)
|
|||
* that the hazard analysis is correct for that code, rather than relying
|
||||
* on this class.
|
||||
*/
|
||||
class JS_PUBLIC_API(AutoSuppressGCAnalysis) : public AutoAssertOnGC
|
||||
class JS_PUBLIC_API(AutoSuppressGCAnalysis) : public AutoAssertNoAlloc
|
||||
{
|
||||
public:
|
||||
AutoSuppressGCAnalysis() : AutoAssertOnGC() {}
|
||||
explicit AutoSuppressGCAnalysis(JSRuntime *rt) : AutoAssertOnGC(rt) {}
|
||||
AutoSuppressGCAnalysis() : AutoAssertNoAlloc() {}
|
||||
explicit AutoSuppressGCAnalysis(JSContext* cx) : AutoAssertNoAlloc(cx) {}
|
||||
} JS_HAZ_GC_SUPPRESSED;
|
||||
|
||||
/**
|
||||
* Assert that code is only ever called from a GC callback, disable the static
|
||||
* rooting hazard analysis and assert if any allocation that could potentially
|
||||
* trigger a GC occurs while this guard object is live.
|
||||
*
|
||||
* This is useful to make the static analysis ignore code that runs in GC
|
||||
* callbacks.
|
||||
*/
|
||||
class JS_PUBLIC_API(AutoAssertGCCallback) : public AutoSuppressGCAnalysis
|
||||
{
|
||||
public:
|
||||
explicit AutoAssertGCCallback(JSObject* obj);
|
||||
};
|
||||
|
||||
/*
|
||||
/**
|
||||
* Place AutoCheckCannotGC in scopes that you believe can never GC. These
|
||||
* annotations will be verified both dynamically via AutoAssertOnGC, and
|
||||
* annotations will be verified both dynamically via AutoAssertNoGC, and
|
||||
* statically with the rooting hazard analysis (implemented by making the
|
||||
* analysis consider AutoCheckCannotGC to be a GC pointer, and therefore
|
||||
* complain if it is live across a GC call.) It is useful when dealing with
|
||||
* internal pointers to GC things where the GC thing itself may not be present
|
||||
* for the static analysis: e.g. acquiring inline chars from a JSString* on the
|
||||
* heap.
|
||||
*
|
||||
* We only do the assertion checking in DEBUG builds.
|
||||
*/
|
||||
class JS_PUBLIC_API(AutoCheckCannotGC) : public AutoAssertOnGC
|
||||
#ifdef DEBUG
|
||||
class JS_PUBLIC_API(AutoCheckCannotGC) : public AutoAssertNoGC
|
||||
{
|
||||
public:
|
||||
AutoCheckCannotGC() : AutoAssertOnGC() {}
|
||||
explicit AutoCheckCannotGC(JSRuntime *rt) : AutoAssertOnGC(rt) {}
|
||||
};
|
||||
AutoCheckCannotGC() : AutoAssertNoGC() {}
|
||||
explicit AutoCheckCannotGC(JSContext* cx) : AutoAssertNoGC(cx) {}
|
||||
} JS_HAZ_GC_INVALIDATED;
|
||||
#else
|
||||
class JS_PUBLIC_API(AutoCheckCannotGC) : public AutoRequireNoGC
|
||||
{
|
||||
public:
|
||||
AutoCheckCannotGC() {}
|
||||
explicit AutoCheckCannotGC(JSContext* cx) {}
|
||||
} JS_HAZ_GC_INVALIDATED;
|
||||
#endif
|
||||
|
||||
/*
|
||||
/**
|
||||
* Unsets the gray bit for anything reachable from |thing|. |kind| should not be
|
||||
* JSTRACE_SHAPE. |thing| should be non-null.
|
||||
* JS::TraceKind::Shape. |thing| should be non-null. The return value indicates
|
||||
* if anything was unmarked.
|
||||
*/
|
||||
extern JS_FRIEND_API(bool)
|
||||
UnmarkGrayGCThingRecursively(void *thing, JSGCTraceKind kind);
|
||||
UnmarkGrayGCThingRecursively(GCCellPtr thing);
|
||||
|
||||
} /* namespace JS */
|
||||
|
||||
namespace js {
|
||||
namespace gc {
|
||||
|
||||
static MOZ_ALWAYS_INLINE void
|
||||
ExposeGCThingToActiveJS(JS::GCCellPtr thing)
|
||||
{
|
||||
// GC things residing in the nursery cannot be gray: they have no mark bits.
|
||||
// All live objects in the nursery are moved to tenured at the beginning of
|
||||
// each GC slice, so the gray marker never sees nursery things.
|
||||
if (IsInsideNursery(thing.asCell()))
|
||||
return;
|
||||
|
||||
// There's nothing to do for permanent GC things that might be owned by
|
||||
// another runtime.
|
||||
if (thing.mayBeOwnedByOtherRuntime())
|
||||
return;
|
||||
|
||||
JS::shadow::Runtime* rt = detail::GetCellRuntime(thing.asCell());
|
||||
MOZ_DIAGNOSTIC_ASSERT(rt->allowGCBarriers());
|
||||
|
||||
if (IsIncrementalBarrierNeededOnTenuredGCThing(rt, thing))
|
||||
JS::IncrementalReferenceBarrier(thing);
|
||||
else if (!thing.mayBeOwnedByOtherRuntime() && js::gc::detail::CellIsMarkedGray(thing.asCell()))
|
||||
JS::UnmarkGrayGCThingRecursively(thing);
|
||||
}
|
||||
|
||||
static MOZ_ALWAYS_INLINE void
|
||||
MarkGCThingAsLive(JSRuntime* aRt, JS::GCCellPtr thing)
|
||||
{
|
||||
// Any object in the nursery will not be freed during any GC running at that
|
||||
// time.
|
||||
if (IsInsideNursery(thing.asCell()))
|
||||
return;
|
||||
|
||||
// There's nothing to do for permanent GC things that might be owned by
|
||||
// another runtime.
|
||||
if (thing.mayBeOwnedByOtherRuntime())
|
||||
return;
|
||||
|
||||
JS::shadow::Runtime* rt = JS::shadow::Runtime::asShadowRuntime(aRt);
|
||||
MOZ_DIAGNOSTIC_ASSERT(rt->allowGCBarriers());
|
||||
|
||||
if (IsIncrementalBarrierNeededOnTenuredGCThing(rt, thing))
|
||||
JS::IncrementalReferenceBarrier(thing);
|
||||
}
|
||||
|
||||
} /* namespace gc */
|
||||
} /* namespace js */
|
||||
|
||||
namespace JS {
|
||||
|
||||
/*
|
||||
* This should be called when an object that is marked gray is exposed to the JS
|
||||
|
|
@ -444,55 +682,26 @@ UnmarkGrayGCThingRecursively(void *thing, JSGCTraceKind kind);
|
|||
* we conservatively mark the object black.
|
||||
*/
|
||||
static MOZ_ALWAYS_INLINE void
|
||||
ExposeGCThingToActiveJS(void *thing, JSGCTraceKind kind)
|
||||
ExposeObjectToActiveJS(JSObject* obj)
|
||||
{
|
||||
MOZ_ASSERT(kind != JSTRACE_SHAPE);
|
||||
|
||||
shadow::Runtime *rt = js::gc::GetGCThingRuntime(thing);
|
||||
#ifdef JSGC_GENERATIONAL
|
||||
/*
|
||||
* GC things residing in the nursery cannot be gray: they have no mark bits.
|
||||
* All live objects in the nursery are moved to tenured at the beginning of
|
||||
* each GC slice, so the gray marker never sees nursery things.
|
||||
*/
|
||||
if (js::gc::IsInsideNursery((js::gc::Cell *)thing))
|
||||
return;
|
||||
#endif
|
||||
if (IsIncrementalBarrierNeededOnGCThing(rt, thing, kind))
|
||||
IncrementalReferenceBarrier(thing, kind);
|
||||
else if (GCThingIsMarkedGray(thing))
|
||||
UnmarkGrayGCThingRecursively(thing, kind);
|
||||
MOZ_ASSERT(obj);
|
||||
js::gc::ExposeGCThingToActiveJS(GCCellPtr(obj));
|
||||
}
|
||||
|
||||
static MOZ_ALWAYS_INLINE void
|
||||
ExposeObjectToActiveJS(JSObject *obj)
|
||||
ExposeScriptToActiveJS(JSScript* script)
|
||||
{
|
||||
ExposeGCThingToActiveJS(obj, JSTRACE_OBJECT);
|
||||
js::gc::ExposeGCThingToActiveJS(GCCellPtr(script));
|
||||
}
|
||||
|
||||
/*
|
||||
* If a GC is currently marking, mark the object black.
|
||||
* If a GC is currently marking, mark the string black.
|
||||
*/
|
||||
static MOZ_ALWAYS_INLINE void
|
||||
MarkGCThingAsLive(JSRuntime *rt_, void *thing, JSGCTraceKind kind)
|
||||
MarkStringAsLive(Zone* zone, JSString* string)
|
||||
{
|
||||
shadow::Runtime *rt = shadow::Runtime::asShadowRuntime(rt_);
|
||||
#ifdef JSGC_GENERATIONAL
|
||||
/*
|
||||
* Any object in the nursery will not be freed during any GC running at that time.
|
||||
*/
|
||||
if (js::gc::IsInsideNursery((js::gc::Cell *)thing))
|
||||
return;
|
||||
#endif
|
||||
if (IsIncrementalBarrierNeededOnGCThing(rt, thing, kind))
|
||||
IncrementalReferenceBarrier(thing, kind);
|
||||
}
|
||||
|
||||
static MOZ_ALWAYS_INLINE void
|
||||
MarkStringAsLive(Zone *zone, JSString *string)
|
||||
{
|
||||
JSRuntime *rt = JS::shadow::Zone::asShadowZone(zone)->runtimeFromMainThread();
|
||||
MarkGCThingAsLive(rt, string, JSTRACE_STRING);
|
||||
JSRuntime* rt = JS::shadow::Zone::asShadowZone(zone)->runtimeFromMainThread();
|
||||
js::gc::MarkGCThingAsLive(rt, GCCellPtr(string));
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -501,13 +710,13 @@ MarkStringAsLive(Zone *zone, JSString *string)
|
|||
* Note: this is not related to the PokeGC in nsJSEnvironment.
|
||||
*/
|
||||
extern JS_FRIEND_API(void)
|
||||
PokeGC(JSRuntime *rt);
|
||||
PokeGC(JSContext* cx);
|
||||
|
||||
/*
|
||||
* Internal to Firefox.
|
||||
*/
|
||||
extern JS_FRIEND_API(void)
|
||||
NotifyDidPaint(JSRuntime *rt);
|
||||
NotifyDidPaint(JSContext* cx);
|
||||
|
||||
} /* namespace JS */
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,57 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* vim: set ts=8 sts=4 et sw=4 tw=99:
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef js_GCAnnotations_h
|
||||
#define js_GCAnnotations_h
|
||||
|
||||
// Set of annotations for the rooting hazard analysis, used to categorize types
|
||||
// and functions.
|
||||
#ifdef XGILL_PLUGIN
|
||||
|
||||
// Mark a type as being a GC thing (eg js::gc::Cell has this annotation).
|
||||
# define JS_HAZ_GC_THING __attribute__((tag("GC Thing")))
|
||||
|
||||
// Mark a type as holding a pointer to a GC thing (eg JS::Value has this
|
||||
// annotation.)
|
||||
# define JS_HAZ_GC_POINTER __attribute__((tag("GC Pointer")))
|
||||
|
||||
// Mark a type as a rooted pointer, suitable for use on the stack (eg all
|
||||
// Rooted<T> instantiations should have this.)
|
||||
# define JS_HAZ_ROOTED __attribute__((tag("Rooted Pointer")))
|
||||
|
||||
// Mark a type as something that should not be held live across a GC, but which
|
||||
// is not itself a GC pointer.
|
||||
# define JS_HAZ_GC_INVALIDATED __attribute__((tag("Invalidated by GC")))
|
||||
|
||||
// Mark a type that would otherwise be considered a GC Pointer (eg because it
|
||||
// contains a JS::Value field) as a non-GC pointer. It is handled almost the
|
||||
// same in the analysis as a rooted pointer, except it will not be reported as
|
||||
// an unnecessary root if used across a GC call. This should rarely be used,
|
||||
// but makes sense for something like ErrorResult, which only contains a GC
|
||||
// pointer when it holds an exception (and it does its own rooting,
|
||||
// conditionally.)
|
||||
# define JS_HAZ_NON_GC_POINTER __attribute__((tag("Suppressed GC Pointer")))
|
||||
|
||||
// Mark a function as something that runs a garbage collection, potentially
|
||||
// invalidating GC pointers.
|
||||
# define JS_HAZ_GC_CALL __attribute__((tag("GC Call")))
|
||||
|
||||
// Mark an RAII class as suppressing GC within its scope.
|
||||
# define JS_HAZ_GC_SUPPRESSED __attribute__((tag("Suppress GC")))
|
||||
|
||||
#else
|
||||
|
||||
# define JS_HAZ_GC_THING
|
||||
# define JS_HAZ_GC_POINTER
|
||||
# define JS_HAZ_ROOTED
|
||||
# define JS_HAZ_GC_INVALIDATED
|
||||
# define JS_HAZ_NON_GC_POINTER
|
||||
# define JS_HAZ_GC_CALL
|
||||
# define JS_HAZ_GC_SUPPRESSED
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* js_GCAnnotations_h */
|
||||
|
|
@ -0,0 +1,399 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* vim: set ts=8 sts=4 et sw=4 tw=99:
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef GCHashTable_h
|
||||
#define GCHashTable_h
|
||||
|
||||
#include "js/GCPolicyAPI.h"
|
||||
#include "js/HashTable.h"
|
||||
#include "js/RootingAPI.h"
|
||||
#include "js/SweepingAPI.h"
|
||||
#include "js/TracingAPI.h"
|
||||
|
||||
namespace JS {
|
||||
|
||||
// Define a reasonable default GC policy for GC-aware Maps.
|
||||
template <typename Key, typename Value>
|
||||
struct DefaultMapSweepPolicy {
|
||||
static bool needsSweep(Key* key, Value* value) {
|
||||
return GCPolicy<Key>::needsSweep(key) || GCPolicy<Value>::needsSweep(value);
|
||||
}
|
||||
};
|
||||
|
||||
// A GCHashMap is a GC-aware HashMap, meaning that it has additional trace and
|
||||
// sweep methods that know how to visit all keys and values in the table.
|
||||
// HashMaps that contain GC pointers will generally want to use this GCHashMap
|
||||
// specialization instead of HashMap, because this conveniently supports tracing
|
||||
// keys and values, and cleaning up weak entries.
|
||||
//
|
||||
// GCHashMap::trace applies GCPolicy<T>::trace to each entry's key and value.
|
||||
// Most types of GC pointers already have appropriate specializations of
|
||||
// GCPolicy, so they should just work as keys and values. Any struct type with a
|
||||
// default constructor and trace and sweep functions should work as well. If you
|
||||
// need to define your own GCPolicy specialization, generic helpers can be found
|
||||
// in js/public/TracingAPI.h.
|
||||
//
|
||||
// The MapSweepPolicy template parameter controls how the table drops entries
|
||||
// when swept. GCHashMap::sweep applies MapSweepPolicy::needsSweep to each table
|
||||
// entry; if it returns true, the entry is dropped. The default MapSweepPolicy
|
||||
// drops the entry if either the key or value is about to be finalized,
|
||||
// according to its GCPolicy<T>::needsSweep method. (This default is almost
|
||||
// always fine: it's hard to imagine keeping such an entry around anyway.)
|
||||
//
|
||||
// Note that this HashMap only knows *how* to trace and sweep, but it does not
|
||||
// itself cause tracing or sweeping to be invoked. For tracing, it must be used
|
||||
// with Rooted or PersistentRooted, or barriered and traced manually. For
|
||||
// sweeping, currently it requires an explicit call to <map>.sweep().
|
||||
template <typename Key,
|
||||
typename Value,
|
||||
typename HashPolicy = js::DefaultHasher<Key>,
|
||||
typename AllocPolicy = js::TempAllocPolicy,
|
||||
typename MapSweepPolicy = DefaultMapSweepPolicy<Key, Value>>
|
||||
class GCHashMap : public js::HashMap<Key, Value, HashPolicy, AllocPolicy>
|
||||
{
|
||||
using Base = js::HashMap<Key, Value, HashPolicy, AllocPolicy>;
|
||||
|
||||
public:
|
||||
explicit GCHashMap(AllocPolicy a = AllocPolicy()) : Base(a) {}
|
||||
|
||||
static void trace(GCHashMap* map, JSTracer* trc) { map->trace(trc); }
|
||||
void trace(JSTracer* trc) {
|
||||
if (!this->initialized())
|
||||
return;
|
||||
for (typename Base::Enum e(*this); !e.empty(); e.popFront()) {
|
||||
GCPolicy<Value>::trace(trc, &e.front().value(), "hashmap value");
|
||||
GCPolicy<Key>::trace(trc, &e.front().mutableKey(), "hashmap key");
|
||||
}
|
||||
}
|
||||
|
||||
void sweep() {
|
||||
if (!this->initialized())
|
||||
return;
|
||||
|
||||
for (typename Base::Enum e(*this); !e.empty(); e.popFront()) {
|
||||
if (MapSweepPolicy::needsSweep(&e.front().mutableKey(), &e.front().value()))
|
||||
e.removeFront();
|
||||
}
|
||||
}
|
||||
|
||||
// GCHashMap is movable
|
||||
GCHashMap(GCHashMap&& rhs) : Base(mozilla::Move(rhs)) {}
|
||||
void operator=(GCHashMap&& rhs) {
|
||||
MOZ_ASSERT(this != &rhs, "self-move assignment is prohibited");
|
||||
Base::operator=(mozilla::Move(rhs));
|
||||
}
|
||||
|
||||
private:
|
||||
// GCHashMap is not copyable or assignable
|
||||
GCHashMap(const GCHashMap& hm) = delete;
|
||||
GCHashMap& operator=(const GCHashMap& hm) = delete;
|
||||
};
|
||||
|
||||
} // namespace JS
|
||||
|
||||
namespace js {
|
||||
|
||||
// HashMap that supports rekeying.
|
||||
//
|
||||
// If your keys are pointers to something like JSObject that can be tenured or
|
||||
// compacted, prefer to use GCHashMap with MovableCellHasher, which takes
|
||||
// advantage of the Zone's stable id table to make rekeying unnecessary.
|
||||
template <typename Key,
|
||||
typename Value,
|
||||
typename HashPolicy = DefaultHasher<Key>,
|
||||
typename AllocPolicy = TempAllocPolicy,
|
||||
typename MapSweepPolicy = JS::DefaultMapSweepPolicy<Key, Value>>
|
||||
class GCRekeyableHashMap : public JS::GCHashMap<Key, Value, HashPolicy, AllocPolicy, MapSweepPolicy>
|
||||
{
|
||||
using Base = JS::GCHashMap<Key, Value, HashPolicy, AllocPolicy>;
|
||||
|
||||
public:
|
||||
explicit GCRekeyableHashMap(AllocPolicy a = AllocPolicy()) : Base(a) {}
|
||||
|
||||
void sweep() {
|
||||
if (!this->initialized())
|
||||
return;
|
||||
|
||||
for (typename Base::Enum e(*this); !e.empty(); e.popFront()) {
|
||||
Key key(e.front().key());
|
||||
if (MapSweepPolicy::needsSweep(&key, &e.front().value()))
|
||||
e.removeFront();
|
||||
else if (!HashPolicy::match(key, e.front().key()))
|
||||
e.rekeyFront(key);
|
||||
}
|
||||
}
|
||||
|
||||
// GCRekeyableHashMap is movable
|
||||
GCRekeyableHashMap(GCRekeyableHashMap&& rhs) : Base(mozilla::Move(rhs)) {}
|
||||
void operator=(GCRekeyableHashMap&& rhs) {
|
||||
MOZ_ASSERT(this != &rhs, "self-move assignment is prohibited");
|
||||
Base::operator=(mozilla::Move(rhs));
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Outer, typename... Args>
|
||||
class GCHashMapOperations
|
||||
{
|
||||
using Map = JS::GCHashMap<Args...>;
|
||||
using Lookup = typename Map::Lookup;
|
||||
|
||||
const Map& map() const { return static_cast<const Outer*>(this)->get(); }
|
||||
|
||||
public:
|
||||
using AddPtr = typename Map::AddPtr;
|
||||
using Ptr = typename Map::Ptr;
|
||||
using Range = typename Map::Range;
|
||||
|
||||
bool initialized() const { return map().initialized(); }
|
||||
Ptr lookup(const Lookup& l) const { return map().lookup(l); }
|
||||
AddPtr lookupForAdd(const Lookup& l) const { return map().lookupForAdd(l); }
|
||||
Range all() const { return map().all(); }
|
||||
bool empty() const { return map().empty(); }
|
||||
uint32_t count() const { return map().count(); }
|
||||
size_t capacity() const { return map().capacity(); }
|
||||
bool has(const Lookup& l) const { return map().lookup(l).found(); }
|
||||
size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const {
|
||||
return map().sizeOfExcludingThis(mallocSizeOf);
|
||||
}
|
||||
size_t sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const {
|
||||
return mallocSizeOf(this) + map().sizeOfExcludingThis(mallocSizeOf);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Outer, typename... Args>
|
||||
class MutableGCHashMapOperations
|
||||
: public GCHashMapOperations<Outer, Args...>
|
||||
{
|
||||
using Map = JS::GCHashMap<Args...>;
|
||||
using Lookup = typename Map::Lookup;
|
||||
|
||||
Map& map() { return static_cast<Outer*>(this)->get(); }
|
||||
|
||||
public:
|
||||
using AddPtr = typename Map::AddPtr;
|
||||
struct Enum : public Map::Enum { explicit Enum(Outer& o) : Map::Enum(o.map()) {} };
|
||||
using Ptr = typename Map::Ptr;
|
||||
using Range = typename Map::Range;
|
||||
|
||||
bool init(uint32_t len = 16) { return map().init(len); }
|
||||
void clear() { map().clear(); }
|
||||
void finish() { map().finish(); }
|
||||
void remove(Ptr p) { map().remove(p); }
|
||||
|
||||
template<typename KeyInput, typename ValueInput>
|
||||
bool add(AddPtr& p, KeyInput&& k, ValueInput&& v) {
|
||||
return map().add(p, mozilla::Forward<KeyInput>(k), mozilla::Forward<ValueInput>(v));
|
||||
}
|
||||
|
||||
template<typename KeyInput>
|
||||
bool add(AddPtr& p, KeyInput&& k) {
|
||||
return map().add(p, mozilla::Forward<KeyInput>(k), Map::Value());
|
||||
}
|
||||
|
||||
template<typename KeyInput, typename ValueInput>
|
||||
bool relookupOrAdd(AddPtr& p, KeyInput&& k, ValueInput&& v) {
|
||||
return map().relookupOrAdd(p, k,
|
||||
mozilla::Forward<KeyInput>(k),
|
||||
mozilla::Forward<ValueInput>(v));
|
||||
}
|
||||
|
||||
template<typename KeyInput, typename ValueInput>
|
||||
bool put(KeyInput&& k, ValueInput&& v) {
|
||||
return map().put(mozilla::Forward<KeyInput>(k), mozilla::Forward<ValueInput>(v));
|
||||
}
|
||||
|
||||
template<typename KeyInput, typename ValueInput>
|
||||
bool putNew(KeyInput&& k, ValueInput&& v) {
|
||||
return map().putNew(mozilla::Forward<KeyInput>(k), mozilla::Forward<ValueInput>(v));
|
||||
}
|
||||
};
|
||||
|
||||
template <typename A, typename B, typename C, typename D, typename E>
|
||||
class RootedBase<JS::GCHashMap<A,B,C,D,E>>
|
||||
: public MutableGCHashMapOperations<JS::Rooted<JS::GCHashMap<A,B,C,D,E>>, A,B,C,D,E>
|
||||
{};
|
||||
|
||||
template <typename A, typename B, typename C, typename D, typename E>
|
||||
class MutableHandleBase<JS::GCHashMap<A,B,C,D,E>>
|
||||
: public MutableGCHashMapOperations<JS::MutableHandle<JS::GCHashMap<A,B,C,D,E>>, A,B,C,D,E>
|
||||
{};
|
||||
|
||||
template <typename A, typename B, typename C, typename D, typename E>
|
||||
class HandleBase<JS::GCHashMap<A,B,C,D,E>>
|
||||
: public GCHashMapOperations<JS::Handle<JS::GCHashMap<A,B,C,D,E>>, A,B,C,D,E>
|
||||
{};
|
||||
|
||||
template <typename A, typename B, typename C, typename D, typename E>
|
||||
class WeakCacheBase<JS::GCHashMap<A,B,C,D,E>>
|
||||
: public MutableGCHashMapOperations<JS::WeakCache<JS::GCHashMap<A,B,C,D,E>>, A,B,C,D,E>
|
||||
{};
|
||||
|
||||
} // namespace js
|
||||
|
||||
namespace JS {
|
||||
|
||||
// A GCHashSet is a HashSet with an additional trace method that knows
|
||||
// be traced to be kept alive will generally want to use this GCHashSet
|
||||
// specialization in lieu of HashSet.
|
||||
//
|
||||
// Most types of GC pointers can be traced with no extra infrastructure. For
|
||||
// structs and non-gc-pointer members, ensure that there is a specialization of
|
||||
// GCPolicy<T> with an appropriate trace method available to handle the custom
|
||||
// type. Generic helpers can be found in js/public/TracingAPI.h.
|
||||
//
|
||||
// Note that although this HashSet's trace will deal correctly with moved
|
||||
// elements, it does not itself know when to barrier or trace elements. To
|
||||
// function properly it must either be used with Rooted or barriered and traced
|
||||
// manually.
|
||||
template <typename T,
|
||||
typename HashPolicy = js::DefaultHasher<T>,
|
||||
typename AllocPolicy = js::TempAllocPolicy>
|
||||
class GCHashSet : public js::HashSet<T, HashPolicy, AllocPolicy>
|
||||
{
|
||||
using Base = js::HashSet<T, HashPolicy, AllocPolicy>;
|
||||
|
||||
public:
|
||||
explicit GCHashSet(AllocPolicy a = AllocPolicy()) : Base(a) {}
|
||||
|
||||
static void trace(GCHashSet* set, JSTracer* trc) { set->trace(trc); }
|
||||
void trace(JSTracer* trc) {
|
||||
if (!this->initialized())
|
||||
return;
|
||||
for (typename Base::Enum e(*this); !e.empty(); e.popFront())
|
||||
GCPolicy<T>::trace(trc, &e.mutableFront(), "hashset element");
|
||||
}
|
||||
|
||||
void sweep() {
|
||||
if (!this->initialized())
|
||||
return;
|
||||
for (typename Base::Enum e(*this); !e.empty(); e.popFront()) {
|
||||
if (GCPolicy<T>::needsSweep(&e.mutableFront()))
|
||||
e.removeFront();
|
||||
}
|
||||
}
|
||||
|
||||
// GCHashSet is movable
|
||||
GCHashSet(GCHashSet&& rhs) : Base(mozilla::Move(rhs)) {}
|
||||
void operator=(GCHashSet&& rhs) {
|
||||
MOZ_ASSERT(this != &rhs, "self-move assignment is prohibited");
|
||||
Base::operator=(mozilla::Move(rhs));
|
||||
}
|
||||
|
||||
private:
|
||||
// GCHashSet is not copyable or assignable
|
||||
GCHashSet(const GCHashSet& hs) = delete;
|
||||
GCHashSet& operator=(const GCHashSet& hs) = delete;
|
||||
};
|
||||
|
||||
} // namespace JS
|
||||
|
||||
namespace js {
|
||||
|
||||
template <typename Outer, typename... Args>
|
||||
class GCHashSetOperations
|
||||
{
|
||||
using Set = JS::GCHashSet<Args...>;
|
||||
using Lookup = typename Set::Lookup;
|
||||
|
||||
const Set& set() const { return static_cast<const Outer*>(this)->get(); }
|
||||
|
||||
public:
|
||||
using AddPtr = typename Set::AddPtr;
|
||||
using Entry = typename Set::Entry;
|
||||
using Ptr = typename Set::Ptr;
|
||||
using Range = typename Set::Range;
|
||||
|
||||
bool initialized() const { return set().initialized(); }
|
||||
Ptr lookup(const Lookup& l) const { return set().lookup(l); }
|
||||
AddPtr lookupForAdd(const Lookup& l) const { return set().lookupForAdd(l); }
|
||||
Range all() const { return set().all(); }
|
||||
bool empty() const { return set().empty(); }
|
||||
uint32_t count() const { return set().count(); }
|
||||
size_t capacity() const { return set().capacity(); }
|
||||
bool has(const Lookup& l) const { return set().lookup(l).found(); }
|
||||
size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const {
|
||||
return set().sizeOfExcludingThis(mallocSizeOf);
|
||||
}
|
||||
size_t sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const {
|
||||
return mallocSizeOf(this) + set().sizeOfExcludingThis(mallocSizeOf);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Outer, typename... Args>
|
||||
class MutableGCHashSetOperations
|
||||
: public GCHashSetOperations<Outer, Args...>
|
||||
{
|
||||
using Set = JS::GCHashSet<Args...>;
|
||||
using Lookup = typename Set::Lookup;
|
||||
|
||||
Set& set() { return static_cast<Outer*>(this)->get(); }
|
||||
|
||||
public:
|
||||
using AddPtr = typename Set::AddPtr;
|
||||
using Entry = typename Set::Entry;
|
||||
struct Enum : public Set::Enum { explicit Enum(Outer& o) : Set::Enum(o.set()) {} };
|
||||
using Ptr = typename Set::Ptr;
|
||||
using Range = typename Set::Range;
|
||||
|
||||
bool init(uint32_t len = 16) { return set().init(len); }
|
||||
void clear() { set().clear(); }
|
||||
void finish() { set().finish(); }
|
||||
void remove(Ptr p) { set().remove(p); }
|
||||
void remove(const Lookup& l) { set().remove(l); }
|
||||
|
||||
template<typename TInput>
|
||||
bool add(AddPtr& p, TInput&& t) {
|
||||
return set().add(p, mozilla::Forward<TInput>(t));
|
||||
}
|
||||
|
||||
template<typename TInput>
|
||||
bool relookupOrAdd(AddPtr& p, const Lookup& l, TInput&& t) {
|
||||
return set().relookupOrAdd(p, l, mozilla::Forward<TInput>(t));
|
||||
}
|
||||
|
||||
template<typename TInput>
|
||||
bool put(TInput&& t) {
|
||||
return set().put(mozilla::Forward<TInput>(t));
|
||||
}
|
||||
|
||||
template<typename TInput>
|
||||
bool putNew(TInput&& t) {
|
||||
return set().putNew(mozilla::Forward<TInput>(t));
|
||||
}
|
||||
|
||||
template<typename TInput>
|
||||
bool putNew(const Lookup& l, TInput&& t) {
|
||||
return set().putNew(l, mozilla::Forward<TInput>(t));
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, typename HP, typename AP>
|
||||
class RootedBase<JS::GCHashSet<T, HP, AP>>
|
||||
: public MutableGCHashSetOperations<JS::Rooted<JS::GCHashSet<T, HP, AP>>, T, HP, AP>
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T, typename HP, typename AP>
|
||||
class MutableHandleBase<JS::GCHashSet<T, HP, AP>>
|
||||
: public MutableGCHashSetOperations<JS::MutableHandle<JS::GCHashSet<T, HP, AP>>, T, HP, AP>
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T, typename HP, typename AP>
|
||||
class HandleBase<JS::GCHashSet<T, HP, AP>>
|
||||
: public GCHashSetOperations<JS::Handle<JS::GCHashSet<T, HP, AP>>, T, HP, AP>
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T, typename HP, typename AP>
|
||||
class WeakCacheBase<JS::GCHashSet<T, HP, AP>>
|
||||
: public MutableGCHashSetOperations<JS::WeakCache<JS::GCHashSet<T, HP, AP>>, T, HP, AP>
|
||||
{
|
||||
};
|
||||
|
||||
} /* namespace js */
|
||||
|
||||
#endif /* GCHashTable_h */
|
||||
|
|
@ -0,0 +1,164 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* vim: set ts=8 sts=4 et sw=4 tw=99:
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// GC Policy Mechanism
|
||||
|
||||
// A GCPolicy controls how the GC interacts with both direct pointers to GC
|
||||
// things (e.g. JSObject* or JSString*), tagged and/or optional pointers to GC
|
||||
// things (e.g. Value or jsid), and C++ container types (e.g.
|
||||
// JSPropertyDescriptor or GCHashMap).
|
||||
//
|
||||
// The GCPolicy provides at a minimum:
|
||||
//
|
||||
// static T initial()
|
||||
// - Construct and return an empty T.
|
||||
//
|
||||
// static void trace(JSTracer, T* tp, const char* name)
|
||||
// - Trace the edge |*tp|, calling the edge |name|. Containers like
|
||||
// GCHashMap and GCHashSet use this method to trace their children.
|
||||
//
|
||||
// static bool needsSweep(T* tp)
|
||||
// - Return true if |*tp| is about to be finalized. Otherwise, update the
|
||||
// edge for moving GC, and return false. Containers like GCHashMap and
|
||||
// GCHashSet use this method to decide when to remove an entry: if this
|
||||
// function returns true on a key/value/member/etc, its entry is dropped
|
||||
// from the container. Specializing this method is the standard way to
|
||||
// get custom weak behavior from a container type.
|
||||
//
|
||||
// The default GCPolicy<T> assumes that T has a default constructor and |trace|
|
||||
// and |needsSweep| methods, and forwards to them. GCPolicy has appropriate
|
||||
// specializations for pointers to GC things and pointer-like types like
|
||||
// JS::Heap<T> and mozilla::UniquePtr<T>.
|
||||
//
|
||||
// There are some stock structs your specializations can inherit from.
|
||||
// IgnoreGCPolicy<T> does nothing. StructGCPolicy<T> forwards the methods to the
|
||||
// referent type T.
|
||||
|
||||
#ifndef GCPolicyAPI_h
|
||||
#define GCPolicyAPI_h
|
||||
|
||||
#include "mozilla/UniquePtr.h"
|
||||
|
||||
#include "js/TraceKind.h"
|
||||
#include "js/TracingAPI.h"
|
||||
|
||||
// Expand the given macro D for each public GC pointer.
|
||||
#define FOR_EACH_PUBLIC_GC_POINTER_TYPE(D) \
|
||||
D(JS::Symbol*) \
|
||||
D(JSAtom*) \
|
||||
D(JSFunction*) \
|
||||
D(JSObject*) \
|
||||
D(JSScript*) \
|
||||
D(JSString*)
|
||||
|
||||
// Expand the given macro D for each public tagged GC pointer type.
|
||||
#define FOR_EACH_PUBLIC_TAGGED_GC_POINTER_TYPE(D) \
|
||||
D(JS::Value) \
|
||||
D(jsid)
|
||||
|
||||
#define FOR_EACH_PUBLIC_AGGREGATE_GC_POINTER_TYPE(D) \
|
||||
D(JSPropertyDescriptor)
|
||||
|
||||
class JSAtom;
|
||||
class JSFunction;
|
||||
class JSObject;
|
||||
class JSScript;
|
||||
class JSString;
|
||||
namespace JS {
|
||||
class Symbol;
|
||||
}
|
||||
|
||||
namespace JS {
|
||||
|
||||
// Defines a policy for container types with non-GC, i.e. C storage. This
|
||||
// policy dispatches to the underlying struct for GC interactions.
|
||||
template <typename T>
|
||||
struct StructGCPolicy
|
||||
{
|
||||
static T initial() {
|
||||
return T();
|
||||
}
|
||||
|
||||
static void trace(JSTracer* trc, T* tp, const char* name) {
|
||||
tp->trace(trc);
|
||||
}
|
||||
|
||||
static void sweep(T* tp) {
|
||||
return tp->sweep();
|
||||
}
|
||||
|
||||
static bool needsSweep(T* tp) {
|
||||
return tp->needsSweep();
|
||||
}
|
||||
};
|
||||
|
||||
// The default GC policy attempts to defer to methods on the underlying type.
|
||||
// Most C++ structures that contain a default constructor, a trace function and
|
||||
// a sweep function will work out of the box with Rooted, Handle, GCVector,
|
||||
// and GCHash{Set,Map}.
|
||||
template <typename T> struct GCPolicy : public StructGCPolicy<T> {};
|
||||
|
||||
// This policy ignores any GC interaction, e.g. for non-GC types.
|
||||
template <typename T>
|
||||
struct IgnoreGCPolicy {
|
||||
static T initial() { return T(); }
|
||||
static void trace(JSTracer* trc, T* t, const char* name) {}
|
||||
static bool needsSweep(T* v) { return false; }
|
||||
};
|
||||
template <> struct GCPolicy<uint32_t> : public IgnoreGCPolicy<uint32_t> {};
|
||||
template <> struct GCPolicy<uint64_t> : public IgnoreGCPolicy<uint64_t> {};
|
||||
|
||||
template <typename T>
|
||||
struct GCPointerPolicy
|
||||
{
|
||||
static T initial() { return nullptr; }
|
||||
static void trace(JSTracer* trc, T* vp, const char* name) {
|
||||
if (*vp)
|
||||
js::UnsafeTraceManuallyBarrieredEdge(trc, vp, name);
|
||||
}
|
||||
static bool needsSweep(T* vp) {
|
||||
if (*vp)
|
||||
return js::gc::IsAboutToBeFinalizedUnbarriered(vp);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
template <> struct GCPolicy<JS::Symbol*> : public GCPointerPolicy<JS::Symbol*> {};
|
||||
template <> struct GCPolicy<JSAtom*> : public GCPointerPolicy<JSAtom*> {};
|
||||
template <> struct GCPolicy<JSFunction*> : public GCPointerPolicy<JSFunction*> {};
|
||||
template <> struct GCPolicy<JSObject*> : public GCPointerPolicy<JSObject*> {};
|
||||
template <> struct GCPolicy<JSScript*> : public GCPointerPolicy<JSScript*> {};
|
||||
template <> struct GCPolicy<JSString*> : public GCPointerPolicy<JSString*> {};
|
||||
|
||||
template <typename T>
|
||||
struct GCPolicy<JS::Heap<T>>
|
||||
{
|
||||
static void trace(JSTracer* trc, JS::Heap<T>* thingp, const char* name) {
|
||||
TraceEdge(trc, thingp, name);
|
||||
}
|
||||
static bool needsSweep(JS::Heap<T>* thingp) {
|
||||
return js::gc::EdgeNeedsSweep(thingp);
|
||||
}
|
||||
};
|
||||
|
||||
// GCPolicy<UniquePtr<T>> forwards the contained pointer to GCPolicy<T>.
|
||||
template <typename T, typename D>
|
||||
struct GCPolicy<mozilla::UniquePtr<T, D>>
|
||||
{
|
||||
static mozilla::UniquePtr<T,D> initial() { return mozilla::UniquePtr<T,D>(); }
|
||||
static void trace(JSTracer* trc, mozilla::UniquePtr<T,D>* tp, const char* name) {
|
||||
if (tp->get())
|
||||
GCPolicy<T>::trace(trc, tp->get(), name);
|
||||
}
|
||||
static bool needsSweep(mozilla::UniquePtr<T,D>* tp) {
|
||||
if (tp->get())
|
||||
return GCPolicy<T>::needsSweep(tp->get());
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace JS
|
||||
|
||||
#endif // GCPolicyAPI_h
|
||||
|
|
@ -0,0 +1,198 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* vim: set ts=8 sts=4 et sw=4 tw=99:
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef js_GCVariant_h
|
||||
#define js_GCVariant_h
|
||||
|
||||
#include "mozilla/Variant.h"
|
||||
|
||||
#include "js/GCPolicyAPI.h"
|
||||
#include "js/RootingAPI.h"
|
||||
#include "js/TracingAPI.h"
|
||||
|
||||
namespace JS {
|
||||
|
||||
// These template specializations allow Variant to be used inside GC wrappers.
|
||||
//
|
||||
// When matching on GC wrappers around Variants, matching should be done on
|
||||
// the wrapper itself. The matcher class's methods should take Handles or
|
||||
// MutableHandles. For example,
|
||||
//
|
||||
// struct MyMatcher
|
||||
// {
|
||||
// using ReturnType = const char*;
|
||||
// ReturnType match(HandleObject o) { return "object"; }
|
||||
// ReturnType match(HandleScript s) { return "script"; }
|
||||
// };
|
||||
//
|
||||
// Rooted<Variant<JSObject*, JSScript*>> v(cx, someScript);
|
||||
// MyMatcher mm;
|
||||
// v.match(mm);
|
||||
//
|
||||
// If you get compile errors about inability to upcast subclasses (e.g., from
|
||||
// NativeObject* to JSObject*) and are inside js/src, be sure to also include
|
||||
// "gc/Policy.h".
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <typename... Ts>
|
||||
struct GCVariantImplementation;
|
||||
|
||||
// The base case.
|
||||
template <typename T>
|
||||
struct GCVariantImplementation<T>
|
||||
{
|
||||
template <typename ConcreteVariant>
|
||||
static void trace(JSTracer* trc, ConcreteVariant* v, const char* name) {
|
||||
T& thing = v->template as<T>();
|
||||
if (!mozilla::IsPointer<T>::value || thing)
|
||||
GCPolicy<T>::trace(trc, &thing, name);
|
||||
}
|
||||
|
||||
template <typename Matcher, typename ConcreteVariant>
|
||||
static typename Matcher::ReturnType
|
||||
match(Matcher& matcher, Handle<ConcreteVariant> v) {
|
||||
const T& thing = v.get().template as<T>();
|
||||
return matcher.match(Handle<T>::fromMarkedLocation(&thing));
|
||||
}
|
||||
|
||||
template <typename Matcher, typename ConcreteVariant>
|
||||
static typename Matcher::ReturnType
|
||||
match(Matcher& matcher, MutableHandle<ConcreteVariant> v) {
|
||||
T& thing = v.get().template as<T>();
|
||||
return matcher.match(MutableHandle<T>::fromMarkedLocation(&thing));
|
||||
}
|
||||
};
|
||||
|
||||
// The inductive case.
|
||||
template <typename T, typename... Ts>
|
||||
struct GCVariantImplementation<T, Ts...>
|
||||
{
|
||||
using Next = GCVariantImplementation<Ts...>;
|
||||
|
||||
template <typename ConcreteVariant>
|
||||
static void trace(JSTracer* trc, ConcreteVariant* v, const char* name) {
|
||||
if (v->template is<T>()) {
|
||||
T& thing = v->template as<T>();
|
||||
if (!mozilla::IsPointer<T>::value || thing)
|
||||
GCPolicy<T>::trace(trc, &thing, name);
|
||||
} else {
|
||||
Next::trace(trc, v, name);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Matcher, typename ConcreteVariant>
|
||||
static typename Matcher::ReturnType
|
||||
match(Matcher& matcher, Handle<ConcreteVariant> v) {
|
||||
if (v.get().template is<T>()) {
|
||||
const T& thing = v.get().template as<T>();
|
||||
return matcher.match(Handle<T>::fromMarkedLocation(&thing));
|
||||
}
|
||||
return Next::match(matcher, v);
|
||||
}
|
||||
|
||||
template <typename Matcher, typename ConcreteVariant>
|
||||
static typename Matcher::ReturnType
|
||||
match(Matcher& matcher, MutableHandle<ConcreteVariant> v) {
|
||||
if (v.get().template is<T>()) {
|
||||
T& thing = v.get().template as<T>();
|
||||
return matcher.match(MutableHandle<T>::fromMarkedLocation(&thing));
|
||||
}
|
||||
return Next::match(matcher, v);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template <typename... Ts>
|
||||
struct GCPolicy<mozilla::Variant<Ts...>>
|
||||
{
|
||||
using Impl = detail::GCVariantImplementation<Ts...>;
|
||||
|
||||
// Variants do not provide initial(). They do not have a default initial
|
||||
// value and one must be provided.
|
||||
|
||||
static void trace(JSTracer* trc, mozilla::Variant<Ts...>* v, const char* name) {
|
||||
Impl::trace(trc, v, name);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace JS
|
||||
|
||||
namespace js {
|
||||
|
||||
template <typename Outer, typename... Ts>
|
||||
class GCVariantOperations
|
||||
{
|
||||
using Impl = JS::detail::GCVariantImplementation<Ts...>;
|
||||
using Variant = mozilla::Variant<Ts...>;
|
||||
|
||||
const Variant& variant() const { return static_cast<const Outer*>(this)->get(); }
|
||||
|
||||
public:
|
||||
template <typename T>
|
||||
bool is() const {
|
||||
return variant().template is<T>();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
JS::Handle<T> as() const {
|
||||
return Handle<T>::fromMarkedLocation(&variant().template as<T>());
|
||||
}
|
||||
|
||||
template <typename Matcher>
|
||||
typename Matcher::ReturnType
|
||||
match(Matcher& matcher) const {
|
||||
return Impl::match(matcher, JS::Handle<Variant>::fromMarkedLocation(&variant()));
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Outer, typename... Ts>
|
||||
class MutableGCVariantOperations
|
||||
: public GCVariantOperations<Outer, Ts...>
|
||||
{
|
||||
using Impl = JS::detail::GCVariantImplementation<Ts...>;
|
||||
using Variant = mozilla::Variant<Ts...>;
|
||||
|
||||
const Variant& variant() const { return static_cast<const Outer*>(this)->get(); }
|
||||
Variant& variant() { return static_cast<Outer*>(this)->get(); }
|
||||
|
||||
public:
|
||||
template <typename T>
|
||||
JS::MutableHandle<T> as() {
|
||||
return JS::MutableHandle<T>::fromMarkedLocation(&variant().template as<T>());
|
||||
}
|
||||
|
||||
template <typename Matcher>
|
||||
typename Matcher::ReturnType
|
||||
match(Matcher& matcher) {
|
||||
return Impl::match(matcher, JS::MutableHandle<Variant>::fromMarkedLocation(&variant()));
|
||||
}
|
||||
};
|
||||
|
||||
template <typename... Ts>
|
||||
class RootedBase<mozilla::Variant<Ts...>>
|
||||
: public MutableGCVariantOperations<JS::Rooted<mozilla::Variant<Ts...>>, Ts...>
|
||||
{ };
|
||||
|
||||
template <typename... Ts>
|
||||
class MutableHandleBase<mozilla::Variant<Ts...>>
|
||||
: public MutableGCVariantOperations<JS::MutableHandle<mozilla::Variant<Ts...>>, Ts...>
|
||||
{ };
|
||||
|
||||
template <typename... Ts>
|
||||
class HandleBase<mozilla::Variant<Ts...>>
|
||||
: public GCVariantOperations<JS::Handle<mozilla::Variant<Ts...>>, Ts...>
|
||||
{ };
|
||||
|
||||
template <typename... Ts>
|
||||
class PersistentRootedBase<mozilla::Variant<Ts...>>
|
||||
: public MutableGCVariantOperations<JS::PersistentRooted<mozilla::Variant<Ts...>>, Ts...>
|
||||
{ };
|
||||
|
||||
} // namespace js
|
||||
|
||||
#endif // js_GCVariant_h
|
||||
|
|
@ -0,0 +1,249 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* vim: set ts=8 sts=4 et sw=4 tw=99:
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef js_GCVector_h
|
||||
#define js_GCVector_h
|
||||
|
||||
#include "mozilla/Vector.h"
|
||||
|
||||
#include "js/GCPolicyAPI.h"
|
||||
#include "js/RootingAPI.h"
|
||||
#include "js/TracingAPI.h"
|
||||
#include "js/Vector.h"
|
||||
|
||||
namespace JS {
|
||||
|
||||
// A GCVector is a Vector with an additional trace method that knows how
|
||||
// to visit all of the items stored in the Vector. For vectors that contain GC
|
||||
// things, this is usually more convenient than manually iterating and marking
|
||||
// the contents.
|
||||
//
|
||||
// Most types of GC pointers as keys and values can be traced with no extra
|
||||
// infrastructure. For structs and non-gc-pointer members, ensure that there is
|
||||
// a specialization of GCPolicy<T> with an appropriate trace method available
|
||||
// to handle the custom type. Generic helpers can be found in
|
||||
// js/public/TracingAPI.h.
|
||||
//
|
||||
// Note that although this Vector's trace will deal correctly with moved items,
|
||||
// it does not itself know when to barrier or trace items. To function properly
|
||||
// it must either be used with Rooted, or barriered and traced manually.
|
||||
template <typename T,
|
||||
size_t MinInlineCapacity = 0,
|
||||
typename AllocPolicy = js::TempAllocPolicy>
|
||||
class GCVector
|
||||
{
|
||||
mozilla::Vector<T, MinInlineCapacity, AllocPolicy> vector;
|
||||
|
||||
public:
|
||||
explicit GCVector(AllocPolicy alloc = AllocPolicy())
|
||||
: vector(alloc)
|
||||
{}
|
||||
|
||||
GCVector(GCVector&& vec)
|
||||
: vector(mozilla::Move(vec.vector))
|
||||
{}
|
||||
|
||||
GCVector& operator=(GCVector&& vec) {
|
||||
vector = mozilla::Move(vec.vector);
|
||||
return *this;
|
||||
}
|
||||
|
||||
size_t length() const { return vector.length(); }
|
||||
bool empty() const { return vector.empty(); }
|
||||
size_t capacity() const { return vector.capacity(); }
|
||||
|
||||
T* begin() { return vector.begin(); }
|
||||
const T* begin() const { return vector.begin(); }
|
||||
|
||||
T* end() { return vector.end(); }
|
||||
const T* end() const { return vector.end(); }
|
||||
|
||||
T& operator[](size_t i) { return vector[i]; }
|
||||
const T& operator[](size_t i) const { return vector[i]; }
|
||||
|
||||
T& back() { return vector.back(); }
|
||||
const T& back() const { return vector.back(); }
|
||||
|
||||
bool initCapacity(size_t cap) { return vector.initCapacity(cap); }
|
||||
bool reserve(size_t req) { return vector.reserve(req); }
|
||||
void shrinkBy(size_t amount) { return vector.shrinkBy(amount); }
|
||||
bool growBy(size_t amount) { return vector.growBy(amount); }
|
||||
bool resize(size_t newLen) { return vector.resize(newLen); }
|
||||
|
||||
void clear() { return vector.clear(); }
|
||||
|
||||
template<typename U> bool append(U&& item) { return vector.append(mozilla::Forward<U>(item)); }
|
||||
|
||||
template<typename... Args>
|
||||
bool
|
||||
emplaceBack(Args&&... args) {
|
||||
return vector.emplaceBack(mozilla::Forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename U>
|
||||
void infallibleAppend(U&& aU) {
|
||||
return vector.infallibleAppend(mozilla::Forward<U>(aU));
|
||||
}
|
||||
void infallibleAppendN(const T& aT, size_t aN) {
|
||||
return vector.infallibleAppendN(aT, aN);
|
||||
}
|
||||
template<typename U> void
|
||||
infallibleAppend(const U* aBegin, const U* aEnd) {
|
||||
return vector.infallibleAppend(aBegin, aEnd);
|
||||
}
|
||||
template<typename U> void infallibleAppend(const U* aBegin, size_t aLength) {
|
||||
return vector.infallibleAppend(aBegin, aLength);
|
||||
}
|
||||
|
||||
template<typename U, size_t O, class BP>
|
||||
bool appendAll(const mozilla::Vector<U, O, BP>& aU) { return vector.appendAll(aU); }
|
||||
template<typename U, size_t O, class BP>
|
||||
bool appendAll(const GCVector<U, O, BP>& aU) { return vector.append(aU.begin(), aU.length()); }
|
||||
|
||||
bool appendN(const T& val, size_t count) { return vector.appendN(val, count); }
|
||||
|
||||
template<typename U> bool append(const U* aBegin, const U* aEnd) {
|
||||
return vector.append(aBegin, aEnd);
|
||||
}
|
||||
template<typename U> bool append(const U* aBegin, size_t aLength) {
|
||||
return vector.append(aBegin, aLength);
|
||||
}
|
||||
|
||||
void popBack() { return vector.popBack(); }
|
||||
T popCopy() { return vector.popCopy(); }
|
||||
|
||||
size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const {
|
||||
return vector.sizeOfExcludingThis(mallocSizeOf);
|
||||
}
|
||||
|
||||
size_t sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const {
|
||||
return vector.sizeOfIncludingThis(mallocSizeOf);
|
||||
}
|
||||
|
||||
static void trace(GCVector* vec, JSTracer* trc) { vec->trace(trc); }
|
||||
|
||||
void trace(JSTracer* trc) {
|
||||
for (auto& elem : vector)
|
||||
GCPolicy<T>::trace(trc, &elem, "vector element");
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace JS
|
||||
|
||||
namespace js {
|
||||
|
||||
template <typename Outer, typename T, size_t Capacity, typename AllocPolicy>
|
||||
class GCVectorOperations
|
||||
{
|
||||
using Vec = JS::GCVector<T, Capacity, AllocPolicy>;
|
||||
const Vec& vec() const { return static_cast<const Outer*>(this)->get(); }
|
||||
|
||||
public:
|
||||
const AllocPolicy& allocPolicy() const { return vec().allocPolicy(); }
|
||||
size_t length() const { return vec().length(); }
|
||||
bool empty() const { return vec().empty(); }
|
||||
size_t capacity() const { return vec().capacity(); }
|
||||
const T* begin() const { return vec().begin(); }
|
||||
const T* end() const { return vec().end(); }
|
||||
const T& back() const { return vec().back(); }
|
||||
|
||||
JS::Handle<T> operator[](size_t aIndex) const {
|
||||
return JS::Handle<T>::fromMarkedLocation(&vec().operator[](aIndex));
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Outer, typename T, size_t Capacity, typename AllocPolicy>
|
||||
class MutableGCVectorOperations
|
||||
: public GCVectorOperations<Outer, T, Capacity, AllocPolicy>
|
||||
{
|
||||
using Vec = JS::GCVector<T, Capacity, AllocPolicy>;
|
||||
const Vec& vec() const { return static_cast<const Outer*>(this)->get(); }
|
||||
Vec& vec() { return static_cast<Outer*>(this)->get(); }
|
||||
|
||||
public:
|
||||
const AllocPolicy& allocPolicy() const { return vec().allocPolicy(); }
|
||||
AllocPolicy& allocPolicy() { return vec().allocPolicy(); }
|
||||
const T* begin() const { return vec().begin(); }
|
||||
T* begin() { return vec().begin(); }
|
||||
const T* end() const { return vec().end(); }
|
||||
T* end() { return vec().end(); }
|
||||
const T& back() const { return vec().back(); }
|
||||
T& back() { return vec().back(); }
|
||||
|
||||
JS::Handle<T> operator[](size_t aIndex) const {
|
||||
return JS::Handle<T>::fromMarkedLocation(&vec().operator[](aIndex));
|
||||
}
|
||||
JS::MutableHandle<T> operator[](size_t aIndex) {
|
||||
return JS::MutableHandle<T>::fromMarkedLocation(&vec().operator[](aIndex));
|
||||
}
|
||||
|
||||
bool initCapacity(size_t aRequest) { return vec().initCapacity(aRequest); }
|
||||
bool reserve(size_t aRequest) { return vec().reserve(aRequest); }
|
||||
void shrinkBy(size_t aIncr) { vec().shrinkBy(aIncr); }
|
||||
bool growBy(size_t aIncr) { return vec().growBy(aIncr); }
|
||||
bool resize(size_t aNewLength) { return vec().resize(aNewLength); }
|
||||
bool growByUninitialized(size_t aIncr) { return vec().growByUninitialized(aIncr); }
|
||||
void infallibleGrowByUninitialized(size_t aIncr) { vec().infallibleGrowByUninitialized(aIncr); }
|
||||
bool resizeUninitialized(size_t aNewLength) { return vec().resizeUninitialized(aNewLength); }
|
||||
void clear() { vec().clear(); }
|
||||
void clearAndFree() { vec().clearAndFree(); }
|
||||
template<typename U> bool append(U&& aU) { return vec().append(mozilla::Forward<U>(aU)); }
|
||||
template<typename... Args> bool emplaceBack(Args&&... aArgs) {
|
||||
return vec().emplaceBack(mozilla::Forward<Args...>(aArgs...));
|
||||
}
|
||||
template<typename U, size_t O, class BP>
|
||||
bool appendAll(const mozilla::Vector<U, O, BP>& aU) { return vec().appendAll(aU); }
|
||||
template<typename U, size_t O, class BP>
|
||||
bool appendAll(const JS::GCVector<U, O, BP>& aU) { return vec().appendAll(aU); }
|
||||
bool appendN(const T& aT, size_t aN) { return vec().appendN(aT, aN); }
|
||||
template<typename U> bool append(const U* aBegin, const U* aEnd) {
|
||||
return vec().append(aBegin, aEnd);
|
||||
}
|
||||
template<typename U> bool append(const U* aBegin, size_t aLength) {
|
||||
return vec().append(aBegin, aLength);
|
||||
}
|
||||
template<typename U> void infallibleAppend(U&& aU) {
|
||||
vec().infallibleAppend(mozilla::Forward<U>(aU));
|
||||
}
|
||||
void infallibleAppendN(const T& aT, size_t aN) { vec().infallibleAppendN(aT, aN); }
|
||||
template<typename U> void infallibleAppend(const U* aBegin, const U* aEnd) {
|
||||
vec().infallibleAppend(aBegin, aEnd);
|
||||
}
|
||||
template<typename U> void infallibleAppend(const U* aBegin, size_t aLength) {
|
||||
vec().infallibleAppend(aBegin, aLength);
|
||||
}
|
||||
void popBack() { vec().popBack(); }
|
||||
T popCopy() { return vec().popCopy(); }
|
||||
template<typename U> T* insert(T* aP, U&& aVal) {
|
||||
return vec().insert(aP, mozilla::Forward<U>(aVal));
|
||||
}
|
||||
void erase(T* aT) { vec().erase(aT); }
|
||||
void erase(T* aBegin, T* aEnd) { vec().erase(aBegin, aEnd); }
|
||||
};
|
||||
|
||||
template <typename T, size_t N, typename AP>
|
||||
class RootedBase<JS::GCVector<T,N,AP>>
|
||||
: public MutableGCVectorOperations<JS::Rooted<JS::GCVector<T,N,AP>>, T,N,AP>
|
||||
{};
|
||||
|
||||
template <typename T, size_t N, typename AP>
|
||||
class MutableHandleBase<JS::GCVector<T,N,AP>>
|
||||
: public MutableGCVectorOperations<JS::MutableHandle<JS::GCVector<T,N,AP>>, T,N,AP>
|
||||
{};
|
||||
|
||||
template <typename T, size_t N, typename AP>
|
||||
class HandleBase<JS::GCVector<T,N,AP>>
|
||||
: public GCVectorOperations<JS::Handle<JS::GCVector<T,N,AP>>, T,N,AP>
|
||||
{};
|
||||
|
||||
template <typename T, size_t N, typename AP>
|
||||
class PersistentRootedBase<JS::GCVector<T,N,AP>>
|
||||
: public MutableGCVectorOperations<JS::PersistentRooted<JS::GCVector<T,N,AP>>, T,N,AP>
|
||||
{};
|
||||
|
||||
} // namespace js
|
||||
|
||||
#endif // js_GCVector_h
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -11,18 +11,14 @@
|
|||
|
||||
#include "jspubtd.h"
|
||||
|
||||
#include "js/TraceKind.h"
|
||||
#include "js/Utility.h"
|
||||
|
||||
/* These values are private to the JS engine. */
|
||||
namespace js {
|
||||
|
||||
// Whether the current thread is permitted access to any part of the specified
|
||||
// runtime or zone.
|
||||
JS_FRIEND_API(bool)
|
||||
CurrentThreadCanAccessRuntime(JSRuntime *rt);
|
||||
|
||||
JS_FRIEND_API(bool)
|
||||
CurrentThreadCanAccessZone(JS::Zone *zone);
|
||||
CurrentThreadCanAccessZone(JS::Zone* zone);
|
||||
|
||||
namespace gc {
|
||||
|
||||
|
|
@ -53,7 +49,11 @@ const size_t ChunkMarkBitmapOffset = 1032352;
|
|||
const size_t ChunkMarkBitmapBits = 129024;
|
||||
#endif
|
||||
const size_t ChunkRuntimeOffset = ChunkSize - sizeof(void*);
|
||||
const size_t ChunkLocationOffset = ChunkSize - 2 * sizeof(void*) - sizeof(uint64_t);
|
||||
const size_t ChunkTrailerSize = 2 * sizeof(uintptr_t) + sizeof(uint64_t);
|
||||
const size_t ChunkLocationOffset = ChunkSize - ChunkTrailerSize;
|
||||
const size_t ArenaZoneOffset = sizeof(size_t);
|
||||
const size_t ArenaHeaderSize = sizeof(size_t) + 2 * sizeof(uintptr_t) +
|
||||
sizeof(size_t) + sizeof(uintptr_t);
|
||||
|
||||
/*
|
||||
* Live objects are marked black. How many other additional colors are available
|
||||
|
|
@ -64,33 +64,27 @@ static const uint32_t BLACK = 0;
|
|||
static const uint32_t GRAY = 1;
|
||||
|
||||
/*
|
||||
* The "location" field in the Chunk trailer is a bit vector indicting various
|
||||
* roles of the chunk.
|
||||
*
|
||||
* The value 0 for the "location" field is invalid, at least one bit must be
|
||||
* set.
|
||||
*
|
||||
* Some bits preclude others, for example, any "nursery" bit precludes any
|
||||
* "tenured" or "middle generation" bit.
|
||||
* The "location" field in the Chunk trailer is a enum indicating various roles
|
||||
* of the chunk.
|
||||
*/
|
||||
const uintptr_t ChunkLocationBitNursery = 1; // Standard GGC nursery
|
||||
const uintptr_t ChunkLocationBitTenuredHeap = 2; // Standard GGC tenured generation
|
||||
const uintptr_t ChunkLocationBitPJSNewspace = 4; // The PJS generational GC's allocation space
|
||||
const uintptr_t ChunkLocationBitPJSFromspace = 8; // The PJS generational GC's fromspace (during GC)
|
||||
|
||||
const uintptr_t ChunkLocationAnyNursery = ChunkLocationBitNursery |
|
||||
ChunkLocationBitPJSNewspace |
|
||||
ChunkLocationBitPJSFromspace;
|
||||
enum class ChunkLocation : uint32_t
|
||||
{
|
||||
Invalid = 0,
|
||||
Nursery = 1,
|
||||
TenuredHeap = 2
|
||||
};
|
||||
|
||||
#ifdef JS_DEBUG
|
||||
/* When downcasting, ensure we are actually the right type. */
|
||||
extern JS_FRIEND_API(void)
|
||||
AssertGCThingHasType(js::gc::Cell *cell, JSGCTraceKind kind);
|
||||
AssertGCThingHasType(js::gc::Cell* cell, JS::TraceKind kind);
|
||||
#else
|
||||
inline void
|
||||
AssertGCThingHasType(js::gc::Cell *cell, JSGCTraceKind kind) {}
|
||||
AssertGCThingHasType(js::gc::Cell* cell, JS::TraceKind kind) {}
|
||||
#endif
|
||||
|
||||
MOZ_ALWAYS_INLINE bool IsInsideNursery(const js::gc::Cell* cell);
|
||||
|
||||
} /* namespace gc */
|
||||
} /* namespace js */
|
||||
|
||||
|
|
@ -98,220 +92,315 @@ namespace JS {
|
|||
struct Zone;
|
||||
|
||||
/* Default size for the generational nursery in bytes. */
|
||||
const uint32_t DefaultNurseryBytes = 16 * 1024 * 1024;
|
||||
const uint32_t DefaultNurseryBytes = 16 * js::gc::ChunkSize;
|
||||
|
||||
/* Default maximum heap size in bytes to pass to JS_NewRuntime(). */
|
||||
const uint32_t DefaultHeapMaxBytes = 32 * 1024 * 1024;
|
||||
|
||||
/*
|
||||
* We cannot expose the class hierarchy: the implementation is hidden. Instead
|
||||
* we provide cast functions with strong debug-mode assertions.
|
||||
*/
|
||||
static MOZ_ALWAYS_INLINE js::gc::Cell *
|
||||
AsCell(JSObject *obj)
|
||||
{
|
||||
js::gc::Cell *cell = reinterpret_cast<js::gc::Cell *>(obj);
|
||||
AssertGCThingHasType(cell, JSTRACE_OBJECT);
|
||||
return cell;
|
||||
}
|
||||
|
||||
static MOZ_ALWAYS_INLINE js::gc::Cell *
|
||||
AsCell(JSFunction *fun)
|
||||
{
|
||||
js::gc::Cell *cell = reinterpret_cast<js::gc::Cell *>(fun);
|
||||
AssertGCThingHasType(cell, JSTRACE_OBJECT);
|
||||
return cell;
|
||||
}
|
||||
|
||||
static MOZ_ALWAYS_INLINE js::gc::Cell *
|
||||
AsCell(JSString *str)
|
||||
{
|
||||
js::gc::Cell *cell = reinterpret_cast<js::gc::Cell *>(str);
|
||||
AssertGCThingHasType(cell, JSTRACE_STRING);
|
||||
return cell;
|
||||
}
|
||||
|
||||
static MOZ_ALWAYS_INLINE js::gc::Cell *
|
||||
AsCell(JSFlatString *flat)
|
||||
{
|
||||
js::gc::Cell *cell = reinterpret_cast<js::gc::Cell *>(flat);
|
||||
AssertGCThingHasType(cell, JSTRACE_STRING);
|
||||
return cell;
|
||||
}
|
||||
|
||||
static MOZ_ALWAYS_INLINE js::gc::Cell *
|
||||
AsCell(JS::Symbol *sym)
|
||||
{
|
||||
js::gc::Cell *cell = reinterpret_cast<js::gc::Cell *>(sym);
|
||||
AssertGCThingHasType(cell, JSTRACE_SYMBOL);
|
||||
return cell;
|
||||
}
|
||||
|
||||
static MOZ_ALWAYS_INLINE js::gc::Cell *
|
||||
AsCell(JSScript *script)
|
||||
{
|
||||
js::gc::Cell *cell = reinterpret_cast<js::gc::Cell *>(script);
|
||||
AssertGCThingHasType(cell, JSTRACE_SCRIPT);
|
||||
return cell;
|
||||
}
|
||||
|
||||
namespace shadow {
|
||||
|
||||
struct ArenaHeader
|
||||
{
|
||||
JS::Zone *zone;
|
||||
};
|
||||
|
||||
struct Zone
|
||||
{
|
||||
protected:
|
||||
JSRuntime *const runtime_;
|
||||
JSTracer *const barrierTracer_; // A pointer to the JSRuntime's |gcMarker|.
|
||||
JSRuntime* const runtime_;
|
||||
JSTracer* const barrierTracer_; // A pointer to the JSRuntime's |gcMarker|.
|
||||
|
||||
public:
|
||||
bool needsBarrier_;
|
||||
// Stack GC roots for Rooted GC pointers.
|
||||
js::RootedListHeads stackRoots_;
|
||||
template <typename T> friend class JS::Rooted;
|
||||
|
||||
Zone(JSRuntime *runtime, JSTracer *barrierTracerArg)
|
||||
bool needsIncrementalBarrier_;
|
||||
|
||||
Zone(JSRuntime* runtime, JSTracer* barrierTracerArg)
|
||||
: runtime_(runtime),
|
||||
barrierTracer_(barrierTracerArg),
|
||||
needsBarrier_(false)
|
||||
{}
|
||||
|
||||
bool needsBarrier() const {
|
||||
return needsBarrier_;
|
||||
needsIncrementalBarrier_(false)
|
||||
{
|
||||
for (auto& stackRootPtr : stackRoots_)
|
||||
stackRootPtr = nullptr;
|
||||
}
|
||||
|
||||
JSTracer *barrierTracer() {
|
||||
MOZ_ASSERT(needsBarrier_);
|
||||
bool needsIncrementalBarrier() const {
|
||||
return needsIncrementalBarrier_;
|
||||
}
|
||||
|
||||
JSTracer* barrierTracer() {
|
||||
MOZ_ASSERT(needsIncrementalBarrier_);
|
||||
MOZ_ASSERT(js::CurrentThreadCanAccessRuntime(runtime_));
|
||||
return barrierTracer_;
|
||||
}
|
||||
|
||||
JSRuntime *runtimeFromMainThread() const {
|
||||
JSRuntime* runtimeFromMainThread() const {
|
||||
MOZ_ASSERT(js::CurrentThreadCanAccessRuntime(runtime_));
|
||||
return runtime_;
|
||||
}
|
||||
|
||||
// Note: Unrestricted access to the zone's runtime from an arbitrary
|
||||
// thread can easily lead to races. Use this method very carefully.
|
||||
JSRuntime *runtimeFromAnyThread() const {
|
||||
JSRuntime* runtimeFromAnyThread() const {
|
||||
return runtime_;
|
||||
}
|
||||
|
||||
static JS::shadow::Zone *asShadowZone(JS::Zone *zone) {
|
||||
static MOZ_ALWAYS_INLINE JS::shadow::Zone* asShadowZone(JS::Zone* zone) {
|
||||
return reinterpret_cast<JS::shadow::Zone*>(zone);
|
||||
}
|
||||
};
|
||||
|
||||
} /* namespace shadow */
|
||||
|
||||
/**
|
||||
* A GC pointer, tagged with the trace kind.
|
||||
*
|
||||
* In general, a GC pointer should be stored with an exact type. This class
|
||||
* is for use when that is not possible because a single pointer must point
|
||||
* to several kinds of GC thing.
|
||||
*/
|
||||
class JS_FRIEND_API(GCCellPtr)
|
||||
{
|
||||
public:
|
||||
// Construction from a void* and trace kind.
|
||||
GCCellPtr(void* gcthing, JS::TraceKind traceKind) : ptr(checkedCast(gcthing, traceKind)) {}
|
||||
|
||||
// Automatically construct a null GCCellPtr from nullptr.
|
||||
MOZ_IMPLICIT GCCellPtr(decltype(nullptr)) : ptr(checkedCast(nullptr, JS::TraceKind::Null)) {}
|
||||
|
||||
// Construction from an explicit type.
|
||||
template <typename T>
|
||||
explicit GCCellPtr(T* p) : ptr(checkedCast(p, JS::MapTypeToTraceKind<T>::kind)) { }
|
||||
explicit GCCellPtr(JSFunction* p) : ptr(checkedCast(p, JS::TraceKind::Object)) { }
|
||||
explicit GCCellPtr(JSFlatString* str) : ptr(checkedCast(str, JS::TraceKind::String)) { }
|
||||
explicit GCCellPtr(const Value& v);
|
||||
|
||||
JS::TraceKind kind() const {
|
||||
JS::TraceKind traceKind = JS::TraceKind(ptr & OutOfLineTraceKindMask);
|
||||
if (uintptr_t(traceKind) != OutOfLineTraceKindMask)
|
||||
return traceKind;
|
||||
return outOfLineKind();
|
||||
}
|
||||
|
||||
// Allow GCCellPtr to be used in a boolean context.
|
||||
explicit operator bool() const {
|
||||
MOZ_ASSERT(bool(asCell()) == (kind() != JS::TraceKind::Null));
|
||||
return asCell();
|
||||
}
|
||||
|
||||
// Simplify checks to the kind.
|
||||
template <typename T>
|
||||
bool is() const { return kind() == JS::MapTypeToTraceKind<T>::kind; }
|
||||
|
||||
// Conversions to more specific types must match the kind. Access to
|
||||
// further refined types is not allowed directly from a GCCellPtr.
|
||||
template <typename T>
|
||||
T& as() const {
|
||||
MOZ_ASSERT(kind() == JS::MapTypeToTraceKind<T>::kind);
|
||||
// We can't use static_cast here, because the fact that JSObject
|
||||
// inherits from js::gc::Cell is not part of the public API.
|
||||
return *reinterpret_cast<T*>(asCell());
|
||||
}
|
||||
|
||||
// Return a pointer to the cell this |GCCellPtr| refers to, or |nullptr|.
|
||||
// (It would be more symmetrical with |to| for this to return a |Cell&|, but
|
||||
// the result can be |nullptr|, and null references are undefined behavior.)
|
||||
js::gc::Cell* asCell() const {
|
||||
return reinterpret_cast<js::gc::Cell*>(ptr & ~OutOfLineTraceKindMask);
|
||||
}
|
||||
|
||||
// The CC's trace logger needs an identity that is XPIDL serializable.
|
||||
uint64_t unsafeAsInteger() const {
|
||||
return static_cast<uint64_t>(unsafeAsUIntPtr());
|
||||
}
|
||||
// Inline mark bitmap access requires direct pointer arithmetic.
|
||||
uintptr_t unsafeAsUIntPtr() const {
|
||||
MOZ_ASSERT(asCell());
|
||||
MOZ_ASSERT(!js::gc::IsInsideNursery(asCell()));
|
||||
return reinterpret_cast<uintptr_t>(asCell());
|
||||
}
|
||||
|
||||
bool mayBeOwnedByOtherRuntime() const;
|
||||
|
||||
private:
|
||||
static uintptr_t checkedCast(void* p, JS::TraceKind traceKind) {
|
||||
js::gc::Cell* cell = static_cast<js::gc::Cell*>(p);
|
||||
MOZ_ASSERT((uintptr_t(p) & OutOfLineTraceKindMask) == 0);
|
||||
AssertGCThingHasType(cell, traceKind);
|
||||
// Note: the OutOfLineTraceKindMask bits are set on all out-of-line kinds
|
||||
// so that we can mask instead of branching.
|
||||
MOZ_ASSERT_IF(uintptr_t(traceKind) >= OutOfLineTraceKindMask,
|
||||
(uintptr_t(traceKind) & OutOfLineTraceKindMask) == OutOfLineTraceKindMask);
|
||||
return uintptr_t(p) | (uintptr_t(traceKind) & OutOfLineTraceKindMask);
|
||||
}
|
||||
|
||||
JS::TraceKind outOfLineKind() const;
|
||||
|
||||
uintptr_t ptr;
|
||||
};
|
||||
|
||||
inline bool
|
||||
operator==(const GCCellPtr& ptr1, const GCCellPtr& ptr2)
|
||||
{
|
||||
return ptr1.asCell() == ptr2.asCell();
|
||||
}
|
||||
|
||||
inline bool
|
||||
operator!=(const GCCellPtr& ptr1, const GCCellPtr& ptr2)
|
||||
{
|
||||
return !(ptr1 == ptr2);
|
||||
}
|
||||
|
||||
// Unwraps the given GCCellPtr and calls the given functor with a template
|
||||
// argument of the actual type of the pointer.
|
||||
template <typename F, typename... Args>
|
||||
auto
|
||||
DispatchTyped(F f, GCCellPtr thing, Args&&... args)
|
||||
-> decltype(f(static_cast<JSObject*>(nullptr), mozilla::Forward<Args>(args)...))
|
||||
{
|
||||
switch (thing.kind()) {
|
||||
#define JS_EXPAND_DEF(name, type, _) \
|
||||
case JS::TraceKind::name: \
|
||||
return f(&thing.as<type>(), mozilla::Forward<Args>(args)...);
|
||||
JS_FOR_EACH_TRACEKIND(JS_EXPAND_DEF);
|
||||
#undef JS_EXPAND_DEF
|
||||
default:
|
||||
MOZ_CRASH("Invalid trace kind in DispatchTyped for GCCellPtr.");
|
||||
}
|
||||
}
|
||||
|
||||
} /* namespace JS */
|
||||
|
||||
namespace js {
|
||||
namespace gc {
|
||||
namespace detail {
|
||||
|
||||
static MOZ_ALWAYS_INLINE uintptr_t *
|
||||
GetGCThingMarkBitmap(const void *thing)
|
||||
static MOZ_ALWAYS_INLINE uintptr_t*
|
||||
GetGCThingMarkBitmap(const uintptr_t addr)
|
||||
{
|
||||
MOZ_ASSERT(thing);
|
||||
uintptr_t addr = uintptr_t(thing);
|
||||
addr &= ~js::gc::ChunkMask;
|
||||
addr |= js::gc::ChunkMarkBitmapOffset;
|
||||
return reinterpret_cast<uintptr_t *>(addr);
|
||||
}
|
||||
|
||||
static MOZ_ALWAYS_INLINE JS::shadow::Runtime *
|
||||
GetGCThingRuntime(const void *thing)
|
||||
{
|
||||
MOZ_ASSERT(thing);
|
||||
uintptr_t addr = uintptr_t(thing);
|
||||
addr &= ~js::gc::ChunkMask;
|
||||
addr |= js::gc::ChunkRuntimeOffset;
|
||||
return *reinterpret_cast<JS::shadow::Runtime **>(addr);
|
||||
MOZ_ASSERT(addr);
|
||||
const uintptr_t bmap_addr = (addr & ~ChunkMask) | ChunkMarkBitmapOffset;
|
||||
return reinterpret_cast<uintptr_t*>(bmap_addr);
|
||||
}
|
||||
|
||||
static MOZ_ALWAYS_INLINE void
|
||||
GetGCThingMarkWordAndMask(const void *thing, uint32_t color,
|
||||
uintptr_t **wordp, uintptr_t *maskp)
|
||||
GetGCThingMarkWordAndMask(const uintptr_t addr, uint32_t color,
|
||||
uintptr_t** wordp, uintptr_t* maskp)
|
||||
{
|
||||
uintptr_t addr = uintptr_t(thing);
|
||||
size_t bit = (addr & js::gc::ChunkMask) / js::gc::CellSize + color;
|
||||
MOZ_ASSERT(addr);
|
||||
const size_t bit = (addr & js::gc::ChunkMask) / js::gc::CellSize + color;
|
||||
MOZ_ASSERT(bit < js::gc::ChunkMarkBitmapBits);
|
||||
uintptr_t *bitmap = GetGCThingMarkBitmap(thing);
|
||||
uintptr_t* bitmap = GetGCThingMarkBitmap(addr);
|
||||
const uintptr_t nbits = sizeof(*bitmap) * CHAR_BIT;
|
||||
*maskp = uintptr_t(1) << (bit % nbits);
|
||||
*wordp = &bitmap[bit / nbits];
|
||||
}
|
||||
|
||||
static MOZ_ALWAYS_INLINE JS::shadow::ArenaHeader *
|
||||
GetGCThingArena(void *thing)
|
||||
static MOZ_ALWAYS_INLINE JS::Zone*
|
||||
GetGCThingZone(const uintptr_t addr)
|
||||
{
|
||||
uintptr_t addr = uintptr_t(thing);
|
||||
addr &= ~js::gc::ArenaMask;
|
||||
return reinterpret_cast<JS::shadow::ArenaHeader *>(addr);
|
||||
MOZ_ASSERT(addr);
|
||||
const uintptr_t zone_addr = (addr & ~ArenaMask) | ArenaZoneOffset;
|
||||
return *reinterpret_cast<JS::Zone**>(zone_addr);
|
||||
|
||||
}
|
||||
|
||||
MOZ_ALWAYS_INLINE bool
|
||||
IsInsideNursery(const js::gc::Cell *cell)
|
||||
static MOZ_ALWAYS_INLINE JS::shadow::Runtime*
|
||||
GetCellRuntime(const Cell* cell)
|
||||
{
|
||||
MOZ_ASSERT(cell);
|
||||
const uintptr_t addr = uintptr_t(cell);
|
||||
const uintptr_t rt_addr = (addr & ~ChunkMask) | ChunkRuntimeOffset;
|
||||
return *reinterpret_cast<JS::shadow::Runtime**>(rt_addr);
|
||||
}
|
||||
|
||||
static MOZ_ALWAYS_INLINE bool
|
||||
CellIsMarkedGray(const Cell* cell)
|
||||
{
|
||||
MOZ_ASSERT(cell);
|
||||
if (js::gc::IsInsideNursery(cell))
|
||||
return false;
|
||||
|
||||
uintptr_t* word, mask;
|
||||
js::gc::detail::GetGCThingMarkWordAndMask(uintptr_t(cell), js::gc::GRAY, &word, &mask);
|
||||
return *word & mask;
|
||||
}
|
||||
|
||||
extern JS_PUBLIC_API(bool)
|
||||
CellIsMarkedGrayIfKnown(const Cell* cell);
|
||||
|
||||
} /* namespace detail */
|
||||
|
||||
MOZ_ALWAYS_INLINE bool
|
||||
IsInsideNursery(const js::gc::Cell* cell)
|
||||
{
|
||||
#ifdef JSGC_GENERATIONAL
|
||||
if (!cell)
|
||||
return false;
|
||||
uintptr_t addr = uintptr_t(cell);
|
||||
addr &= ~js::gc::ChunkMask;
|
||||
addr |= js::gc::ChunkLocationOffset;
|
||||
uint32_t location = *reinterpret_cast<uint32_t *>(addr);
|
||||
JS_ASSERT(location != 0);
|
||||
return location & ChunkLocationAnyNursery;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
auto location = *reinterpret_cast<ChunkLocation*>(addr);
|
||||
MOZ_ASSERT(location == ChunkLocation::Nursery || location == ChunkLocation::TenuredHeap);
|
||||
return location == ChunkLocation::Nursery;
|
||||
}
|
||||
|
||||
} /* namespace gc */
|
||||
|
||||
} /* namespace js */
|
||||
|
||||
namespace JS {
|
||||
|
||||
static MOZ_ALWAYS_INLINE Zone *
|
||||
GetGCThingZone(void *thing)
|
||||
static MOZ_ALWAYS_INLINE Zone*
|
||||
GetTenuredGCThingZone(GCCellPtr thing)
|
||||
{
|
||||
MOZ_ASSERT(thing);
|
||||
return js::gc::GetGCThingArena(thing)->zone;
|
||||
MOZ_ASSERT(!js::gc::IsInsideNursery(thing.asCell()));
|
||||
return js::gc::detail::GetGCThingZone(thing.unsafeAsUIntPtr());
|
||||
}
|
||||
|
||||
static MOZ_ALWAYS_INLINE Zone *
|
||||
GetObjectZone(JSObject *obj)
|
||||
static MOZ_ALWAYS_INLINE Zone*
|
||||
GetStringZone(JSString* str)
|
||||
{
|
||||
return GetGCThingZone(obj);
|
||||
return js::gc::detail::GetGCThingZone(uintptr_t(str));
|
||||
}
|
||||
|
||||
extern JS_PUBLIC_API(Zone*)
|
||||
GetObjectZone(JSObject* obj);
|
||||
|
||||
static MOZ_ALWAYS_INLINE bool
|
||||
GCThingIsMarkedGray(void *thing)
|
||||
GCThingIsMarkedGray(GCCellPtr thing)
|
||||
{
|
||||
#ifdef JSGC_GENERATIONAL
|
||||
/*
|
||||
* GC things residing in the nursery cannot be gray: they have no mark bits.
|
||||
* All live objects in the nursery are moved to tenured at the beginning of
|
||||
* each GC slice, so the gray marker never sees nursery things.
|
||||
*/
|
||||
if (js::gc::IsInsideNursery((js::gc::Cell *)thing))
|
||||
if (thing.mayBeOwnedByOtherRuntime())
|
||||
return false;
|
||||
#endif
|
||||
uintptr_t *word, mask;
|
||||
js::gc::GetGCThingMarkWordAndMask(thing, js::gc::GRAY, &word, &mask);
|
||||
return *word & mask;
|
||||
return js::gc::detail::CellIsMarkedGrayIfKnown(thing.asCell());
|
||||
}
|
||||
|
||||
static MOZ_ALWAYS_INLINE bool
|
||||
IsIncrementalBarrierNeededOnGCThing(shadow::Runtime *rt, void *thing, JSGCTraceKind kind)
|
||||
{
|
||||
if (!rt->needsBarrier_)
|
||||
return false;
|
||||
JS::Zone *zone = GetGCThingZone(thing);
|
||||
return reinterpret_cast<shadow::Zone *>(zone)->needsBarrier_;
|
||||
}
|
||||
extern JS_PUBLIC_API(JS::TraceKind)
|
||||
GCThingTraceKind(void* thing);
|
||||
|
||||
} /* namespace JS */
|
||||
|
||||
namespace js {
|
||||
namespace gc {
|
||||
|
||||
static MOZ_ALWAYS_INLINE bool
|
||||
IsIncrementalBarrierNeededOnTenuredGCThing(JS::shadow::Runtime* rt, const JS::GCCellPtr thing)
|
||||
{
|
||||
MOZ_ASSERT(thing);
|
||||
MOZ_ASSERT(!js::gc::IsInsideNursery(thing.asCell()));
|
||||
|
||||
// TODO: I'd like to assert !isHeapBusy() here but this gets called while we
|
||||
// are tracing the heap, e.g. during memory reporting (see bug 1313318).
|
||||
MOZ_ASSERT(!rt->isHeapCollecting());
|
||||
|
||||
JS::Zone* zone = JS::GetTenuredGCThingZone(thing);
|
||||
return JS::shadow::Zone::asShadowZone(zone)->needsIncrementalBarrier();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an object providing access to the garbage collector's internal notion
|
||||
* of the current state of memory (both GC heap memory and GCthing-controlled
|
||||
* malloc memory.
|
||||
*/
|
||||
extern JS_PUBLIC_API(JSObject*)
|
||||
NewMemoryInfoObject(JSContext* cx);
|
||||
|
||||
} /* namespace gc */
|
||||
} /* namespace js */
|
||||
|
||||
#endif /* js_HeapAPI_h */
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#define js_Id_h
|
||||
|
||||
// A jsid is an identifier for a property or method of an object which is
|
||||
// either a 31-bit signed integer, interned string or object.
|
||||
// either a 31-bit unsigned integer, interned string or symbol.
|
||||
//
|
||||
// Also, there is an additional jsid value, JSID_VOID, which does not occur in
|
||||
// JS scripts but may be used to indicate the absence of a valid jsid. A void
|
||||
|
|
@ -17,11 +17,9 @@
|
|||
// entry points expecting a jsid and do not need to handle JSID_VOID in hooks
|
||||
// receiving a jsid except when explicitly noted in the API contract.
|
||||
//
|
||||
// A jsid is not implicitly convertible to or from a jsval; JS_ValueToId or
|
||||
// A jsid is not implicitly convertible to or from a Value; JS_ValueToId or
|
||||
// JS_IdToValue must be used instead.
|
||||
|
||||
#include "mozilla/NullPtr.h"
|
||||
|
||||
#include "jstypes.h"
|
||||
|
||||
#include "js/HeapAPI.h"
|
||||
|
|
@ -32,9 +30,9 @@
|
|||
struct jsid
|
||||
{
|
||||
size_t asBits;
|
||||
bool operator==(jsid rhs) const { return asBits == rhs.asBits; }
|
||||
bool operator!=(jsid rhs) const { return asBits != rhs.asBits; }
|
||||
};
|
||||
bool operator==(const jsid& rhs) const { return asBits == rhs.asBits; }
|
||||
bool operator!=(const jsid& rhs) const { return asBits != rhs.asBits; }
|
||||
} JS_HAZ_GC_POINTER;
|
||||
#define JSID_BITS(id) (id.asBits)
|
||||
|
||||
#define JSID_TYPE_STRING 0x0
|
||||
|
|
@ -53,18 +51,22 @@ JSID_IS_STRING(jsid id)
|
|||
return (JSID_BITS(id) & JSID_TYPE_MASK) == 0;
|
||||
}
|
||||
|
||||
static MOZ_ALWAYS_INLINE JSString *
|
||||
static MOZ_ALWAYS_INLINE JSString*
|
||||
JSID_TO_STRING(jsid id)
|
||||
{
|
||||
MOZ_ASSERT(JSID_IS_STRING(id));
|
||||
return (JSString *)JSID_BITS(id);
|
||||
return (JSString*)JSID_BITS(id);
|
||||
}
|
||||
|
||||
static MOZ_ALWAYS_INLINE bool
|
||||
JSID_IS_ZERO(jsid id)
|
||||
{
|
||||
return JSID_BITS(id) == 0;
|
||||
}
|
||||
/**
|
||||
* Only JSStrings that have been interned via the JSAPI can be turned into
|
||||
* jsids by API clients.
|
||||
*
|
||||
* N.B. if a jsid is backed by a string which has not been interned, that
|
||||
* string must be appropriately rooted to avoid being collected by the GC.
|
||||
*/
|
||||
JS_PUBLIC_API(jsid)
|
||||
INTERNED_STRING_TO_JSID(JSContext* cx, JSString* str);
|
||||
|
||||
static MOZ_ALWAYS_INLINE bool
|
||||
JSID_IS_INT(jsid id)
|
||||
|
|
@ -104,21 +106,20 @@ JSID_IS_SYMBOL(jsid id)
|
|||
JSID_BITS(id) != JSID_TYPE_SYMBOL;
|
||||
}
|
||||
|
||||
static MOZ_ALWAYS_INLINE JS::Symbol *
|
||||
static MOZ_ALWAYS_INLINE JS::Symbol*
|
||||
JSID_TO_SYMBOL(jsid id)
|
||||
{
|
||||
MOZ_ASSERT(JSID_IS_SYMBOL(id));
|
||||
return (JS::Symbol *)(JSID_BITS(id) & ~(size_t)JSID_TYPE_MASK);
|
||||
return (JS::Symbol*)(JSID_BITS(id) & ~(size_t)JSID_TYPE_MASK);
|
||||
}
|
||||
|
||||
static MOZ_ALWAYS_INLINE jsid
|
||||
SYMBOL_TO_JSID(JS::Symbol *sym)
|
||||
SYMBOL_TO_JSID(JS::Symbol* sym)
|
||||
{
|
||||
jsid id;
|
||||
MOZ_ASSERT(sym != nullptr);
|
||||
MOZ_ASSERT((size_t(sym) & JSID_TYPE_MASK) == 0);
|
||||
JS_ASSERT(!js::gc::IsInsideNursery(JS::AsCell(sym)));
|
||||
JS_ASSERT(!JS::IsPoisonedPtr(sym));
|
||||
MOZ_ASSERT(!js::gc::IsInsideNursery(reinterpret_cast<js::gc::Cell*>(sym)));
|
||||
JSID_BITS(id) = (size_t(sym) | JSID_TYPE_SYMBOL);
|
||||
return id;
|
||||
}
|
||||
|
|
@ -129,10 +130,14 @@ JSID_IS_GCTHING(jsid id)
|
|||
return JSID_IS_STRING(id) || JSID_IS_SYMBOL(id);
|
||||
}
|
||||
|
||||
static MOZ_ALWAYS_INLINE void *
|
||||
static MOZ_ALWAYS_INLINE JS::GCCellPtr
|
||||
JSID_TO_GCTHING(jsid id)
|
||||
{
|
||||
return (void *)(JSID_BITS(id) & ~(size_t)JSID_TYPE_MASK);
|
||||
void* thing = (void*)(JSID_BITS(id) & ~(size_t)JSID_TYPE_MASK);
|
||||
if (JSID_IS_STRING(id))
|
||||
return JS::GCCellPtr(thing, JS::TraceKind::String);
|
||||
MOZ_ASSERT(JSID_IS_SYMBOL(id));
|
||||
return JS::GCCellPtr(thing, JS::TraceKind::Symbol);
|
||||
}
|
||||
|
||||
static MOZ_ALWAYS_INLINE bool
|
||||
|
|
@ -140,13 +145,13 @@ JSID_IS_VOID(const jsid id)
|
|||
{
|
||||
MOZ_ASSERT_IF(((size_t)JSID_BITS(id) & JSID_TYPE_MASK) == JSID_TYPE_VOID,
|
||||
JSID_BITS(id) == JSID_TYPE_VOID);
|
||||
return ((size_t)JSID_BITS(id) == JSID_TYPE_VOID);
|
||||
return (size_t)JSID_BITS(id) == JSID_TYPE_VOID;
|
||||
}
|
||||
|
||||
static MOZ_ALWAYS_INLINE bool
|
||||
JSID_IS_EMPTY(const jsid id)
|
||||
{
|
||||
return ((size_t)JSID_BITS(id) == JSID_TYPE_SYMBOL);
|
||||
return (size_t)JSID_BITS(id) == JSID_TYPE_SYMBOL;
|
||||
}
|
||||
|
||||
extern JS_PUBLIC_DATA(const jsid) JSID_VOID;
|
||||
|
|
@ -155,31 +160,48 @@ extern JS_PUBLIC_DATA(const jsid) JSID_EMPTY;
|
|||
extern JS_PUBLIC_DATA(const JS::HandleId) JSID_VOIDHANDLE;
|
||||
extern JS_PUBLIC_DATA(const JS::HandleId) JSID_EMPTYHANDLE;
|
||||
|
||||
namespace js {
|
||||
namespace JS {
|
||||
|
||||
inline bool
|
||||
IsPoisonedId(jsid id)
|
||||
{
|
||||
if (JSID_IS_STRING(id))
|
||||
return JS::IsPoisonedPtr(JSID_TO_STRING(id));
|
||||
if (JSID_IS_SYMBOL(id))
|
||||
return JS::IsPoisonedPtr(JSID_TO_SYMBOL(id));
|
||||
return false;
|
||||
}
|
||||
|
||||
template <> struct GCMethods<jsid>
|
||||
template <>
|
||||
struct GCPolicy<jsid>
|
||||
{
|
||||
static jsid initial() { return JSID_VOID; }
|
||||
static bool poisoned(jsid id) { return IsPoisonedId(id); }
|
||||
static bool needsPostBarrier(jsid id) { return false; }
|
||||
#ifdef JSGC_GENERATIONAL
|
||||
static void postBarrier(jsid *idp) {}
|
||||
static void relocate(jsid *idp) {}
|
||||
#endif
|
||||
static void trace(JSTracer* trc, jsid* idp, const char* name) {
|
||||
js::UnsafeTraceManuallyBarrieredEdge(trc, idp, name);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace JS
|
||||
|
||||
namespace js {
|
||||
|
||||
template <>
|
||||
struct BarrierMethods<jsid>
|
||||
{
|
||||
static void postBarrier(jsid* idp, jsid prev, jsid next) {}
|
||||
static void exposeToJS(jsid id) {
|
||||
if (JSID_IS_GCTHING(id))
|
||||
js::gc::ExposeGCThingToActiveJS(JSID_TO_GCTHING(id));
|
||||
}
|
||||
};
|
||||
|
||||
// If the jsid is a GC pointer type, convert to that type and call |f| with
|
||||
// the pointer. If the jsid is not a GC type, calls F::defaultValue.
|
||||
template <typename F, typename... Args>
|
||||
auto
|
||||
DispatchTyped(F f, const jsid& id, Args&&... args)
|
||||
-> decltype(f(static_cast<JSString*>(nullptr), mozilla::Forward<Args>(args)...))
|
||||
{
|
||||
if (JSID_IS_STRING(id))
|
||||
return f(JSID_TO_STRING(id), mozilla::Forward<Args>(args)...);
|
||||
if (JSID_IS_SYMBOL(id))
|
||||
return f(JSID_TO_SYMBOL(id), mozilla::Forward<Args>(args)...);
|
||||
MOZ_ASSERT(!JSID_IS_GCTHING(id));
|
||||
return F::defaultValue(id);
|
||||
}
|
||||
|
||||
#undef id
|
||||
|
||||
}
|
||||
} // namespace js
|
||||
|
||||
#endif /* js_Id_h */
|
||||
|
|
|
|||
|
|
@ -0,0 +1,125 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/* SpiderMonkey initialization and shutdown APIs. */
|
||||
|
||||
#ifndef js_Initialization_h
|
||||
#define js_Initialization_h
|
||||
|
||||
#include "jstypes.h"
|
||||
|
||||
namespace JS {
|
||||
namespace detail {
|
||||
|
||||
enum class InitState { Uninitialized = 0, Running, ShutDown };
|
||||
|
||||
/**
|
||||
* SpiderMonkey's initialization status is tracked here, and it controls things
|
||||
* that should happen only once across all runtimes. It's an API requirement
|
||||
* that JS_Init (and JS_ShutDown, if called) be called in a thread-aware
|
||||
* manner, so this (internal -- embedders, don't use!) variable doesn't need to
|
||||
* be atomic.
|
||||
*/
|
||||
extern JS_PUBLIC_DATA(InitState)
|
||||
libraryInitState;
|
||||
|
||||
extern JS_PUBLIC_API(const char*)
|
||||
InitWithFailureDiagnostic(bool isDebugBuild);
|
||||
|
||||
} // namespace detail
|
||||
} // namespace JS
|
||||
|
||||
// These are equivalent to ICU's |UMemAllocFn|, |UMemReallocFn|, and
|
||||
// |UMemFreeFn| types. The first argument (called |context| in the ICU docs)
|
||||
// will always be nullptr and should be ignored.
|
||||
typedef void* (*JS_ICUAllocFn)(const void*, size_t size);
|
||||
typedef void* (*JS_ICUReallocFn)(const void*, void* p, size_t size);
|
||||
typedef void (*JS_ICUFreeFn)(const void*, void* p);
|
||||
|
||||
/**
|
||||
* This function can be used to track memory used by ICU. If it is called, it
|
||||
* *must* be called before JS_Init. Don't use it unless you know what you're
|
||||
* doing!
|
||||
*/
|
||||
extern JS_PUBLIC_API(bool)
|
||||
JS_SetICUMemoryFunctions(JS_ICUAllocFn allocFn,
|
||||
JS_ICUReallocFn reallocFn,
|
||||
JS_ICUFreeFn freeFn);
|
||||
|
||||
/**
|
||||
* Initialize SpiderMonkey, returning true only if initialization succeeded.
|
||||
* Once this method has succeeded, it is safe to call JS_NewRuntime and other
|
||||
* JSAPI methods.
|
||||
*
|
||||
* This method must be called before any other JSAPI method is used on any
|
||||
* thread. Once it has been used, it is safe to call any JSAPI method, and it
|
||||
* remains safe to do so until JS_ShutDown is correctly called.
|
||||
*
|
||||
* It is currently not possible to initialize SpiderMonkey multiple times (that
|
||||
* is, calling JS_Init/JSAPI methods/JS_ShutDown in that order, then doing so
|
||||
* again). This restriction may eventually be lifted.
|
||||
*/
|
||||
inline bool
|
||||
JS_Init(void)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
return !JS::detail::InitWithFailureDiagnostic(true);
|
||||
#else
|
||||
return !JS::detail::InitWithFailureDiagnostic(false);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* A variant of JS_Init. On success it returns nullptr. On failure it returns a
|
||||
* pointer to a string literal that describes how initialization failed, which
|
||||
* can be useful for debugging purposes.
|
||||
*/
|
||||
inline const char*
|
||||
JS_InitWithFailureDiagnostic(void)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
return JS::detail::InitWithFailureDiagnostic(true);
|
||||
#else
|
||||
return JS::detail::InitWithFailureDiagnostic(false);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns true if SpiderMonkey has been initialized successfully, even if it has
|
||||
* possibly been shut down.
|
||||
*
|
||||
* Note that it is the responsibility of the embedder to call JS_Init() and
|
||||
* JS_ShutDown() at the correct times, and therefore this API should ideally not
|
||||
* be necessary to use. This is only intended to be used in cases where the
|
||||
* embedder isn't in full control of deciding whether to initialize SpiderMonkey
|
||||
* or hand off the task to another consumer.
|
||||
*/
|
||||
inline bool
|
||||
JS_IsInitialized(void)
|
||||
{
|
||||
return JS::detail::libraryInitState != JS::detail::InitState::Uninitialized;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy free-standing resources allocated by SpiderMonkey, not associated
|
||||
* with any runtime, context, or other structure.
|
||||
*
|
||||
* This method should be called after all other JSAPI data has been properly
|
||||
* cleaned up: every new runtime must have been destroyed, every new context
|
||||
* must have been destroyed, and so on. Calling this method before all other
|
||||
* resources have been destroyed has undefined behavior.
|
||||
*
|
||||
* Failure to call this method, at present, has no adverse effects other than
|
||||
* leaking memory. This may not always be the case; it's recommended that all
|
||||
* embedders call this method when all other JSAPI operations have completed.
|
||||
*
|
||||
* It is currently not possible to initialize SpiderMonkey multiple times (that
|
||||
* is, calling JS_Init/JSAPI methods/JS_ShutDown in that order, then doing so
|
||||
* again). This restriction may eventually be lifted.
|
||||
*/
|
||||
extern JS_PUBLIC_API(void)
|
||||
JS_ShutDown(void);
|
||||
|
||||
#endif /* js_Initialization_h */
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue