dev-libs/rsaref: initial import

Signed-off-by: Anna (cybertailor) Vyalkova <cyber+gentoo@sysrq.in>
This commit is contained in:
Anna (cybertailor) Vyalkova
2021-12-29 15:37:14 +05:00
parent fd7f2d35ea
commit 5bfe94c0f2
7 changed files with 311 additions and 0 deletions

View File

@@ -0,0 +1,73 @@
--- a/source/rsa.c
+++ b/source/rsa.c
@@ -11,10 +11,10 @@
#include "rsa.h"
#include "nn.h"
-static int RSAPublicBlock PROTO_LIST
+int RSAPublicBlock PROTO_LIST
((unsigned char *, unsigned int *, unsigned char *, unsigned int,
R_RSA_PUBLIC_KEY *));
-static int RSAPrivateBlock PROTO_LIST
+int RSAPrivateBlock PROTO_LIST
((unsigned char *, unsigned int *, unsigned char *, unsigned int,
R_RSA_PRIVATE_KEY *));
@@ -33,6 +33,9 @@
unsigned char byte, pkcsBlock[MAX_RSA_MODULUS_LEN];
unsigned int i, modulusLen;
+ if (inputLen+3>MAX_RSA_MODULUS_LEN) return (RE_LEN);
+ if (publicKey->bits > MAX_RSA_MODULUS_BITS) return (RE_LEN);
+
modulusLen = (publicKey->bits + 7) / 8;
if (inputLen + 11 > modulusLen)
return (RE_LEN);
@@ -78,6 +81,9 @@
unsigned char pkcsBlock[MAX_RSA_MODULUS_LEN];
unsigned int i, modulusLen, pkcsBlockLen;
+ if (inputLen>MAX_RSA_MODULUS_LEN) return (RE_LEN);
+ if (publicKey->bits > MAX_RSA_MODULUS_BITS) return (RE_LEN);
+
modulusLen = (publicKey->bits + 7) / 8;
if (inputLen > modulusLen)
return (RE_LEN);
@@ -129,6 +135,9 @@
unsigned char pkcsBlock[MAX_RSA_MODULUS_LEN];
unsigned int i, modulusLen;
+ if (inputLen+3>MAX_RSA_MODULUS_LEN) return (RE_LEN);
+ if (privateKey->bits > MAX_RSA_MODULUS_BITS) return (RE_LEN);
+
modulusLen = (privateKey->bits + 7) / 8;
if (inputLen + 11 > modulusLen)
return (RE_LEN);
@@ -168,6 +177,9 @@
unsigned char pkcsBlock[MAX_RSA_MODULUS_LEN];
unsigned int i, modulusLen, pkcsBlockLen;
+ if (inputLen>MAX_RSA_MODULUS_LEN) return (RE_LEN);
+ if (privateKey->bits > MAX_RSA_MODULUS_BITS) return (RE_LEN);
+
modulusLen = (privateKey->bits + 7) / 8;
if (inputLen > modulusLen)
return (RE_LEN);
@@ -212,7 +224,7 @@
Assumes inputLen < length of modulus.
Requires input < modulus.
*/
-static int RSAPublicBlock (output, outputLen, input, inputLen, publicKey)
+int RSAPublicBlock (output, outputLen, input, inputLen, publicKey)
unsigned char *output; /* output block */
unsigned int *outputLen; /* length of output block */
unsigned char *input; /* input block */
@@ -252,7 +264,7 @@
Assumes inputLen < length of modulus.
Requires input < modulus.
*/
-static int RSAPrivateBlock (output, outputLen, input, inputLen, privateKey)
+int RSAPrivateBlock (output, outputLen, input, inputLen, privateKey)
unsigned char *output; /* output block */
unsigned int *outputLen; /* length of output block */
unsigned char *input; /* input block */