1 /* Session key definitions for the rsa-encrypt and rsa-decrypt programs.
4 #ifndef NETTLE_EXAMPLES_RSA_SESSION_H_INCLUDED
5 #define NETTLE_EXAMPLES_RSA_SESSION_H_INCLUDED
13 /* Encryption program using the following file format:
19 uint8_t hmac[SHA1_DIGEST_SIZE];
24 uint8_t aes_key[AES_KEY_SIZE];
25 uint8_t iv[AES_BLOCK_SIZE];
26 uint8_t hmac_key[SHA1_DIGEST_SIZE];
28 of size (4 + AES_KEY_SIZE + AES_BLOCK_SIZE + SHA1_DIGEST_SIZE) = 72
29 bytes, encrypted using rsa-pkcs1.
31 The cleartext input is encrypted using aes-cbc. The final block is
34 | data | random octets | padding length |
36 where the last octet is the padding length, a number between 1 and
37 AES_BLOCK_SIZE (inclusive).
42 struct CBC_CTX(struct aes_ctx
, AES_BLOCK_SIZE
) aes
;
43 struct hmac_sha1_ctx hmac
;
44 struct yarrow256_ctx yarrow
;
47 struct rsa_session_info
49 /* Version followed by aes key, iv and mac key */
50 uint8_t key
[4 + AES_KEY_SIZE
+ AES_BLOCK_SIZE
+ SHA1_DIGEST_SIZE
];
53 #define SESSION_VERSION(s) ((s)->key)
54 #define SESSION_AES_KEY(s) ((s)->key + 4)
55 #define SESSION_IV(s) ((s)->key + 4 + AES_KEY_SIZE)
56 #define SESSION_HMAC_KEY(s) ((s)->key + 4 + AES_KEY_SIZE + AES_BLOCK_SIZE)
59 rsa_session_set_encrypt_key(struct rsa_session
*ctx
,
60 const struct rsa_session_info
*key
);
63 rsa_session_set_decrypt_key(struct rsa_session
*ctx
,
64 const struct rsa_session_info
*key
);
66 #endif /* NETTLE_EXAMPLES_RSA_SESSION_H_INCLUDED */