source: azure_iot_hub/trunk/wolfssl-3.15.7/wolfssl/openssl/rsa.h@ 388

Last change on this file since 388 was 388, checked in by coas-nagasima, 5 years ago

Azure IoT Hub Device C SDK を使ったサンプルの追加

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