| OLD | NEW |
| 1 /* | 1 /* |
| 2 * gf2_8.h | 2 * aes_icm.h |
| 3 * | 3 * |
| 4 * GF(256) implementation | 4 * Header for AES Integer Counter Mode. |
| 5 * | 5 * |
| 6 * David A. McGrew | 6 * David A. McGrew |
| 7 * Cisco Systems, Inc. | 7 * Cisco Systems, Inc. |
| 8 * |
| 8 */ | 9 */ |
| 9 | 10 |
| 10 /* | 11 /* |
| 11 * | 12 * |
| 12 * Copyright (c) 2001-2006, Cisco Systems, Inc. | 13 * Copyright (c) 2001-2006, Cisco Systems, Inc. |
| 13 * All rights reserved. | 14 * All rights reserved. |
| 14 * | 15 * |
| 15 * Redistribution and use in source and binary forms, with or without | 16 * Redistribution and use in source and binary forms, with or without |
| 16 * modification, are permitted provided that the following conditions | 17 * modification, are permitted provided that the following conditions |
| 17 * are met: | 18 * are met: |
| (...skipping 18 matching lines...) Expand all Loading... |
| 36 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 37 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 37 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | 38 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 38 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 39 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | 40 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 40 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 41 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 41 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | 42 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
| 42 * OF THE POSSIBILITY OF SUCH DAMAGE. | 43 * OF THE POSSIBILITY OF SUCH DAMAGE. |
| 43 * | 44 * |
| 44 */ | 45 */ |
| 45 | 46 |
| 47 #ifndef AES_ICM_H |
| 48 #define AES_ICM_H |
| 46 | 49 |
| 47 #ifndef GF2_8_H | 50 #include "aes.h" |
| 48 #define GF2_8_H | 51 #include "cipher.h" |
| 49 | 52 |
| 50 #include "datatypes.h" /* for uint8_t definition */ | 53 typedef struct { |
| 54 v128_t counter; /* holds the counter value */ |
| 55 v128_t offset; /* initial offset value */ |
| 56 v128_t keystream_buffer; /* buffers bytes of keystream */ |
| 57 srtp_aes_expanded_key_t expanded_key; /* the cipher key */ |
| 58 int bytes_in_buffer; /* number of unused bytes in buffer */ |
| 59 int key_size; /* AES key size + 14 byte SALT */ |
| 60 } srtp_aes_icm_ctx_t; |
| 51 | 61 |
| 52 typedef uint8_t gf2_8; | 62 #endif /* AES_ICM_H */ |
| 53 | 63 |
| 54 #define gf2_8_field_polynomial 0x1B | |
| 55 | |
| 56 /* | |
| 57 * gf2_8_shift(x) returns | |
| 58 */ | |
| 59 | |
| 60 /* | |
| 61 * gf2_8_shift(z) returns the result of the GF(2^8) 'multiply by x' | |
| 62 * operation, using the field representation from AES; that is, the | |
| 63 * next gf2_8 value in the cyclic representation of that field. The | |
| 64 * value z should be an uint8_t. | |
| 65 */ | |
| 66 | |
| 67 #define gf2_8_shift(z) (((z) & 128) ? \ | |
| 68 (((z) << 1) ^ gf2_8_field_polynomial) : ((z) << 1)) | |
| 69 | |
| 70 gf2_8 | |
| 71 gf2_8_compute_inverse(gf2_8 x); | |
| 72 | |
| 73 void | |
| 74 test_gf2_8(void); | |
| 75 | |
| 76 gf2_8 | |
| 77 gf2_8_multiply(gf2_8 x, gf2_8 y); | |
| 78 | |
| 79 #endif /* GF2_8_H */ | |
| OLD | NEW |