Rename null auth/cipher functions to comply with library name. Change some functions to static.
diff --git a/crypto/cipher/null_cipher.c b/crypto/cipher/null_cipher.c
index 9875ddc..36313e3 100644
--- a/crypto/cipher/null_cipher.c
+++ b/crypto/cipher/null_cipher.c
@@ -9,26 +9,26 @@
*/
/*
- *
+ *
* Copyright (c) 2001-2006,2013 Cisco Systems, Inc.
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
- *
+ *
* Neither the name of the Cisco Systems, Inc. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
@@ -56,82 +56,81 @@
extern debug_module_t srtp_mod_cipher;
-srtp_err_status_t
-null_cipher_alloc(srtp_cipher_t **c, int key_len, int tlen) {
- extern srtp_cipher_type_t null_cipher;
- uint8_t *pointer;
-
- debug_print(srtp_mod_cipher,
- "allocating cipher with key length %d", key_len);
+static srtp_err_status_t srtp_null_cipher_alloc (srtp_cipher_t **c, int key_len, int tlen)
+{
+ extern srtp_cipher_type_t srtp_null_cipher;
+ uint8_t *pointer;
- /* allocate memory a cipher of type null_cipher */
- pointer = (uint8_t*)srtp_crypto_alloc(sizeof(null_cipher_ctx_t) + sizeof(srtp_cipher_t));
- if (pointer == NULL)
- return srtp_err_status_alloc_fail;
+ debug_print(srtp_mod_cipher,
+ "allocating cipher with key length %d", key_len);
- /* set pointers */
- *c = (srtp_cipher_t *)pointer;
- (*c)->algorithm = NULL_CIPHER;
- (*c)->type = &null_cipher;
- (*c)->state = pointer + sizeof(srtp_cipher_t);
+ /* allocate memory a cipher of type null_cipher */
+ pointer = (uint8_t*)srtp_crypto_alloc(sizeof(srtp_null_cipher_ctx_t) + sizeof(srtp_cipher_t));
+ if (pointer == NULL) {
+ return srtp_err_status_alloc_fail;
+ }
- /* set key size */
- (*c)->key_len = key_len;
+ /* set pointers */
+ *c = (srtp_cipher_t*)pointer;
+ (*c)->algorithm = NULL_CIPHER;
+ (*c)->type = &srtp_null_cipher;
+ (*c)->state = pointer + sizeof(srtp_cipher_t);
- return srtp_err_status_ok;
-
+ /* set key size */
+ (*c)->key_len = key_len;
+
+ return srtp_err_status_ok;
+
}
-srtp_err_status_t
-null_cipher_dealloc(srtp_cipher_t *c) {
- extern srtp_cipher_type_t null_cipher;
+static srtp_err_status_t srtp_null_cipher_dealloc (srtp_cipher_t *c)
+{
+ extern srtp_cipher_type_t srtp_null_cipher;
- /* zeroize entire state*/
- octet_string_set_to_zero((uint8_t *)c,
- sizeof(null_cipher_ctx_t) + sizeof(srtp_cipher_t));
+ /* zeroize entire state*/
+ octet_string_set_to_zero((uint8_t*)c,
+ sizeof(srtp_null_cipher_ctx_t) + sizeof(srtp_cipher_t));
- /* free memory of type null_cipher */
- srtp_crypto_free(c);
+ /* free memory of type null_cipher */
+ srtp_crypto_free(c);
- return srtp_err_status_ok;
-
+ return srtp_err_status_ok;
+
}
-srtp_err_status_t
-null_cipher_init(null_cipher_ctx_t *ctx, const uint8_t *key, int key_len) {
+static srtp_err_status_t srtp_null_cipher_init (srtp_null_cipher_ctx_t *ctx, const uint8_t *key, int key_len)
+{
- debug_print(srtp_mod_cipher, "initializing null cipher", NULL);
+ debug_print(srtp_mod_cipher, "initializing null cipher", NULL);
- return srtp_err_status_ok;
+ return srtp_err_status_ok;
}
-srtp_err_status_t
-null_cipher_set_iv(null_cipher_ctx_t *c, void *iv) {
- return srtp_err_status_ok;
+static srtp_err_status_t srtp_null_cipher_set_iv (srtp_null_cipher_ctx_t *c, void *iv)
+{
+ return srtp_err_status_ok;
}
-srtp_err_status_t
-null_cipher_encrypt(null_cipher_ctx_t *c,
- unsigned char *buf, unsigned int *bytes_to_encr) {
- return srtp_err_status_ok;
+static srtp_err_status_t srtp_null_cipher_encrypt (srtp_null_cipher_ctx_t *c,
+ unsigned char *buf, unsigned int *bytes_to_encr)
+{
+ return srtp_err_status_ok;
}
-char
-null_cipher_description[] = "null cipher";
+static char srtp_null_cipher_description[] = "null cipher";
-srtp_cipher_test_case_t
-null_cipher_test_0 = {
- 0, /* octets in key */
- NULL, /* key */
- 0, /* packet index */
- 0, /* octets in plaintext */
- NULL, /* plaintext */
- 0, /* octets in plaintext */
- NULL, /* ciphertext */
- 0,
- NULL,
- 0,
- NULL /* pointer to next testcase */
+static srtp_cipher_test_case_t srtp_null_cipher_test_0 = {
+ 0, /* octets in key */
+ NULL, /* key */
+ 0, /* packet index */
+ 0, /* octets in plaintext */
+ NULL, /* plaintext */
+ 0, /* octets in plaintext */
+ NULL, /* ciphertext */
+ 0,
+ NULL,
+ 0,
+ NULL /* pointer to next testcase */
};
@@ -139,18 +138,18 @@
* note: the decrypt function is idential to the encrypt function
*/
-srtp_cipher_type_t null_cipher = {
- (cipher_alloc_func_t) null_cipher_alloc,
- (cipher_dealloc_func_t) null_cipher_dealloc,
- (cipher_init_func_t) null_cipher_init,
- (cipher_set_aad_func_t) 0,
- (cipher_encrypt_func_t) null_cipher_encrypt,
- (cipher_decrypt_func_t) null_cipher_encrypt,
- (cipher_set_iv_func_t) null_cipher_set_iv,
- (cipher_get_tag_func_t) 0,
- (char *) null_cipher_description,
- (srtp_cipher_test_case_t *) &null_cipher_test_0,
- (debug_module_t *) NULL,
- (srtp_cipher_type_id_t) NULL_CIPHER
+srtp_cipher_type_t srtp_null_cipher = {
+ (cipher_alloc_func_t)srtp_null_cipher_alloc,
+ (cipher_dealloc_func_t)srtp_null_cipher_dealloc,
+ (cipher_init_func_t)srtp_null_cipher_init,
+ (cipher_set_aad_func_t)0,
+ (cipher_encrypt_func_t)srtp_null_cipher_encrypt,
+ (cipher_decrypt_func_t)srtp_null_cipher_encrypt,
+ (cipher_set_iv_func_t)srtp_null_cipher_set_iv,
+ (cipher_get_tag_func_t)0,
+ (char*)srtp_null_cipher_description,
+ (srtp_cipher_test_case_t*)&srtp_null_cipher_test_0,
+ (debug_module_t*)NULL,
+ (srtp_cipher_type_id_t)NULL_CIPHER
};
diff --git a/crypto/hash/null_auth.c b/crypto/hash/null_auth.c
index b050f27..7f7b648 100644
--- a/crypto/hash/null_auth.c
+++ b/crypto/hash/null_auth.c
@@ -9,26 +9,26 @@
*/
/*
- *
+ *
* Copyright (c) 2001-2006, Cisco Systems, Inc.
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
- *
+ *
* Neither the name of the Cisco Systems, Inc. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
@@ -48,76 +48,77 @@
#include <config.h>
#endif
-#include "null_auth.h"
+#include "null_auth.h"
#include "alloc.h"
/* null_auth uses the auth debug module */
extern debug_module_t srtp_mod_auth;
-srtp_err_status_t
-null_auth_alloc(srtp_auth_t **a, int key_len, int out_len) {
- extern srtp_auth_type_t null_auth;
- uint8_t *pointer;
+static srtp_err_status_t srtp_null_auth_alloc (srtp_auth_t **a, int key_len, int out_len)
+{
+ extern srtp_auth_type_t srtp_null_auth;
+ uint8_t *pointer;
- debug_print(srtp_mod_auth, "allocating auth func with key length %d", key_len);
- debug_print(srtp_mod_auth, " tag length %d", out_len);
+ debug_print(srtp_mod_auth, "allocating auth func with key length %d", key_len);
+ debug_print(srtp_mod_auth, " tag length %d", out_len);
- /* allocate memory for auth and null_auth_ctx_t structures */
- pointer = (uint8_t*)srtp_crypto_alloc(sizeof(null_auth_ctx_t) + sizeof(srtp_auth_t));
- if (pointer == NULL)
- return srtp_err_status_alloc_fail;
+ /* allocate memory for auth and srtp_null_auth_ctx_t structures */
+ pointer = (uint8_t*)srtp_crypto_alloc(sizeof(srtp_null_auth_ctx_t) + sizeof(srtp_auth_t));
+ if (pointer == NULL) {
+ return srtp_err_status_alloc_fail;
+ }
- /* set pointers */
- *a = (srtp_auth_t *)pointer;
- (*a)->type = &null_auth;
- (*a)->state = pointer + sizeof (srtp_auth_t);
- (*a)->out_len = out_len;
- (*a)->prefix_len = out_len;
- (*a)->key_len = key_len;
+ /* set pointers */
+ *a = (srtp_auth_t*)pointer;
+ (*a)->type = &srtp_null_auth;
+ (*a)->state = pointer + sizeof(srtp_auth_t);
+ (*a)->out_len = out_len;
+ (*a)->prefix_len = out_len;
+ (*a)->key_len = key_len;
- return srtp_err_status_ok;
+ return srtp_err_status_ok;
}
-srtp_err_status_t
-null_auth_dealloc(srtp_auth_t *a) {
- extern srtp_auth_type_t null_auth;
-
- /* zeroize entire state*/
- octet_string_set_to_zero((uint8_t *)a,
- sizeof(null_auth_ctx_t) + sizeof(srtp_auth_t));
+static srtp_err_status_t srtp_null_auth_dealloc (srtp_auth_t *a)
+{
+ extern srtp_auth_type_t srtp_null_auth;
- /* free memory */
- srtp_crypto_free(a);
-
- return srtp_err_status_ok;
+ /* zeroize entire state*/
+ octet_string_set_to_zero((uint8_t*)a,
+ sizeof(srtp_null_auth_ctx_t) + sizeof(srtp_auth_t));
+
+ /* free memory */
+ srtp_crypto_free(a);
+
+ return srtp_err_status_ok;
}
-srtp_err_status_t
-null_auth_init(null_auth_ctx_t *state, const uint8_t *key, int key_len) {
+static srtp_err_status_t srtp_null_auth_init (srtp_null_auth_ctx_t *state, const uint8_t *key, int key_len)
+{
- /* accept any length of key, and do nothing */
-
- return srtp_err_status_ok;
+ /* accept any length of key, and do nothing */
+
+ return srtp_err_status_ok;
}
-srtp_err_status_t
-null_auth_compute(null_auth_ctx_t *state, uint8_t *message,
- int msg_octets, int tag_len, uint8_t *result) {
+static srtp_err_status_t srtp_null_auth_compute (srtp_null_auth_ctx_t *state, uint8_t *message,
+ int msg_octets, int tag_len, uint8_t *result)
+{
- return srtp_err_status_ok;
+ return srtp_err_status_ok;
}
-srtp_err_status_t
-null_auth_update(null_auth_ctx_t *state, uint8_t *message,
- int msg_octets) {
+static srtp_err_status_t srtp_null_auth_update (srtp_null_auth_ctx_t *state, uint8_t *message,
+ int msg_octets)
+{
- return srtp_err_status_ok;
+ return srtp_err_status_ok;
}
-srtp_err_status_t
-null_auth_start(null_auth_ctx_t *state) {
- return srtp_err_status_ok;
+static srtp_err_status_t srtp_null_auth_start (srtp_null_auth_ctx_t *state)
+{
+ return srtp_err_status_ok;
}
/*
@@ -127,32 +128,30 @@
/* begin test case 0 */
-srtp_auth_test_case_t
-null_auth_test_case_0 = {
- 0, /* octets in key */
- NULL, /* key */
- 0, /* octets in data */
- NULL, /* data */
- 0, /* octets in tag */
- NULL, /* tag */
- NULL /* pointer to next testcase */
+static srtp_auth_test_case_t srtp_null_auth_test_case_0 = {
+ 0, /* octets in key */
+ NULL, /* key */
+ 0, /* octets in data */
+ NULL, /* data */
+ 0, /* octets in tag */
+ NULL, /* tag */
+ NULL /* pointer to next testcase */
};
/* end test case 0 */
-char null_auth_description[] = "null authentication function";
+static char srtp_null_auth_description[] = "null authentication function";
-srtp_auth_type_t
-null_auth = {
- (auth_alloc_func) null_auth_alloc,
- (auth_dealloc_func) null_auth_dealloc,
- (auth_init_func) null_auth_init,
- (auth_compute_func) null_auth_compute,
- (auth_update_func) null_auth_update,
- (auth_start_func) null_auth_start,
- (char *) null_auth_description,
- (srtp_auth_test_case_t *) &null_auth_test_case_0,
- (debug_module_t *) NULL,
- (srtp_auth_type_id_t) NULL_AUTH
+srtp_auth_type_t srtp_null_auth = {
+ (auth_alloc_func)srtp_null_auth_alloc,
+ (auth_dealloc_func)srtp_null_auth_dealloc,
+ (auth_init_func)srtp_null_auth_init,
+ (auth_compute_func)srtp_null_auth_compute,
+ (auth_update_func)srtp_null_auth_update,
+ (auth_start_func)srtp_null_auth_start,
+ (char*)srtp_null_auth_description,
+ (srtp_auth_test_case_t*)&srtp_null_auth_test_case_0,
+ (debug_module_t*)NULL,
+ (srtp_auth_type_id_t)NULL_AUTH
};
diff --git a/crypto/include/null_auth.h b/crypto/include/null_auth.h
index 896c945..dc3c3f6 100644
--- a/crypto/include/null_auth.h
+++ b/crypto/include/null_auth.h
@@ -7,26 +7,26 @@
*/
/*
- *
+ *
* Copyright (c) 2001-2006, Cisco Systems, Inc.
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
- *
+ *
* Neither the name of the Cisco Systems, Inc. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
@@ -48,16 +48,18 @@
#include "auth.h"
typedef struct {
- char foo;
-} null_auth_ctx_t;
+ char foo;
+} srtp_null_auth_ctx_t;
-srtp_err_status_t null_auth_alloc(srtp_auth_t **a, int key_len, int out_len);
+#if 0
+srtp_err_status_t srtp_null_auth_alloc(srtp_auth_t **a, int key_len, int out_len);
-srtp_err_status_t null_auth_dealloc(srtp_auth_t *a);
+srtp_err_status_t srtp_null_auth_dealloc(srtp_auth_t *a);
-srtp_err_status_t null_auth_init(null_auth_ctx_t *state, const uint8_t *key, int key_len);
+srtp_err_status_t srtp_null_auth_init(srtp_null_auth_ctx_t *state, const uint8_t *key, int key_len);
-srtp_err_status_t null_auth_compute (null_auth_ctx_t *state, uint8_t *message, int msg_octets, int tag_len, uint8_t *result);
+srtp_err_status_t srtp_null_auth_compute(srtp_null_auth_ctx_t *state, uint8_t *message, int msg_octets, int tag_len, uint8_t *result);
+#endif
#endif /* NULL_AUTH_H */
diff --git a/crypto/include/null_cipher.h b/crypto/include/null_cipher.h
index d7d6dbb..f7db5f7 100644
--- a/crypto/include/null_cipher.h
+++ b/crypto/include/null_cipher.h
@@ -9,26 +9,26 @@
*/
/*
- *
+ *
* Copyright (c) 2001-2006, Cisco Systems, Inc.
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
- *
+ *
* Neither the name of the Cisco Systems, Inc. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
@@ -52,20 +52,7 @@
#include "cipher.h"
typedef struct {
- char foo ;/* empty, for now */
-} null_cipher_ctx_t;
-
-
-/*
- * none of these functions do anything (though future versions may keep
- * track of bytes encrypted, number of instances, and/or other info).
- */
-srtp_err_status_t null_cipher_init(null_cipher_ctx_t *c, const uint8_t *key, int key_len);
-
-srtp_err_status_t null_cipher_set_segment(null_cipher_ctx_t *c, unsigned long segment_index);
-
-srtp_err_status_t null_cipher_encrypt(null_cipher_ctx_t *c, unsigned char *buf, unsigned int *bytes_to_encr);
-
-srtp_err_status_t null_cipher_encrypt_aligned(null_cipher_ctx_t *c, unsigned char *buf, int bytes_to_encr);
+ char foo; /* empty, for now */
+} srtp_null_cipher_ctx_t;
#endif /* NULL_CIPHER_H */
diff --git a/crypto/kernel/crypto_kernel.c b/crypto/kernel/crypto_kernel.c
index c2d2e1b..4b47a44 100644
--- a/crypto/kernel/crypto_kernel.c
+++ b/crypto/kernel/crypto_kernel.c
@@ -71,7 +71,7 @@
* cipher types that can be included in the kernel
*/
-extern srtp_cipher_type_t null_cipher;
+extern srtp_cipher_type_t srtp_null_cipher;
extern srtp_cipher_type_t srtp_aes_icm;
#ifdef OPENSSL
extern srtp_cipher_type_t srtp_aes_gcm_128_openssl;
@@ -83,7 +83,7 @@
* auth func types that can be included in the kernel
*/
-extern srtp_auth_type_t null_auth;
+extern srtp_auth_type_t srtp_null_auth;
extern srtp_auth_type_t hmac;
/* crypto_kernel is a global variable, the only one of its datatype */
@@ -145,7 +145,7 @@
return status;
/* load cipher types */
- status = crypto_kernel_load_cipher_type(&null_cipher, NULL_CIPHER);
+ status = crypto_kernel_load_cipher_type(&srtp_null_cipher, NULL_CIPHER);
if (status)
return status;
status = crypto_kernel_load_cipher_type(&srtp_aes_icm, AES_ICM);
@@ -163,7 +163,7 @@
#endif
/* load auth func types */
- status = crypto_kernel_load_auth_type(&null_auth, NULL_AUTH);
+ status = crypto_kernel_load_auth_type(&srtp_null_auth, NULL_AUTH);
if (status)
return status;
status = crypto_kernel_load_auth_type(&hmac, HMAC_SHA1);
diff --git a/crypto/test/cipher_driver.c b/crypto/test/cipher_driver.c
index db6be58..8f85396 100644
--- a/crypto/test/cipher_driver.c
+++ b/crypto/test/cipher_driver.c
@@ -121,7 +121,7 @@
* declared external so that we can use these cipher types here
*/
-extern srtp_cipher_type_t null_cipher;
+extern srtp_cipher_type_t srtp_null_cipher;
extern srtp_cipher_type_t srtp_aes_icm;
#ifdef OPENSSL
extern srtp_cipher_type_t srtp_aes_icm_192;
@@ -180,7 +180,7 @@
int num_cipher;
for (num_cipher=1; num_cipher < max_num_cipher; num_cipher *=8)
- cipher_driver_test_array_throughput(&null_cipher, 0, num_cipher);
+ cipher_driver_test_array_throughput(&srtp_null_cipher, 0, num_cipher);
for (num_cipher=1; num_cipher < max_num_cipher; num_cipher *=8)
cipher_driver_test_array_throughput(&srtp_aes_icm, 30, num_cipher);
@@ -206,7 +206,7 @@
}
if (do_validation) {
- cipher_driver_self_test(&null_cipher);
+ cipher_driver_self_test(&srtp_null_cipher);
cipher_driver_self_test(&srtp_aes_icm);
#ifdef OPENSSL
cipher_driver_self_test(&srtp_aes_icm_192);
@@ -216,8 +216,8 @@
#endif
}
- /* do timing and/or buffer_test on null_cipher */
- status = cipher_type_alloc(&null_cipher, &c, 0, 0);
+ /* do timing and/or buffer_test on srtp_null_cipher */
+ status = cipher_type_alloc(&srtp_null_cipher, &c, 0, 0);
check_status(status);
status = cipher_init(c, NULL);