Return to drbg_plugin.c CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / strongswan / src / libstrongswan / plugins / drbg |
1.1 misho 1: /* 2: * Copyright (C) 2019 Andreas Steffen 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: #include "drbg_plugin.h" 17: #include "drbg_ctr.h" 18: #include "drbg_hmac.h" 19: 20: #include <library.h> 21: 22: typedef struct private_drbg_plugin_t private_drbg_plugin_t; 23: 24: /** 25: * private data of drbg_plugin 26: */ 27: struct private_drbg_plugin_t { 28: 29: /** 30: * public functions 31: */ 32: drbg_plugin_t public; 33: }; 34: 35: METHOD(plugin_t, get_name, char*, 36: private_drbg_plugin_t *this) 37: { 38: return "drbg"; 39: } 40: 41: METHOD(plugin_t, get_features, int, 42: private_drbg_plugin_t *this, plugin_feature_t *features[]) 43: { 44: static plugin_feature_t f[] = { 45: /* NIST CTR DRBG */ 46: PLUGIN_REGISTER(DRBG, drbg_ctr_create), 47: PLUGIN_PROVIDE(DRBG, DRBG_CTR_AES128), 48: PLUGIN_DEPENDS(CRYPTER, ENCR_AES_ECB, 16), 49: PLUGIN_PROVIDE(DRBG, DRBG_CTR_AES192), 50: PLUGIN_DEPENDS(CRYPTER, ENCR_AES_ECB, 24), 51: PLUGIN_PROVIDE(DRBG, DRBG_CTR_AES256), 52: PLUGIN_DEPENDS(CRYPTER, ENCR_AES_ECB, 32), 53: /* NIST HMAC DRBG */ 54: PLUGIN_REGISTER(DRBG, drbg_hmac_create), 55: PLUGIN_PROVIDE(DRBG, DRBG_HMAC_SHA1), 56: PLUGIN_DEPENDS(PRF, PRF_HMAC_SHA1), 57: PLUGIN_PROVIDE(DRBG, DRBG_HMAC_SHA256), 58: PLUGIN_DEPENDS(PRF, PRF_HMAC_SHA2_256), 59: PLUGIN_PROVIDE(DRBG, DRBG_HMAC_SHA384), 60: PLUGIN_DEPENDS(PRF, PRF_HMAC_SHA2_384), 61: PLUGIN_PROVIDE(DRBG, DRBG_HMAC_SHA512), 62: PLUGIN_DEPENDS(PRF, PRF_HMAC_SHA2_512), 63: }; 64: *features = f; 65: return countof(f); 66: } 67: 68: METHOD(plugin_t, destroy, void, 69: private_drbg_plugin_t *this) 70: { 71: free(this); 72: } 73: 74: /* 75: * see header file 76: */ 77: plugin_t *drbg_plugin_create() 78: { 79: private_drbg_plugin_t *this; 80: 81: INIT(this, 82: .public = { 83: .plugin = { 84: .get_name = _get_name, 85: .get_features = _get_features, 86: .destroy = _destroy, 87: }, 88: }, 89: ); 90: 91: return &this->public.plugin; 92: }