Skip to content

Feature/add sm2 pke tests #1172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

peiqing6888
Copy link
Contributor

Description

Add comprehensive test suite for SM2 PKE (Public Key Encryption) implementation.

Changes

Added new test file pke_extended.rs with the following test cases:

  • Test vectors for different plaintext lengths (empty, 1 byte, 32 bytes, 256 bytes)
  • Ciphertext tampering detection tests
  • Special plaintext cases (all zeros, all ones, control characters, UTF-8)
  • Encryption mode tests (C1C3C2 and C1C2C3)
  • Property-based tests for encryption consistency

Testing

All tests pass successfully. The new tests provide better coverage for:

  • Edge cases
  • Security properties
  • Encryption modes
  • Randomness properties
  • Error handling

Related Issues

N/A

Checklist

  • Tests added
  • All tests passing
  • No unsafe code
  • Documentation comments in English

Add new test file dsa_extended.rs with comprehensive tests for SM2 DSA: - Test different message lengths - Test signature tampering detection - Test special message cases - Add property-based tests for signature consistency
let cipher2 = ek.encrypt(&mut rand_core::OsRng, &plaintext1).unwrap();

// Different ciphertexts for same plaintext (due to randomness)
prop_assert_ne!(cipher1, cipher2);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you need to borrow here:

Suggested change
prop_assert_ne!(cipher1, cipher2);
prop_assert_ne!(&cipher1, &cipher2);

@peiqing6888 peiqing6888 closed this May 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants