26
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-28 17:38:54 +01:00

Added md2/1 support

This commit is contained in:
Evgeniy Khramtsov 2010-06-22 02:56:34 +10:00
parent 9cd2d5e0cf
commit 49dd83e731
2 changed files with 11 additions and 1 deletions

View File

@ -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";

View File

@ -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);