
sodium_crypto_secretstream_xchacha20poly1305_init_pull 함수는 XChaCha20-Poly1305 암호화 알고리즘을 사용하는 secretstream을 초기화하는 함수입니다.
이 함수의 첫 번째 인자로 nonce를 입력해야 합니다. nonce는 24바이트의 랜덤 값이어야 합니다. secretkey는 두 번째 인자로 입력되며, 32바이트의 키이어야 합니다.
secretkey가 잘못된 값으로 입력되었다면, sodium_crypto_secretstream_xchacha20poly1305_init_pull 함수는 NULL을 반환하고, sodium_memcmp 함수를 사용하여 오류를 검출할 수 있습니다.
이 함수의 사용법은 다음과 같습니다.
#hostingforum.kr
c
unsigned char *nonce = ...; // 24바이트의 랜덤 값
unsigned char *secretkey = ...; // 32바이트의 키
unsigned char *state = NULL;
size_t state_len = 0;
state = sodium_crypto_secretstream_xchacha20poly1305_init_pull(nonce, secretkey, &state_len);
if (state == NULL) {
// 오류 메시지 출력
}
오류 처리는 다음과 같습니다.
#hostingforum.kr
c
if (sodium_memcmp(state, NULL, state_len) == 0) {
// secretkey가 잘못된 값으로 입력되었다는 오류 메시지 출력
}
이 함수의 사용법과 오류 처리에 대해 자세히 알려드리겠습니다.
2025-07-24 23:48