]> git.ipfire.org Git - thirdparty/openssl.git/blob - crypto/rsa/rsa_none.c
Update copyright year
[thirdparty/openssl.git] / crypto / rsa / rsa_none.c
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 {
23 if (flen > tlen) {
24 RSAerr(RSA_F_RSA_PADDING_ADD_NONE, RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE);
25 return 0;
26 }
27
28 if (flen < tlen) {
29 RSAerr(RSA_F_RSA_PADDING_ADD_NONE, RSA_R_DATA_TOO_SMALL_FOR_KEY_SIZE);
30 return 0;
31 }
32
33 memcpy(to, from, (unsigned int)flen);
34 return 1;
35 }
36
37 int RSA_padding_check_none(unsigned char *to, int tlen,
38 const unsigned char *from, int flen, int num)
39 {
40
41 if (flen > tlen) {
42 RSAerr(RSA_F_RSA_PADDING_CHECK_NONE, RSA_R_DATA_TOO_LARGE);
43 return -1;
44 }
45
46 memset(to, 0, tlen - flen);
47 memcpy(to + tlen - flen, from, flen);
48 return tlen;
49 }