pike.git/
src/
post_modules/
Nettle/
hash.cmod
Branch:
Tag:
Non-build tags
All tags
No tags
2003-07-29
2003-07-29 04:10:12 by Martin Nilsson <mani@lysator.liu.se>
0980777b14c029be3cc363a089560bbab8f4ec6b (
56
lines) (+
55
/-
1
)
[
Show
|
Annotate
]
Branch:
7.9
Added SHA256
Rev: src/post_modules/Nettle/hash.cmod:1.9
1:
/* hash.cmod -*- c -*- */ #include "global.h"
-
RCSID("$Id: hash.cmod,v 1.
8
2003/07/29
03
:
48
:
48
nilsson Exp $");
+
RCSID("$Id: hash.cmod,v 1.
9
2003/07/29
04
:
10
:
12
nilsson Exp $");
#include "interpret.h" #include "svalue.h"
295:
} /*! @endclass SHA1_State */
+
/*! @class SHA256_Info
+
*!
+
*! Internal mixin class, intended to be multiply inherited
+
*! together with HashInfo. */
+
+
PIKECLASS SHA256_Info
+
{
+
INIT
+
{
+
struct HashInfo_struct *HashInfo
+
= (struct HashInfo_struct *) get_storage(Pike_fp->current_object,
+
HashInfo_program);
+
+
werror("SHA256_Info->INIT\n");
+
+
if (HashInfo && !HashInfo->meta)
+
HashInfo->meta = &nettle_sha256;
+
else {
+
/* Can't call Pike_error here.
+
* Pike_error("Can't initialize this object.\n"); */
+
werror("SHA256_Info->INIT failed\n");
+
}
+
}
+
}
+
+
/*! @endclass SHA256_Info */
+
+
/*! @class SHA256_State
+
*!
+
*! State for SHA256 hashing.
+
*/
+
+
PIKECLASS SHA256_State
+
{
+
INHERIT SHA256_Info;
+
INHERIT HashState;
+
CVAR struct sha256_ctx sha256;
+
+
INIT
+
{
+
struct HashState_struct *instance
+
= (struct HashState_struct *) get_storage(Pike_fp->current_object,
+
HashState_program);
+
werror("SHA256_State->INIT\n");
+
+
assert(instance);
+
+
sha256_init(&THIS->sha256);
+
instance->ctx = &THIS->sha256;
+
}
+
}
+
/*! @endclass SHA256_State */
+
/*! @endmodule Nettle */ void