Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:12:40

0001 #ifndef crypto_secretstream_xchacha20poly1305_H
0002 #define crypto_secretstream_xchacha20poly1305_H
0003 
0004 #include <stddef.h>
0005 
0006 #include "crypto_aead_xchacha20poly1305.h"
0007 #include "crypto_stream_chacha20.h"
0008 #include "export.h"
0009 
0010 #ifdef __cplusplus
0011 # ifdef __GNUC__
0012 #  pragma GCC diagnostic ignored "-Wlong-long"
0013 # endif
0014 extern "C" {
0015 #endif
0016 
0017 #define crypto_secretstream_xchacha20poly1305_ABYTES \
0018     (1U + crypto_aead_xchacha20poly1305_ietf_ABYTES)
0019 SODIUM_EXPORT
0020 size_t crypto_secretstream_xchacha20poly1305_abytes(void);
0021 
0022 #define crypto_secretstream_xchacha20poly1305_HEADERBYTES \
0023     crypto_aead_xchacha20poly1305_ietf_NPUBBYTES
0024 SODIUM_EXPORT
0025 size_t crypto_secretstream_xchacha20poly1305_headerbytes(void);
0026 
0027 #define crypto_secretstream_xchacha20poly1305_KEYBYTES \
0028     crypto_aead_xchacha20poly1305_ietf_KEYBYTES
0029 SODIUM_EXPORT
0030 size_t crypto_secretstream_xchacha20poly1305_keybytes(void);
0031 
0032 #define crypto_secretstream_xchacha20poly1305_MESSAGEBYTES_MAX \
0033     SODIUM_MIN(SODIUM_SIZE_MAX - crypto_secretstream_xchacha20poly1305_ABYTES, \
0034               (64ULL * ((1ULL << 32) - 2ULL)))
0035 SODIUM_EXPORT
0036 size_t crypto_secretstream_xchacha20poly1305_messagebytes_max(void);
0037 
0038 #define crypto_secretstream_xchacha20poly1305_TAG_MESSAGE 0x00
0039 SODIUM_EXPORT
0040 unsigned char crypto_secretstream_xchacha20poly1305_tag_message(void);
0041 
0042 #define crypto_secretstream_xchacha20poly1305_TAG_PUSH    0x01
0043 SODIUM_EXPORT
0044 unsigned char crypto_secretstream_xchacha20poly1305_tag_push(void);
0045 
0046 #define crypto_secretstream_xchacha20poly1305_TAG_REKEY   0x02
0047 SODIUM_EXPORT
0048 unsigned char crypto_secretstream_xchacha20poly1305_tag_rekey(void);
0049 
0050 #define crypto_secretstream_xchacha20poly1305_TAG_FINAL \
0051     (crypto_secretstream_xchacha20poly1305_TAG_PUSH | \
0052      crypto_secretstream_xchacha20poly1305_TAG_REKEY)
0053 SODIUM_EXPORT
0054 unsigned char crypto_secretstream_xchacha20poly1305_tag_final(void);
0055 
0056 typedef struct crypto_secretstream_xchacha20poly1305_state {
0057     unsigned char k[crypto_stream_chacha20_ietf_KEYBYTES];
0058     unsigned char nonce[crypto_stream_chacha20_ietf_NONCEBYTES];
0059     unsigned char _pad[8];
0060 } crypto_secretstream_xchacha20poly1305_state;
0061 
0062 SODIUM_EXPORT
0063 size_t crypto_secretstream_xchacha20poly1305_statebytes(void);
0064 
0065 SODIUM_EXPORT
0066 void crypto_secretstream_xchacha20poly1305_keygen
0067    (unsigned char k[crypto_secretstream_xchacha20poly1305_KEYBYTES])
0068             __attribute__ ((nonnull));
0069 
0070 SODIUM_EXPORT
0071 int crypto_secretstream_xchacha20poly1305_init_push
0072    (crypto_secretstream_xchacha20poly1305_state *state,
0073     unsigned char header[crypto_secretstream_xchacha20poly1305_HEADERBYTES],
0074     const unsigned char k[crypto_secretstream_xchacha20poly1305_KEYBYTES])
0075             __attribute__ ((nonnull));
0076 
0077 SODIUM_EXPORT
0078 int crypto_secretstream_xchacha20poly1305_push
0079    (crypto_secretstream_xchacha20poly1305_state *state,
0080     unsigned char *c, unsigned long long *clen_p,
0081     const unsigned char *m, unsigned long long mlen,
0082     const unsigned char *ad, unsigned long long adlen, unsigned char tag)
0083             __attribute__ ((nonnull(1)));
0084 
0085 SODIUM_EXPORT
0086 int crypto_secretstream_xchacha20poly1305_init_pull
0087    (crypto_secretstream_xchacha20poly1305_state *state,
0088     const unsigned char header[crypto_secretstream_xchacha20poly1305_HEADERBYTES],
0089     const unsigned char k[crypto_secretstream_xchacha20poly1305_KEYBYTES])
0090             __attribute__ ((nonnull));
0091 
0092 SODIUM_EXPORT
0093 int crypto_secretstream_xchacha20poly1305_pull
0094    (crypto_secretstream_xchacha20poly1305_state *state,
0095     unsigned char *m, unsigned long long *mlen_p, unsigned char *tag_p,
0096     const unsigned char *c, unsigned long long clen,
0097     const unsigned char *ad, unsigned long long adlen)
0098             __attribute__ ((nonnull(1)));
0099 
0100 SODIUM_EXPORT
0101 void crypto_secretstream_xchacha20poly1305_rekey
0102     (crypto_secretstream_xchacha20poly1305_state *state);
0103 
0104 #ifdef __cplusplus
0105 }
0106 #endif
0107 
0108 #endif