[svn-commits] dvossel: branch dvossel/func_aes_trunk r170151 - /team/dvossel/func_aes_trunk...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Thu Jan 22 11:04:53 CST 2009
Author: dvossel
Date: Thu Jan 22 11:04:53 2009
New Revision: 170151
URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=170151
Log:
Fixed tabs and coding guildlines in func_aes.c
Modified:
team/dvossel/func_aes_trunk/funcs/func_aes.c
Modified: team/dvossel/func_aes_trunk/funcs/func_aes.c
URL: http://svn.digium.com/svn-view/asterisk/team/dvossel/func_aes_trunk/funcs/func_aes.c?view=diff&rev=170151&r1=170150&r2=170151
==============================================================================
--- team/dvossel/func_aes_trunk/funcs/func_aes.c (original)
+++ team/dvossel/func_aes_trunk/funcs/func_aes.c Thu Jan 22 11:04:53 2009
@@ -35,102 +35,102 @@
static int aes_encrypt_read(struct ast_channel *chan, const char *cmd, char *data,
char *buf, size_t len)
{
-
- unsigned char curblock[16];
+
+ unsigned char curblock[16];
char *src;
char *dst;
- int x, data_len;
-
- AST_DECLARE_APP_ARGS(args,
- AST_APP_ARG(key);
- AST_APP_ARG(data);
+ int x, data_len;
+ ast_aes_encrypt_key ecx; /* AES 128 Encryption context */
+
+ AST_DECLARE_APP_ARGS(args,
+ AST_APP_ARG(key);
+ AST_APP_ARG(data);
);
-
- AST_STANDARD_APP_ARGS(args, data);
-
- if (ast_strlen_zero(args.data) || ast_strlen_zero(args.key)) {
- ast_log(LOG_WARNING, "Syntax: AES_ENCRYPT(<key>, <data>) - missing argument!\n");
- return -1;
- }
-
- if (strlen(args.key) != 16 ) { /* key must be of 16 characters in length, 128 bits */
- ast_log(LOG_WARNING, "Syntax: AES_ENCRYPT(<key>, <data>) - <key> parameter must be exactly 16 characters!\n");
- return -1;
- }
-
- ast_aes_encrypt_key ecx; /* AES 128 Encryption context */
- ast_aes_encrypt_key(args.key, &ecx);
-
- dst = buf;
- src = args.data;
+
+ AST_STANDARD_APP_ARGS(args, data);
+
+ if (ast_strlen_zero(args.data) || ast_strlen_zero(args.key)) {
+ ast_log(LOG_WARNING, "Syntax: AES_ENCRYPT(<key>, <data>) - missing argument!\n");
+ return -1;
+ }
+
+ if (strlen(args.key) != 16 ) { /* key must be of 16 characters in length, 128 bits */
+ ast_log(LOG_WARNING, "Syntax: AES_ENCRYPT(<key>, <data>) - <key> parameter must be exactly 16 characters!\n");
+ return -1;
+ }
+
+ ast_aes_encrypt_key(args.key, &ecx);
+
+ dst = buf;
+ src = args.data;
data_len = strlen(args.data);
- memset(curblock, '\0', sizeof(curblock));
-
- if(data_len >= len){ /* make sure to not go over buffer len */
- data_len = (len-1);
- }
-
- while(data_len > 0) {
- for (x=0;x<16;x++)
- curblock[x] = src[x];
- ast_aes_encrypt(curblock, dst, &ecx);
- memcpy(curblock, dst, sizeof(curblock));
- dst += 16;
- src += 16;
- data_len -= 16;
- }
-
- return 0;
+ memset(curblock, '\0', sizeof(curblock));
+
+ if (data_len >= len) { /* make sure to not go over buffer len */
+ data_len = (len-1);
+ }
+
+ while (data_len > 0) {
+ for (x = 0; x < 16; x++)
+ curblock[x] = src[x];
+ ast_aes_encrypt(curblock, dst, &ecx);
+ memcpy(curblock, dst, sizeof(curblock));
+ dst += 16;
+ src += 16;
+ data_len -= 16;
+ }
+
+ return 0;
}
static int aes_decrypt_read(struct ast_channel *chan, const char *cmd, char *data,
- char *buf, size_t len)
+ char *buf, size_t len)
{
- unsigned char curblock[16];
+ unsigned char curblock[16];
char *src;
char *dst;
- int x, data_len;
+ int x, data_len;
+ ast_aes_decrypt_key dcx; /*!< AES 128 Encryption context */
+
+ AST_DECLARE_APP_ARGS(args,
+ AST_APP_ARG(key);
+ AST_APP_ARG(data);
+ );
+
+ AST_STANDARD_APP_ARGS(args, data);
+
+ if (ast_strlen_zero(args.data) || ast_strlen_zero(args.key)) {
+ ast_log(LOG_WARNING, "Syntax: AES_DECRYPT(<key>, <data>) - missing argument!\n");
+ return -1;
+ }
- AST_DECLARE_APP_ARGS(args,
- AST_APP_ARG(key);
- AST_APP_ARG(data);
- );
-
- AST_STANDARD_APP_ARGS(args, data);
-
- if (ast_strlen_zero(args.data) || ast_strlen_zero(args.key)) {
- ast_log(LOG_WARNING, "Syntax: AES_DECRYPT(<key>, <data>) - missing argument!\n");
- return -1;
- }
-
- if (strlen(args.key) != 16 ) { /* key must be of 16 characters in length, 128 bits */
- ast_log(LOG_WARNING, "Syntax: AES_DECRYPT(<key>, <data>) - <key> parameter must be exactly 16 characters!\n");
- return -1;
- }
-
- ast_aes_decrypt_key dcx; /*!< AES 128 Encryption context */
- ast_aes_decrypt_key(args.key, &dcx);
-
- dst = buf;
- src = args.data;
+ if (strlen(args.key) != 16 ) { /* key must be of 16 characters in length, 128 bits */
+ ast_log(LOG_WARNING, "Syntax: AES_DECRYPT(<key>, <data>) - <key> parameter must be exactly 16 characters!\n");
+ return -1;
+ }
+
+ ast_aes_decrypt_key(args.key, &dcx);
+
+ dst = buf;
+ src = args.data;
data_len = strlen(args.data);
- memset(curblock, '\0', sizeof(curblock));
-
- if(data_len >= len){ /* make sure to not go over buffer len */
- data_len = (len-1);
- }
-
- while(data_len > 0) {
- for (x=0;x<16;x++)
- curblock[x] = src[x];
- ast_aes_decrypt(curblock, dst, &dcx);
- memcpy(curblock, dst, sizeof(curblock));
- dst += 16;
- src += 16;
- data_len -= 16;
- }
-
- return 0;
+ memset(curblock, '\0', sizeof(curblock));
+
+ if (data_len >= len) { /* make sure to not go over buffer len */
+ data_len = (len-1);
+ }
+
+ while (data_len > 0) {
+ for (x = 0; x < 16; x++)
+ curblock[x] = src[x];
+ ast_aes_decrypt(curblock, dst, &dcx);
+ memcpy(curblock, dst, sizeof(curblock));
+ dst += 16;
+ src += 16;
+ data_len -= 16;
+ }
+
+ return 0;
}
static struct ast_custom_function aes_encrypt_function = {
@@ -152,7 +152,7 @@
static int load_module(void)
{
- int res = ast_custom_function_register(&aes_decrypt_function);
+ int res = ast_custom_function_register(&aes_decrypt_function);
return res |= ast_custom_function_register(&aes_encrypt_function);
}
More information about the svn-commits
mailing list