/src/openssl/crypto/rsa/rsa_none.c
Line  | Count  | Source  | 
1  |  | /*  | 
2  |  |  * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.  | 
3  |  |  *  | 
4  |  |  * Licensed under the Apache License 2.0 (the "License").  You may not use  | 
5  |  |  * this file except in compliance with the License.  You can obtain a copy  | 
6  |  |  * in the file LICENSE in the source distribution or at  | 
7  |  |  * https://www.openssl.org/source/license.html  | 
8  |  |  */  | 
9  |  |  | 
10  |  | /*  | 
11  |  |  * RSA low level APIs are deprecated for public use, but still ok for  | 
12  |  |  * internal use.  | 
13  |  |  */  | 
14  |  | #include "internal/deprecated.h"  | 
15  |  |  | 
16  |  | #include "internal/cryptlib.h"  | 
17  |  | #include <openssl/bn.h>  | 
18  |  | #include <openssl/rsa.h>  | 
19  |  |  | 
20  |  | int RSA_padding_add_none(unsigned char *to, int tlen,  | 
21  |  |                          const unsigned char *from, int flen)  | 
22  | 0  | { | 
23  | 0  |     if (flen > tlen) { | 
24  | 0  |         ERR_raise(ERR_LIB_RSA, RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE);  | 
25  | 0  |         return 0;  | 
26  | 0  |     }  | 
27  |  |  | 
28  | 0  |     if (flen < tlen) { | 
29  | 0  |         ERR_raise(ERR_LIB_RSA, RSA_R_DATA_TOO_SMALL_FOR_KEY_SIZE);  | 
30  | 0  |         return 0;  | 
31  | 0  |     }  | 
32  |  |  | 
33  | 0  |     memcpy(to, from, (unsigned int)flen);  | 
34  | 0  |     return 1;  | 
35  | 0  | }  | 
36  |  |  | 
37  |  | int RSA_padding_check_none(unsigned char *to, int tlen,  | 
38  |  |                            const unsigned char *from, int flen, int num)  | 
39  | 0  | { | 
40  |  | 
  | 
41  | 0  |     if (flen > tlen) { | 
42  | 0  |         ERR_raise(ERR_LIB_RSA, RSA_R_DATA_TOO_LARGE);  | 
43  | 0  |         return -1;  | 
44  | 0  |     }  | 
45  |  |  | 
46  | 0  |     memset(to, 0, tlen - flen);  | 
47  | 0  |     memcpy(to + tlen - flen, from, flen);  | 
48  | 0  |     return tlen;  | 
49  | 0  | }  |