@@ -23,7 +23,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23
23
#define ROTL32 (v , n ) ((v) << (n)) | ((v) >> (32 - (n)))
24
24
25
25
26
- #define U32V (v ) ((uint32_t )(v) & U32_C(0xFFFFFFFF))
26
+ #define U32V (v ) ((u32 )(v) & U32_C(0xFFFFFFFF))
27
27
#define ROTATE (v ,c ) (ROTL32(v,c))
28
28
#define XOR (v ,w ) ((v) ^ (w))
29
29
#define PLUS (v ,w ) (U32V((v) + (w)))
@@ -41,8 +41,8 @@ extern "C"
41
41
42
42
struct chacha20_ctx
43
43
{
44
- uint32_t schedule [16 ];
45
- uint32_t keystream [16 ];
44
+ u32 schedule [16 ];
45
+ u32 keystream [16 ];
46
46
size_t available ;
47
47
size_t nonce_length ; // may be 8 or 12
48
48
};
@@ -51,30 +51,30 @@ typedef struct chacha20_ctx chacha20_ctx;
51
51
52
52
typedef struct chacha20poly1305_ctx {
53
53
chacha20_ctx local_chacha ;
54
- uint8_t local_iv [12 ];
54
+ u8 local_iv [12 ];
55
55
chacha20_ctx remote_chacha ;
56
- uint8_t remote_iv [12 ];
56
+ u8 remote_iv [12 ];
57
57
} chacha20poly1305_ctx ;
58
58
59
59
60
60
61
61
//Call this to initilize a chacha20_ctx, must be called before all other functions
62
- void chacha20_keysetup (chacha20_ctx * ctx , const uint8_t * key , size_t length );
63
- void chacha20_ivsetup (chacha20_ctx * ctx , const uint8_t * nonce , size_t nonce_length , uint64_t counter , const uint8_t * sequence );
62
+ void chacha20_keysetup (chacha20_ctx * ctx , const u8 * key , size_t length );
63
+ void chacha20_ivsetup (chacha20_ctx * ctx , const u8 * nonce , size_t nonce_length , u64 counter , const u8 * sequence );
64
64
65
65
66
66
//Call this if you need to process a particular block number
67
- void chacha20_counter_set (chacha20_ctx * ctx , uint64_t counter );
67
+ void chacha20_counter_set (chacha20_ctx * ctx , u64 counter );
68
68
69
- //Raw keystream for the current block, convert output to uint8_t [] for individual bytes. Counter is incremented upon use
70
- void chacha20_block (chacha20_ctx * ctx , uint32_t output [16 ]);
69
+ //Raw keystream for the current block, convert output to u8 [] for individual bytes. Counter is incremented upon use
70
+ void chacha20_block (chacha20_ctx * ctx , u32 output [16 ]);
71
71
72
72
//Encrypt an arbitrary amount of plaintext, call continuously as needed
73
- void chacha20_encrypt (chacha20_ctx * ctx , const uint8_t * in , uint8_t * out , size_t length );
74
- void chacha_encrypt_bytes (chacha20_ctx * x , const uint8_t * m , uint8_t * c , uint32_t bytes ) ;
73
+ void chacha20_encrypt (chacha20_ctx * ctx , const u8 * in , u8 * out , size_t length );
74
+ void chacha_encrypt_bytes (chacha20_ctx * x , const u8 * m , u8 * c , u32 bytes ) ;
75
75
76
76
//Decrypt an arbitrary amount of ciphertext. Actually, for chacha20, decryption is the same function as encryption
77
- void chacha20_decrypt (chacha20_ctx * ctx , const uint8_t * in , uint8_t * out , size_t length );
77
+ void chacha20_decrypt (chacha20_ctx * ctx , const u8 * in , u8 * out , size_t length );
78
78
79
79
//Generate POLY1305 key
80
80
void chacha20_poly1305_key (struct chacha20_ctx * ctx , unsigned char * poly1305_key );
0 commit comments