1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
$NetBSD: patch-ah,v 1.3 1999/12/14 21:43:06 sommerfeld Exp $
--- ../source/rsa.c.orig Fri Mar 25 14:01:48 1994
+++ ../source/rsa.c Tue Dec 14 16:28:19 1999
@@ -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 */
|