/src/openssl/crypto/rsa/rsa_none.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved. |
3 | | * |
4 | | * Licensed under the OpenSSL license (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 | | #include "internal/cryptlib.h" |
11 | | #include <openssl/bn.h> |
12 | | #include <openssl/rsa.h> |
13 | | |
14 | | int RSA_padding_add_none(unsigned char *to, int tlen, |
15 | | const unsigned char *from, int flen) |
16 | 0 | { |
17 | 0 | if (flen > tlen) { |
18 | 0 | RSAerr(RSA_F_RSA_PADDING_ADD_NONE, RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE); |
19 | 0 | return 0; |
20 | 0 | } |
21 | 0 |
|
22 | 0 | if (flen < tlen) { |
23 | 0 | RSAerr(RSA_F_RSA_PADDING_ADD_NONE, RSA_R_DATA_TOO_SMALL_FOR_KEY_SIZE); |
24 | 0 | return 0; |
25 | 0 | } |
26 | 0 |
|
27 | 0 | memcpy(to, from, (unsigned int)flen); |
28 | 0 | return 1; |
29 | 0 | } |
30 | | |
31 | | int RSA_padding_check_none(unsigned char *to, int tlen, |
32 | | const unsigned char *from, int flen, int num) |
33 | 0 | { |
34 | 0 |
|
35 | 0 | if (flen > tlen) { |
36 | 0 | RSAerr(RSA_F_RSA_PADDING_CHECK_NONE, RSA_R_DATA_TOO_LARGE); |
37 | 0 | return -1; |
38 | 0 | } |
39 | 0 |
|
40 | 0 | memset(to, 0, tlen - flen); |
41 | 0 | memcpy(to + tlen - flen, from, flen); |
42 | 0 | return tlen; |
43 | 0 | } |