Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.62 KB | None | 0 0
  1. #define SECRET_KEY_SIZE 20 //The size of the secret (symmetric) key)
  2. #define ENCRYPTED_KEY_SIZE 128 //The size of the encrypted symmetric key
  3. #define PUB_KEY_SIZE 128 //1024 bits: The size of the public and private keys
  4.  
  5. //generate a public and private key pair
  6. void sec_key_gen(char public_key[PUB_KEY_SIZE], char private_key[PUB_KEY_SIZE]);
  7.  
  8. //use the public key to encrypt the 'in' buffer (a secret key).
  9. //The ciphertext is returned in the 'out' buffer.
  10. void sec_pk_encrypt(char in[SECRET_KEY_SIZE], char out[ENCRYPTED_KEY_SIZE],
  11.     char pub_key[PUB_KEY_SIZE]);
  12.  
  13. //use the private key to decrypt the 'in' buffer.
  14. //The recovered secret key is returned in the 'out' buffer.
  15. void sec_pk_decrypt(char in[ENCRYPTED_KEY_SIZE], char out[SECRET_KEY_SIZE],
  16.     char priv_key[PUB_KEY_SIZE]);
  17.  
  18. //use the symmetric key to encrypt the 'input' buffer using a block cipher.
  19. //Memory is allocated for the ciphertext, which is returned in 'output'.
  20. //The output length is also returned as it may be different from the input.
  21. //The caller is responsible for freeing the memory for the output when done.
  22. void sec_symmetric_encrypt(char *input, int input_len,
  23.     char **output, int *output_len, char key[SECRET_KEY_SIZE]);
  24.  
  25. //use the symmetric key to decrypt the 'input' buffer using a block cipher.
  26. //Memory is allocated for the plaintext, which is returned in 'output'.
  27. //The output length is also returned as it may be different from the input.
  28. //The caller is responsible for freeing the memory for the output when done.
  29. void sec_symmetric_decrypt(char *input, int input_len,
  30.     char **output, int *output_len, char key[SECRET_KEY_SIZE]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement