67 static const unsigned char zeroes[] = {0,0,0,0,0,0,0,0};
69 #if defined(_MSC_VER) && defined(_ARM_)
70 #pragma optimize("g", off)
74 const EVP_MD *Hash,
const unsigned char *EM,
int sLen)
81 const unsigned char *EM,
int sLen)
85 int hLen, maskedDBLen, MSBits, emLen;
86 const unsigned char *
H;
87 unsigned char *DB = NULL;
104 if (sLen == -1) sLen = hLen;
105 else if (sLen == -2) sLen = -2;
114 if (EM[0] & (0xFF << MSBits))
124 if (emLen < (hLen + sLen + 2))
129 if (EM[emLen - 1] != 0xbc)
134 maskedDBLen = emLen - hLen - 1;
135 H = EM + maskedDBLen;
142 if (
PKCS1_MGF1(DB, maskedDBLen, H, hLen, mgf1Hash) < 0)
144 for (i = 0; i < maskedDBLen; i++)
147 DB[0] &= 0xFF >> (8 - MSBits);
148 for (i = 0; DB[i] == 0 && i < (maskedDBLen-1); i++) ;
154 if (sLen >= 0 && (maskedDBLen - i) != sLen)
170 if (memcmp(H_, H, hLen))
188 const unsigned char *mHash,
189 const EVP_MD *Hash,
int sLen)
195 const unsigned char *mHash,
200 int hLen, maskedDBLen, MSBits, emLen;
201 unsigned char *
H, *salt = NULL, *
p;
204 if (mgf1Hash == NULL)
216 if (sLen == -1) sLen = hLen;
217 else if (sLen == -2) sLen = -2;
233 sLen = emLen - hLen - 2;
235 else if (emLen < (hLen + sLen + 2))
251 maskedDBLen = emLen - hLen - 1;
252 H = EM + maskedDBLen;
265 if (
PKCS1_MGF1(EM, maskedDBLen, H, hLen, mgf1Hash))
274 p += emLen - sLen - hLen - 2;
278 for (i = 0; i < sLen; i++)
282 EM[0] &= 0xFF >> (8 - MSBits);
286 EM[emLen - 1] = 0xbc;
298 #if defined(_MSC_VER)
299 #pragma optimize("",on)