//\r
// Allocates & Initializes RSA Context by OpenSSL RSA_new()\r
//\r
- return (VOID *)RSA_new ();\r
+ return (VOID *) RSA_new ();\r
}\r
\r
/**\r
//\r
// Free OpenSSL RSA Context\r
//\r
- RSA_free ((RSA *)RsaContext);\r
+ RSA_free ((RSA *) RsaContext);\r
}\r
\r
/**\r
//\r
// Check input parameters.\r
//\r
- if (RsaContext == NULL) {\r
+ if (RsaContext == NULL || BnSize > INT_MAX) {\r
return FALSE;\r
}\r
\r
- RsaKey = (RSA *)RsaContext;\r
+ RsaKey = (RSA *) RsaContext;\r
//\r
// Set RSA Key Components by converting octet string to OpenSSL BN representation.\r
// NOTE: For RSA public key (used in signature verification), only public components\r
break;\r
}\r
RsaKey->n = BN_bin2bn (BigNumber, (UINT32) BnSize, RsaKey->n);\r
+ if (RsaKey->n == NULL) {\r
+ return FALSE;\r
+ }\r
+\r
break;\r
\r
//\r
break;\r
}\r
RsaKey->e = BN_bin2bn (BigNumber, (UINT32) BnSize, RsaKey->e);\r
+ if (RsaKey->e == NULL) {\r
+ return FALSE;\r
+ }\r
+\r
break;\r
\r
//\r
break;\r
}\r
RsaKey->d = BN_bin2bn (BigNumber, (UINT32) BnSize, RsaKey->d);\r
+ if (RsaKey->d == NULL) {\r
+ return FALSE;\r
+ }\r
+\r
break;\r
\r
//\r
break;\r
}\r
RsaKey->p = BN_bin2bn (BigNumber, (UINT32) BnSize, RsaKey->p);\r
+ if (RsaKey->p == NULL) {\r
+ return FALSE;\r
+ }\r
+\r
break;\r
\r
//\r
break;\r
}\r
RsaKey->q = BN_bin2bn (BigNumber, (UINT32) BnSize, RsaKey->q);\r
+ if (RsaKey->q == NULL) {\r
+ return FALSE;\r
+ }\r
+\r
break;\r
\r
//\r
break;\r
}\r
RsaKey->dmp1 = BN_bin2bn (BigNumber, (UINT32) BnSize, RsaKey->dmp1);\r
+ if (RsaKey->dmp1 == NULL) {\r
+ return FALSE;\r
+ }\r
+\r
break;\r
\r
//\r
break;\r
}\r
RsaKey->dmq1 = BN_bin2bn (BigNumber, (UINT32) BnSize, RsaKey->dmq1);\r
+ if (RsaKey->dmq1 == NULL) {\r
+ return FALSE;\r
+ }\r
+\r
break;\r
\r
//\r
break;\r
}\r
RsaKey->iqmp = BN_bin2bn (BigNumber, (UINT32) BnSize, RsaKey->iqmp);\r
+ if (RsaKey->iqmp == NULL) {\r
+ return FALSE;\r
+ }\r
+\r
break;\r
\r
default:\r
//\r
// Check input parameters.\r
//\r
- if (RsaContext == NULL || MessageHash == NULL || Signature == NULL) {\r
+ if (RsaContext == NULL || MessageHash == NULL || Signature == NULL || SigSize > INT_MAX) {\r
return FALSE;\r
}\r
\r