summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/rsa/rsa_none.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/rsa/rsa_none.c')
-rw-r--r--src/lib/libcrypto/rsa/rsa_none.c59
1 files changed, 29 insertions, 30 deletions
diff --git a/src/lib/libcrypto/rsa/rsa_none.c b/src/lib/libcrypto/rsa/rsa_none.c
index 1904c7c098..fde5eb6ef6 100644
--- a/src/lib/libcrypto/rsa/rsa_none.c
+++ b/src/lib/libcrypto/rsa/rsa_none.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: rsa_none.c,v 1.4 2014/06/12 15:49:30 deraadt Exp $ */ 1/* $OpenBSD: rsa_none.c,v 1.5 2014/07/09 08:20:08 miod Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -62,37 +62,36 @@
62#include <openssl/rsa.h> 62#include <openssl/rsa.h>
63#include <openssl/rand.h> 63#include <openssl/rand.h>
64 64
65int RSA_padding_add_none(unsigned char *to, int tlen, 65int
66 const unsigned char *from, int flen) 66RSA_padding_add_none(unsigned char *to, int tlen, const unsigned char *from,
67 { 67 int flen)
68 if (flen > tlen) 68{
69 { 69 if (flen > tlen) {
70 RSAerr(RSA_F_RSA_PADDING_ADD_NONE,RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE); 70 RSAerr(RSA_F_RSA_PADDING_ADD_NONE,
71 return(0); 71 RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE);
72 } 72 return 0;
73
74 if (flen < tlen)
75 {
76 RSAerr(RSA_F_RSA_PADDING_ADD_NONE,RSA_R_DATA_TOO_SMALL_FOR_KEY_SIZE);
77 return(0);
78 }
79
80 memcpy(to,from,(unsigned int)flen);
81 return(1);
82 } 73 }
83 74
84int RSA_padding_check_none(unsigned char *to, int tlen, 75 if (flen < tlen) {
85 const unsigned char *from, int flen, int num) 76 RSAerr(RSA_F_RSA_PADDING_ADD_NONE,
86 { 77 RSA_R_DATA_TOO_SMALL_FOR_KEY_SIZE);
87 78 return 0;
88 if (flen > tlen) 79 }
89 { 80
90 RSAerr(RSA_F_RSA_PADDING_CHECK_NONE,RSA_R_DATA_TOO_LARGE); 81 memcpy(to, from, (unsigned int)flen);
91 return(-1); 82 return 1;
92 } 83}
93 84
94 memset(to,0,tlen-flen); 85int
95 memcpy(to+tlen-flen,from,flen); 86RSA_padding_check_none(unsigned char *to, int tlen, const unsigned char *from,
96 return(tlen); 87 int flen, int num)
88{
89 if (flen > tlen) {
90 RSAerr(RSA_F_RSA_PADDING_CHECK_NONE, RSA_R_DATA_TOO_LARGE);
91 return -1;
97 } 92 }
98 93
94 memset(to, 0, tlen - flen);
95 memcpy(to + tlen - flen, from, flen);
96 return tlen;
97}