|
@@ -67,7 +67,7 @@ typedef struct Rsa_key {
|
|
|
|
|
|
int rsa_make_key(prng_state *prng, int wprng, int size, long e, rsa_key *key);
|
|
int rsa_make_key(prng_state *prng, int wprng, int size, long e, rsa_key *key);
|
|
|
|
|
|
-int rsa_get_size(rsa_key *key);
|
|
|
|
|
|
+int rsa_get_size(const rsa_key *key);
|
|
|
|
|
|
int rsa_exptmod(const unsigned char *in, unsigned long inlen,
|
|
int rsa_exptmod(const unsigned char *in, unsigned long inlen,
|
|
unsigned char *out, unsigned long *outlen, int which,
|
|
unsigned char *out, unsigned long *outlen, int which,
|
|
@@ -119,7 +119,7 @@ int rsa_verify_hash_ex(const unsigned char *sig, unsigned long siglen,
|
|
int rsa_sign_saltlen_get_max_ex(int padding, int hash_idx, rsa_key *key);
|
|
int rsa_sign_saltlen_get_max_ex(int padding, int hash_idx, rsa_key *key);
|
|
|
|
|
|
/* PKCS #1 import/export */
|
|
/* PKCS #1 import/export */
|
|
-int rsa_export(unsigned char *out, unsigned long *outlen, int type, rsa_key *key);
|
|
|
|
|
|
+int rsa_export(unsigned char *out, unsigned long *outlen, int type, const rsa_key *key);
|
|
int rsa_import(const unsigned char *in, unsigned long inlen, rsa_key *key);
|
|
int rsa_import(const unsigned char *in, unsigned long inlen, rsa_key *key);
|
|
|
|
|
|
int rsa_import_x509(const unsigned char *in, unsigned long inlen, rsa_key *key);
|
|
int rsa_import_x509(const unsigned char *in, unsigned long inlen, rsa_key *key);
|
|
@@ -205,9 +205,9 @@ typedef struct {
|
|
void *prime;
|
|
void *prime;
|
|
} dh_key;
|
|
} dh_key;
|
|
|
|
|
|
-int dh_get_groupsize(dh_key *key);
|
|
|
|
|
|
+int dh_get_groupsize(const dh_key *key);
|
|
|
|
|
|
-int dh_export(unsigned char *out, unsigned long *outlen, int type, dh_key *key);
|
|
|
|
|
|
+int dh_export(unsigned char *out, unsigned long *outlen, int type, const dh_key *key);
|
|
int dh_import(const unsigned char *in, unsigned long inlen, dh_key *key);
|
|
int dh_import(const unsigned char *in, unsigned long inlen, dh_key *key);
|
|
|
|
|
|
int dh_set_pg(const unsigned char *p, unsigned long plen,
|
|
int dh_set_pg(const unsigned char *p, unsigned long plen,
|
|
@@ -219,12 +219,12 @@ int dh_set_pg_groupsize(int groupsize, dh_key *key);
|
|
int dh_set_key(const unsigned char *in, unsigned long inlen, int type, dh_key *key);
|
|
int dh_set_key(const unsigned char *in, unsigned long inlen, int type, dh_key *key);
|
|
int dh_generate_key(prng_state *prng, int wprng, dh_key *key);
|
|
int dh_generate_key(prng_state *prng, int wprng, dh_key *key);
|
|
|
|
|
|
-int dh_shared_secret(dh_key *private_key, dh_key *public_key,
|
|
|
|
|
|
+int dh_shared_secret(const dh_key *private_key, const dh_key *public_key,
|
|
unsigned char *out, unsigned long *outlen);
|
|
unsigned char *out, unsigned long *outlen);
|
|
|
|
|
|
void dh_free(dh_key *key);
|
|
void dh_free(dh_key *key);
|
|
|
|
|
|
-int dh_export_key(void *out, unsigned long *outlen, int type, dh_key *key);
|
|
|
|
|
|
+int dh_export_key(void *out, unsigned long *outlen, int type, const dh_key *key);
|
|
|
|
|
|
#ifdef LTC_SOURCE
|
|
#ifdef LTC_SOURCE
|
|
typedef struct {
|
|
typedef struct {
|
|
@@ -235,7 +235,7 @@ typedef struct {
|
|
extern const ltc_dh_set_type ltc_dh_sets[];
|
|
extern const ltc_dh_set_type ltc_dh_sets[];
|
|
|
|
|
|
/* internal helper functions */
|
|
/* internal helper functions */
|
|
-int dh_check_pubkey(dh_key *key);
|
|
|
|
|
|
+int dh_check_pubkey(const dh_key *key);
|
|
#endif
|
|
#endif
|
|
|
|
|
|
#endif /* LTC_MDH */
|
|
#endif /* LTC_MDH */
|
|
@@ -603,8 +603,8 @@ extern const char* der_asn1_tag_to_string_map[];
|
|
extern const unsigned long der_asn1_tag_to_string_map_sz;
|
|
extern const unsigned long der_asn1_tag_to_string_map_sz;
|
|
|
|
|
|
/* SEQUENCE */
|
|
/* SEQUENCE */
|
|
-int der_encode_sequence_ex(ltc_asn1_list *list, unsigned long inlen,
|
|
|
|
- unsigned char *out, unsigned long *outlen, int type_of);
|
|
|
|
|
|
+int der_encode_sequence_ex(const ltc_asn1_list *list, unsigned long inlen,
|
|
|
|
+ unsigned char *out, unsigned long *outlen, int type_of);
|
|
|
|
|
|
#define der_encode_sequence(list, inlen, out, outlen) der_encode_sequence_ex(list, inlen, out, outlen, LTC_ASN1_SEQUENCE)
|
|
#define der_encode_sequence(list, inlen, out, outlen) der_encode_sequence_ex(list, inlen, out, outlen, LTC_ASN1_SEQUENCE)
|
|
|
|
|
|
@@ -635,7 +635,7 @@ int der_decode_sequence_ex(const unsigned char *in, unsigned long inlen,
|
|
#define der_decode_sequence(in, inlen, list, outlen) der_decode_sequence_ex(in, inlen, list, outlen, LTC_DER_SEQ_SEQUENCE | LTC_DER_SEQ_RELAXED)
|
|
#define der_decode_sequence(in, inlen, list, outlen) der_decode_sequence_ex(in, inlen, list, outlen, LTC_DER_SEQ_SEQUENCE | LTC_DER_SEQ_RELAXED)
|
|
#define der_decode_sequence_strict(in, inlen, list, outlen) der_decode_sequence_ex(in, inlen, list, outlen, LTC_DER_SEQ_SEQUENCE | LTC_DER_SEQ_STRICT)
|
|
#define der_decode_sequence_strict(in, inlen, list, outlen) der_decode_sequence_ex(in, inlen, list, outlen, LTC_DER_SEQ_SEQUENCE | LTC_DER_SEQ_STRICT)
|
|
|
|
|
|
-int der_length_sequence(ltc_asn1_list *list, unsigned long inlen,
|
|
|
|
|
|
+int der_length_sequence(const ltc_asn1_list *list, unsigned long inlen,
|
|
unsigned long *outlen);
|
|
unsigned long *outlen);
|
|
|
|
|
|
|
|
|
|
@@ -664,7 +664,7 @@ int der_encode_asn1_length(unsigned long len, unsigned char* out, unsigned long*
|
|
int der_decode_asn1_length(const unsigned char* len, unsigned long* lenlen, unsigned long* outlen);
|
|
int der_decode_asn1_length(const unsigned char* len, unsigned long* lenlen, unsigned long* outlen);
|
|
int der_length_asn1_length(unsigned long len, unsigned long *outlen);
|
|
int der_length_asn1_length(unsigned long len, unsigned long *outlen);
|
|
|
|
|
|
-int der_length_sequence_ex(ltc_asn1_list *list, unsigned long inlen,
|
|
|
|
|
|
+int der_length_sequence_ex(const ltc_asn1_list *list, unsigned long inlen,
|
|
unsigned long *outlen, unsigned long *payloadlen);
|
|
unsigned long *outlen, unsigned long *payloadlen);
|
|
|
|
|
|
extern const ltc_asn1_type der_asn1_tag_to_type_map[];
|
|
extern const ltc_asn1_type der_asn1_tag_to_type_map[];
|
|
@@ -677,11 +677,11 @@ extern const unsigned long der_asn1_type_to_identifier_map_sz;
|
|
/* SET */
|
|
/* SET */
|
|
#define der_decode_set(in, inlen, list, outlen) der_decode_sequence_ex(in, inlen, list, outlen, LTC_DER_SEQ_SET)
|
|
#define der_decode_set(in, inlen, list, outlen) der_decode_sequence_ex(in, inlen, list, outlen, LTC_DER_SEQ_SET)
|
|
#define der_length_set der_length_sequence
|
|
#define der_length_set der_length_sequence
|
|
-int der_encode_set(ltc_asn1_list *list, unsigned long inlen,
|
|
|
|
- unsigned char *out, unsigned long *outlen);
|
|
|
|
|
|
+int der_encode_set(const ltc_asn1_list *list, unsigned long inlen,
|
|
|
|
+ unsigned char *out, unsigned long *outlen);
|
|
|
|
|
|
-int der_encode_setof(ltc_asn1_list *list, unsigned long inlen,
|
|
|
|
- unsigned char *out, unsigned long *outlen);
|
|
|
|
|
|
+int der_encode_setof(const ltc_asn1_list *list, unsigned long inlen,
|
|
|
|
+ unsigned char *out, unsigned long *outlen);
|
|
|
|
|
|
/* VA list handy helpers with triplets of <type, size, data> */
|
|
/* VA list handy helpers with triplets of <type, size, data> */
|
|
int der_encode_sequence_multi(unsigned char *out, unsigned long *outlen, ...);
|
|
int der_encode_sequence_multi(unsigned char *out, unsigned long *outlen, ...);
|
|
@@ -736,7 +736,7 @@ int der_encode_object_identifier(unsigned long *words, unsigned long nwords,
|
|
unsigned char *out, unsigned long *outlen);
|
|
unsigned char *out, unsigned long *outlen);
|
|
int der_decode_object_identifier(const unsigned char *in, unsigned long inlen,
|
|
int der_decode_object_identifier(const unsigned char *in, unsigned long inlen,
|
|
unsigned long *words, unsigned long *outlen);
|
|
unsigned long *words, unsigned long *outlen);
|
|
-int der_length_object_identifier(unsigned long *words, unsigned long nwords, unsigned long *outlen);
|
|
|
|
|
|
+int der_length_object_identifier(const unsigned long *words, unsigned long nwords, unsigned long *outlen);
|
|
unsigned long der_object_identifier_bits(unsigned long x);
|
|
unsigned long der_object_identifier_bits(unsigned long x);
|
|
|
|
|
|
/* IA5 STRING */
|
|
/* IA5 STRING */
|
|
@@ -821,7 +821,7 @@ int der_encode_utctime(ltc_utctime *utctime,
|
|
int der_decode_utctime(const unsigned char *in, unsigned long *inlen,
|
|
int der_decode_utctime(const unsigned char *in, unsigned long *inlen,
|
|
ltc_utctime *out);
|
|
ltc_utctime *out);
|
|
|
|
|
|
-int der_length_utctime(ltc_utctime *utctime, unsigned long *outlen);
|
|
|
|
|
|
+int der_length_utctime(const ltc_utctime *utctime, unsigned long *outlen);
|
|
|
|
|
|
/* GeneralizedTime */
|
|
/* GeneralizedTime */
|
|
typedef struct {
|
|
typedef struct {
|
|
@@ -843,7 +843,7 @@ int der_encode_generalizedtime(ltc_generalizedtime *gtime,
|
|
int der_decode_generalizedtime(const unsigned char *in, unsigned long *inlen,
|
|
int der_decode_generalizedtime(const unsigned char *in, unsigned long *inlen,
|
|
ltc_generalizedtime *out);
|
|
ltc_generalizedtime *out);
|
|
|
|
|
|
-int der_length_generalizedtime(ltc_generalizedtime *gtime, unsigned long *outlen);
|
|
|
|
|
|
+int der_length_generalizedtime(const ltc_generalizedtime *gtime, unsigned long *outlen);
|
|
|
|
|
|
#ifdef LTC_SOURCE
|
|
#ifdef LTC_SOURCE
|
|
/* internal helper functions */
|
|
/* internal helper functions */
|