pike.git/
src/
post_modules/
Nettle/
hash.cmod
Branch:
Tag:
Non-build tags
All tags
No tags
2011-12-20
2011-12-20 16:43:28 by Henrik Grubbström (Grubba) <grubba@grubba.org>
88064b688b9bdb71b06921352c33166ba3b25ef1 (
283
lines) (+
27
/-
256
)
[
Show
|
Annotate
]
Branch:
7.9
Nettle: Parameterized hash.cmod by using cmod API level 4.
366:
/*! @endclass HashState */
-
/*! @class MD5
_
Info
-
*!
-
*! Internal mixin class, intended to be multiply inherited
-
*! together with HashInfo. */
+
#cmod
_
define
TOSTR(DEF)
#DEF
-
PIKECLASS
MD5
_
Info
-
{
-
INIT
-
{
-
struct HashInfo
_
struct
*HashInfo
-
= (struct HashInfo
_
struct
*) get
_
storage(Pike_fp->current_object,
-
HashInfo
_
program);
+
#cmod_define
PIKE
_
NAME
MD5
+
#cmod_define
NETTLE_NAME
md5
+
#cmod
_
include
"hash.H"
+
#cmod
_
undef
PIKE
_
NAME
+
#cmod
_
undef
NETTLE
_
NAME
-
werror("MD5_Info->INIT\n");
-
-
if (HashInfo && !HashInfo->meta)
-
HashInfo->meta = &nettle_md5;
-
else {
-
/* Can't call Pike_error here.
-
* Pike_error("Can't initialize this object.\n"); */
-
werror("MD5_Info->INIT failed\n");
-
}
-
}
-
}
-
-
/*! @endclass MD5_Info */
-
-
/*! @class MD5_State
-
*!
-
*! State for MD5 hashing.
-
*/
-
PIKECLASS MD5_State
-
{
-
INHERIT MD5_Info;
-
INHERIT HashState;
-
CVAR struct md5_ctx md5;
-
-
INIT
-
{
-
struct HashState_struct *instance
-
= (struct HashState_struct *) get_storage(Pike_fp->current_object,
-
HashState_program);
-
werror("MD5_State->INIT\n");
-
-
assert(instance);
-
-
md5_init(&THIS->md5);
-
instance->ctx = &THIS->md5;
-
}
-
}
-
/*! @endclass MD5_State */
-
+
#ifdef HAVE_NETTLE_MD4_INIT
-
/*!
@class
MD4
_Info
-
*!
-
*! Internal mixin class, intended to be multiply inherited
-
*! together with HashInfo
.
*/
+
#cmod_define
PIKE_NAME
MD4
+
#cmod
_
define NETTLE_NAME md4
+
#cmod_include
"hash.H"
+
#cmod_undef
PIKE_NAME
+
#cmod_undef
NETTLE_NAME
-
PIKECLASS
MD4
_
Info
-
{
-
INIT
-
{
-
struct HashInfo
_
struct
*HashInfo
-
= (struct HashInfo
_
struct
*) get
_
storage(Pike_fp->current_object,
-
HashInfo
_
program);
+
#cmod_define
PIKE
_
NAME
MD2
+
#cmod_define
NETTLE_NAME
md2
+
#cmod
_
include
"hash.H"
+
#cmod
_
undef
PIKE
_
NAME
+
#cmod
_
undef
NETTLE
_
NAME
-
werror("MD4_Info->INIT\n");
-
-
if (HashInfo && !HashInfo->meta)
-
HashInfo->meta = &nettle_md4;
-
else {
-
/* Can't call Pike_error here.
-
* Pike_error("Can't initialize this object.\n"); */
-
werror("MD4_Info->INIT failed\n");
-
}
-
}
-
}
-
-
/*! @endclass MD4_Info */
-
-
/*! @class MD4_State
-
*!
-
*! State for MD4 hashing.
-
*/
-
PIKECLASS MD4_State
-
{
-
INHERIT MD4_Info;
-
INHERIT HashState;
-
CVAR struct md4_ctx md4;
-
-
INIT
-
{
-
struct HashState_struct *instance
-
= (struct HashState_struct *) get_storage(Pike_fp->current_object,
-
HashState_program);
-
werror("MD4_State->INIT\n");
-
-
assert(instance);
-
-
md4_init(&THIS->md4);
-
instance->ctx = &THIS->md4;
-
}
-
}
-
/*! @endclass MD4_State */
-
-
/*! @class MD2_Info
-
*!
-
*! Internal mixin class, intended to be multiply inherited
-
*! together with HashInfo. */
-
-
PIKECLASS MD2_Info
-
{
-
INIT
-
{
-
struct HashInfo_struct *HashInfo
-
= (struct HashInfo_struct *) get_storage(Pike_fp->current_object,
-
HashInfo_program);
-
-
werror("MD2_Info->INIT\n");
-
-
if (HashInfo && !HashInfo->meta)
-
HashInfo->meta = &nettle_md2;
-
else {
-
/* Can't call Pike_error here.
-
* Pike_error("Can't initialize this object.\n"); */
-
werror("MD2_Info->INIT failed\n");
-
}
-
}
-
}
-
-
/*! @endclass MD2_Info */
-
-
/*! @class MD2_State
-
*!
-
*! State for MD2 hashing.
-
*/
-
PIKECLASS MD2_State
-
{
-
INHERIT MD2_Info;
-
INHERIT HashState;
-
CVAR struct md2_ctx md2;
-
-
INIT
-
{
-
struct HashState_struct *instance
-
= (struct HashState_struct *) get_storage(Pike_fp->current_object,
-
HashState_program);
-
werror("MD2_State->INIT\n");
-
-
assert(instance);
-
-
md2_init(&THIS->md2);
-
instance->ctx = &THIS->md2;
-
}
-
}
-
/*! @endclass MD2_State */
-
+
#endif /* HAVE_NETTLE_MD4_INIT */
-
/*!
@class
SHA1
_Info
-
*!
-
*! Internal mixin class, intended to be multiply inherited
-
*! together with HashInfo
.
*/
+
#cmod_define
PIKE_NAME
SHA1
+
#cmod
_
define NETTLE_NAME sha1
+
#cmod_include
"hash.H"
+
#cmod_undef
PIKE_NAME
+
#cmod_undef
NETTLE_NAME
-
PIKECLASS
SHA1
_
Info
-
{
-
INIT
-
{
-
struct HashInfo
_
struct
*HashInfo
-
= (struct HashInfo
_
struct
*) get
_
storage(Pike_fp->current_object,
-
HashInfo
_
program);
+
#cmod_define
PIKE
_
NAME
SHA256
+
#cmod_define
NETTLE_NAME
sha256
+
#cmod
_
include
"hash.H"
+
#cmod
_
undef
PIKE
_
NAME
+
#cmod
_
undef
NETTLE
_
NAME
-
werror("SHA1_Info->INIT\n");
-
-
if (HashInfo && !HashInfo->meta)
-
HashInfo->meta = &nettle_sha1;
-
else {
-
/* Can't call Pike_error here.
-
* Pike_error("Can't initialize this object.\n"); */
-
werror("SHA1_Info->INIT failed\n");
-
}
-
}
-
}
-
-
/*! @endclass SHA1_Info */
-
-
/*! @class SHA1_State
-
*!
-
*! State for SHA1 hashing.
-
*/
-
-
PIKECLASS SHA1_State
-
{
-
INHERIT SHA1_Info;
-
INHERIT HashState;
-
CVAR struct sha1_ctx sha1;
-
-
INIT
-
{
-
struct HashState_struct *instance
-
= (struct HashState_struct *) get_storage(Pike_fp->current_object,
-
HashState_program);
-
werror("SHA1_State->INIT\n");
-
-
assert(instance);
-
-
sha1_init(&THIS->sha1);
-
instance->ctx = &THIS->sha1;
-
}
-
}
-
/*! @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