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

Side by Side Diff: plugins/crypto_descbc.c

Issue 6659006: flimflam: add support for multiple profiles (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/flimflam.git@master
Patch Set: more ers comments Created 9 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « include/wifi.h ('k') | plugins/crypto_rot47.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Encrypt/decrypt plugin using DES-CBC. 2 * Encrypt/decrypt plugin using DES-CBC.
3 * 3 *
4 * Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 4 * Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #ifdef HAVE_CONFIG_H 9 #ifdef HAVE_CONFIG_H
10 #include <config.h> 10 #include <config.h>
(...skipping 25 matching lines...) Expand all
36 36
37 /* 37 /*
38 * This is appended to the plaintext before encryption, and checked during 38 * This is appended to the plaintext before encryption, and checked during
39 * decryption to detect decryption failures. This is at the end of the string 39 * decryption to detect decryption failures. This is at the end of the string
40 * rather than the beginning to simplify its removal during decryption. 40 * rather than the beginning to simplify its removal during decryption.
41 * This was introduced in version 2. 41 * This was introduced in version 2.
42 */ 42 */
43 static char sentinel_suffix[] = "[ok]"; 43 static char sentinel_suffix[] = "[ok]";
44 static int sentinel_length = 4; 44 static int sentinel_length = 4;
45 45
46 static char *descbc_encrypt(const char *profile_name, 46 static char *descbc_encrypt(const char *key, const char *value);
47 const char *key, const char *value); 47 static char *descbc_decrypt(const char *key, const char *value);
48 static char *descbc_decrypt(const char *profile_name,
49 const char *key, const char *value);
50 48
51 static struct connman_crypto crypto_descbc = { 49 static struct connman_crypto crypto_descbc = {
52 .name = "des-cbc", 50 .name = "des-cbc",
53 .priority = CONNMAN_CRYPTO_PRIORITY_HIGH, 51 .priority = CONNMAN_CRYPTO_PRIORITY_HIGH,
54 .encrypt_keyvalue = descbc_encrypt, 52 .encrypt_keyvalue = descbc_encrypt,
55 .decrypt_keyvalue = descbc_decrypt, 53 .decrypt_keyvalue = descbc_decrypt,
56 }; 54 };
57 55
58 static char *descbc_encrypt(const char *profile_name, 56 static char *descbc_encrypt(const char *key, const char *value)
59 const char *key, const char *value)
60 { 57 {
61 char *ciphertext = NULL; 58 char *ciphertext = NULL;
62 char *b64_ciphertext = NULL; 59 char *b64_ciphertext = NULL;
63 char *versioned_ciphertext = NULL; 60 char *versioned_ciphertext = NULL;
64 char local_iv[BLOCK_SIZE]; 61 char local_iv[BLOCK_SIZE];
65 int rv, len, blocks; 62 int rv, len, blocks;
66 gsize ciphertext_size; 63 gsize ciphertext_size;
67 64
68 if (initialized == FALSE) 65 if (initialized == FALSE)
69 return NULL; 66 return NULL;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 b64_ciphertext = g_base64_encode((const guchar *)ciphertext, ciphertext_ size); 110 b64_ciphertext = g_base64_encode((const guchar *)ciphertext, ciphertext_ size);
114 g_free(ciphertext); 111 g_free(ciphertext);
115 112
116 versioned_ciphertext = g_strdup_printf("%s%s", version_2_prefix, 113 versioned_ciphertext = g_strdup_printf("%s%s", version_2_prefix,
117 b64_ciphertext); 114 b64_ciphertext);
118 g_free(b64_ciphertext); 115 g_free(b64_ciphertext);
119 116
120 return versioned_ciphertext; 117 return versioned_ciphertext;
121 } 118 }
122 119
123 static char *descbc_decrypt(const char *profile_name, 120 static char *descbc_decrypt(const char *key, const char *value)
124 const char *key, const char *value)
125 { 121 {
126 gsize ciphertext_size; 122 gsize ciphertext_size;
127 int rv; 123 int rv;
128 int version = 1; 124 int version = 1;
129 char *buf = NULL; 125 char *buf = NULL;
130 char local_iv[BLOCK_SIZE]; 126 char local_iv[BLOCK_SIZE];
131 127
132 if (initialized == FALSE) 128 if (initialized == FALSE)
133 return NULL; 129 return NULL;
134 130
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 238
243 static void descbc_finish(void) 239 static void descbc_finish(void)
244 { 240 {
245 if (initialized) 241 if (initialized)
246 connman_crypto_unregister(&crypto_descbc); 242 connman_crypto_unregister(&crypto_descbc);
247 } 243 }
248 244
249 CONNMAN_PLUGIN_DEFINE(crypto_rot47, "DES-CBC Plugin", VERSION, 245 CONNMAN_PLUGIN_DEFINE(crypto_rot47, "DES-CBC Plugin", VERSION,
250 CONNMAN_PLUGIN_PRIORITY_DEFAULT, descbc_init, 246 CONNMAN_PLUGIN_PRIORITY_DEFAULT, descbc_init,
251 descbc_finish) 247 descbc_finish)
OLDNEW
« no previous file with comments | « include/wifi.h ('k') | plugins/crypto_rot47.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698