Annotation of embedaddon/strongswan/src/libstrongswan/crypto/drbgs/drbg.h, revision 1.1.1.1

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: /**
                     17:  * @defgroup drbg drbg
                     18:  * @{ @ingroup crypto
                     19:  */
                     20: 
                     21: #ifndef DRBG_H_
                     22: #define DRBG_H_
                     23: 
                     24: typedef enum drbg_type_t drbg_type_t;
                     25: typedef struct drbg_t drbg_t;
                     26: 
                     27: #include <library.h>
                     28: 
                     29: /**
                     30:  * Deterministic Random Bit Generator.(DRBG) Type
                     31:  */
                     32: enum drbg_type_t {
                     33:        DRBG_UNDEFINED,
                     34:        DRBG_HMAC_SHA1,
                     35:        DRBG_HMAC_SHA256,
                     36:        DRBG_HMAC_SHA384,
                     37:        DRBG_HMAC_SHA512,
                     38:        DRBG_CTR_AES128,
                     39:        DRBG_CTR_AES192,
                     40:        DRBG_CTR_AES256,
                     41: };
                     42: 
                     43: /**
                     44:  * enum name for drbg_type_t.
                     45:  */
                     46: extern enum_name_t *drbg_type_names;
                     47: 
                     48: /**
                     49:  * Interface for a Deterministic Random Bit Generator (DRBG)
                     50:  * compliant with NIST SP 800-90A
                     51:  */
                     52: struct drbg_t {
                     53: 
                     54:        /**
                     55:         * Return the type of the DRBG
                     56:         *
                     57:         * @return                      DRBG type
                     58:         */
                     59:        drbg_type_t (*get_type)(drbg_t *this);
                     60: 
                     61:        /**
                     62:         * Return the security strength of the  DRBG
                     63:         *
                     64:         * @return                      configured security strength in bits
                     65:         */
                     66:        uint32_t (*get_strength)(drbg_t *this);
                     67: 
                     68:        /**
                     69:         * Reseed the instantiated DRBG
                     70:         *
                     71:         * @return                      TRUE if successful
                     72:         */
                     73:        bool (*reseed)(drbg_t *this);
                     74: 
                     75:        /**
                     76:         * Generate pseudorandom bytes.
                     77:         * If the maximum number of requests has been reached, reseeding occurs
                     78:         *
                     79:         * @param len           number of octets to generate
                     80:         * @param out           address of output buffer
                     81:         * @return                      TRUE if successful
                     82:         */
                     83:        bool (*generate)(drbg_t *this, uint32_t len, uint8_t *out);
                     84: 
                     85:        /**
                     86:         * Get a reference on an drbg_t object increasing the count by one
                     87:         *
                     88:         * @return                      reference to the drbg_t object
                     89:         */
                     90:        drbg_t* (*get_ref)(drbg_t *this);
                     91: 
                     92:        /**
                     93:         * Uninstantiate and destroy the DRBG object
                     94:         */
                     95:        void (*destroy)(drbg_t *this);
                     96: 
                     97: };
                     98: 
                     99: #endif /** DRBG_H_ @}*/

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>