aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/sha.erl6
-rw-r--r--src/tls/sha_drv.c6
2 files changed, 11 insertions, 1 deletions
diff --git a/src/sha.erl b/src/sha.erl
index 591ed6f30..64c15c166 100644
--- a/src/sha.erl
+++ b/src/sha.erl
@@ -27,7 +27,8 @@
-module(sha).
-author('alexey@process-one.net').
--export([start/0, sha/1, sha1/1, sha224/1, sha256/1, sha384/1, sha512/1]).
+-export([start/0, sha/1, sha1/1, sha224/1, sha256/1, sha384/1,
+ sha512/1, md2/1]).
-include("ejabberd.hrl").
@@ -79,6 +80,9 @@ sha384(Text) ->
sha512(Text) ->
erlang:port_control(?DRIVER, 512, Text).
+md2(Text) ->
+ erlang:port_control(?DRIVER, 2, Text).
+
driver_path() ->
Suffix = case os:type() of
{win32, _} -> ".dll";
diff --git a/src/tls/sha_drv.c b/src/tls/sha_drv.c
index bfb101391..13d65803a 100644
--- a/src/tls/sha_drv.c
+++ b/src/tls/sha_drv.c
@@ -20,6 +20,7 @@
#include <erl_driver.h>
#include <openssl/sha.h>
+#include <openssl/md2.h>
static ErlDrvData sha_drv_start(ErlDrvPort port, char *buf)
{
@@ -35,6 +36,11 @@ static int sha_drv_control(ErlDrvData handle,
ErlDrvBinary *b = NULL;
switch (command) {
+ case 2:
+ rlen = MD2_DIGEST_LENGTH;
+ b = driver_alloc_binary(rlen);
+ if (b) MD2((unsigned char*)buf, len, (unsigned char*)b->orig_bytes);
+ break;
case 224:
rlen = SHA224_DIGEST_LENGTH;
b = driver_alloc_binary(rlen);