Correct PPTP server firewall rules chain.
[tomato/davidwu.git] / release / src / router / nettle / examples / rsa-session.h
blob44b85ec70e6611aef1d7b4985bbec9c59a7d0c32
1 /* Session key definitions for the rsa-encrypt and rsa-decrypt programs.
2 */
4 #ifndef NETTLE_EXAMPLES_RSA_SESSION_H_INCLUDED
5 #define NETTLE_EXAMPLES_RSA_SESSION_H_INCLUDED
7 #include "aes.h"
8 #include "cbc.h"
9 #include "hmac.h"
11 #define RSA_VERSION 1
13 /* Encryption program using the following file format:
15 uint32_t version = 1;
16 uint32_t nsize;
17 uint8_t x[nsize];
18 uint8_t encrypted[n];
19 uint8_t hmac[SHA1_DIGEST_SIZE];
21 where x is the data
23 uint32_t version = 1;
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
32 padded as
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).
40 struct rsa_session
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)
58 void
59 rsa_session_set_encrypt_key(struct rsa_session *ctx,
60 const struct rsa_session_info *key);
62 void
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 */