mirror of https://github.com/wolfSSL/wolfssl.git
Rename variable index to idx to avoid conflicting declaration.
parent
813e36a823
commit
a814683684
|
@ -2189,7 +2189,7 @@ int wolfSSL_GetSessionIndex(WOLFSSL* ssl);
|
||||||
\sa LockMutex
|
\sa LockMutex
|
||||||
\sa wolfSSL_GetSessionIndex
|
\sa wolfSSL_GetSessionIndex
|
||||||
*/
|
*/
|
||||||
int wolfSSL_GetSessionAtIndex(int index, WOLFSSL_SESSION* session);
|
int wolfSSL_GetSessionAtIndex(int idx, WOLFSSL_SESSION* session);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\ingroup IO
|
\ingroup IO
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
\param [in] salt Random non-secret value.
|
\param [in] salt Random non-secret value.
|
||||||
\param [in] saltSz Size of random in bytes.
|
\param [in] saltSz Size of random in bytes.
|
||||||
\param [in] kdrIdx Key derivation rate. kdr = 0 when -1, otherwise kdr = 2^kdrIdx.
|
\param [in] kdrIdx Key derivation rate. kdr = 0 when -1, otherwise kdr = 2^kdrIdx.
|
||||||
\param [in] index Index value to XOR in.
|
\param [in] idx Index value to XOR in.
|
||||||
\param [out] key1 First key. Label value of 0x00.
|
\param [out] key1 First key. Label value of 0x00.
|
||||||
\param [in] key1Sz Size of first key in bytes.
|
\param [in] key1Sz Size of first key in bytes.
|
||||||
\param [out] key2 Second key. Label value of 0x01.
|
\param [out] key2 Second key. Label value of 0x01.
|
||||||
|
@ -29,14 +29,14 @@
|
||||||
\code
|
\code
|
||||||
unsigned char key[16] = { ... };
|
unsigned char key[16] = { ... };
|
||||||
unsigned char salt[14] = { ... };
|
unsigned char salt[14] = { ... };
|
||||||
unsigned char index[6] = { ... };
|
unsigned char idx[6] = { ... };
|
||||||
unsigned char keyE[16];
|
unsigned char keyE[16];
|
||||||
unsigned char keyA[20];
|
unsigned char keyA[20];
|
||||||
unsigned char keyS[14];
|
unsigned char keyS[14];
|
||||||
int kdrIdx = 0; // Use all of index
|
int kdrIdx = 0; // Use all of index
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = wc_SRTP_KDF(key, sizeof(key), salt, sizeof(salt), kdrIdx, index,
|
ret = wc_SRTP_KDF(key, sizeof(key), salt, sizeof(salt), kdrIdx, idx,
|
||||||
keyE, sizeof(keyE), keyA, sizeof(keyA), keyS, sizeof(keyS));
|
keyE, sizeof(keyE), keyA, sizeof(keyA), keyS, sizeof(keyS));
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
WOLFSSL_MSG("wc_SRTP_KDF failed");
|
WOLFSSL_MSG("wc_SRTP_KDF failed");
|
||||||
|
@ -49,7 +49,7 @@
|
||||||
\sa wc_SRTP_KDF_kdr_to_idx
|
\sa wc_SRTP_KDF_kdr_to_idx
|
||||||
*/
|
*/
|
||||||
int wc_SRTP_KDF(const byte* key, word32 keySz, const byte* salt, word32 saltSz,
|
int wc_SRTP_KDF(const byte* key, word32 keySz, const byte* salt, word32 saltSz,
|
||||||
int kdrIdx, const byte* index, byte* key1, word32 key1Sz, byte* key2,
|
int kdrIdx, const byte* idx, byte* key1, word32 key1Sz, byte* key2,
|
||||||
word32 key2Sz, byte* key3, word32 key3Sz);
|
word32 key2Sz, byte* key3, word32 key3Sz);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -69,7 +69,7 @@ int wc_SRTP_KDF(const byte* key, word32 keySz, const byte* salt, word32 saltSz,
|
||||||
\param [in] salt Random non-secret value.
|
\param [in] salt Random non-secret value.
|
||||||
\param [in] saltSz Size of random in bytes.
|
\param [in] saltSz Size of random in bytes.
|
||||||
\param [in] kdrIdx Key derivation rate. kdr = 0 when -1, otherwise kdr = 2^kdrIdx.
|
\param [in] kdrIdx Key derivation rate. kdr = 0 when -1, otherwise kdr = 2^kdrIdx.
|
||||||
\param [in] index Index value to XOR in.
|
\param [in] idx Index value to XOR in.
|
||||||
\param [out] key1 First key. Label value of 0x00.
|
\param [out] key1 First key. Label value of 0x00.
|
||||||
\param [in] key1Sz Size of first key in bytes.
|
\param [in] key1Sz Size of first key in bytes.
|
||||||
\param [out] key2 Second key. Label value of 0x01.
|
\param [out] key2 Second key. Label value of 0x01.
|
||||||
|
@ -82,14 +82,14 @@ int wc_SRTP_KDF(const byte* key, word32 keySz, const byte* salt, word32 saltSz,
|
||||||
\code
|
\code
|
||||||
unsigned char key[16] = { ... };
|
unsigned char key[16] = { ... };
|
||||||
unsigned char salt[14] = { ... };
|
unsigned char salt[14] = { ... };
|
||||||
unsigned char index[4] = { ... };
|
unsigned char idx[4] = { ... };
|
||||||
unsigned char keyE[16];
|
unsigned char keyE[16];
|
||||||
unsigned char keyA[20];
|
unsigned char keyA[20];
|
||||||
unsigned char keyS[14];
|
unsigned char keyS[14];
|
||||||
int kdrIdx = 0; // Use all of index
|
int kdrIdx = 0; // Use all of index
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = wc_SRTCP_KDF(key, sizeof(key), salt, sizeof(salt), kdrIdx, index,
|
ret = wc_SRTCP_KDF(key, sizeof(key), salt, sizeof(salt), kdrIdx, idx,
|
||||||
keyE, sizeof(keyE), keyA, sizeof(keyA), keyS, sizeof(keyS));
|
keyE, sizeof(keyE), keyA, sizeof(keyA), keyS, sizeof(keyS));
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
WOLFSSL_MSG("wc_SRTP_KDF failed");
|
WOLFSSL_MSG("wc_SRTP_KDF failed");
|
||||||
|
@ -102,7 +102,7 @@ int wc_SRTP_KDF(const byte* key, word32 keySz, const byte* salt, word32 saltSz,
|
||||||
\sa wc_SRTP_KDF_kdr_to_idx
|
\sa wc_SRTP_KDF_kdr_to_idx
|
||||||
*/
|
*/
|
||||||
int wc_SRTCP_KDF(const byte* key, word32 keySz, const byte* salt, word32 saltSz,
|
int wc_SRTCP_KDF(const byte* key, word32 keySz, const byte* salt, word32 saltSz,
|
||||||
int kdrIdx, const byte* index, byte* key1, word32 key1Sz, byte* key2,
|
int kdrIdx, const byte* idx, byte* key1, word32 key1Sz, byte* key2,
|
||||||
word32 key2Sz, byte* key3, word32 key3Sz);
|
word32 key2Sz, byte* key3, word32 key3Sz);
|
||||||
/*!
|
/*!
|
||||||
\ingroup SrtpKdf
|
\ingroup SrtpKdf
|
||||||
|
@ -121,7 +121,7 @@ int wc_SRTCP_KDF(const byte* key, word32 keySz, const byte* salt, word32 saltSz,
|
||||||
\param [in] salt Random non-secret value.
|
\param [in] salt Random non-secret value.
|
||||||
\param [in] saltSz Size of random in bytes.
|
\param [in] saltSz Size of random in bytes.
|
||||||
\param [in] kdrIdx Key derivation rate. kdr = 0 when -1, otherwise kdr = 2^kdrIdx.
|
\param [in] kdrIdx Key derivation rate. kdr = 0 when -1, otherwise kdr = 2^kdrIdx.
|
||||||
\param [in] index Index value to XOR in.
|
\param [in] idx Index value to XOR in.
|
||||||
\param [in] label Label to use when deriving key.
|
\param [in] label Label to use when deriving key.
|
||||||
\param [out] outKey Derived key.
|
\param [out] outKey Derived key.
|
||||||
\param [in] outKeySz Size of derived key in bytes.
|
\param [in] outKeySz Size of derived key in bytes.
|
||||||
|
@ -131,12 +131,12 @@ int wc_SRTCP_KDF(const byte* key, word32 keySz, const byte* salt, word32 saltSz,
|
||||||
\code
|
\code
|
||||||
unsigned char key[16] = { ... };
|
unsigned char key[16] = { ... };
|
||||||
unsigned char salt[14] = { ... };
|
unsigned char salt[14] = { ... };
|
||||||
unsigned char index[6] = { ... };
|
unsigned char idx[6] = { ... };
|
||||||
unsigned char keyE[16];
|
unsigned char keyE[16];
|
||||||
int kdrIdx = 0; // Use all of index
|
int kdrIdx = 0; // Use all of index
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = wc_SRTP_KDF_label(key, sizeof(key), salt, sizeof(salt), kdrIdx, index,
|
ret = wc_SRTP_KDF_label(key, sizeof(key), salt, sizeof(salt), kdrIdx, idx,
|
||||||
WC_SRTP_LABEL_ENCRYPTION, keyE, sizeof(keyE));
|
WC_SRTP_LABEL_ENCRYPTION, keyE, sizeof(keyE));
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
WOLFSSL_MSG("wc_SRTP_KDF failed");
|
WOLFSSL_MSG("wc_SRTP_KDF failed");
|
||||||
|
@ -149,7 +149,7 @@ int wc_SRTCP_KDF(const byte* key, word32 keySz, const byte* salt, word32 saltSz,
|
||||||
\sa wc_SRTP_KDF_kdr_to_idx
|
\sa wc_SRTP_KDF_kdr_to_idx
|
||||||
*/
|
*/
|
||||||
int wc_SRTP_KDF_label(const byte* key, word32 keySz, const byte* salt,
|
int wc_SRTP_KDF_label(const byte* key, word32 keySz, const byte* salt,
|
||||||
word32 saltSz, int kdrIdx, const byte* index, byte label, byte* outKey,
|
word32 saltSz, int kdrIdx, const byte* idx, byte label, byte* outKey,
|
||||||
word32 outKeySz);
|
word32 outKeySz);
|
||||||
/*!
|
/*!
|
||||||
\ingroup SrtpKdf
|
\ingroup SrtpKdf
|
||||||
|
@ -168,7 +168,7 @@ int wc_SRTP_KDF_label(const byte* key, word32 keySz, const byte* salt,
|
||||||
\param [in] salt Random non-secret value.
|
\param [in] salt Random non-secret value.
|
||||||
\param [in] saltSz Size of random in bytes.
|
\param [in] saltSz Size of random in bytes.
|
||||||
\param [in] kdrIdx Key derivation rate. kdr = 0 when -1, otherwise kdr = 2^kdrIdx.
|
\param [in] kdrIdx Key derivation rate. kdr = 0 when -1, otherwise kdr = 2^kdrIdx.
|
||||||
\param [in] index Index value to XOR in.
|
\param [in] idx Index value to XOR in.
|
||||||
\param [in] label Label to use when deriving key.
|
\param [in] label Label to use when deriving key.
|
||||||
\param [out] outKey Derived key.
|
\param [out] outKey Derived key.
|
||||||
\param [in] outKeySz Size of derived key in bytes.
|
\param [in] outKeySz Size of derived key in bytes.
|
||||||
|
@ -178,13 +178,13 @@ int wc_SRTP_KDF_label(const byte* key, word32 keySz, const byte* salt,
|
||||||
\code
|
\code
|
||||||
unsigned char key[16] = { ... };
|
unsigned char key[16] = { ... };
|
||||||
unsigned char salt[14] = { ... };
|
unsigned char salt[14] = { ... };
|
||||||
unsigned char index[4] = { ... };
|
unsigned char idx[4] = { ... };
|
||||||
unsigned char keyE[16];
|
unsigned char keyE[16];
|
||||||
int kdrIdx = 0; // Use all of index
|
int kdrIdx = 0; // Use all of index
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = wc_SRTCP_KDF_label(key, sizeof(key), salt, sizeof(salt), kdrIdx,
|
ret = wc_SRTCP_KDF_label(key, sizeof(key), salt, sizeof(salt), kdrIdx,
|
||||||
index, WC_SRTCP_LABEL_ENCRYPTION, keyE, sizeof(keyE));
|
idx, WC_SRTCP_LABEL_ENCRYPTION, keyE, sizeof(keyE));
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
WOLFSSL_MSG("wc_SRTP_KDF failed");
|
WOLFSSL_MSG("wc_SRTP_KDF failed");
|
||||||
}
|
}
|
||||||
|
@ -196,7 +196,7 @@ int wc_SRTP_KDF_label(const byte* key, word32 keySz, const byte* salt,
|
||||||
\sa wc_SRTP_KDF_kdr_to_idx
|
\sa wc_SRTP_KDF_kdr_to_idx
|
||||||
*/
|
*/
|
||||||
int wc_SRTP_KDF_label(const byte* key, word32 keySz, const byte* salt,
|
int wc_SRTP_KDF_label(const byte* key, word32 keySz, const byte* salt,
|
||||||
word32 saltSz, int kdrIdx, const byte* index, byte label, byte* outKey,
|
word32 saltSz, int kdrIdx, const byte* idx, byte label, byte* outKey,
|
||||||
word32 outKeySz);
|
word32 outKeySz);
|
||||||
/*!
|
/*!
|
||||||
\ingroup SrtpKdf
|
\ingroup SrtpKdf
|
||||||
|
|
|
@ -2847,7 +2847,7 @@ int wolfSSL_GetSessionIndex(WOLFSSL* ssl);
|
||||||
\sa LockMutex
|
\sa LockMutex
|
||||||
\sa wolfSSL_GetSessionIndex
|
\sa wolfSSL_GetSessionIndex
|
||||||
*/
|
*/
|
||||||
int wolfSSL_GetSessionAtIndex(int index, WOLFSSL_SESSION* session);
|
int wolfSSL_GetSessionAtIndex(int idx, WOLFSSL_SESSION* session);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\ingroup IO
|
\ingroup IO
|
||||||
|
|
|
@ -3269,25 +3269,25 @@ static int ProcessClientKeyExchange(const byte* input, int* sslBytes,
|
||||||
static int ProcessKeyShare(KeyShareInfo* info, const byte* input, int len,
|
static int ProcessKeyShare(KeyShareInfo* info, const byte* input, int len,
|
||||||
word16 filter_group)
|
word16 filter_group)
|
||||||
{
|
{
|
||||||
int index = 0;
|
int idx = 0;
|
||||||
while (index < len) {
|
while (idx < len) {
|
||||||
/* clear info (reset dh_key_bits and curve_id) */
|
/* clear info (reset dh_key_bits and curve_id) */
|
||||||
XMEMSET(info, 0, sizeof(KeyShareInfo));
|
XMEMSET(info, 0, sizeof(KeyShareInfo));
|
||||||
|
|
||||||
/* Named group and public key */
|
/* Named group and public key */
|
||||||
info->named_group = (word16)((input[index] << 8) | input[index+1]);
|
info->named_group = (word16)((input[idx] << 8) | input[idx+1]);
|
||||||
index += OPAQUE16_LEN;
|
idx += OPAQUE16_LEN;
|
||||||
info->key_len = 0;
|
info->key_len = 0;
|
||||||
info->key = NULL;
|
info->key = NULL;
|
||||||
/* If key was provided... (a hello_retry_request will not send a key) */
|
/* If key was provided... (a hello_retry_request will not send a key) */
|
||||||
if (index + 2 <= len) {
|
if (idx + 2 <= len) {
|
||||||
info->key_len = (word16)((input[index] << 8) | input[index+1]);
|
info->key_len = (word16)((input[idx] << 8) | input[idx+1]);
|
||||||
index += OPAQUE16_LEN;
|
idx += OPAQUE16_LEN;
|
||||||
if (info->key_len == 0 || info->key_len > len - index) {
|
if (info->key_len == 0 || info->key_len > len - idx) {
|
||||||
return WOLFSSL_FATAL_ERROR;
|
return WOLFSSL_FATAL_ERROR;
|
||||||
}
|
}
|
||||||
info->key = &input[index];
|
info->key = &input[idx];
|
||||||
index += info->key_len;
|
idx += info->key_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (info->named_group) {
|
switch (info->named_group) {
|
||||||
|
@ -7289,7 +7289,7 @@ static int addSecretNode(unsigned char* clientRandom,
|
||||||
unsigned char* secret,
|
unsigned char* secret,
|
||||||
char* error)
|
char* error)
|
||||||
{
|
{
|
||||||
int index = 0;
|
int idx = 0;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
SecretNode* node = NULL;
|
SecretNode* node = NULL;
|
||||||
|
|
||||||
|
@ -7299,8 +7299,8 @@ static int addSecretNode(unsigned char* clientRandom,
|
||||||
|
|
||||||
LOCK_SECRET_LIST();
|
LOCK_SECRET_LIST();
|
||||||
|
|
||||||
index = secretHashFunction(clientRandom);
|
idx = secretHashFunction(clientRandom);
|
||||||
node = secretHashTable[index];
|
node = secretHashTable[idx];
|
||||||
|
|
||||||
while(node) {
|
while(node) {
|
||||||
/* Node already exists, so just add the requested secret */
|
/* Node already exists, so just add the requested secret */
|
||||||
|
@ -7343,12 +7343,12 @@ static unsigned char* findSecret(unsigned char* clientRandom, int type)
|
||||||
{
|
{
|
||||||
unsigned char* secret = NULL;
|
unsigned char* secret = NULL;
|
||||||
SecretNode* node = NULL;
|
SecretNode* node = NULL;
|
||||||
unsigned int index = 0;
|
unsigned int idx = 0;
|
||||||
|
|
||||||
LOCK_SECRET_LIST();
|
LOCK_SECRET_LIST();
|
||||||
|
|
||||||
index = secretHashFunction(clientRandom);
|
idx = secretHashFunction(clientRandom);
|
||||||
node = secretHashTable[index];
|
node = secretHashTable[idx];
|
||||||
|
|
||||||
while (node != NULL) {
|
while (node != NULL) {
|
||||||
if (XMEMCMP(node->clientRandom,
|
if (XMEMCMP(node->clientRandom,
|
||||||
|
|
|
@ -8630,7 +8630,7 @@ void bench_srtpkdf(void)
|
||||||
const byte *key = bench_key_buf;
|
const byte *key = bench_key_buf;
|
||||||
const byte salt[14] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
|
const byte salt[14] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
|
||||||
0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e };
|
0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e };
|
||||||
const byte index[6] = { 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA };
|
const byte idx[6] = { 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA };
|
||||||
int kdrIdx = 0;
|
int kdrIdx = 0;
|
||||||
int i;
|
int i;
|
||||||
DECLARE_MULTI_VALUE_STATS_VARS()
|
DECLARE_MULTI_VALUE_STATS_VARS()
|
||||||
|
@ -8640,7 +8640,7 @@ void bench_srtpkdf(void)
|
||||||
do {
|
do {
|
||||||
for (i = 0; i < numBlocks * 1000; i++) {
|
for (i = 0; i < numBlocks * 1000; i++) {
|
||||||
ret = wc_SRTP_KDF(key, AES_128_KEY_SIZE, salt, sizeof(salt),
|
ret = wc_SRTP_KDF(key, AES_128_KEY_SIZE, salt, sizeof(salt),
|
||||||
kdrIdx, index, keyE, AES_128_KEY_SIZE, keyA, sizeof(keyA),
|
kdrIdx, idx, keyE, AES_128_KEY_SIZE, keyA, sizeof(keyA),
|
||||||
keyS, sizeof(keyS));
|
keyS, sizeof(keyS));
|
||||||
RECORD_MULTI_VALUE_STATS();
|
RECORD_MULTI_VALUE_STATS();
|
||||||
}
|
}
|
||||||
|
@ -8663,7 +8663,7 @@ void bench_srtpkdf(void)
|
||||||
do {
|
do {
|
||||||
for (i = 0; i < numBlocks * 1000; i++) {
|
for (i = 0; i < numBlocks * 1000; i++) {
|
||||||
ret = wc_SRTP_KDF(key, AES_256_KEY_SIZE, salt, sizeof(salt),
|
ret = wc_SRTP_KDF(key, AES_256_KEY_SIZE, salt, sizeof(salt),
|
||||||
kdrIdx, index, keyE, AES_256_KEY_SIZE, keyA, sizeof(keyA),
|
kdrIdx, idx, keyE, AES_256_KEY_SIZE, keyA, sizeof(keyA),
|
||||||
keyS, sizeof(keyS));
|
keyS, sizeof(keyS));
|
||||||
RECORD_MULTI_VALUE_STATS();
|
RECORD_MULTI_VALUE_STATS();
|
||||||
}
|
}
|
||||||
|
@ -8686,7 +8686,7 @@ void bench_srtpkdf(void)
|
||||||
do {
|
do {
|
||||||
for (i = 0; i < numBlocks * 1000; i++) {
|
for (i = 0; i < numBlocks * 1000; i++) {
|
||||||
ret = wc_SRTCP_KDF(key, AES_128_KEY_SIZE, salt, sizeof(salt),
|
ret = wc_SRTCP_KDF(key, AES_128_KEY_SIZE, salt, sizeof(salt),
|
||||||
kdrIdx, index, keyE, AES_128_KEY_SIZE, keyA, sizeof(keyA),
|
kdrIdx, idx, keyE, AES_128_KEY_SIZE, keyA, sizeof(keyA),
|
||||||
keyS, sizeof(keyS));
|
keyS, sizeof(keyS));
|
||||||
RECORD_MULTI_VALUE_STATS();
|
RECORD_MULTI_VALUE_STATS();
|
||||||
}
|
}
|
||||||
|
@ -8709,7 +8709,7 @@ void bench_srtpkdf(void)
|
||||||
do {
|
do {
|
||||||
for (i = 0; i < numBlocks * 1000; i++) {
|
for (i = 0; i < numBlocks * 1000; i++) {
|
||||||
ret = wc_SRTCP_KDF(key, AES_256_KEY_SIZE, salt, sizeof(salt),
|
ret = wc_SRTCP_KDF(key, AES_256_KEY_SIZE, salt, sizeof(salt),
|
||||||
kdrIdx, index, keyE, AES_256_KEY_SIZE, keyA, sizeof(keyA),
|
kdrIdx, idx, keyE, AES_256_KEY_SIZE, keyA, sizeof(keyA),
|
||||||
keyS, sizeof(keyS));
|
keyS, sizeof(keyS));
|
||||||
RECORD_MULTI_VALUE_STATS();
|
RECORD_MULTI_VALUE_STATS();
|
||||||
}
|
}
|
||||||
|
|
|
@ -902,12 +902,12 @@ int wc_SSH_KDF(byte hashId, byte keyId, byte* key, word32 keySz,
|
||||||
* @param [in] saltSz Size of random value in bytes.
|
* @param [in] saltSz Size of random value in bytes.
|
||||||
* @param [in] kdrIdx Key derivation rate. kdr = 0 when -1, otherwise
|
* @param [in] kdrIdx Key derivation rate. kdr = 0 when -1, otherwise
|
||||||
* kdr = 2^kdrIdx.
|
* kdr = 2^kdrIdx.
|
||||||
* @param [in] index Index value to XOR in.
|
* @param [in] idx Index value to XOR in.
|
||||||
* @param [in] indexSz Size of index value in bytes.
|
* @param [in] idxSz Size of index value in bytes.
|
||||||
* @param [out] block First block to encrypt.
|
* @param [out] block First block to encrypt.
|
||||||
*/
|
*/
|
||||||
static void wc_srtp_kdf_first_block(const byte* salt, word32 saltSz, int kdrIdx,
|
static void wc_srtp_kdf_first_block(const byte* salt, word32 saltSz, int kdrIdx,
|
||||||
const byte* index, int indexSz, unsigned char* block)
|
const byte* idx, int idxSz, unsigned char* block)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -924,21 +924,21 @@ static void wc_srtp_kdf_first_block(const byte* salt, word32 saltSz, int kdrIdx,
|
||||||
/* Get the number of bits to shift index by. */
|
/* Get the number of bits to shift index by. */
|
||||||
word32 bits = kdrIdx & 0x7;
|
word32 bits = kdrIdx & 0x7;
|
||||||
/* Reduce index size by number of bytes to remove. */
|
/* Reduce index size by number of bytes to remove. */
|
||||||
indexSz -= kdrIdx >> 3;
|
idxSz -= kdrIdx >> 3;
|
||||||
|
|
||||||
if ((kdrIdx & 0x7) == 0) {
|
if ((kdrIdx & 0x7) == 0) {
|
||||||
/* Just XOR in as no bit shifting. */
|
/* Just XOR in as no bit shifting. */
|
||||||
for (i = 0; i < indexSz; i++) {
|
for (i = 0; i < idxSz; i++) {
|
||||||
block[i + WC_SRTP_MAX_SALT - indexSz] ^= index[i];
|
block[i + WC_SRTP_MAX_SALT - idxSz] ^= idx[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* XOR in as bit shifted index. */
|
/* XOR in as bit shifted index. */
|
||||||
block[WC_SRTP_MAX_SALT - indexSz] ^= (byte)(index[0] >> bits);
|
block[WC_SRTP_MAX_SALT - idxSz] ^= (byte)(idx[0] >> bits);
|
||||||
for (i = 1; i < indexSz; i++) {
|
for (i = 1; i < idxSz; i++) {
|
||||||
block[i + WC_SRTP_MAX_SALT - indexSz] ^=
|
block[i + WC_SRTP_MAX_SALT - idxSz] ^=
|
||||||
(byte)((index[i-1] << (8 - bits)) |
|
(byte)((idx[i-1] << (8 - bits)) |
|
||||||
(index[i+0] >> bits ));
|
(idx[i+0] >> bits ));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -955,7 +955,7 @@ static void wc_srtp_kdf_first_block(const byte* salt, word32 saltSz, int kdrIdx,
|
||||||
* @param [in] aes AES object to encrypt with.
|
* @param [in] aes AES object to encrypt with.
|
||||||
* @return 0 on success.
|
* @return 0 on success.
|
||||||
*/
|
*/
|
||||||
static int wc_srtp_kdf_derive_key(byte* block, int indexSz, byte label,
|
static int wc_srtp_kdf_derive_key(byte* block, int idxSz, byte label,
|
||||||
byte* key, word32 keySz, Aes* aes)
|
byte* key, word32 keySz, Aes* aes)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
@ -964,7 +964,7 @@ static int wc_srtp_kdf_derive_key(byte* block, int indexSz, byte label,
|
||||||
int blocks = (int)(keySz / WC_AES_BLOCK_SIZE);
|
int blocks = (int)(keySz / WC_AES_BLOCK_SIZE);
|
||||||
|
|
||||||
/* XOR in label. */
|
/* XOR in label. */
|
||||||
block[WC_SRTP_MAX_SALT - indexSz - 1] ^= label;
|
block[WC_SRTP_MAX_SALT - idxSz - 1] ^= label;
|
||||||
for (i = 0; (ret == 0) && (i < blocks); i++) {
|
for (i = 0; (ret == 0) && (i < blocks); i++) {
|
||||||
/* Set counter. */
|
/* Set counter. */
|
||||||
block[15] = (byte)i;
|
block[15] = (byte)i;
|
||||||
|
@ -988,7 +988,7 @@ static int wc_srtp_kdf_derive_key(byte* block, int indexSz, byte label,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* XOR out label. */
|
/* XOR out label. */
|
||||||
block[WC_SRTP_MAX_SALT - indexSz - 1] ^= label;
|
block[WC_SRTP_MAX_SALT - idxSz - 1] ^= label;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -1018,7 +1018,7 @@ static int wc_srtp_kdf_derive_key(byte* block, int indexSz, byte label,
|
||||||
* @return 0 on success.
|
* @return 0 on success.
|
||||||
*/
|
*/
|
||||||
int wc_SRTP_KDF(const byte* key, word32 keySz, const byte* salt, word32 saltSz,
|
int wc_SRTP_KDF(const byte* key, word32 keySz, const byte* salt, word32 saltSz,
|
||||||
int kdrIdx, const byte* index, byte* key1, word32 key1Sz, byte* key2,
|
int kdrIdx, const byte* idx, byte* key1, word32 key1Sz, byte* key2,
|
||||||
word32 key2Sz, byte* key3, word32 key3Sz)
|
word32 key2Sz, byte* key3, word32 key3Sz)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
@ -1056,7 +1056,7 @@ int wc_SRTP_KDF(const byte* key, word32 keySz, const byte* salt, word32 saltSz,
|
||||||
|
|
||||||
/* Calculate first block that can be used in each derivation. */
|
/* Calculate first block that can be used in each derivation. */
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
wc_srtp_kdf_first_block(salt, saltSz, kdrIdx, index, WC_SRTP_INDEX_LEN,
|
wc_srtp_kdf_first_block(salt, saltSz, kdrIdx, idx, WC_SRTP_INDEX_LEN,
|
||||||
block);
|
block);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1109,7 +1109,7 @@ int wc_SRTP_KDF(const byte* key, word32 keySz, const byte* salt, word32 saltSz,
|
||||||
* @return 0 on success.
|
* @return 0 on success.
|
||||||
*/
|
*/
|
||||||
int wc_SRTCP_KDF_ex(const byte* key, word32 keySz, const byte* salt, word32 saltSz,
|
int wc_SRTCP_KDF_ex(const byte* key, word32 keySz, const byte* salt, word32 saltSz,
|
||||||
int kdrIdx, const byte* index, byte* key1, word32 key1Sz, byte* key2,
|
int kdrIdx, const byte* idx, byte* key1, word32 key1Sz, byte* key2,
|
||||||
word32 key2Sz, byte* key3, word32 key3Sz, int idxLenIndicator)
|
word32 key2Sz, byte* key3, word32 key3Sz, int idxLenIndicator)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
@ -1156,7 +1156,7 @@ int wc_SRTCP_KDF_ex(const byte* key, word32 keySz, const byte* salt, word32 salt
|
||||||
|
|
||||||
/* Calculate first block that can be used in each derivation. */
|
/* Calculate first block that can be used in each derivation. */
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
wc_srtp_kdf_first_block(salt, saltSz, kdrIdx, index, idxLen, block);
|
wc_srtp_kdf_first_block(salt, saltSz, kdrIdx, idx, idxLen, block);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Calculate first key if required. */
|
/* Calculate first key if required. */
|
||||||
|
@ -1184,11 +1184,11 @@ int wc_SRTCP_KDF_ex(const byte* key, word32 keySz, const byte* salt, word32 salt
|
||||||
}
|
}
|
||||||
|
|
||||||
int wc_SRTCP_KDF(const byte* key, word32 keySz, const byte* salt, word32 saltSz,
|
int wc_SRTCP_KDF(const byte* key, word32 keySz, const byte* salt, word32 saltSz,
|
||||||
int kdrIdx, const byte* index, byte* key1, word32 key1Sz, byte* key2,
|
int kdrIdx, const byte* idx, byte* key1, word32 key1Sz, byte* key2,
|
||||||
word32 key2Sz, byte* key3, word32 key3Sz)
|
word32 key2Sz, byte* key3, word32 key3Sz)
|
||||||
{
|
{
|
||||||
/* The default 32-bit IDX expected by many implementations */
|
/* The default 32-bit IDX expected by many implementations */
|
||||||
return wc_SRTCP_KDF_ex(key, keySz, salt, saltSz, kdrIdx, index,
|
return wc_SRTCP_KDF_ex(key, keySz, salt, saltSz, kdrIdx, idx,
|
||||||
key1, key1Sz, key2, key2Sz, key3, key3Sz,
|
key1, key1Sz, key2, key2Sz, key3, key3Sz,
|
||||||
WC_SRTCP_32BIT_IDX);
|
WC_SRTCP_32BIT_IDX);
|
||||||
}
|
}
|
||||||
|
@ -1214,7 +1214,7 @@ int wc_SRTCP_KDF(const byte* key, word32 keySz, const byte* salt, word32 saltSz,
|
||||||
* @return 0 on success.
|
* @return 0 on success.
|
||||||
*/
|
*/
|
||||||
int wc_SRTP_KDF_label(const byte* key, word32 keySz, const byte* salt,
|
int wc_SRTP_KDF_label(const byte* key, word32 keySz, const byte* salt,
|
||||||
word32 saltSz, int kdrIdx, const byte* index, byte label, byte* outKey,
|
word32 saltSz, int kdrIdx, const byte* idx, byte label, byte* outKey,
|
||||||
word32 outKeySz)
|
word32 outKeySz)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
@ -1253,7 +1253,7 @@ int wc_SRTP_KDF_label(const byte* key, word32 keySz, const byte* salt,
|
||||||
|
|
||||||
/* Calculate first block that can be used in each derivation. */
|
/* Calculate first block that can be used in each derivation. */
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
wc_srtp_kdf_first_block(salt, saltSz, kdrIdx, index, WC_SRTP_INDEX_LEN,
|
wc_srtp_kdf_first_block(salt, saltSz, kdrIdx, idx, WC_SRTP_INDEX_LEN,
|
||||||
block);
|
block);
|
||||||
}
|
}
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
|
@ -1293,7 +1293,7 @@ int wc_SRTP_KDF_label(const byte* key, word32 keySz, const byte* salt,
|
||||||
* @return 0 on success.
|
* @return 0 on success.
|
||||||
*/
|
*/
|
||||||
int wc_SRTCP_KDF_label(const byte* key, word32 keySz, const byte* salt,
|
int wc_SRTCP_KDF_label(const byte* key, word32 keySz, const byte* salt,
|
||||||
word32 saltSz, int kdrIdx, const byte* index, byte label, byte* outKey,
|
word32 saltSz, int kdrIdx, const byte* idx, byte label, byte* outKey,
|
||||||
word32 outKeySz)
|
word32 outKeySz)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
@ -1332,7 +1332,7 @@ int wc_SRTCP_KDF_label(const byte* key, word32 keySz, const byte* salt,
|
||||||
|
|
||||||
/* Calculate first block that can be used in each derivation. */
|
/* Calculate first block that can be used in each derivation. */
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
wc_srtp_kdf_first_block(salt, saltSz, kdrIdx, index, WC_SRTCP_INDEX_LEN,
|
wc_srtp_kdf_first_block(salt, saltSz, kdrIdx, idx, WC_SRTCP_INDEX_LEN,
|
||||||
block);
|
block);
|
||||||
}
|
}
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
|
|
|
@ -664,7 +664,7 @@ __global__ void AesEncrypt_C_CUDA(word32* rkBase, const byte* inBlockBase, byte*
|
||||||
word32 s0, s1, s2, s3;
|
word32 s0, s1, s2, s3;
|
||||||
word32 t0, t1, t2, t3;
|
word32 t0, t1, t2, t3;
|
||||||
word32 sBox;
|
word32 sBox;
|
||||||
int index = blockIdx.x * blockDim.x + threadIdx.x;
|
int idx = blockIdx.x * blockDim.x + threadIdx.x;
|
||||||
int stride = blockDim.x * gridDim.x;
|
int stride = blockDim.x * gridDim.x;
|
||||||
const byte* inBlock = inBlockBase;
|
const byte* inBlock = inBlockBase;
|
||||||
byte* outBlock = outBlockBase;
|
byte* outBlock = outBlockBase;
|
||||||
|
|
|
@ -535,7 +535,7 @@ static int Pkcs11Slot_FindByTokenName(Pkcs11Dev* dev,
|
||||||
CK_RV rv;
|
CK_RV rv;
|
||||||
CK_ULONG slotCnt = 0;
|
CK_ULONG slotCnt = 0;
|
||||||
CK_TOKEN_INFO tinfo;
|
CK_TOKEN_INFO tinfo;
|
||||||
int index = -1;
|
int idx = -1;
|
||||||
CK_SLOT_ID* slot = NULL;
|
CK_SLOT_ID* slot = NULL;
|
||||||
|
|
||||||
rv = dev->func->C_GetSlotList(CK_TRUE, NULL, &slotCnt);
|
rv = dev->func->C_GetSlotList(CK_TRUE, NULL, &slotCnt);
|
||||||
|
@ -547,12 +547,12 @@ static int Pkcs11Slot_FindByTokenName(Pkcs11Dev* dev,
|
||||||
rv = dev->func->C_GetSlotList(CK_TRUE, slot, &slotCnt);
|
rv = dev->func->C_GetSlotList(CK_TRUE, slot, &slotCnt);
|
||||||
if (rv != CKR_OK)
|
if (rv != CKR_OK)
|
||||||
goto out;
|
goto out;
|
||||||
for (index = 0; index < (int)slotCnt; index++) {
|
for (idx = 0; idx < (int)slotCnt; idx++) {
|
||||||
rv = dev->func->C_GetTokenInfo(slot[index], &tinfo);
|
rv = dev->func->C_GetTokenInfo(slot[idx], &tinfo);
|
||||||
PKCS11_RV("C_GetTokenInfo", rv);
|
PKCS11_RV("C_GetTokenInfo", rv);
|
||||||
if (rv == CKR_OK &&
|
if (rv == CKR_OK &&
|
||||||
XMEMCMP(tinfo.label, tokenName, tokenNameSz) == 0) {
|
XMEMCMP(tinfo.label, tokenName, tokenNameSz) == 0) {
|
||||||
ret = (int)slot[index];
|
ret = (int)slot[idx];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,19 +147,19 @@ enum {
|
||||||
#define WC_SRTP_MAX_SALT 14
|
#define WC_SRTP_MAX_SALT 14
|
||||||
|
|
||||||
WOLFSSL_API int wc_SRTP_KDF(const byte* key, word32 keySz, const byte* salt,
|
WOLFSSL_API int wc_SRTP_KDF(const byte* key, word32 keySz, const byte* salt,
|
||||||
word32 saltSz, int kdrIdx, const byte* index, byte* key1, word32 key1Sz,
|
word32 saltSz, int kdrIdx, const byte* idx, byte* key1, word32 key1Sz,
|
||||||
byte* key2, word32 key2Sz, byte* key3, word32 key3Sz);
|
byte* key2, word32 key2Sz, byte* key3, word32 key3Sz);
|
||||||
WOLFSSL_API int wc_SRTCP_KDF(const byte* key, word32 keySz, const byte* salt,
|
WOLFSSL_API int wc_SRTCP_KDF(const byte* key, word32 keySz, const byte* salt,
|
||||||
word32 saltSz, int kdrIdx, const byte* index, byte* key1, word32 key1Sz,
|
word32 saltSz, int kdrIdx, const byte* idx, byte* key1, word32 key1Sz,
|
||||||
byte* key2, word32 key2Sz, byte* key3, word32 key3Sz);
|
byte* key2, word32 key2Sz, byte* key3, word32 key3Sz);
|
||||||
WOLFSSL_API int wc_SRTCP_KDF_ex(const byte* key, word32 keySz, const byte* salt,
|
WOLFSSL_API int wc_SRTCP_KDF_ex(const byte* key, word32 keySz, const byte* salt,
|
||||||
word32 saltSz, int kdrIdx, const byte* index, byte* key1, word32 key1Sz,
|
word32 saltSz, int kdrIdx, const byte* idx, byte* key1, word32 key1Sz,
|
||||||
byte* key2, word32 key2Sz, byte* key3, word32 key3Sz, int idxLenIndicator);
|
byte* key2, word32 key2Sz, byte* key3, word32 key3Sz, int idxLenIndicator);
|
||||||
WOLFSSL_API int wc_SRTP_KDF_label(const byte* key, word32 keySz,
|
WOLFSSL_API int wc_SRTP_KDF_label(const byte* key, word32 keySz,
|
||||||
const byte* salt, word32 saltSz, int kdrIdx, const byte* index, byte label,
|
const byte* salt, word32 saltSz, int kdrIdx, const byte* idx, byte label,
|
||||||
byte* outKey, word32 outKeySz);
|
byte* outKey, word32 outKeySz);
|
||||||
WOLFSSL_API int wc_SRTCP_KDF_label(const byte* key, word32 keySz,
|
WOLFSSL_API int wc_SRTCP_KDF_label(const byte* key, word32 keySz,
|
||||||
const byte* salt, word32 saltSz, int kdrIdx, const byte* index, byte label,
|
const byte* salt, word32 saltSz, int kdrIdx, const byte* idx, byte label,
|
||||||
byte* outKey, word32 outKeySz);
|
byte* outKey, word32 outKeySz);
|
||||||
|
|
||||||
WOLFSSL_API int wc_SRTP_KDF_kdr_to_idx(word32 kdr);
|
WOLFSSL_API int wc_SRTP_KDF_kdr_to_idx(word32 kdr);
|
||||||
|
|
Loading…
Reference in New Issue