VirtualBox

source: vbox/trunk/src/libs/openssl-3.0.1/crypto/rsa/rsa_none.c@ 94082

Last change on this file since 94082 was 94082, checked in by vboxsync, 3 years ago

libs/openssl-3.0.1: started applying and adjusting our OpenSSL changes to 3.0.1. bugref:10128

File size: 1.3 KB
Line 
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
20int RSA_padding_add_none(unsigned char *to, int tlen,
21 const unsigned char *from, int flen)
22{
23 if (flen > tlen) {
24 ERR_raise(ERR_LIB_RSA, RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE);
25 return 0;
26 }
27
28 if (flen < tlen) {
29 ERR_raise(ERR_LIB_RSA, 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
37int 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 ERR_raise(ERR_LIB_RSA, 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}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette