Return to shared_key.h CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / strongswan / src / libstrongswan / credentials / keys |
1.1 misho 1: /* 2: * Copyright (C) 2007 Martin Willi 3: * HSR Hochschule fuer Technik Rapperswil 4: * 5: * This program is free software; you can redistribute it and/or modify it 6: * under the terms of the GNU General Public License as published by the 7: * Free Software Foundation; either version 2 of the License, or (at your 8: * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. 9: * 10: * This program is distributed in the hope that it will be useful, but 11: * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13: * for more details. 14: */ 15: 16: /** 17: * @defgroup shared_key shared_key 18: * @{ @ingroup keys 19: */ 20: 21: #ifndef SHARED_KEY_H_ 22: #define SHARED_KEY_H_ 23: 24: #include <collections/enumerator.h> 25: #include <utils/identification.h> 26: 27: typedef struct shared_key_t shared_key_t; 28: typedef enum shared_key_type_t shared_key_type_t; 29: 30: /** 31: * Type of a shared key. 32: */ 33: enum shared_key_type_t { 34: /** wildcard for all keys */ 35: SHARED_ANY, 36: /** PSK for IKE authentication */ 37: SHARED_IKE, 38: /** key for a EAP authentication method */ 39: SHARED_EAP, 40: /** key to decrypt encrypted private keys */ 41: SHARED_PRIVATE_KEY_PASS, 42: /** PIN to unlock a smartcard */ 43: SHARED_PIN, 44: /** Calculated NT Hash = MD4(UTF-16LE(password)) */ 45: SHARED_NT_HASH, 46: /** Postquantum Preshared Key */ 47: SHARED_PPK, 48: }; 49: 50: /** 51: * enum names for shared_key_type_t 52: */ 53: extern enum_name_t *shared_key_type_names; 54: 55: /** 56: * A symmetric key shared between multiple owners. 57: * 58: * This class is not thread save, do not add owners while others might be 59: * reading. 60: */ 61: struct shared_key_t { 62: 63: /** 64: * Get the kind of this key. 65: * 66: * @return type of the key 67: */ 68: shared_key_type_t (*get_type)(shared_key_t *this); 69: 70: /** 71: * Get the shared key data. 72: * 73: * @return chunk pointing to the internal key 74: */ 75: chunk_t (*get_key)(shared_key_t *this); 76: 77: /** 78: * Increase refcount of the key. 79: * 80: * @return this with an increased refcount 81: */ 82: shared_key_t* (*get_ref)(shared_key_t *this); 83: 84: /** 85: * Destroy a shared_key instance if all references are gone. 86: */ 87: void (*destroy)(shared_key_t *this); 88: }; 89: 90: /** 91: * A simple private key implementation 92: * 93: * @param type type of the shared key 94: * @param key key data, gets owned by instance 95: * @return simple shared key instance 96: */ 97: shared_key_t *shared_key_create(shared_key_type_t type, chunk_t key); 98: 99: #endif /** SHARED_KEY_H_ @} */