Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
.claude/
dist/
*.iml

### ACVP Research
*_response.json
test-vectors/

### Rust template
# Generated by Cargo
Expand Down
33 changes: 32 additions & 1 deletion COMPLIANCE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
# 인증 및 규정 준수 사항

작업 진행 중.
> [!IMPORTANT]
> 테스트 벡터를 통과했다고 해서, 각 암호화 모듈 및 알고리즘 구현이 완전히 검증됐다는 것이 아닙니다.
> 이러한 테스트 벡터의 사용은 CAVP(Cryptographic Algorithm Validation Program)를 통해 얻은 검증을 대체하지 않습니다.

NIST CAVP는 단일 알고리즘에 대한 검증 작업입니다. 실제 프로덕션 환경에서 사용되기 위해서는 FIPS 140-2/3에 따른 CMVP(Cryptographic Module Validation Program) 검증이 필요합니다. 즉, CAVP 인증은 CMVP 인증의 필수 선수 조건입니다.

## RNG

> [NIST CAVP - Random Number Generators](https://csrc.nist.gov/Projects/cryptographic-algorithm-validation-program/Random-Number-Generators)

- [ ] SP 800-90A DRBG(Deterministic Random Bit Generators)

## SHA2

> [NIST CAVP - Secure Hashing](https://csrc.nist.gov/projects/cryptographic-algorithm-validation-program/secure-hashing) (ISO/IEC 10118-3)

- [ ] FIPS 180-4 SHA Test Vectors for Hashing Bit/Byte-Oriented Messages

> [KCMVP](https://seed.kisa.or.kr/kisa/kcmvp/EgovVerification.do) KS X ISO/IEC 10118-3:2001

- [ ] Security techniques - Hash-functions - Part 3: Dedicated hash-functions (2018)

## SHA3

> [NIST CAVP - Secure Hashing](https://csrc.nist.gov/projects/cryptographic-algorithm-validation-program/secure-hashing) (ISO/IEC 10118-3)

- [X] FIPS 202 SHA-3 Hash Function Test Vectors for Hashing Bit/Byte-Oriented Messages
- [X] FIPS 202 SHA-3 XOF Test Vectors for Bit/Byte-Oriented Output

> [KCMVP](https://seed.kisa.or.kr/kisa/kcmvp/EgovVerification.do) KS X ISO/IEC 10118-3:2001

- [X] Security techniques - Hash-functions - Part 3: Dedicated hash-functions (2018)
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ entlib-native-core-secure = { path = "./crypto/core-secure", version =
entlib-native-rng = { path = "./crypto/rng", version = "1.1.2-Alpha" }
entlib-native-sha2 = { path = "./crypto/sha2", version = "1.1.2-Alpha" }
entlib-native-sha3 = { path = "./crypto/sha3", version = "1.1.2-Alpha" }
entlib-native-chacha20 = { path = "./crypto/chacha20", version = "1.1.2-Alpha" }
entlib-native-chacha20 = { path = "./crypto/chacha20", version = "1.1.2-Alpha" }
21 changes: 21 additions & 0 deletions crypto/sha3/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,33 @@ license.workspace = true
crate-type = ["cdylib", "rlib"]

[dependencies]
hex = "0.4.3" # 다음 커밋에 제거

[dev-dependencies]
criterion = { version = "0.8.2", features = ["html_reports"] }
entlib-native-core-secure.workspace = true
entlib-native-rng.workspace = true

[[bin]]
name = "cavp_sha3_bit"
path = "src/bin/cavp_sha3_bit.rs"

[[bin]]
name = "cavp_sha3_byte"
path = "src/bin/cavp_sha3_byte.rs"

[[bin]]
name = "cavp_shake_xof_bit"
path = "src/bin/cavp_shake_xof_bit.rs"

[[bin]]
name = "cavp_shake_xof_byte"
path = "src/bin/cavp_shake_xof_byte.rs"

[[bin]]
name = "kcmvp_sha3_byte"
path = "src/bin/kcmvp_sha3_byte.rs"

[[bench]]
name = "sha3_bench"
harness = false
46 changes: 38 additions & 8 deletions crypto/sha3/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ impl SHA3_224 {

// 해시 연산 완료 및 다이제스트 반환
pub fn finalize(self) -> Vec<u8> {
self.0.finalize(28)
self.0.finalize(28, None)
}

// last_bits: 0~7 사이의 값. 마지막 바이트의 유효 비트 개수
pub fn finalize_bits(self, last_byte: u8, valid_bits: usize) -> Vec<u8> {
self.0.finalize(28, Some((last_byte, valid_bits)))
}
}

Expand Down Expand Up @@ -66,7 +71,12 @@ impl SHA3_256 {

// 해시 연산 완료 및 다이제스트 반환
pub fn finalize(self) -> Vec<u8> {
self.0.finalize(32)
self.0.finalize(32, None)
}

// last_bits: 0~7 사이의 값. 마지막 바이트의 유효 비트 개수
pub fn finalize_bits(self, last_byte: u8, valid_bits: usize) -> Vec<u8> {
self.0.finalize(32, Some((last_byte, valid_bits)))
}
}

Expand Down Expand Up @@ -96,7 +106,12 @@ impl SHA3_384 {

// 해시 연산 완료 및 다이제스트 반환
pub fn finalize(self) -> Vec<u8> {
self.0.finalize(48)
self.0.finalize(48, None)
}

// last_bits: 0~7 사이의 값. 마지막 바이트의 유효 비트 개수
pub fn finalize_bits(self, last_byte: u8, valid_bits: usize) -> Vec<u8> {
self.0.finalize(48, Some((last_byte, valid_bits)))
}
}

Expand Down Expand Up @@ -126,7 +141,12 @@ impl SHA3_512 {

// 해시 연산 완료 및 다이제스트 반환
pub fn finalize(self) -> Vec<u8> {
self.0.finalize(64)
self.0.finalize(64, None)
}

// last_bits: 0~7 사이의 값. 마지막 바이트의 유효 비트 개수
pub fn finalize_bits(self, last_byte: u8, valid_bits: usize) -> Vec<u8> {
self.0.finalize(64, Some((last_byte, valid_bits)))
}
}

Expand Down Expand Up @@ -154,9 +174,14 @@ impl SHAKE128 {
self.0.update(data);
}

// XOF 연산 완료 및 지정된 길이의 다이제스트 반환
// 바이트가 정확히 맞아떨어질 때 사용 (불완전 바이트 없음)
pub fn finalize(self, output_len: usize) -> Vec<u8> {
self.0.finalize(output_len)
self.0.finalize(output_len, None)
}

// 불완전한 마지막 바이트(last_byte)와 그 유효 비트 수(valid_bits)를 함께 받음
pub fn finalize_bits(self, output_len: usize, last_byte: u8, valid_bits: usize) -> Vec<u8> {
self.0.finalize(output_len, Some((last_byte, valid_bits)))
}
}

Expand Down Expand Up @@ -184,9 +209,14 @@ impl SHAKE256 {
self.0.update(data);
}

// XOF 연산 완료 및 지정된 길이의 다이제스트 반환
// 바이트가 정확히 맞아떨어질 때 사용 (불완전 바이트 없음)
pub fn finalize(self, output_len: usize) -> Vec<u8> {
self.0.finalize(output_len)
self.0.finalize(output_len, None)
}

// 불완전한 마지막 바이트(last_byte)와 그 유효 비트 수(valid_bits)를 함께 받음
pub fn finalize_bits(self, output_len: usize, last_byte: u8, valid_bits: usize) -> Vec<u8> {
self.0.finalize(output_len, Some((last_byte, valid_bits)))
}
}

Expand Down
Loading