Lines Matching refs:key
32 static void subM(const RSAPublicKey *key, uint32_t *a) {
35 for (i = 0; i < key->len; ++i) {
36 A += (uint64_t)a[i] - key->n[i];
43 static int geM(const RSAPublicKey *key, const uint32_t *a) {
45 for (i = key->len; i;) {
47 if (a[i] < key->n[i]) return 0;
48 if (a[i] > key->n[i]) return 1;
54 static void montMulAdd(const RSAPublicKey *key,
59 uint32_t d0 = (uint32_t)A * key->n0inv;
60 uint64_t B = (uint64_t)d0 * key->n[0] + (uint32_t)A;
63 for (i = 1; i < key->len; ++i) {
65 B = (B >> 32) + (uint64_t)d0 * key->n[i] + (uint32_t)A;
74 subM(key, c);
79 static void montMul(const RSAPublicKey *key,
84 for (i = 0; i < key->len; ++i) {
87 for (i = 0; i < key->len; ++i) {
88 montMulAdd(key, c, a[i], b);
95 static void modpow3(const RSAPublicKey *key,
104 for (i = 0; i < key->len; ++i) {
106 (inout[((key->len - 1 - i) * 4) + 0] << 24) |
107 (inout[((key->len - 1 - i) * 4) + 1] << 16) |
108 (inout[((key->len - 1 - i) * 4) + 2] << 8) |
109 (inout[((key->len - 1 - i) * 4) + 3] << 0);
113 montMul(key, aR, a, key->rr); /* aR = a * RR / R mod M */
114 montMul(key, aaR, aR, aR); /* aaR = aR * aR / R mod M */
115 montMul(key, aaa, aaR, a); /* aaa = aaR * a / R mod M */
118 if (geM(key, aaa)) {
119 subM(key, aaa);
123 for (i = key->len - 1; i >= 0; --i) {
162 int RSA_verify(const RSAPublicKey *key,
169 if (key->len != RSANUMWORDS) {
170 return 0; /* Wrong key passed in. */
181 modpow3(key, buf);