|
22 | 22 | #include <stdint.h> |
23 | 23 | #include <sodium.h> |
24 | 24 | #include "sphinx.h" |
| 25 | +#include <string.h> |
25 | 26 | #ifdef TRACE |
26 | 27 | #include "common.h" |
27 | 28 | #endif |
@@ -105,20 +106,30 @@ int sphinx_respond(const uint8_t chal[crypto_core_ristretto255_BYTES], const uin |
105 | 106 | * pwd: (input) the password |
106 | 107 | * p_len: (input) the password length |
107 | 108 | * bfac: (input) bfac from challenge(), array of crypto_core_ristretto255_SCALARBYTES (32) bytes |
| 109 | + * chal: (input) the challenge generated in sphinx_challenge, crypto_core_ristretto255_BYTES(32) bytes array |
108 | 110 | * resp: (input) the response from respond(), crypto_core_ristretto255_BYTES (32) bytes array |
109 | 111 | * salt: (input) salt for the final password hashing, crypto_pwhash_SALTBYTES bytes array |
110 | 112 | * rwd: (output) the derived password, crypto_core_ristretto255_BYTES (32) bytes array |
111 | 113 | * returns -1 on error, 0 on success |
112 | 114 | */ |
113 | | -int sphinx_finish(const uint8_t *pwd, const size_t p_len, const uint8_t bfac[crypto_core_ristretto255_SCALARBYTES], const uint8_t resp[crypto_core_ristretto255_BYTES], const uint8_t salt[crypto_pwhash_SALTBYTES], uint8_t rwd[crypto_core_ristretto255_BYTES]) { |
| 115 | +int sphinx_finish(const uint8_t *pwd, const size_t p_len, |
| 116 | + const uint8_t bfac[crypto_core_ristretto255_SCALARBYTES], |
| 117 | + const uint8_t chal[crypto_core_ristretto255_BYTES], |
| 118 | + const uint8_t resp[crypto_core_ristretto255_BYTES], |
| 119 | + const uint8_t salt[crypto_pwhash_SALTBYTES], |
| 120 | + uint8_t rwd[crypto_core_ristretto255_BYTES]) { |
114 | 121 | #ifdef TRACE |
115 | 122 | dump(bfac, crypto_core_ristretto255_SCALARBYTES, "r"); |
| 123 | + dump(chal, crypto_core_ristretto255_BYTES, "alpha"); |
116 | 124 | dump(resp, crypto_core_ristretto255_BYTES, "beta"); |
117 | 125 | dump(pwd, p_len, "pwd"); |
118 | 126 | dump(salt, crypto_pwhash_SALTBYTES, "salt"); |
119 | 127 | #endif |
120 | 128 | // Checks that resp ∈ G^∗ . If not, abort; |
121 | 129 | if(crypto_core_ristretto255_is_valid_point(resp)!=1) return -1; |
| 130 | + if(memcmp(chal,resp,crypto_core_ristretto255_BYTES)==0) { |
| 131 | + return -1; |
| 132 | + } |
122 | 133 |
|
123 | 134 | // invert bfac = 1/bfac |
124 | 135 | unsigned char ir[crypto_core_ristretto255_SCALARBYTES]; |
|
0 commit comments