|
Document of c-modernization-kit (porter) 1.0.0
|
Linux 向け暗号化・復号モジュール (OpenSSL AES-256-GCM)。 More...
Go to the source code of this file.
Functions | |
| int | potr_encrypt (uint8_t *dst, size_t *dst_len, const uint8_t *src, size_t src_len, const uint8_t *key, const uint8_t *nonce, const uint8_t *aad, size_t aad_len) |
| AES-256-GCM でデータを暗号化します。 | |
| int | potr_decrypt (uint8_t *dst, size_t *dst_len, const uint8_t *src, size_t src_len, const uint8_t *key, const uint8_t *nonce, const uint8_t *aad, size_t aad_len) |
| AES-256-GCM でデータを復号し、認証タグを検証します。 | |
| int | potr_passphrase_to_key (uint8_t *key, const uint8_t *passphrase, size_t passphrase_len) |
| 任意のパスフレーズを SHA-256 ハッシュにより AES-256 鍵に変換します。 | |
Linux 向け暗号化・復号モジュール (OpenSSL AES-256-GCM)。
OpenSSL の EVP インターフェースを使用して AES-256-GCM 暗号化・復号を実装します。
Windows 実装 (BCrypt) と同一の wire フォーマット ([暗号文][GCM タグ 16B]) を使用するため、 クロスプラットフォーム通信に対応します。
本ファイルは Linux ビルドでのみコンパイルされます (_WIN32 未定義時)。
Definition in file crypto_linux.c.
| int potr_encrypt | ( | uint8_t * | dst, |
| size_t * | dst_len, | ||
| const uint8_t * | src, | ||
| size_t | src_len, | ||
| const uint8_t * | key, | ||
| const uint8_t * | nonce, | ||
| const uint8_t * | aad, | ||
| size_t | aad_len ) |
AES-256-GCM でデータを暗号化します。
| [out] | dst | 暗号化後データを格納するバッファ。 内容: [暗号文: src_len バイト][GCM タグ: POTR_CRYPTO_TAG_SIZE バイト] dst == src の in-place 暗号化も可能。 |
| [in,out] | dst_len | 入力: dst のバッファサイズ (>= src_len + POTR_CRYPTO_TAG_SIZE)。 出力: 書き込んだバイト数 (= src_len + POTR_CRYPTO_TAG_SIZE)。 |
| [in] | src | 平文データへのポインタ。 |
| [in] | src_len | 平文データのバイト数。 |
| [in] | key | AES-256 鍵 (POTR_CRYPTO_KEY_SIZE バイト)。 |
| [in] | nonce | ノンス (POTR_CRYPTO_NONCE_SIZE バイト)。 |
| [in] | aad | 追加認証データへのポインタ。NULL の場合は AAD なし。 |
| [in] | aad_len | AAD のバイト数。 |
Definition at line 29 of file crypto_linux.c.
References POTR_CRYPTO_NONCE_SIZE, and POTR_CRYPTO_TAG_SIZE.
Referenced by flush_packed(), flush_packed_peer(), health_thread_func(), n1_send_nack(), n1_send_ping_reply(), n1_send_reject(), peer_send_fin(), send_fin(), send_nack(), send_ping_reply(), send_reject(), tcp_health_thread_func(), and tcp_send_ping_reply().
| int potr_decrypt | ( | uint8_t * | dst, |
| size_t * | dst_len, | ||
| const uint8_t * | src, | ||
| size_t | src_len, | ||
| const uint8_t * | key, | ||
| const uint8_t * | nonce, | ||
| const uint8_t * | aad, | ||
| size_t | aad_len ) |
AES-256-GCM でデータを復号し、認証タグを検証します。
| [out] | dst | 復号後データを格納するバッファ。 |
| [in,out] | dst_len | 入力: dst のバッファサイズ (>= src_len - POTR_CRYPTO_TAG_SIZE)。 出力: 書き込んだバイト数 (= src_len - POTR_CRYPTO_TAG_SIZE)。 |
| [in] | src | 暗号化データへのポインタ。 内容: [暗号文: src_len - POTR_CRYPTO_TAG_SIZE バイト][GCM タグ: POTR_CRYPTO_TAG_SIZE バイト] |
| [in] | src_len | 暗号化データのバイト数 (タグを含む)。>= POTR_CRYPTO_TAG_SIZE。 |
| [in] | key | AES-256 鍵 (POTR_CRYPTO_KEY_SIZE バイト)。 |
| [in] | nonce | ノンス (POTR_CRYPTO_NONCE_SIZE バイト)。 |
| [in] | aad | 追加認証データへのポインタ。NULL の場合は AAD なし。 |
| [in] | aad_len | AAD のバイト数。 |
Definition at line 116 of file crypto_linux.c.
References POTR_CRYPTO_NONCE_SIZE, and POTR_CRYPTO_TAG_SIZE.
Referenced by recv_thread_func(), and tcp_recv_thread_func().
| int potr_passphrase_to_key | ( | uint8_t * | key, |
| const uint8_t * | passphrase, | ||
| size_t | passphrase_len ) |
任意のパスフレーズを SHA-256 ハッシュにより AES-256 鍵に変換します。
設定ファイルの encrypt_key に 64 文字 hex 以外の文字列が指定された場合に使用します。
入力バイト列の SHA-256 ダイジェストをそのまま鍵として使用します。
送受信の双方で同一のパスフレーズを指定すれば、同一の鍵が導出されます。
| [out] | key | 出力鍵バッファ (POTR_CRYPTO_KEY_SIZE = 32 バイト)。 |
| [in] | passphrase | パスフレーズへのポインタ (任意のバイト列)。 |
| [in] | passphrase_len | パスフレーズの長さ (バイト)。0 の場合も有効。 |
Definition at line 213 of file crypto_linux.c.
References POTR_CRYPTO_KEY_SIZE.
Referenced by apply_service_kv().