Xuyi Wang / wolfSSL

Dependents:   OS

Committer:
wolfSSL
Date:
Sat Aug 18 22:20:43 2018 +0000
Revision:
15:117db924cf7c
wolfSSL 3.15.3

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wolfSSL 15:117db924cf7c 1 /* rsa.h
wolfSSL 15:117db924cf7c 2 *
wolfSSL 15:117db924cf7c 3 * Copyright (C) 2006-2017 wolfSSL Inc.
wolfSSL 15:117db924cf7c 4 *
wolfSSL 15:117db924cf7c 5 * This file is part of wolfSSL.
wolfSSL 15:117db924cf7c 6 *
wolfSSL 15:117db924cf7c 7 * wolfSSL is free software; you can redistribute it and/or modify
wolfSSL 15:117db924cf7c 8 * it under the terms of the GNU General Public License as published by
wolfSSL 15:117db924cf7c 9 * the Free Software Foundation; either version 2 of the License, or
wolfSSL 15:117db924cf7c 10 * (at your option) any later version.
wolfSSL 15:117db924cf7c 11 *
wolfSSL 15:117db924cf7c 12 * wolfSSL is distributed in the hope that it will be useful,
wolfSSL 15:117db924cf7c 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
wolfSSL 15:117db924cf7c 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
wolfSSL 15:117db924cf7c 15 * GNU General Public License for more details.
wolfSSL 15:117db924cf7c 16 *
wolfSSL 15:117db924cf7c 17 * You should have received a copy of the GNU General Public License
wolfSSL 15:117db924cf7c 18 * along with this program; if not, write to the Free Software
wolfSSL 15:117db924cf7c 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
wolfSSL 15:117db924cf7c 20 */
wolfSSL 15:117db924cf7c 21
wolfSSL 15:117db924cf7c 22 /* rsa.h for openSSL */
wolfSSL 15:117db924cf7c 23
wolfSSL 15:117db924cf7c 24
wolfSSL 15:117db924cf7c 25 #ifndef WOLFSSL_RSA_H_
wolfSSL 15:117db924cf7c 26 #define WOLFSSL_RSA_H_
wolfSSL 15:117db924cf7c 27
wolfSSL 15:117db924cf7c 28 #include <wolfssl/openssl/bn.h>
wolfSSL 15:117db924cf7c 29
wolfSSL 15:117db924cf7c 30
wolfSSL 15:117db924cf7c 31 #ifdef __cplusplus
wolfSSL 15:117db924cf7c 32 extern "C" {
wolfSSL 15:117db924cf7c 33 #endif
wolfSSL 15:117db924cf7c 34
wolfSSL 15:117db924cf7c 35 /* Padding types */
wolfSSL 15:117db924cf7c 36 #define RSA_PKCS1_PADDING 0
wolfSSL 15:117db924cf7c 37 #define RSA_PKCS1_OAEP_PADDING 1
wolfSSL 15:117db924cf7c 38
wolfSSL 15:117db924cf7c 39 #ifndef WOLFSSL_RSA_TYPE_DEFINED /* guard on redeclaration */
wolfSSL 15:117db924cf7c 40 typedef struct WOLFSSL_RSA WOLFSSL_RSA;
wolfSSL 15:117db924cf7c 41 #define WOLFSSL_RSA_TYPE_DEFINED
wolfSSL 15:117db924cf7c 42 #endif
wolfSSL 15:117db924cf7c 43
wolfSSL 15:117db924cf7c 44 typedef WOLFSSL_RSA RSA;
wolfSSL 15:117db924cf7c 45
wolfSSL 15:117db924cf7c 46 struct WOLFSSL_RSA {
wolfSSL 15:117db924cf7c 47 #ifdef WC_RSA_BLINDING
wolfSSL 15:117db924cf7c 48 WC_RNG* rng; /* for PrivateDecrypt blinding */
wolfSSL 15:117db924cf7c 49 #endif
wolfSSL 15:117db924cf7c 50 WOLFSSL_BIGNUM* n;
wolfSSL 15:117db924cf7c 51 WOLFSSL_BIGNUM* e;
wolfSSL 15:117db924cf7c 52 WOLFSSL_BIGNUM* d;
wolfSSL 15:117db924cf7c 53 WOLFSSL_BIGNUM* p;
wolfSSL 15:117db924cf7c 54 WOLFSSL_BIGNUM* q;
wolfSSL 15:117db924cf7c 55 WOLFSSL_BIGNUM* dmp1; /* dP */
wolfSSL 15:117db924cf7c 56 WOLFSSL_BIGNUM* dmq1; /* dQ */
wolfSSL 15:117db924cf7c 57 WOLFSSL_BIGNUM* iqmp; /* u */
wolfSSL 15:117db924cf7c 58 void* heap;
wolfSSL 15:117db924cf7c 59 void* internal; /* our RSA */
wolfSSL 15:117db924cf7c 60 char inSet; /* internal set from external ? */
wolfSSL 15:117db924cf7c 61 char exSet; /* external set from internal ? */
wolfSSL 15:117db924cf7c 62 char ownRng; /* flag for if the rng should be free'd */
wolfSSL 15:117db924cf7c 63 };
wolfSSL 15:117db924cf7c 64
wolfSSL 15:117db924cf7c 65
wolfSSL 15:117db924cf7c 66 WOLFSSL_API WOLFSSL_RSA* wolfSSL_RSA_new(void);
wolfSSL 15:117db924cf7c 67 WOLFSSL_API void wolfSSL_RSA_free(WOLFSSL_RSA*);
wolfSSL 15:117db924cf7c 68
wolfSSL 15:117db924cf7c 69 WOLFSSL_API int wolfSSL_RSA_generate_key_ex(WOLFSSL_RSA*, int bits, WOLFSSL_BIGNUM*,
wolfSSL 15:117db924cf7c 70 void* cb);
wolfSSL 15:117db924cf7c 71
wolfSSL 15:117db924cf7c 72 WOLFSSL_API int wolfSSL_RSA_blinding_on(WOLFSSL_RSA*, WOLFSSL_BN_CTX*);
wolfSSL 15:117db924cf7c 73 WOLFSSL_API int wolfSSL_RSA_public_encrypt(int len, const unsigned char* fr,
wolfSSL 15:117db924cf7c 74 unsigned char* to, WOLFSSL_RSA*, int padding);
wolfSSL 15:117db924cf7c 75 WOLFSSL_API int wolfSSL_RSA_private_decrypt(int len, const unsigned char* fr,
wolfSSL 15:117db924cf7c 76 unsigned char* to, WOLFSSL_RSA*, int padding);
wolfSSL 15:117db924cf7c 77 WOLFSSL_API int wolfSSL_RSA_private_encrypt(int len, unsigned char* in,
wolfSSL 15:117db924cf7c 78 unsigned char* out, WOLFSSL_RSA* rsa, int padding);
wolfSSL 15:117db924cf7c 79
wolfSSL 15:117db924cf7c 80 WOLFSSL_API int wolfSSL_RSA_size(const WOLFSSL_RSA*);
wolfSSL 15:117db924cf7c 81 WOLFSSL_API int wolfSSL_RSA_sign(int type, const unsigned char* m,
wolfSSL 15:117db924cf7c 82 unsigned int mLen, unsigned char* sigRet,
wolfSSL 15:117db924cf7c 83 unsigned int* sigLen, WOLFSSL_RSA*);
wolfSSL 15:117db924cf7c 84 WOLFSSL_API int wolfSSL_RSA_sign_ex(int type, const unsigned char* m,
wolfSSL 15:117db924cf7c 85 unsigned int mLen, unsigned char* sigRet,
wolfSSL 15:117db924cf7c 86 unsigned int* sigLen, WOLFSSL_RSA*, int);
wolfSSL 15:117db924cf7c 87 WOLFSSL_API int wolfSSL_RSA_verify(int type, const unsigned char* m,
wolfSSL 15:117db924cf7c 88 unsigned int mLen, const unsigned char* sig,
wolfSSL 15:117db924cf7c 89 unsigned int sigLen, WOLFSSL_RSA*);
wolfSSL 15:117db924cf7c 90 WOLFSSL_API int wolfSSL_RSA_public_decrypt(int flen, const unsigned char* from,
wolfSSL 15:117db924cf7c 91 unsigned char* to, WOLFSSL_RSA*, int padding);
wolfSSL 15:117db924cf7c 92 WOLFSSL_API int wolfSSL_RSA_GenAdd(WOLFSSL_RSA*);
wolfSSL 15:117db924cf7c 93 WOLFSSL_API int wolfSSL_RSA_LoadDer(WOLFSSL_RSA*, const unsigned char*, int sz);
wolfSSL 15:117db924cf7c 94 WOLFSSL_API int wolfSSL_RSA_LoadDer_ex(WOLFSSL_RSA*, const unsigned char*, int sz, int opt);
wolfSSL 15:117db924cf7c 95
wolfSSL 15:117db924cf7c 96 #define WOLFSSL_RSA_LOAD_PRIVATE 1
wolfSSL 15:117db924cf7c 97 #define WOLFSSL_RSA_LOAD_PUBLIC 2
wolfSSL 15:117db924cf7c 98 #define WOLFSSL_RSA_F4 0x10001L
wolfSSL 15:117db924cf7c 99
wolfSSL 15:117db924cf7c 100 #define RSA_new wolfSSL_RSA_new
wolfSSL 15:117db924cf7c 101 #define RSA_free wolfSSL_RSA_free
wolfSSL 15:117db924cf7c 102
wolfSSL 15:117db924cf7c 103 #define RSA_generate_key_ex wolfSSL_RSA_generate_key_ex
wolfSSL 15:117db924cf7c 104
wolfSSL 15:117db924cf7c 105 #define RSA_blinding_on wolfSSL_RSA_blinding_on
wolfSSL 15:117db924cf7c 106 #define RSA_public_encrypt wolfSSL_RSA_public_encrypt
wolfSSL 15:117db924cf7c 107 #define RSA_private_decrypt wolfSSL_RSA_private_decrypt
wolfSSL 15:117db924cf7c 108 #define RSA_private_encrypt wolfSSL_RSA_private_encrypt
wolfSSL 15:117db924cf7c 109
wolfSSL 15:117db924cf7c 110 #define RSA_size wolfSSL_RSA_size
wolfSSL 15:117db924cf7c 111 #define RSA_sign wolfSSL_RSA_sign
wolfSSL 15:117db924cf7c 112 #define RSA_verify wolfSSL_RSA_verify
wolfSSL 15:117db924cf7c 113 #define RSA_public_decrypt wolfSSL_RSA_public_decrypt
wolfSSL 15:117db924cf7c 114
wolfSSL 15:117db924cf7c 115 #define RSA_F4 WOLFSSL_RSA_F4
wolfSSL 15:117db924cf7c 116
wolfSSL 15:117db924cf7c 117 #ifdef __cplusplus
wolfSSL 15:117db924cf7c 118 } /* extern "C" */
wolfSSL 15:117db924cf7c 119 #endif
wolfSSL 15:117db924cf7c 120
wolfSSL 15:117db924cf7c 121 #endif /* header */
wolfSSL 15:117db924cf7c 122