| OLD | NEW |
| 1 /* | 1 /* |
| 2 * aes_cbc.h | 2 * aes_cbc.h |
| 3 * | 3 * |
| 4 * Header for AES Cipher Blobk Chaining Mode. | 4 * Header for AES Cipher Blobk Chaining 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: |
| 18 * | 19 * |
| 19 * Redistributions of source code must retain the above copyright | 20 * Redistributions of source code must retain the above copyright |
| (...skipping 25 matching lines...) Expand all Loading... |
| 45 | 46 |
| 46 #ifndef AES_CBC_H | 47 #ifndef AES_CBC_H |
| 47 #define AES_CBC_H | 48 #define AES_CBC_H |
| 48 | 49 |
| 49 #include "aes.h" | 50 #include "aes.h" |
| 50 #include "cipher.h" | 51 #include "cipher.h" |
| 51 | 52 |
| 52 typedef struct { | 53 typedef struct { |
| 53 v128_t state; /* cipher chaining state */ | 54 v128_t state; /* cipher chaining state */ |
| 54 v128_t previous; /* previous ciphertext block */ | 55 v128_t previous; /* previous ciphertext block */ |
| 56 uint8_t key[32]; |
| 57 int key_len; |
| 55 aes_expanded_key_t expanded_key; /* the cipher key */ | 58 aes_expanded_key_t expanded_key; /* the cipher key */ |
| 56 } aes_cbc_ctx_t; | 59 } aes_cbc_ctx_t; |
| 57 | 60 |
| 58 err_status_t | 61 err_status_t |
| 59 aes_cbc_set_key(aes_cbc_ctx_t *c, | 62 aes_cbc_set_key(aes_cbc_ctx_t *c, |
| 60 const unsigned char *key); | 63 const unsigned char *key); |
| 61 | 64 |
| 62 err_status_t | 65 err_status_t |
| 63 aes_cbc_encrypt(aes_cbc_ctx_t *c, | 66 aes_cbc_encrypt(aes_cbc_ctx_t *c, |
| 64 unsigned char *buf, | 67 unsigned char *buf, |
| 65 unsigned int *bytes_in_data); | 68 unsigned int *bytes_in_data); |
| 66 | 69 |
| 67 err_status_t | 70 err_status_t |
| 68 aes_cbc_context_init(aes_cbc_ctx_t *c, const uint8_t *key, | 71 aes_cbc_context_init(aes_cbc_ctx_t *c, const uint8_t *key, |
| 69 » » int key_len, cipher_direction_t dir); | 72 » » int key_len); |
| 70 | 73 |
| 71 err_status_t | 74 err_status_t |
| 72 aes_cbc_set_iv(aes_cbc_ctx_t *c, void *iv); | 75 aes_cbc_set_iv(aes_cbc_ctx_t *c, void *iv, int direction); |
| 73 | 76 |
| 74 err_status_t | 77 err_status_t |
| 75 aes_cbc_nist_encrypt(aes_cbc_ctx_t *c, | 78 aes_cbc_nist_encrypt(aes_cbc_ctx_t *c, |
| 76 unsigned char *data, | 79 unsigned char *data, |
| 77 unsigned int *bytes_in_data); | 80 unsigned int *bytes_in_data); |
| 78 | 81 |
| 79 err_status_t | 82 err_status_t |
| 80 aes_cbc_nist_decrypt(aes_cbc_ctx_t *c, | 83 aes_cbc_nist_decrypt(aes_cbc_ctx_t *c, |
| 81 unsigned char *data, | 84 unsigned char *data, |
| 82 unsigned int *bytes_in_data); | 85 unsigned int *bytes_in_data); |
| 83 | 86 |
| 84 #endif /* AES_CBC_H */ | 87 #endif /* AES_CBC_H */ |
| 85 | 88 |
| OLD | NEW |