| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Crypto plugin API. | 2 * Crypto plugin API. |
| 3 * | 3 * |
| 4 * This file initially created by Google, Inc. | 4 * This file initially created by Google, Inc. |
| 5 * | 5 * |
| 6 * This program is free software; you can redistribute it and/or modify | 6 * This program is free software; you can redistribute it and/or modify |
| 7 * it under the terms of the GNU General Public License version 2 as | 7 * it under the terms of the GNU General Public License version 2 as |
| 8 * published by the Free Software Foundation. | 8 * published by the Free Software Foundation. |
| 9 * | 9 * |
| 10 * This program is distributed in the hope that it will be useful, | 10 * This program is distributed in the hope that it will be useful, |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 * Remove a previously registered crypto module | 69 * Remove a previously registered crypto module |
| 70 */ | 70 */ |
| 71 void connman_crypto_unregister(struct connman_crypto *crypto) | 71 void connman_crypto_unregister(struct connman_crypto *crypto) |
| 72 { | 72 { |
| 73 _DBG_CRYPTO("crypto %p name %s", crypto, crypto->name); | 73 _DBG_CRYPTO("crypto %p name %s", crypto, crypto->name); |
| 74 | 74 |
| 75 g_free(crypto->prefix); | 75 g_free(crypto->prefix); |
| 76 crypto_list = g_slist_remove(crypto_list, crypto); | 76 crypto_list = g_slist_remove(crypto_list, crypto); |
| 77 } | 77 } |
| 78 | 78 |
| 79 char *__connman_crypto_decrypt_keyvalue(const char *profile_name, | 79 char *__connman_crypto_decrypt_keyvalue(const char *key, const char *value) |
| 80 const char *key, const char *value) | |
| 81 { | 80 { |
| 82 GSList *list; | 81 GSList *list; |
| 83 | 82 |
| 84 CONNMAN_ASSERT(value != NULL); | 83 CONNMAN_ASSERT(value != NULL); |
| 85 | 84 |
| 86 for (list = crypto_list; list; list = list->next) { | 85 for (list = crypto_list; list; list = list->next) { |
| 87 struct connman_crypto *crypto = list->data; | 86 struct connman_crypto *crypto = list->data; |
| 88 | 87 |
| 89 if (strncmp(crypto->prefix, value, crypto->prefix_size) == 0) { | 88 if (strncmp(crypto->prefix, value, crypto->prefix_size) == 0) { |
| 90 /* | 89 /* |
| 91 * The prefix matches, so this plugin *must* be the | 90 * The prefix matches, so this plugin *must* be the |
| 92 * one that knows how to decrypt. | 91 * one that knows how to decrypt. |
| 93 */ | 92 */ |
| 94 return crypto->decrypt_keyvalue(profile_name, key, | 93 return crypto->decrypt_keyvalue(key, |
| 95 &value[crypto->prefix_size]); | 94 &value[crypto->prefix_size]); |
| 96 } | 95 } |
| 97 } | 96 } |
| 98 | 97 |
| 99 /* | 98 /* |
| 100 * No plugins match the prefix of the encrypted value, return a copy of | 99 * No plugins match the prefix of the encrypted value, return a copy of |
| 101 * the plaintext. | 100 * the plaintext. |
| 102 */ | 101 */ |
| 103 return g_strdup(value); | 102 return g_strdup(value); |
| 104 } | 103 } |
| 105 | 104 |
| 106 char *__connman_crypto_encrypt_keyvalue(const char *profile_name, | 105 char *__connman_crypto_encrypt_keyvalue(const char *key, const char *value) |
| 107 const char *key, const char *value) | |
| 108 { | 106 { |
| 109 GSList *list; | 107 GSList *list; |
| 110 char *rv = NULL; | 108 char *rv = NULL; |
| 111 | 109 |
| 112 if (value == NULL) | 110 if (value == NULL) |
| 113 return NULL; | 111 return NULL; |
| 114 | 112 |
| 115 for (list = crypto_list; list; list = list->next) { | 113 for (list = crypto_list; list; list = list->next) { |
| 116 struct connman_crypto *crypto = list->data; | 114 struct connman_crypto *crypto = list->data; |
| 117 char *ciphertext = crypto->encrypt_keyvalue( | 115 char *ciphertext = crypto->encrypt_keyvalue(key, value); |
| 118 profile_name, key, value); | |
| 119 | 116 |
| 120 if (ciphertext != NULL) { | 117 if (ciphertext != NULL) { |
| 121 rv = g_strdup_printf("%s%s", crypto->prefix, | 118 rv = g_strdup_printf("%s%s", crypto->prefix, |
| 122 ciphertext); | 119 ciphertext); |
| 123 g_free(ciphertext); | 120 g_free(ciphertext); |
| 124 break; | 121 break; |
| 125 } | 122 } |
| 126 } | 123 } |
| 127 | 124 |
| 128 if (rv == NULL) { | 125 if (rv == NULL) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 140 { | 137 { |
| 141 _DBG_CRYPTO(""); | 138 _DBG_CRYPTO(""); |
| 142 | 139 |
| 143 return 0; | 140 return 0; |
| 144 } | 141 } |
| 145 | 142 |
| 146 void __connman_crypto_cleanup(void) | 143 void __connman_crypto_cleanup(void) |
| 147 { | 144 { |
| 148 _DBG_CRYPTO(""); | 145 _DBG_CRYPTO(""); |
| 149 } | 146 } |
| OLD | NEW |