| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  *  Rot-47 "encryption", obfuscates sensitive data so that it's not visible | 2  *  Rot-47 "encryption", obfuscates sensitive data so that it's not visible | 
| 3  *  on accident. | 3  *  on accident. | 
| 4  * | 4  * | 
| 5  * Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 5  * Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 
| 6  * Use of this source code is governed by a BSD-style license that can be | 6  * Use of this source code is governed by a BSD-style license that can be | 
| 7  * found in the LICENSE file. | 7  * found in the LICENSE file. | 
| 8  */ | 8  */ | 
| 9 | 9 | 
| 10 #ifdef HAVE_CONFIG_H | 10 #ifdef HAVE_CONFIG_H | 
| 11 #include <config.h> | 11 #include <config.h> | 
| 12 #endif | 12 #endif | 
| 13 | 13 | 
| 14 #define CONNMAN_API_SUBJECT_TO_CHANGE | 14 #define CONNMAN_API_SUBJECT_TO_CHANGE | 
| 15 #include <connman/crypto.h> | 15 #include <connman/crypto.h> | 
| 16 #include <connman/log.h> | 16 #include <connman/log.h> | 
| 17 #include <connman/plugin.h> | 17 #include <connman/plugin.h> | 
| 18 #include <glib.h> | 18 #include <glib.h> | 
| 19 #include <string.h> | 19 #include <string.h> | 
| 20 | 20 | 
| 21 #define ROT_SIZE 94 | 21 #define ROT_SIZE 94 | 
| 22 #define ROT_HALF (ROT_SIZE / 2) | 22 #define ROT_HALF (ROT_SIZE / 2) | 
| 23 #define ROT_MIN '!' | 23 #define ROT_MIN '!' | 
| 24 #define ROT_MAX  (ROT_MIN + ROT_SIZE) | 24 #define ROT_MAX  (ROT_MIN + ROT_SIZE) | 
| 25 | 25 | 
| 26 static char *rotate_encrypt(const char *profile_name, | 26 static char *rotate_encrypt(const char *key, const char *value); | 
| 27     const char *key, const char *value); |  | 
| 28 | 27 | 
| 29 static struct connman_crypto crypto_rot47 = { | 28 static struct connman_crypto crypto_rot47 = { | 
| 30         .name                   = "rot47", | 29         .name                   = "rot47", | 
| 31         .priority               = CONNMAN_CRYPTO_PRIORITY_DEFAULT, | 30         .priority               = CONNMAN_CRYPTO_PRIORITY_DEFAULT, | 
| 32         .encrypt_keyvalue       = rotate_encrypt, | 31         .encrypt_keyvalue       = rotate_encrypt, | 
| 33         .decrypt_keyvalue       = rotate_encrypt, | 32         .decrypt_keyvalue       = rotate_encrypt, | 
| 34 }; | 33 }; | 
| 35 | 34 | 
| 36 static char *rotate_encrypt(const char *profile_name, | 35 static char *rotate_encrypt(const char *key, const char *value) | 
| 37     const char *key, const char *value) |  | 
| 38 { | 36 { | 
| 39         char *rv = g_strdup(value); | 37         char *rv = g_strdup(value); | 
| 40         gsize i, len = strlen(rv); | 38         gsize i, len = strlen(rv); | 
| 41 | 39 | 
| 42         for (i = 0; i < len; ++i) { | 40         for (i = 0; i < len; ++i) { | 
| 43                 if (rv[i] < ROT_MIN || rv[i] > ROT_MAX) | 41                 if (rv[i] < ROT_MIN || rv[i] > ROT_MAX) | 
| 44                         continue; | 42                         continue; | 
| 45 | 43 | 
| 46                 /* Temporary storage in an int to avoid overflowing a char. */ | 44                 /* Temporary storage in an int to avoid overflowing a char. */ | 
| 47                 int ch = rv[i] + ROT_HALF; | 45                 int ch = rv[i] + ROT_HALF; | 
| (...skipping 18 matching lines...) Expand all  Loading... | 
| 66 } | 64 } | 
| 67 | 65 | 
| 68 static void rotate_finish(void) | 66 static void rotate_finish(void) | 
| 69 { | 67 { | 
| 70         connman_crypto_unregister(&crypto_rot47); | 68         connman_crypto_unregister(&crypto_rot47); | 
| 71 } | 69 } | 
| 72 | 70 | 
| 73 CONNMAN_PLUGIN_DEFINE(crypto_rot47, "Rot47 Plugin", VERSION, | 71 CONNMAN_PLUGIN_DEFINE(crypto_rot47, "Rot47 Plugin", VERSION, | 
| 74     CONNMAN_PLUGIN_PRIORITY_DEFAULT, rotate_init, | 72     CONNMAN_PLUGIN_PRIORITY_DEFAULT, rotate_init, | 
| 75     rotate_finish) | 73     rotate_finish) | 
| OLD | NEW | 
|---|