mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-23 00:47:31 +09:00
re-introduce old nss im too tired for this
This commit is contained in:
parent
3c46be320d
commit
3a838106b9
2871 changed files with 1374431 additions and 1762417 deletions
|
|
@ -9,10 +9,10 @@
|
|||
#include "softoken.h"
|
||||
#include "hmacct.h"
|
||||
|
||||
/* sftk_HMACMechanismToHash converts a PKCS#11 MAC mechanism into a freebl hash
|
||||
/* HMACMechanismToHash converts a PKCS#11 MAC mechanism into a freebl hash
|
||||
* type. */
|
||||
HASH_HashType
|
||||
sftk_HMACMechanismToHash(CK_MECHANISM_TYPE mech)
|
||||
static HASH_HashType
|
||||
HMACMechanismToHash(CK_MECHANISM_TYPE mech)
|
||||
{
|
||||
switch (mech) {
|
||||
case CKM_MD2_HMAC:
|
||||
|
|
@ -50,7 +50,7 @@ SetupMAC(CK_MECHANISM_PTR mech, SFTKObject *key)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
alg = sftk_HMACMechanismToHash(params->macAlg);
|
||||
alg = HMACMechanismToHash(params->macAlg);
|
||||
if (alg == HASH_AlgNULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -69,7 +69,6 @@ SetupMAC(CK_MECHANISM_PTR mech, SFTKObject *key)
|
|||
|
||||
ctx = PORT_Alloc(sizeof(sftk_MACConstantTimeCtx));
|
||||
if (!ctx) {
|
||||
PORT_Memset(secret, 0, secretLength);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -77,7 +76,6 @@ SetupMAC(CK_MECHANISM_PTR mech, SFTKObject *key)
|
|||
ctx->secretLength = secretLength;
|
||||
ctx->hash = HASH_GetRawHashObject(alg);
|
||||
ctx->totalLength = params->ulBodyTotalLen;
|
||||
PORT_Memset(secret, 0, secretLength);
|
||||
|
||||
return ctx;
|
||||
}
|
||||
|
|
@ -190,7 +188,7 @@ sftk_MACConstantTime_EndHash(void *pctx, void *out, unsigned int *outLength,
|
|||
void
|
||||
sftk_MACConstantTime_DestroyContext(void *pctx, PRBool free)
|
||||
{
|
||||
PORT_ZFree(pctx, sizeof(sftk_MACConstantTimeCtx));
|
||||
PORT_Free(pctx);
|
||||
}
|
||||
|
||||
CK_RV
|
||||
|
|
@ -219,7 +217,7 @@ CK_RV
|
|||
sftk_MAC_Init(sftk_MACCtx *ctx, CK_MECHANISM_TYPE mech, SFTKObject *key)
|
||||
{
|
||||
SFTKAttribute *keyval = NULL;
|
||||
PRBool isFIPS = sftk_isFIPS(key->slot->slotID);
|
||||
PRBool isFIPS = (key->slot->slotID == FIPS_SLOT_ID);
|
||||
CK_RV ret = CKR_OK;
|
||||
|
||||
/* Find the actual value of the key. */
|
||||
|
|
@ -234,9 +232,7 @@ sftk_MAC_Init(sftk_MACCtx *ctx, CK_MECHANISM_TYPE mech, SFTKObject *key)
|
|||
keyval->attrib.ulValueLen, isFIPS);
|
||||
|
||||
done:
|
||||
if (keyval) {
|
||||
sftk_FreeAttribute(keyval);
|
||||
}
|
||||
sftk_FreeAttribute(keyval);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -265,7 +261,7 @@ sftk_MAC_InitRaw(sftk_MACCtx *ctx, CK_MECHANISM_TYPE mech, const unsigned char *
|
|||
case CKM_SHA256_HMAC:
|
||||
case CKM_SHA384_HMAC:
|
||||
case CKM_SHA512_HMAC:
|
||||
hashObj = HASH_GetRawHashObject(sftk_HMACMechanismToHash(mech));
|
||||
hashObj = HASH_GetRawHashObject(HMACMechanismToHash(mech));
|
||||
|
||||
/* Because we condition above only on hashes we know to be valid,
|
||||
* hashObj should never be NULL. This assert is only useful when
|
||||
|
|
@ -359,7 +355,7 @@ sftk_MAC_Reset(sftk_MACCtx *ctx)
|
|||
}
|
||||
|
||||
CK_RV
|
||||
sftk_MAC_Update(sftk_MACCtx *ctx, const CK_BYTE *data, unsigned int data_len)
|
||||
sftk_MAC_Update(sftk_MACCtx *ctx, CK_BYTE_PTR data, unsigned int data_len)
|
||||
{
|
||||
switch (ctx->mech) {
|
||||
case CKM_MD2_HMAC:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue