mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-30 16:36:29 +01:00
Added md2/1 support
This commit is contained in:
parent
e04a690303
commit
b0b66be747
@ -27,7 +27,8 @@
|
|||||||
-module(sha).
|
-module(sha).
|
||||||
-author('alexey@process-one.net').
|
-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").
|
-include("ejabberd.hrl").
|
||||||
|
|
||||||
@ -79,6 +80,9 @@ sha384(Text) ->
|
|||||||
sha512(Text) ->
|
sha512(Text) ->
|
||||||
erlang:port_control(?DRIVER, 512, Text).
|
erlang:port_control(?DRIVER, 512, Text).
|
||||||
|
|
||||||
|
md2(Text) ->
|
||||||
|
erlang:port_control(?DRIVER, 2, Text).
|
||||||
|
|
||||||
driver_path() ->
|
driver_path() ->
|
||||||
Suffix = case os:type() of
|
Suffix = case os:type() of
|
||||||
{win32, _} -> ".dll";
|
{win32, _} -> ".dll";
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include <erl_driver.h>
|
#include <erl_driver.h>
|
||||||
#include <openssl/sha.h>
|
#include <openssl/sha.h>
|
||||||
|
#include <openssl/md2.h>
|
||||||
|
|
||||||
static ErlDrvData sha_drv_start(ErlDrvPort port, char *buf)
|
static ErlDrvData sha_drv_start(ErlDrvPort port, char *buf)
|
||||||
{
|
{
|
||||||
@ -35,6 +36,11 @@ static int sha_drv_control(ErlDrvData handle,
|
|||||||
ErlDrvBinary *b = NULL;
|
ErlDrvBinary *b = NULL;
|
||||||
|
|
||||||
switch (command) {
|
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:
|
case 224:
|
||||||
rlen = SHA224_DIGEST_LENGTH;
|
rlen = SHA224_DIGEST_LENGTH;
|
||||||
b = driver_alloc_binary(rlen);
|
b = driver_alloc_binary(rlen);
|
||||||
|
Loading…
Reference in New Issue
Block a user