summaryrefslogtreecommitdiff
path: root/digest-openssl.c
diff options
context:
space:
mode:
Diffstat (limited to 'digest-openssl.c')
-rw-r--r--digest-openssl.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/digest-openssl.c b/digest-openssl.c
index 02b170341..13b63c2f0 100644
--- a/digest-openssl.c
+++ b/digest-openssl.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: digest-openssl.c,v 1.4 2014/07/03 03:26:43 djm Exp $ */ 1/* $OpenBSD: digest-openssl.c,v 1.5 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 * 4 *
@@ -17,6 +17,8 @@
17 17
18#include "includes.h" 18#include "includes.h"
19 19
20#ifdef WITH_OPENSSL
21
20#include <sys/types.h> 22#include <sys/types.h>
21#include <limits.h> 23#include <limits.h>
22#include <stdlib.h> 24#include <stdlib.h>
@@ -74,6 +76,26 @@ ssh_digest_by_alg(int alg)
74 return &(digests[alg]); 76 return &(digests[alg]);
75} 77}
76 78
79int
80ssh_digest_alg_by_name(const char *name)
81{
82 int alg;
83
84 for (alg = 0; digests[alg].id != -1; alg++) {
85 if (strcasecmp(name, digests[alg].name) == 0)
86 return digests[alg].id;
87 }
88 return -1;
89}
90
91const char *
92ssh_digest_alg_name(int alg)
93{
94 const struct ssh_digest *digest = ssh_digest_by_alg(alg);
95
96 return digest == NULL ? NULL : digest->name;
97}
98
77size_t 99size_t
78ssh_digest_bytes(int alg) 100ssh_digest_bytes(int alg)
79{ 101{
@@ -180,3 +202,4 @@ ssh_digest_buffer(int alg, const struct sshbuf *b, u_char *d, size_t dlen)
180{ 202{
181 return ssh_digest_memory(alg, sshbuf_ptr(b), sshbuf_len(b), d, dlen); 203 return ssh_digest_memory(alg, sshbuf_ptr(b), sshbuf_len(b), d, dlen);
182} 204}
205#endif /* WITH_OPENSSL */