Kyber_SM2
Module Contents
Functions
|
Generates the public key and private key for the hybrid encryption scheme. |
|
Encrypts the given message using the hybrid encryption scheme. |
|
Decrypts the given ciphertext using the hybrid encryption scheme. |
|
Performs a bitwise XOR operation on two hexadecimal strings. |
|
Encrypts the given data using the SM4 encryption algorithm. |
|
- Kyber_SM2.key_gen_hybrid() Tuple[str, str] [源代码]
Generates the public key and private key for the hybrid encryption scheme.
- Returns:
Tuple containing the public key and private key. - pk (bytes): Public key containing two parts of information. - sk (bytes): Private key containing two parts of information,
private key for Kyber algorithm and private key for SM2 encryption.
- Kyber_SM2.enc_hybrid(pk: str)[源代码]
Encrypts the given message using the hybrid encryption scheme.
- Args:
pk (bytes): Public key containing two parts of information, Kyber pk || SM2 pk .
msg (list): List of messages to be encrypted.
- Returns:
Tuple containing the encrypted ciphertext, symmetric key, and encrypted message. - c_text (bytes): Encrypted ciphertext containing two parts of information,
ciphertext encrypted using Kyber algorithm and ciphertext encrypted using SM2 encryption.
sym_key (str): Symmetric key used for encryption.
msg_enc (list): Encrypted message.
- Kyber_SM2.dec_hybrid(c_text1, c_text2, sk) [str, str] [源代码]
Decrypts the given ciphertext using the hybrid encryption scheme.
- Args:
c_text (bytes): Ciphertext to be decrypted, containing two parts of information, ciphertext encrypted using Kyber algorithm and ciphertext encrypted using SM2 encryption.
sk (bytes): Private key containing two parts of information, private key for Kyber algorithm and private key for SM2 encryption.
msg_enc (list): Encrypted message.
- Returns:
Decrypted message.
- Kyber_SM2.xor_hex_strings(hex_str1: str, hex_str2: str)[源代码]
Performs a bitwise XOR operation on two hexadecimal strings.
- Args:
hex_str1 (str): The first hexadecimal string. hex_str2 (str): The second hexadecimal string.
- Returns:
The result of the XOR operation as a hexadecimal string.