summaryrefslogtreecommitdiff
path: root/digest-libc.c
diff options
context:
space:
mode:
Diffstat (limited to 'digest-libc.c')
-rw-r--r--digest-libc.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/digest-libc.c b/digest-libc.c
index 1b4423a05..169ded075 100644
--- a/digest-libc.c
+++ b/digest-libc.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: digest-libc.c,v 1.3 2014/06/24 01:13:21 djm Exp $ */ 1/* $OpenBSD: digest-libc.c,v 1.4 2014/12/21 22:27:56 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2013 Damien Miller <djm@mindrot.org> 3 * Copyright (c) 2013 Damien Miller <djm@mindrot.org>
4 * Copyright (c) 2014 Markus Friedl. All rights reserved. 4 * Copyright (c) 2014 Markus Friedl. All rights reserved.
@@ -126,6 +126,26 @@ ssh_digest_by_alg(int alg)
126 return &(digests[alg]); 126 return &(digests[alg]);
127} 127}
128 128
129int
130ssh_digest_alg_by_name(const char *name)
131{
132 int alg;
133
134 for (alg = 0; alg < SSH_DIGEST_MAX; alg++) {
135 if (strcasecmp(name, digests[alg].name) == 0)
136 return digests[alg].id;
137 }
138 return -1;
139}
140
141const char *
142ssh_digest_alg_name(int alg)
143{
144 const struct ssh_digest *digest = ssh_digest_by_alg(alg);
145
146 return digest == NULL ? NULL : digest->name;
147}
148
129size_t 149size_t
130ssh_digest_bytes(int alg) 150ssh_digest_bytes(int alg)
131{ 151{