Files
wolfssl/doc/dox_comments/header_files-ja/dh.h

282 lines
11 KiB
C
Raw Normal View History

/*!
\ingroup Diffie-Hellman
\brief Diffie-Hellman Exchangeプロトコルを使用して安全な秘密鍵を交渉するのに使用するためのDiffie-Hellmanキーを初期化します
\return none
_Example_
\code
DhKey key;
wc_InitDhKey(&key); // initialize DH key
\endcode
\sa wc_FreeDhKey
\sa wc_DhGenerateKeyPair
*/
int wc_InitDhKey(DhKey* key);
/*!
\ingroup Diffie-Hellman
\brief Diffie-Hellman Exchangeプロトコルを使用して安全な秘密鍵をネゴシエートするために使用された後にDiffie-Hellmanキーを解放します
\return none
_Example_
\code
DhKey key;
// initialize key, perform key exchange
wc_FreeDhKey(&key); // free DH key to avoid memory leaks
\endcode
\sa wc_InitDhKey
*/
void wc_FreeDhKey(DhKey* key);
/*!
\ingroup Diffie-Hellman
\brief diffie-hellmanパブリックパラメータに基づいてパブリック/PRIVSの秘密鍵とPubの公開鍵を格納しますDiffie-Hellmanキーと初期化されたRNG構造を取ります
\return BAD_FUNC_ARG 1
\return RNG_FAILURE_E RNGを使用して乱数を生成するエラーが発生した場合
\return MP_INIT_E
\return MP_READ_E
\return MP_EXPTMOD_E
\return MP_TO_E
\param key DHKEY構造体へのポインタ
\param rng RNG
\param priv
\param privSz PRIVに書かれた秘密鍵のサイズを保存します
\param pub
_Example_
\code
DhKey key;
int ret;
byte priv[256];
byte pub[256];
word32 privSz, pubSz;
wc_InitDhKey(&key); // initialize key
// Set DH parameters using wc_DhSetKey or wc_DhKeyDecode
WC_RNG rng;
wc_InitRng(&rng); // initialize rng
ret = wc_DhGenerateKeyPair(&key, &rng, priv, &privSz, pub, &pubSz);
\endcode
\sa wc_InitDhKey
\sa wc_DhSetKey
\sa wc_DhKeyDecode
*/
int wc_DhGenerateKeyPair(DhKey* key, WC_RNG* rng, byte* priv,
word32* privSz, byte* pub, word32* pubSz);
/*!
\ingroup Diffie-Hellman
\brief
\return 0
\return MP_INIT_E
\return MP_READ_E
\return MP_EXPTMOD_E
\return MP_TO_E
\param key 使DHKEY構造体へのポインタ
\param agree
\param agreeSz
\param priv
\param privSz
\param otherPub
_Example_
\code
DhKey key;
int ret;
byte priv[256];
byte agree[256];
word32 agreeSz;
// initialize key, set key prime and base
// wc_DhGenerateKeyPair -- store private key in priv
byte pub[] = { // initialized with the received public key };
ret = wc_DhAgree(&key, agree, &agreeSz, priv, sizeof(priv), pub,
sizeof(pub));
if ( ret != 0 ) {
// error generating shared key
}
\endcode
\sa wc_DhGenerateKeyPair
*/
int wc_DhAgree(DhKey* key, byte* agree, word32* agreeSz,
const byte* priv, word32 privSz, const byte* otherPub,
word32 pubSz);
/*!
\ingroup Diffie-Hellman
\brief DERフォーマットのキーを含む与えられた入力バッファからDiffie-HellmanキーをデコードしますDHKEY構造体に格納します
\return 0
\return ASN_PARSE_E
\return ASN_DH_KEY_E
\param input derフォーマットされたdiffie-hellmanキーを含むバッファへのポインタ
\param inOutIdx
\param key DHKEY構造体へのポインタ
_Example_
\code
DhKey key;
word32 idx = 0;
byte keyBuff[1024];
// initialize with DER formatted key
wc_DhKeyInit(&key);
ret = wc_DhKeyDecode(keyBuff, &idx, &key, sizeof(keyBuff));
if ( ret != 0 ) {
// error decoding key
}
\endcode
\sa wc_DhSetKey
*/
int wc_DhKeyDecode(const byte* input, word32* inOutIdx, DhKey* key,
word32);
/*!
\ingroup Diffie-Hellman
\brief 使DHKEY構造体のキーを設定しますWC_DHKEYDECODEとは異なりDERフォーマットでフォーマットされPARSED入力パラメータPPrimeGBase
\return 0
\return BAD_FUNC_ARG NULLに評価された場合に返されます
\return MP_INIT_E
\return ASN_DH_KEY_E DHキーパラメータPおよびGでエラーの読み取りがある場合は返されます
\param key DHKEY構造体へのポインタ
\param p 使
\param pSz
\param g 使
_Example_
\code
DhKey key;
byte p[] = { // initialize with prime };
byte g[] = { // initialize with base };
wc_DhKeyInit(&key);
ret = wc_DhSetKey(key, p, sizeof(p), g, sizeof(g));
if ( ret != 0 ) {
// error setting key
}
\endcode
\sa wc_DhKeyDecode
*/
int wc_DhSetKey(DhKey* key, const byte* p, word32 pSz, const byte* g,
word32 gSz);
/*!
\ingroup Diffie-Hellman
\brief Diffie-HellmanパラメータPPrimeG
\return 0 DHパラメータの抽出に成功しました
\return ASN_PARSE_E DERフォーマットのDH証明書の解析中にエラーが発生した場合に返されます
\return BUFFER_E PまたはGに不適切なスペースがある場合
\param input DERフォーマットされたDifie-Hellman証明書を含むバッファへのポインタ
\param inSz
\param p
\param pInOutSz Pバッファ内の使用可能なサイズを含むWord32オブジェクトへのポインタ
\param g
_Example_
\code
byte dhCert[] = { initialize with DER formatted certificate };
byte p[MAX_DH_SIZE];
byte g[MAX_DH_SIZE];
word32 pSz = MAX_DH_SIZE;
word32 gSz = MAX_DH_SIZE;
ret = wc_DhParamsLoad(dhCert, sizeof(dhCert), p, &pSz, g, &gSz);
if ( ret != 0 ) {
// error parsing inputs
}
\endcode
\sa wc_DhSetKey
\sa wc_DhKeyDecode
*/
int wc_DhParamsLoad(const byte* input, word32 inSz, byte* p,
word32* pInOutSz, byte* g, word32* gInOutSz);
/*!
\ingroup Diffie-Hellman
\sa wc_Dh_ffdhe3072_Get
\sa wc_Dh_ffdhe4096_Get
\sa wc_Dh_ffdhe6144_Get
\sa wc_Dh_ffdhe8192_Get
*/
const DhParams* wc_Dh_ffdhe2048_Get(void);
/*!
\ingroup Diffie-Hellman
\sa wc_Dh_ffdhe2048_Get
\sa wc_Dh_ffdhe4096_Get
\sa wc_Dh_ffdhe6144_Get
\sa wc_Dh_ffdhe8192_Get
*/
const DhParams* wc_Dh_ffdhe3072_Get(void);
/*!
\ingroup Diffie-Hellman
\sa wc_Dh_ffdhe2048_Get
\sa wc_Dh_ffdhe3072_Get
\sa wc_Dh_ffdhe6144_Get
\sa wc_Dh_ffdhe8192_Get
*/
const DhParams* wc_Dh_ffdhe4096_Get(void);
/*!
\ingroup Diffie-Hellman
\sa wc_Dh_ffdhe2048_Get
\sa wc_Dh_ffdhe3072_Get
\sa wc_Dh_ffdhe4096_Get
\sa wc_Dh_ffdhe8192_Get
*/
const DhParams* wc_Dh_ffdhe6144_Get(void);
/*!
\ingroup Diffie-Hellman
\sa wc_Dh_ffdhe2048_Get
\sa wc_Dh_ffdhe3072_Get
\sa wc_Dh_ffdhe4096_Get
\sa wc_Dh_ffdhe6144_Get
*/
const DhParams* wc_Dh_ffdhe8192_Get(void);
/*!
\ingroup Diffie-Hellman
*/
int wc_DhCheckKeyPair(DhKey* key, const byte* pub, word32 pubSz,
const byte* priv, word32 privSz);
/*!
\ingroup Diffie-Hellman
*/
int wc_DhCheckPrivKey(DhKey* key, const byte* priv, word32 pubSz);
/*!
*/
int wc_DhCheckPrivKey_ex(DhKey* key, const byte* priv, word32 pubSz,
const byte* prime, word32 primeSz);
/*!
*/
int wc_DhCheckPubKey(DhKey* key, const byte* pub, word32 pubSz);
/*!
*/
int wc_DhCheckPubKey_ex(DhKey* key, const byte* pub, word32 pubSz,
const byte* prime, word32 primeSz);
/*!
*/
int wc_DhExportParamsRaw(DhKey* dh, byte* p, word32* pSz,
byte* q, word32* qSz, byte* g, word32* gSz);
/*!
*/
int wc_DhGenerateParams(WC_RNG *rng, int modSz, DhKey *dh);
/*!
*/
int wc_DhSetCheckKey(DhKey* key, const byte* p, word32 pSz,
const byte* g, word32 gSz, const byte* q, word32 qSz,
int trusted, WC_RNG* rng);
/*!
*/
int wc_DhSetKey_ex(DhKey* key, const byte* p, word32 pSz,
const byte* g, word32 gSz, const byte* q, word32 qSz);
/*!
*/
int wc_FreeDhKey(DhKey* key);