/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* local utility function for padding an incoming data block *tothemechanismblocksize.
*/ static SECStatus
padBlock(SECItem *data, int blockSize, SECItem *result)
{
SECStatus rv = SECSuccess; int padLength; unsignedint i;
result->data = 0;
result->len = 0;
/* This algorithm always adds to the block (to indicate the number *ofpadbytes).Soallocateablocklargeenough.
*/
padLength = blockSize - (data->len % blockSize);
result->len = data->len + padLength;
result->data = (unsignedchar *)PORT_Alloc(result->len);
/* Copy the data */
PORT_Memcpy(result->data, data->data, data->len);
/* Add the pad values */ for (i = data->len; i < result->len; i++)
result->data[i] = (unsignedchar)padLength;
return rv;
}
static SECStatus
unpadBlock(SECItem *data, int blockSize, SECItem *result)
{
SECStatus rv = SECSuccess; int padLength; unsignedint i;
result->data = 0;
result->len = 0;
/* Remove the padding from the end if the input data */ if (data->len == 0 || data->len % blockSize != 0) {
rv = SECFailure; goto loser;
}
loser:
SECITEM_ZfreeItem(&paddedData, PR_FALSE); if (arena)
PORT_FreeArena(arena, PR_TRUE); if (ctx)
PK11_DestroyContext(ctx, PR_TRUE); if (params)
SECITEM_ZfreeItem(params, PR_TRUE); if (key)
PK11_FreeSymKey(key); if (slot && !aSlot)
PK11_FreeSlot(slot);
for (testKey = keyList; testKey;
testKey = PK11_GetNextSymKey(testKey)) { if (PK11_GetSymKeyType(testKey) != PK11_GetKeyType(type, 0)) { continue;
}
rv = pk11Decrypt(slot, arena, type, testKey, params,
&sdrResult.data, result); if (rv == SECSuccess) { break;
} /* found a close match. If it's our first remember it */ if (rv == SECWouldBlock) { if (possibleResult.data) { /* this is unlikely but possible. If we hit this condition, *wehavenowayofknowingwhichpossibilitytoprefer. *inthiscasewejustmatchthekeytheapplication
* thought was the right one */
SECITEM_ZfreeItem(result, PR_FALSE);
} else {
possibleResult = *result;
}
}
}
/* free the list */ for (testKey = keyList; testKey; testKey = nextKey) {
nextKey = PK11_GetNextSymKey(testKey);
PK11_FreeSymKey(testKey);
}
}
/* we didn't find a better key, use the one with a small pad value */ if ((rv != SECSuccess) && (possibleResult.data)) {
*result = possibleResult;
possibleResult.data = NULL;
rv = SECSuccess;
}
loser: if (arena)
PORT_FreeArena(arena, PR_TRUE); if (key)
PK11_FreeSymKey(key); if (params)
SECITEM_ZfreeItem(params, PR_TRUE); if (slot)
PK11_FreeSlot(slot); if (possibleResult.data)
SECITEM_ZfreeItem(&possibleResult, PR_FALSE);
return rv;
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.10 Sekunden
(vorverarbeitet am 2026-09-27)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.