OLD | NEW |
1 /* | 1 /* |
2 * datatypes.h | 2 * datatypes.h |
3 * | 3 * |
4 * data types for bit vectors and finite fields | 4 * data types for bit vectors and finite fields |
5 * | 5 * |
6 * David A. McGrew | 6 * David A. McGrew |
7 * Cisco Systems, Inc. | 7 * Cisco Systems, Inc. |
8 */ | 8 */ |
9 | 9 |
10 /* | 10 /* |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 # elif defined HAVE_BYTESWAP_METHODS_H | 63 # elif defined HAVE_BYTESWAP_METHODS_H |
64 # include <stdlib.h> | 64 # include <stdlib.h> |
65 # define ntohl(x) _byteswap_ulong (x) | 65 # define ntohl(x) _byteswap_ulong (x) |
66 # define ntohs(x) _byteswap_ushort (x) | 66 # define ntohs(x) _byteswap_ushort (x) |
67 # define htonl(x) _byteswap_ulong (x) | 67 # define htonl(x) _byteswap_ulong (x) |
68 # define htons(x) _byteswap_ushort (x) | 68 # define htons(x) _byteswap_ushort (x) |
69 # endif | 69 # endif |
70 #endif | 70 #endif |
71 | 71 |
72 | 72 |
73 | |
74 /* if DATATYPES_USE_MACROS is defined, then little functions are macros */ | 73 /* if DATATYPES_USE_MACROS is defined, then little functions are macros */ |
75 #define DATATYPES_USE_MACROS | 74 #define DATATYPES_USE_MACROS |
76 | 75 |
77 typedef union { | 76 typedef union { |
78 uint8_t v8[2]; | 77 uint8_t v8[2]; |
79 uint16_t value; | 78 uint16_t value; |
80 } v16_t; | 79 } v16_t; |
81 | 80 |
82 typedef union { | 81 typedef union { |
83 uint8_t v8[4]; | 82 uint8_t v8[4]; |
84 uint16_t v16[2]; | 83 uint16_t v16[2]; |
85 uint32_t value; | 84 uint32_t value; |
86 } v32_t; | 85 } v32_t; |
87 | 86 |
88 typedef union { | 87 typedef union { |
89 uint8_t v8[8]; | 88 uint8_t v8[8]; |
90 uint16_t v16[4]; | 89 uint16_t v16[4]; |
91 uint32_t v32[2]; | 90 uint32_t v32[2]; |
92 uint64_t value; | 91 uint64_t value; |
93 } v64_t; | 92 } v64_t; |
94 | 93 |
95 typedef union { | 94 typedef union { |
96 uint8_t v8[16]; | 95 uint8_t v8[16]; |
97 uint16_t v16[8]; | 96 uint16_t v16[8]; |
98 uint32_t v32[4]; | 97 uint32_t v32[4]; |
99 uint64_t v64[2]; | 98 uint64_t v64[2]; |
100 } v128_t; | 99 } v128_t; |
101 | 100 |
| 101 typedef union { |
| 102 uint8_t v8[32]; |
| 103 uint16_t v16[16]; |
| 104 uint32_t v32[8]; |
| 105 uint64_t v64[4]; |
| 106 } v256_t; |
102 | 107 |
103 | 108 |
104 /* some useful and simple math functions */ | 109 /* some useful and simple math functions */ |
105 | 110 |
106 #define pow_2(X) ( (unsigned int)1 << (X) ) /* 2^X */ | 111 #define pow_2(X) ( (unsigned int)1 << (X) ) /* 2^X */ |
107 | 112 |
108 #define pow_minus_one(X) ( (X) ? -1 : 1 ) /* (-1)^X */ | 113 #define pow_minus_one(X) ( (X) ? -1 : 1 ) /* (-1)^X */ |
109 | 114 |
110 | 115 |
111 /* | 116 /* |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 * and b are not equal, returns 0 otherwise | 382 * and b are not equal, returns 0 otherwise |
378 */ | 383 */ |
379 | 384 |
380 int | 385 int |
381 octet_string_is_eq(uint8_t *a, uint8_t *b, int len); | 386 octet_string_is_eq(uint8_t *a, uint8_t *b, int len); |
382 | 387 |
383 void | 388 void |
384 octet_string_set_to_zero(uint8_t *s, int len); | 389 octet_string_set_to_zero(uint8_t *s, int len); |
385 | 390 |
386 | 391 |
387 #ifndef SRTP_KERNEL_LINUX | 392 #if !defined(SRTP_KERNEL_LINUX) |
388 | 393 |
389 /* | 394 /* |
390 * Convert big endian integers to CPU byte order. | 395 * Convert big endian integers to CPU byte order. |
391 */ | 396 */ |
392 #ifdef WORDS_BIGENDIAN | 397 #ifdef WORDS_BIGENDIAN |
393 /* Nothing to do. */ | 398 /* Nothing to do. */ |
394 # define be32_to_cpu(x) (x) | 399 # define be32_to_cpu(x) (x) |
395 # define be64_to_cpu(x) (x) | 400 # define be64_to_cpu(x) (x) |
396 #elif defined(HAVE_BYTESWAP_H) | 401 #elif defined(HAVE_BYTESWAP_H) |
397 /* We have (hopefully) optimized versions in byteswap.h */ | 402 /* We have (hopefully) optimized versions in byteswap.h */ |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 void | 509 void |
505 bitvector_set_to_zero(bitvector_t *x); | 510 bitvector_set_to_zero(bitvector_t *x); |
506 | 511 |
507 void | 512 void |
508 bitvector_left_shift(bitvector_t *x, int index); | 513 bitvector_left_shift(bitvector_t *x, int index); |
509 | 514 |
510 char * | 515 char * |
511 bitvector_bit_string(bitvector_t *x, char* buf, int len); | 516 bitvector_bit_string(bitvector_t *x, char* buf, int len); |
512 | 517 |
513 #endif /* _DATATYPES_H */ | 518 #endif /* _DATATYPES_H */ |
OLD | NEW |