diff options
author | Nick Mathewson <nickm@torproject.org> | 2003-09-26 20:41:23 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2003-09-26 20:41:23 +0000 |
commit | febb2251cac30594cf81965bd38714a1abfd8d76 (patch) | |
tree | 6e8c8286db8241bb26b71d125b5a45a4bde50c8c /src/common/crypto.c | |
parent | a3e08a01192831f8f686c9a03b394dff4031b10f (diff) | |
download | tor-febb2251cac30594cf81965bd38714a1abfd8d76.tar.gz tor-febb2251cac30594cf81965bd38714a1abfd8d76.zip |
Add code to parse fingerprint files and compare routers against fingerprint files.
svn:r490
Diffstat (limited to 'src/common/crypto.c')
-rw-r--r-- | src/common/crypto.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/common/crypto.c b/src/common/crypto.c index cf209451a1..fa1bf2b734 100644 --- a/src/common/crypto.c +++ b/src/common/crypto.c @@ -677,11 +677,27 @@ crypto_pk_get_fingerprint(crypto_pk_env_t *pk, char *fp_out) } *bufp = '\0'; assert(strlen(buf) == FINGERPRINT_LEN); + assert(crypto_pk_check_fingerprint_syntax(buf)); strcpy(fp_out, buf); free(buf); return 0; } +int +crypto_pk_check_fingerprint_syntax(const char *s) +{ + int i; + for (i = 0; i < FINGERPRINT_LEN; ++i) { + if ((i%5) == 4) { + if (!isspace(s[i])) return 0; + } else { + if (!isxdigit(s[i])) return 0; + } + } + if (s[FINGERPRINT_LEN]) return 0; + return 1; +} + /* symmetric crypto */ int crypto_cipher_generate_key(crypto_cipher_env_t *env) { |