-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbytes.h
More file actions
25 lines (20 loc) · 915 Bytes
/
bytes.h
File metadata and controls
25 lines (20 loc) · 915 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#ifndef STREAM_CIPHER_BYTES_H
#define STREAM_CIPHER_BYTES_H
#include "sfmt/SFMT.h"
extern sfmt_t mtrand;
typedef unsigned char byte;
#define two_power(n) (1u << (n))
void print_bytes(byte *bytes, unsigned int length);
void print_bits(byte *bits, unsigned int length);
void byte_to_bit_array(/*IN*/ byte *bytes, unsigned int bytelength, /*OUT*/ byte *bits);
void bit_to_byte_array(/*IN*/ byte *bits, unsigned int bitslength, /*OUT*/ byte *bytes);
byte * generate_random_bytes(unsigned int length);
byte * generate_random_bits(unsigned int bitlength);
void xor_bytes(/*IN*/ byte *b1, /*IN*/ byte *b2, /*OUT*/ byte *result, unsigned int length);
unsigned int isset_bit(byte *b, int pos);
void flip_bit(byte *b, int pos);
void set_bit(byte *b, int pos);
void unset_bit(byte *b, int pos);
unsigned int hamming_weight(byte *b, unsigned int length);
void inc_byte(byte *b, int idx);
#endif //STREAM_CIPHER_BYTES_H