From 5576a3a094de49246e501bb24d1b3dc3a5d610b9 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Wed, 16 Sep 2009 12:34:44 -0400 Subject: Parse detached signature documents with multiple flavors and algorithms. --- src/common/crypto.c | 12 ++++++++++++ src/common/crypto.h | 1 + 2 files changed, 13 insertions(+) (limited to 'src/common') diff --git a/src/common/crypto.c b/src/common/crypto.c index ac0e628c48..f335f99aba 100644 --- a/src/common/crypto.c +++ b/src/common/crypto.c @@ -1481,6 +1481,18 @@ crypto_digest_algorithm_get_name(digest_algorithm_t alg) } } +/** DOCDOC */ +int +crypto_digest_algorithm_parse_name(const char *name) +{ + if (!strcmp(name, "sha1")) + return DIGEST_SHA1; + else if (!strcmp(name, "sha256")) + return DIGEST_SHA256; + else + return -1; +} + /** Intermediate information about the digest of a stream of data. */ struct crypto_digest_env_t { union { diff --git a/src/common/crypto.h b/src/common/crypto.h index ed8468046f..c0a4526255 100644 --- a/src/common/crypto.h +++ b/src/common/crypto.h @@ -177,6 +177,7 @@ int crypto_digest256(char *digest, const char *m, size_t len, digest_algorithm_t algorithm); int crypto_digest_all(digests_t *ds_out, const char *m, size_t len); const char *crypto_digest_algorithm_get_name(digest_algorithm_t alg); +int crypto_digest_algorithm_parse_name(const char *name); crypto_digest_env_t *crypto_new_digest_env(void); crypto_digest_env_t *crypto_new_digest256_env(digest_algorithm_t algorithm); void crypto_free_digest_env(crypto_digest_env_t *digest); -- cgit v1.2.3-54-g00ecf