version 1.1, 2004/01/12 13:16:28 |
version 1.3, 2004/05/16 15:02:39 |
|
|
/* $OpenXM$ */ |
/* $OpenXM: OpenXM/src/ox_ntl/crypt/sha1/ntlsha.cpp,v 1.2 2004/03/25 13:34:19 iwane Exp $ */ |
/* see sha1.c */ |
/* RFC 3174 -- see sha1.c */ |
|
|
#include <NTL/ZZ.h> |
#include <NTL/ZZ.h> |
|
|
#include <stdlib.h> |
#include <stdlib.h> |
|
#include <stdio.h> |
|
|
#include "sha1.h" |
#include "sha1.h" |
|
|
Line 18 ntl_sha1_h(ZZ &sha, const ZZ &m, unsigned int *t) |
|
Line 19 ntl_sha1_h(ZZ &sha, const ZZ &m, unsigned int *t) |
|
int ret; |
int ret; |
|
|
msglen = NumBytes(m); |
msglen = NumBytes(m); |
if (msglen <= sizeof(msg)) { |
if (msglen <= sizeof(msg_buf)) { |
msg = msg_buf; |
msg = msg_buf; |
} else { |
} else { |
msg = new unsigned char[msglen]; |
msg = new unsigned char[msglen]; |
Line 32 ntl_sha1_h(ZZ &sha, const ZZ &m, unsigned int *t) |
|
Line 33 ntl_sha1_h(ZZ &sha, const ZZ &m, unsigned int *t) |
|
msg[msglen - i - 1] = uch; |
msg[msglen - i - 1] = uch; |
} |
} |
|
|
if (t == NULL) { |
ret = sha1_h(h, msg, msglen, t); |
ret = sha1(h, msg, msglen); |
|
} else { |
|
ret = sha1_h(h, msg, msglen, t); |
|
|
|
} |
|
|
|
if (msg != msg_buf) |
if (msg != msg_buf) |
delete [] msg; |
delete [] msg; |