kdf.h
Functions
| Name | |
|---|---|
| int | wc_SRTP_KDF(const byte * key, word32 keySz, const byte * salt, word32 saltSz, int kdrIdx, const byte * idx, byte * key1, word32 key1Sz, byte * key2, word32 key2Sz, byte * key3, word32 key3Sz) この関数はSRTP KDFアルゴリズムを使用して鍵を導出します。 |
| int | wc_SRTCP_KDF(const byte * key, word32 keySz, const byte * salt, word32 saltSz, int kdrIdx, const byte * idx, byte * key1, word32 key1Sz, byte * key2, word32 key2Sz, byte * key3, word32 key3Sz) この関数はSRTCP KDFアルゴリズムを使用して鍵を導出します。 |
| int | wc_SRTP_KDF_label(const byte * key, word32 keySz, const byte * salt, word32 saltSz, int kdrIdx, const byte * idx, byte label, byte * outKey, word32 outKeySz) この関数はSRTP KDFアルゴリズムを使用してラベル付きの鍵を導出します。 |
| int | wc_SRTCP_KDF_label(const byte * key, word32 keySz, const byte * salt, word32 saltSz, int kdrIdx, const byte * idx, byte label, byte * outKey, word32 outKeySz) この関数はSRTCP KDFアルゴリズムを使用してラベル付きの鍵を導出します。 |
| int | wc_SRTP_KDF_kdr_to_idx(word32 kdr) この関数はkdr値をSRTP/SRTCP KDF APIで使用するインデックスに変換します。 |
| int | wc_KDA_KDF_onestep(const byte * z, word32 zSz, const byte * fixedInfo, word32 fixedInfoSz, word32 derivedSecretSz, enum wc_HashType hashType, byte * output, word32 outputSz) SP800_56Cオプション1で規定されている単一ステップ鍵導出関数(KDF)を実行します。 |
Functions Documentation
function wc_SRTP_KDF
int wc_SRTP_KDF(
const byte * key,
word32 keySz,
const byte * salt,
word32 saltSz,
int kdrIdx,
const byte * idx,
byte * key1,
word32 key1Sz,
byte * key2,
word32 key2Sz,
byte * key3,
word32 key3Sz
)
この関数はSRTP KDFアルゴリズムを使用して鍵を導出します。
Parameters:
- key 暗号化で使用する鍵。
- keySz 鍵のサイズ(バイト単位)。
- salt ランダムな非秘密値。
- saltSz ランダム値のサイズ(バイト単位)。
- kdrIdx 鍵導出率。-1の場合kdr = 0、それ以外の場合kdr = 2^kdrIdx。
- idx XORするインデックス値。
- key1 最初の鍵。ラベル値は0x00。
- key1Sz 最初の鍵のサイズ(バイト単位)。
- key2 2番目の鍵。ラベル値は0x01。
- key2Sz 2番目の鍵のサイズ(バイト単位)。
- key3 3番目の鍵。ラベル値は0x02。
- key3Sz 3番目の鍵のサイズ(バイト単位)。
See:
Return:
- 0 鍵の導出に成功した場合に返されます。
- BAD_FUNC_ARG keyまたはsaltがNULLの場合に返されます
- BAD_FUNC_ARG 鍵の長さが16、24、または32でない場合に返されます。
- BAD_FUNC_ARG saltSzが14より大きい場合に返されます。
- BAD_FUNC_ARG kdrIdxが-1未満または24より大きい場合に返されます。
- MEMORY_E 動的メモリ割り当ての失敗時。
Example
unsigned char key[16] = { ... };
unsigned char salt[14] = { ... };
unsigned char idx[6] = { ... };
unsigned char keyE[16];
unsigned char keyA[20];
unsigned char keyS[14];
int kdrIdx = 0; // インデックスのすべてを使用
int ret;
ret = wc_SRTP_KDF(key, sizeof(key), salt, sizeof(salt), kdrIdx, idx,
keyE, sizeof(keyE), keyA, sizeof(keyA), keyS, sizeof(keyS));
if (ret != 0) {
WOLFSSL_MSG("wc_SRTP_KDF failed");
}
function wc_SRTCP_KDF
int wc_SRTCP_KDF(
const byte * key,
word32 keySz,
const byte * salt,
word32 saltSz,
int kdrIdx,
const byte * idx,
byte * key1,
word32 key1Sz,
byte * key2,
word32 key2Sz,
byte * key3,
word32 key3Sz
)
この関数はSRTCP KDFアルゴリズムを使用して鍵を導出します。
Parameters:
- key 暗号化で使用する鍵。
- keySz 鍵のサイズ(バイト単位)。
- salt ランダムな非秘密値。
- saltSz ランダム値のサイズ(バイト単位)。
- kdrIdx 鍵導出率。-1の場合kdr = 0、それ以外の場合kdr = 2^kdrIdx。
- idx XORするインデックス値。
- key1 最初の鍵。ラベル値は0x00。
- key1Sz 最初の鍵のサイズ(バイト単位)。
- key2 2番目の鍵。ラベル値は0x01。
- key2Sz 2番目の鍵のサイズ(バイト単位)。
- key3 3番目の鍵。ラベル値は0x02。
- key3Sz 3番目の鍵のサイズ(バイト単位)。
See:
Return:
- 0 鍵の導出に成功した場合に返されます。
- BAD_FUNC_ARG keyまたはsaltがNULLの場合に返されます
- BAD_FUNC_ARG 鍵の長さが16、24、または32でない場合に返されます。
- BAD_FUNC_ARG saltSzが14より大きい場合に返されます。
- BAD_FUNC_ARG kdrIdxが-1未満または24より大きい場合に返されます。
- MEMORY_E 動的メモリ割り当ての失敗時。
Example
unsigned char key[16] = { ... };
unsigned char salt[14] = { ... };
unsigned char idx[4] = { ... };
unsigned char keyE[16];
unsigned char keyA[20];
unsigned char keyS[14];
int kdrIdx = 0; // インデックスのすべてを使用
int ret;
ret = wc_SRTCP_KDF(key, sizeof(key), salt, sizeof(salt), kdrIdx, idx,
keyE, sizeof(keyE), keyA, sizeof(keyA), keyS, sizeof(keyS));
if (ret != 0) {
WOLFSSL_MSG("wc_SRTP_KDF failed");
}
function wc_SRTP_KDF_label
int wc_SRTP_KDF_label(
const byte * key,
word32 keySz,
const byte * salt,
word32 saltSz,
int kdrIdx,
const byte * idx,
byte label,
byte * outKey,
word32 outKeySz
)
この関数はSRTP KDFアルゴリズムを使用してラベル付きの鍵を導出します。
Parameters:
- key 暗号化で使用する鍵。
- keySz 鍵のサイズ(バイト単位)。
- salt ランダムな非秘密値。
- saltSz ランダム値のサイズ(バイト単位)。
- kdrIdx 鍵導出率。-1の場合kdr = 0、それ以外の場合kdr = 2^kdrIdx。
- idx XORするインデックス値。
- label 鍵を導出する際に使用するラベル。
- outKey 導出された鍵。
- outKeySz 導出された鍵のサイズ(バイト単位)。
See:
Return:
- 0 鍵の導出に成功した場合に返されます。
- BAD_FUNC_ARG key、salt、またはoutKeyがNULLの場合に返されます
- BAD_FUNC_ARG 鍵の長さが16、24、または32でない場合に返されます。
- BAD_FUNC_ARG saltSzが14より大きい場合に返されます。
- BAD_FUNC_ARG kdrIdxが-1未満または24より大きい場合に返されます。
- MEMORY_E 動的メモリ割り当ての失敗時。
Example
unsigned char key[16] = { ... };
unsigned char salt[14] = { ... };
unsigned char idx[6] = { ... };
unsigned char keyE[16];
int kdrIdx = 0; // インデックスのすべてを使用
int ret;
ret = wc_SRTP_KDF_label(key, sizeof(key), salt, sizeof(salt), kdrIdx, idx,
WC_SRTP_LABEL_ENCRYPTION, keyE, sizeof(keyE));
if (ret != 0) {
WOLFSSL_MSG("wc_SRTP_KDF failed");
}
function wc_SRTCP_KDF_label
int wc_SRTCP_KDF_label(
const byte * key,
word32 keySz,
const byte * salt,
word32 saltSz,
int kdrIdx,
const byte * idx,
byte label,
byte * outKey,
word32 outKeySz
)
この関数はSRTCP KDFアルゴリズムを使用してラベル付きの鍵を導出します。
Parameters:
- key 暗号化で使用する鍵。
- keySz 鍵のサイズ(バイト単位)。
- salt ランダムな非秘密値。
- saltSz ランダム値のサイズ(バイト単位)。
- kdrIdx 鍵導出率。-1の場合kdr = 0、それ以外の場合kdr = 2^kdrIdx。
- idx XORするインデックス値。
- label 鍵を導出する際に使用するラベル。
- outKey 導出された鍵。
- outKeySz 導出された鍵のサイズ(バイト単位)。
See:
Return:
- 0 鍵の導出に成功した場合に返されます。
- BAD_FUNC_ARG key、salt、またはoutKeyがNULLの場合に返されます
- BAD_FUNC_ARG 鍵の長さが16、24、または32でない場合に返されます。
- BAD_FUNC_ARG saltSzが14より大きい場合に返されます。
- BAD_FUNC_ARG kdrIdxが-1未満または24より大きい場合に返されます。
- MEMORY_E 動的メモリ割り当ての失敗時。
Example
unsigned char key[16] = { ... };
unsigned char salt[14] = { ... };
unsigned char idx[4] = { ... };
unsigned char keyE[16];
int kdrIdx = 0; // インデックスのすべてを使用
int ret;
ret = wc_SRTCP_KDF_label(key, sizeof(key), salt, sizeof(salt), kdrIdx,
idx, WC_SRTCP_LABEL_ENCRYPTION, keyE, sizeof(keyE));
if (ret != 0) {
WOLFSSL_MSG("wc_SRTP_KDF failed");
}
function wc_SRTP_KDF_kdr_to_idx
int wc_SRTP_KDF_kdr_to_idx(
word32 kdr
)
この関数はkdr値をSRTP/SRTCP KDF APIで使用するインデックスに変換します。
Parameters:
- kdr 変換する鍵導出率。
See:
Return: インデックスとしての鍵導出率。
Example
word32 kdr = 0x00000010;
int kdrIdx;
int ret;
kdrIdx = wc_SRTP_KDF_kdr_to_idx(kdr);
function wc_KDA_KDF_onestep
int wc_KDA_KDF_onestep(
const byte * z,
word32 zSz,
const byte * fixedInfo,
word32 fixedInfoSz,
word32 derivedSecretSz,
enum wc_HashType hashType,
byte * output,
word32 outputSz
)
SP800-56Cオプション1で規定されている単一ステップ鍵導出関数(KDF)を実行します。
Parameters:
- z 入力鍵材料。
- zSz 入力鍵材料のサイズ。
- fixedInfo KDFに含める固定情報。
- fixedInfoSz 固定情報のサイズ。
- derivedSecretSz 導出される秘密の希望サイズ。
- hashType KDFで使用するハッシュアルゴリズム。
- output 導出された秘密を格納するバッファ。
- outputSz 出力バッファのサイズ。
Return:
- 0 KDF操作が成功した場合、
- BAD_FUNC_ARG 入力パラメータが無効な場合。
- 負のエラーコード KDF操作が失敗した場合。
Example
unsigned char z[32] = { ... };
unsigned char fixedInfo[16] = { ... };
unsigned char output[32];
int ret;
ret = wc_KDA_KDF_onestep(z, sizeof(z), fixedInfo, sizeof(fixedInfo),
sizeof(output), WC_HASH_TYPE_SHA256, output, sizeof(output));
if (ret != 0) {
WOLFSSL_MSG("wc_KDA_KDF_onestep failed");
}
Source code
int wc_SRTP_KDF(const byte* key, word32 keySz, const byte* salt, word32 saltSz,
int kdrIdx, const byte* idx, byte* key1, word32 key1Sz, byte* key2,
word32 key2Sz, byte* key3, word32 key3Sz);
int wc_SRTCP_KDF(const byte* key, word32 keySz, const byte* salt, word32 saltSz,
int kdrIdx, const byte* idx, byte* key1, word32 key1Sz, byte* key2,
word32 key2Sz, byte* key3, word32 key3Sz);
int wc_SRTP_KDF_label(const byte* key, word32 keySz, const byte* salt,
word32 saltSz, int kdrIdx, const byte* idx, byte label, byte* outKey,
word32 outKeySz);
int wc_SRTCP_KDF_label(const byte* key, word32 keySz, const byte* salt,
word32 saltSz, int kdrIdx, const byte* idx, byte label, byte* outKey,
word32 outKeySz);
int wc_SRTP_KDF_kdr_to_idx(word32 kdr);
int wc_KDA_KDF_onestep(const byte* z, word32 zSz,
const byte* fixedInfo, word32 fixedInfoSz, word32 derivedSecretSz,
enum wc_HashType hashType, byte* output, word32 outputSz);
Updated on 2025-12-12 at 03:08:17 +0000