Skip to content

Commit

Permalink
Fix convention
Browse files Browse the repository at this point in the history
  • Loading branch information
gvanas committed Feb 14, 2025
1 parent e4d9351 commit 47ff5fc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions lib/KangarooTwelve.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ and related or neighboring rights to the source code in this file.

/* ---------------------------------------------------------------- */

static void TurboSHAKE_Initialize(TurboSHAKE_Instance *instance, int securityLevel)
static void TurboSHAKE_Initialize(TurboSHAKE_Instance *instance, unsigned int capacity)
{
KeccakP1600_Initialize(instance->state);
instance->rate = (1600-(2*securityLevel));
instance->rate = 1600 - capacity;
instance->byteIOIndex = 0;
instance->squeezing = 0;
}
Expand Down Expand Up @@ -201,12 +201,14 @@ static unsigned int right_encode(unsigned char * encbuf, size_t value)

int KangarooTwelve_Initialize(KangarooTwelve_Instance *ktInstance, int securityLevel, size_t outputByteLen)
{
if ((securityLevel != 128) && (securityLevel != 256))
return 1;
ktInstance->fixedOutputLength = outputByteLen;
ktInstance->queueAbsorbedLen = 0;
ktInstance->blockNumber = 0;
ktInstance->phase = ABSORBING;
ktInstance->securityLevel = securityLevel;
TurboSHAKE_Initialize(&ktInstance->finalNode, securityLevel);
TurboSHAKE_Initialize(&ktInstance->finalNode, 2*securityLevel);
return 0;
}

Expand Down Expand Up @@ -267,7 +269,7 @@ int KangarooTwelve_Update(KangarooTwelve_Instance *ktInstance, const unsigned ch

while (inputByteLen > 0) {
unsigned int len = (inputByteLen < K12_chunkSize) ? (unsigned int)inputByteLen : K12_chunkSize;
TurboSHAKE_Initialize(&ktInstance->queueNode, ktInstance->securityLevel);
TurboSHAKE_Initialize(&ktInstance->queueNode, 2*ktInstance->securityLevel);
TurboSHAKE_Absorb(&ktInstance->queueNode, input, len);
input += len;
inputByteLen -= len;
Expand Down
4 changes: 2 additions & 2 deletions lib/KangarooTwelve.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ typedef struct KangarooTwelve_InstanceStruct {
} KangarooTwelve_Instance;

/** Extendable ouput function KangarooTwelve.
* @param securityLevel 128 for KT128 or 256 for KT256
* @param input Pointer to the input message (M).
* @param inputByteLen The length of the input message in bytes.
* @param output Pointer to the output buffer.
* @param outputByteLen The desired number of output bytes.
* @param customization Pointer to the customization string (C).
* @param customByteLen The length of the customization string in bytes.
* @param securityLevel The desired security strength level (128 bits or 256 bits).
* @return 0 if successful, 1 otherwise.
*/
int KangarooTwelve(int securityLevel, const unsigned char *input, size_t inputByteLen, unsigned char *output, size_t outputByteLen, const unsigned char *customization, size_t customByteLen);
Expand All @@ -64,7 +64,7 @@ int KT256(const unsigned char *input, size_t inputByteLen, unsigned char *output
/**
* Function to initialize a KangarooTwelve instance.
* @param ktInstance Pointer to the instance to be initialized.
* @param securityLevel The desired security strength level (128 bits or 256 bits).
* @param securityLevel 128 for KT128 or 256 for KT256
* @param outputByteLen The desired number of output bytes,
* or 0 for an arbitrarily-long output.
* @return 0 if successful, 1 otherwise.
Expand Down

0 comments on commit 47ff5fc

Please sign in to comment.