Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/sodium/crypto_stream_chacha20.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 #ifndef crypto_stream_chacha20_H
0002 #define crypto_stream_chacha20_H
0003 
0004 /*
0005  *  WARNING: This is just a stream cipher. It is NOT authenticated encryption.
0006  *  While it provides some protection against eavesdropping, it does NOT
0007  *  provide any security against active attacks.
0008  *  Unless you know what you're doing, what you are looking for is probably
0009  *  the crypto_box functions.
0010  */
0011 
0012 #include <stddef.h>
0013 #include <stdint.h>
0014 #include "export.h"
0015 
0016 #ifdef __cplusplus
0017 # ifdef __GNUC__
0018 #  pragma GCC diagnostic ignored "-Wlong-long"
0019 # endif
0020 extern "C" {
0021 #endif
0022 
0023 #define crypto_stream_chacha20_KEYBYTES 32U
0024 SODIUM_EXPORT
0025 size_t crypto_stream_chacha20_keybytes(void);
0026 
0027 #define crypto_stream_chacha20_NONCEBYTES 8U
0028 SODIUM_EXPORT
0029 size_t crypto_stream_chacha20_noncebytes(void);
0030 
0031 #define crypto_stream_chacha20_MESSAGEBYTES_MAX SODIUM_SIZE_MAX
0032 SODIUM_EXPORT
0033 size_t crypto_stream_chacha20_messagebytes_max(void);
0034 
0035 /* ChaCha20 with a 64-bit nonce and a 64-bit counter, as originally designed */
0036 
0037 SODIUM_EXPORT
0038 int crypto_stream_chacha20(unsigned char *c, unsigned long long clen,
0039                            const unsigned char *n, const unsigned char *k)
0040             __attribute__ ((nonnull));
0041 
0042 SODIUM_EXPORT
0043 int crypto_stream_chacha20_xor(unsigned char *c, const unsigned char *m,
0044                                unsigned long long mlen, const unsigned char *n,
0045                                const unsigned char *k)
0046             __attribute__ ((nonnull));
0047 
0048 SODIUM_EXPORT
0049 int crypto_stream_chacha20_xor_ic(unsigned char *c, const unsigned char *m,
0050                                   unsigned long long mlen,
0051                                   const unsigned char *n, uint64_t ic,
0052                                   const unsigned char *k)
0053             __attribute__ ((nonnull));
0054 
0055 SODIUM_EXPORT
0056 void crypto_stream_chacha20_keygen(unsigned char k[crypto_stream_chacha20_KEYBYTES])
0057             __attribute__ ((nonnull));
0058 
0059 /* ChaCha20 with a 96-bit nonce and a 32-bit counter (IETF) */
0060 
0061 #define crypto_stream_chacha20_ietf_KEYBYTES 32U
0062 SODIUM_EXPORT
0063 size_t crypto_stream_chacha20_ietf_keybytes(void);
0064 
0065 #define crypto_stream_chacha20_ietf_NONCEBYTES 12U
0066 SODIUM_EXPORT
0067 size_t crypto_stream_chacha20_ietf_noncebytes(void);
0068 
0069 #define crypto_stream_chacha20_ietf_MESSAGEBYTES_MAX \
0070     SODIUM_MIN(SODIUM_SIZE_MAX, 64ULL * (1ULL << 32))
0071 SODIUM_EXPORT
0072 size_t crypto_stream_chacha20_ietf_messagebytes_max(void);
0073 
0074 SODIUM_EXPORT
0075 int crypto_stream_chacha20_ietf(unsigned char *c, unsigned long long clen,
0076                                 const unsigned char *n, const unsigned char *k)
0077             __attribute__ ((nonnull));
0078 
0079 SODIUM_EXPORT
0080 int crypto_stream_chacha20_ietf_xor(unsigned char *c, const unsigned char *m,
0081                                     unsigned long long mlen, const unsigned char *n,
0082                                     const unsigned char *k)
0083             __attribute__ ((nonnull));
0084 
0085 SODIUM_EXPORT
0086 int crypto_stream_chacha20_ietf_xor_ic(unsigned char *c, const unsigned char *m,
0087                                        unsigned long long mlen,
0088                                        const unsigned char *n, uint32_t ic,
0089                                        const unsigned char *k)
0090             __attribute__ ((nonnull));
0091 
0092 SODIUM_EXPORT
0093 void crypto_stream_chacha20_ietf_keygen(unsigned char k[crypto_stream_chacha20_ietf_KEYBYTES])
0094             __attribute__ ((nonnull));
0095 
0096 /* Aliases */
0097 
0098 #define crypto_stream_chacha20_IETF_KEYBYTES crypto_stream_chacha20_ietf_KEYBYTES
0099 #define crypto_stream_chacha20_IETF_NONCEBYTES crypto_stream_chacha20_ietf_NONCEBYTES
0100 #define crypto_stream_chacha20_IETF_MESSAGEBYTES_MAX crypto_stream_chacha20_ietf_MESSAGEBYTES_MAX
0101 
0102 #ifdef __cplusplus
0103 }
0104 #endif
0105 
0106 #endif