diff options
author | Ralf S. Engelschall <rse@openssl.org> | 1998-12-21 10:56:39 +0000 |
---|---|---|
committer | Ralf S. Engelschall <rse@openssl.org> | 1998-12-21 10:56:39 +0000 |
commit | 58964a492275ca9a59a0cd9c8155cb2491b4b909 (patch) | |
tree | c7b16876a5789463bbbb468ef4829c8129b3d718 /crypto/rsa/rsa.h | |
parent | d02b48c63a58ea4367a0e905979f140b7d090f86 (diff) | |
download | openssl-58964a492275ca9a59a0cd9c8155cb2491b4b909.tar.gz |
Import of old SSLeay release: SSLeay 0.9.0b
Diffstat (limited to 'crypto/rsa/rsa.h')
-rw-r--r-- | crypto/rsa/rsa.h | 137 |
1 files changed, 109 insertions, 28 deletions
diff --git a/crypto/rsa/rsa.h b/crypto/rsa/rsa.h index 821e928a1c..aeb78ffcd3 100644 --- a/crypto/rsa/rsa.h +++ b/crypto/rsa/rsa.h @@ -1,5 +1,5 @@ /* crypto/rsa/rsa.h */ -/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written @@ -64,6 +64,7 @@ extern "C" { #endif #include "bn.h" +#include "crypto.h" typedef struct rsa_meth_st { @@ -72,10 +73,13 @@ typedef struct rsa_meth_st int (*rsa_pub_dec)(); int (*rsa_priv_enc)(); int (*rsa_priv_dec)(); - int (*rsa_mod_exp)(); - int (*bn_mod_exp)(); + int (*rsa_mod_exp)(); /* Can be null */ + int (*bn_mod_exp)(); /* Can be null */ int (*init)(/* RSA * */); /* called at new */ int (*finish)(/* RSA * */); /* called at free */ + + int flags; /* RSA_METHOD_FLAG_* things */ + char *app_data; /* may be needed! */ } RSA_METHOD; typedef struct rsa_st @@ -94,22 +98,40 @@ typedef struct rsa_st BIGNUM *dmq1; BIGNUM *iqmp; /* be carefull using this if the RSA structure is shared */ - char *app_data; + CRYPTO_EX_DATA ex_data; int references; + int flags; + + /* Normally used to cached montgomery values */ + char *method_mod_n; + char *method_mod_p; + char *method_mod_q; + + BN_BLINDING *blinding; } RSA; #define RSA_3 0x3L #define RSA_F4 0x10001L -#define RSA_PKCS1_PADDING 11 -#define RSA_SSLV23_PADDING 12 +#define RSA_METHOD_FLAG_NO_CHECK 0x01 /* don't check pub/private match */ +#define RSA_FLAG_CACHE_PUBLIC 0x02 +#define RSA_FLAG_CACHE_PRIVATE 0x04 +#define RSA_FLAG_BLINDING 0x08 +#define RSA_FLAG_THREAD_SAFE 0x10 + +#define RSA_PKCS1_PADDING 1 +#define RSA_SSLV23_PADDING 2 +#define RSA_NO_PADDING 3 + +#define RSA_set_app_data(s,arg) RSA_set_ex_data(s,0,(char *)arg) +#define RSA_get_app_data(s) RSA_get_ex_data(s,0) #ifndef NOPROTO RSA * RSA_new(void); RSA * RSA_new_method(RSA_METHOD *method); int RSA_size(RSA *); RSA * RSA_generate_key(int bits, unsigned long e,void - (*callback)(int,int)); + (*callback)(int,int,char *),char *cb_arg); /* next 4 return -1 on error */ int RSA_public_encrypt(int flen, unsigned char *from, unsigned char *to, RSA *rsa,int padding); @@ -121,10 +143,12 @@ int RSA_private_decrypt(int flen, unsigned char *from, unsigned char *to, RSA *rsa,int padding); void RSA_free (RSA *r); +int RSA_flags(RSA *r); + void RSA_set_default_method(RSA_METHOD *meth); /* If you have RSAref compiled in. */ -/* RSA_METHOD *RSA_PKCS1_RSAref(void); */ +RSA_METHOD *RSA_PKCS1_RSAref(void); /* these are the actual SSLeay RSA functions */ RSA_METHOD *RSA_PKCS1_SSLeay(void); @@ -135,7 +159,7 @@ RSA * d2i_RSAPublicKey(RSA **a, unsigned char **pp, long length); int i2d_RSAPublicKey(RSA *a, unsigned char **pp); RSA * d2i_RSAPrivateKey(RSA **a, unsigned char **pp, long length); int i2d_RSAPrivateKey(RSA *a, unsigned char **pp); -#ifndef WIN16 +#ifndef NO_FP_API int RSA_print_fp(FILE *fp, RSA *r,int offset); #endif @@ -145,6 +169,9 @@ int RSA_print(BIO *bp, RSA *r,int offset); int i2d_Netscape_RSA(RSA *a, unsigned char **pp, int (*cb)()); RSA *d2i_Netscape_RSA(RSA **a, unsigned char **pp, long length, int (*cb)()); +/* Naughty internal function required elsewhere, to handle a MS structure + * that is the same as the netscape one :-) */ +RSA *d2i_Netscape_RSA_2(RSA **a, unsigned char **pp, long length, int (*cb)()); /* The following 2 functions sign and verify a X509_SIG ASN1 object * inside PKCS#1 padded RSA encryption */ @@ -160,6 +187,31 @@ int RSA_sign_ASN1_OCTET_STRING(int type, unsigned char *m, unsigned int m_len, int RSA_verify_ASN1_OCTET_STRING(int type, unsigned char *m, unsigned int m_len, unsigned char *sigbuf, unsigned int siglen, RSA *rsa); +int RSA_blinding_on(RSA *rsa, BN_CTX *ctx); +void RSA_blinding_off(RSA *rsa); + +int RSA_padding_add_PKCS1_type_1(unsigned char *to,int tlen, + unsigned char *f,int fl); +int RSA_padding_check_PKCS1_type_1(unsigned char *to,int tlen, + unsigned char *f,int fl); +int RSA_padding_add_PKCS1_type_2(unsigned char *to,int tlen, + unsigned char *f,int fl); +int RSA_padding_check_PKCS1_type_2(unsigned char *to,int tlen, + unsigned char *f,int fl); +int RSA_padding_add_SSLv23(unsigned char *to,int tlen, + unsigned char *f,int fl); +int RSA_padding_check_SSLv23(unsigned char *to,int tlen, + unsigned char *f,int fl); +int RSA_padding_add_none(unsigned char *to,int tlen, + unsigned char *f,int fl); +int RSA_padding_check_none(unsigned char *to,int tlen, + unsigned char *f,int fl); + +int RSA_get_ex_new_index(long argl, char *argp, int (*new_func)(), + int (*dup_func)(), void (*free_func)()); +int RSA_set_ex_data(RSA *r,int idx,char *arg); +char *RSA_get_ex_data(RSA *r, int idx); + #else RSA * RSA_new(); @@ -172,6 +224,8 @@ int RSA_public_decrypt(); int RSA_private_decrypt(); void RSA_free (); +int RSA_flags(); + void RSA_set_default_method(); /* RSA_METHOD *RSA_PKCS1_RSAref(); */ @@ -183,7 +237,7 @@ RSA * d2i_RSAPublicKey(); int i2d_RSAPublicKey(); RSA * d2i_RSAPrivateKey(); int i2d_RSAPrivateKey(); -#ifndef WIN16 +#ifndef NO_FP_API int RSA_print_fp(); #endif @@ -191,13 +245,28 @@ int RSA_print(); int i2d_Netscape_RSA(); RSA *d2i_Netscape_RSA(); +RSA *d2i_Netscape_RSA_2(); int RSA_sign(); int RSA_verify(); int RSA_sign_ASN1_OCTET_STRING(); int RSA_verify_ASN1_OCTET_STRING(); - +int RSA_blinding_on(); +void RSA_blinding_off(); + +int RSA_padding_add_PKCS1_type_1(); +int RSA_padding_check_PKCS1_type_1(); +int RSA_padding_add_PKCS1_type_2(); +int RSA_padding_check_PKCS1_type_2(); +int RSA_padding_add_SSLv23(); +int RSA_padding_check_SSLv23(); +int RSA_padding_add_none(); +int RSA_padding_check_none(); + +int RSA_get_ex_new_index(); +int RSA_set_ex_data(); +char *RSA_get_ex_data(); #endif @@ -211,12 +280,20 @@ int RSA_verify_ASN1_OCTET_STRING(); #define RSA_F_RSA_EAY_PUBLIC_ENCRYPT 103 #define RSA_F_RSA_GENERATE_KEY 104 #define RSA_F_RSA_NEW_METHOD 105 -#define RSA_F_RSA_PRINT 106 -#define RSA_F_RSA_PRINT_FP 107 -#define RSA_F_RSA_SIGN 108 -#define RSA_F_RSA_SIGN_ASN1_OCTET_STRING 109 -#define RSA_F_RSA_VERIFY 110 -#define RSA_F_RSA_VERIFY_ASN1_OCTET_STRING 111 +#define RSA_F_RSA_PADDING_ADD_NONE 106 +#define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_1 107 +#define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_2 108 +#define RSA_F_RSA_PADDING_ADD_SSLV23 109 +#define RSA_F_RSA_PADDING_CHECK_NONE 110 +#define RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_1 111 +#define RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2 112 +#define RSA_F_RSA_PADDING_CHECK_SSLV23 113 +#define RSA_F_RSA_PRINT 114 +#define RSA_F_RSA_PRINT_FP 115 +#define RSA_F_RSA_SIGN 116 +#define RSA_F_RSA_SIGN_ASN1_OCTET_STRING 117 +#define RSA_F_RSA_VERIFY 118 +#define RSA_F_RSA_VERIFY_ASN1_OCTET_STRING 119 /* Reason codes. */ #define RSA_R_ALGORITHM_MISMATCH 100 @@ -224,17 +301,21 @@ int RSA_verify_ASN1_OCTET_STRING(); #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 105 -#define RSA_R_BLOCK_TYPE_IS_NOT_02 106 -#define RSA_R_DATA_GREATER_THAN_MOD_LEN 107 -#define RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 108 -#define RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY 109 -#define RSA_R_NULL_BEFORE_BLOCK_MISSING 110 -#define RSA_R_SSLV3_ROLLBACK_ATTACK 111 -#define RSA_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 112 -#define RSA_R_UNKNOWN_ALGORITHM_TYPE 113 -#define RSA_R_UNKNOWN_PADDING_TYPE 114 -#define RSA_R_WRONG_SIGNATURE_LENGTH 115 +#define RSA_R_BAD_ZERO_BYTE 105 +#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_SMALL 111 +#define RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY 112 +#define RSA_R_NULL_BEFORE_BLOCK_MISSING 113 +#define RSA_R_PADDING_CHECK_FAILED 114 +#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_PADDING_TYPE 118 +#define RSA_R_WRONG_SIGNATURE_LENGTH 119 #ifdef __cplusplus } |