Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(402)

Unified Diff: srtp/crypto/include/cipher.h

Issue 889083003: Update libsrtp to upstream 1.5.0 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/libsrtp@master
Patch Set: Updated to libsrtp 1.5.1 Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « srtp/crypto/include/aes_icm_ossl.h ('k') | srtp/crypto/include/crypto.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: srtp/crypto/include/cipher.h
diff --git a/srtp/crypto/include/cipher.h b/srtp/crypto/include/cipher.h
index eff6dd154b63ee2fccdcae25b442aabe6dd17993..d0d6b57f27b6aba9ed809ff5abf276ce162fea8d 100644
--- a/srtp/crypto/include/cipher.h
+++ b/srtp/crypto/include/cipher.h
@@ -8,7 +8,7 @@
*/
/*
*
- * Copyright (c) 2001-2006, Cisco Systems, Inc.
+ * Copyright (c) 2001-2006,2013 Cisco Systems, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -80,15 +80,14 @@ typedef struct cipher_t *cipher_pointer_t;
*/
typedef err_status_t (*cipher_alloc_func_t)
- (cipher_pointer_t *cp, int key_len);
+ (cipher_pointer_t *cp, int key_len, int tag_len);
/*
* a cipher_init_func_t [re-]initializes a cipher_t with a given key
- * and direction (i.e., encrypt or decrypt)
*/
typedef err_status_t (*cipher_init_func_t)
-(void *state, const uint8_t *key, int key_len, cipher_direction_t dir);
+(void *state, const uint8_t *key, int key_len);
/* a cipher_dealloc_func_t de-allocates a cipher_t */
@@ -99,6 +98,13 @@ typedef err_status_t (*cipher_dealloc_func_t)(cipher_pointer_t cp);
typedef err_status_t (*cipher_set_segment_func_t)
(void *state, xtd_seq_num_t idx);
+/*
+ * a cipher_set_aad_func_t processes the AAD data for AEAD ciphers
+ */
+typedef err_status_t (*cipher_set_aad_func_t)
+ (void *state, uint8_t *aad, unsigned int aad_len);
+
+
/* a cipher_encrypt_func_t encrypts data in-place */
typedef err_status_t (*cipher_encrypt_func_t)
@@ -114,7 +120,15 @@ typedef err_status_t (*cipher_decrypt_func_t)
*/
typedef err_status_t (*cipher_set_iv_func_t)
- (cipher_pointer_t cp, void *iv);
+ (cipher_pointer_t cp, void *iv, cipher_direction_t direction);
+
+/*
+ * a cipher_get_tag_funct_t function is used to get the authentication
+ * tag that was calculated by an AEAD cipher.
+ */
+typedef err_status_t (*cipher_get_tag_func_t)
+ (void *state, void *tag, int *len);
+
/*
* cipher_test_case_t is a (list of) key, salt, xtd_seq_num_t,
@@ -132,6 +146,9 @@ typedef struct cipher_test_case_t {
uint8_t *plaintext; /* plaintext */
int ciphertext_length_octets; /* octets in plaintext */
uint8_t *ciphertext; /* ciphertext */
+ int aad_length_octets; /* octets in AAD */
+ uint8_t *aad; /* AAD */
+ int tag_length_octets; /* Length of AEAD tag */
struct cipher_test_case_t *next_test_case; /* pointer to next testcase */
} cipher_test_case_t;
@@ -141,9 +158,11 @@ typedef struct cipher_type_t {
cipher_alloc_func_t alloc;
cipher_dealloc_func_t dealloc;
cipher_init_func_t init;
+ cipher_set_aad_func_t set_aad;
cipher_encrypt_func_t encrypt;
cipher_encrypt_func_t decrypt;
cipher_set_iv_func_t set_iv;
+ cipher_get_tag_func_t get_tag;
char *description;
int ref_count;
cipher_test_case_t *test_data;
@@ -160,27 +179,32 @@ typedef struct cipher_t {
cipher_type_t *type;
void *state;
int key_len;
-#ifdef FORCE_64BIT_ALIGN
- int pad;
-#endif
+ int algorithm;
} cipher_t;
/* some syntactic sugar on these function types */
-#define cipher_type_alloc(ct, c, klen) ((ct)->alloc((c), (klen)))
+#define cipher_type_alloc(ct, c, klen, tlen) ((ct)->alloc((c), (klen), (tlen)))
#define cipher_dealloc(c) (((c)->type)->dealloc(c))
-#define cipher_init(c, k, dir) (((c)->type)->init(((c)->state), (k), ((c)->key_len), (dir)))
+#define cipher_init(c, k) (((c)->type)->init(((c)->state), (k), ((c)->key_len)))
#define cipher_encrypt(c, buf, len) \
(((c)->type)->encrypt(((c)->state), (buf), (len)))
+#define cipher_get_tag(c, buf, len) \
+ (((c)->type)->get_tag(((c)->state), (buf), (len)))
+
#define cipher_decrypt(c, buf, len) \
(((c)->type)->decrypt(((c)->state), (buf), (len)))
-#define cipher_set_iv(c, n) \
- ((c) ? (((c)->type)->set_iv(((cipher_pointer_t)(c)->state), (n))) : \
+#define cipher_set_iv(c, n, dir) \
+ ((c) ? (((c)->type)->set_iv(((cipher_pointer_t)(c)->state), (n), (dir))) : \
+ err_status_no_such_op)
+#define cipher_set_aad(c, a, l) \
+ (((c) && (((c)->type)->set_aad)) ? \
+ (((c)->type)->set_aad(((c)->state), (a), (l))) : \
err_status_no_such_op)
err_status_t
« no previous file with comments | « srtp/crypto/include/aes_icm_ossl.h ('k') | srtp/crypto/include/crypto.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698