summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/crypto.c12
-rw-r--r--src/common/crypto.h1
2 files changed, 13 insertions, 0 deletions
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);