Annotation of embedaddon/strongswan/src/libstrongswan/plugins/wolfssl/wolfssl_util.h, revision 1.1.1.1

1.1       misho       1: /*
                      2:  * Copyright (C) 2019 Sean Parkinson, wolfSSL Inc.
                      3:  *
                      4:  * Permission is hereby granted, free of charge, to any person obtaining a copy
                      5:  * of this software and associated documentation files (the "Software"), to deal
                      6:  * in the Software without restriction, including without limitation the rights
                      7:  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
                      8:  * copies of the Software, and to permit persons to whom the Software is
                      9:  * furnished to do so, subject to the following conditions:
                     10:  *
                     11:  * The above copyright notice and this permission notice shall be included in
                     12:  * all copies or substantial portions of the Software.
                     13:  *
                     14:  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
                     15:  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
                     16:  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
                     17:  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
                     18:  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
                     19:  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
                     20:  * THE SOFTWARE.
                     21:  */
                     22: 
                     23: /**
                     24:  * @defgroup wolfssl_util wolfssl_util
                     25:  * @{ @ingroup wolfssl_p
                     26:  */
                     27: 
                     28: #ifndef WOLFSSL_PLUGIN_UTIL_H_
                     29: #define WOLFSSL_PLUGIN_UTIL_H_
                     30: 
                     31: #include <wolfssl/wolfcrypt/integer.h>
                     32: #include <wolfssl/wolfcrypt/hash.h>
                     33: 
                     34: /**
                     35:  * Creates a hash of a given type of a chunk of data.
                     36:  *
                     37:  * Note: this function allocates memory for the hash
                     38:  *
                     39:  * @param hash_type Hash enumeration
                     40:  * @param data         the chunk of data to hash
                     41:  * @param hash         chunk that contains the hash
                     42:  * @return                     TRUE on success, FALSE otherwise
                     43:  */
                     44: bool wolfssl_hash_chunk(int hash_type, chunk_t data, chunk_t *hash);
                     45: 
                     46: /**
                     47:  * Exports the given integer (assumed to be a positive number) to a chunk in
                     48:  * two's complement format (i.e. a zero byte is added if the MSB is set).
                     49:  *
                     50:  * @param mp           the integer to export
                     51:  * @param chunk                the chunk (data gets allocated)
                     52:  * @return                     TRUE on success, FALSE otherwise
                     53:  */
                     54: bool wolfssl_mp2chunk(mp_int *mp, chunk_t *chunk);
                     55: 
                     56: /**
                     57:  * Splits a chunk into two mp_ints of equal binary length.
                     58:  *
                     59:  * @param chunk                a chunk that contains the two integers
                     60:  * @param a                    first mp_int
                     61:  * @param b                    second mp_int
                     62:  * @return                     TRUE on success, FALSE otherwise
                     63:  */
                     64: bool wolfssl_mp_split(chunk_t chunk, mp_int *a, mp_int *b);
                     65: 
                     66: /**
                     67:  * Concatenates two integers into a chunk, thereby enforcing the length of
                     68:  * a single integer, if necessary, by pre-pending it with zeros.
                     69:  *
                     70:  * Note: this function allocates memory for the chunk
                     71:  *
                     72:  * @param len          the length of a single integer
                     73:  * @param a                    first integer
                     74:  * @param b                    second integer
                     75:  * @param chunk                resulting chunk
                     76:  * @return                     TRUE on success, FALSE otherwise
                     77:  */
                     78: bool wolfssl_mp_cat(int len, mp_int *a, mp_int *b, chunk_t *chunk);
                     79: 
                     80: /**
                     81:  * Convert the hash algorithm to a wolfSSL hash type.
                     82:  *
                     83:  * @param hash         hash algorithm
                     84:  * @param type         Hash enumeration from wolfSSL
                     85:  * @return                     TRUE on success, FALSE otherwise
                     86:  */
                     87: bool wolfssl_hash2type(hash_algorithm_t hash, enum wc_HashType *type);
                     88: 
                     89: /**
                     90:  * Convert the mgf1 hash algorithm to a wolfSSL mgf1 type.
                     91:  *
                     92:  * @param hash         hash algorithm
                     93:  * @param mgf1         MGF1 algorithm from wolfSSL
                     94:  * @return                     TRUE on success, FALSE otherwise
                     95:  */
                     96: bool wolfssl_hash2mgf1(hash_algorithm_t hash, int *mgf1);
                     97: 
                     98: #endif /** WOLFSSL_PLUGIN_UTIL_H_ @}*/

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