mbed TLS v2.16.7
nist_kw.h
Go to the documentation of this file.
1 
18 /*
19  * Copyright (C) 2018, Arm Limited (or its affiliates), All Rights Reserved
20  * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
21  *
22  * This file is provided under the Apache License 2.0, or the
23  * GNU General Public License v2.0 or later.
24  *
25  * **********
26  * Apache License 2.0:
27  *
28  * Licensed under the Apache License, Version 2.0 (the "License"); you may
29  * not use this file except in compliance with the License.
30  * You may obtain a copy of the License at
31  *
32  * http://www.apache.org/licenses/LICENSE-2.0
33  *
34  * Unless required by applicable law or agreed to in writing, software
35  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
36  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
37  * See the License for the specific language governing permissions and
38  * limitations under the License.
39  *
40  * **********
41  *
42  * **********
43  * GNU General Public License v2.0 or later:
44  *
45  * This program is free software; you can redistribute it and/or modify
46  * it under the terms of the GNU General Public License as published by
47  * the Free Software Foundation; either version 2 of the License, or
48  * (at your option) any later version.
49  *
50  * This program is distributed in the hope that it will be useful,
51  * but WITHOUT ANY WARRANTY; without even the implied warranty of
52  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
53  * GNU General Public License for more details.
54  *
55  * You should have received a copy of the GNU General Public License along
56  * with this program; if not, write to the Free Software Foundation, Inc.,
57  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
58  *
59  * **********
60  *
61  * This file is part of Mbed TLS (https://tls.mbed.org)
62  */
63 
64 #ifndef MBEDTLS_NIST_KW_H
65 #define MBEDTLS_NIST_KW_H
66 
67 #if !defined(MBEDTLS_CONFIG_FILE)
68 #include "config.h"
69 #else
70 #include MBEDTLS_CONFIG_FILE
71 #endif
72 
73 #include "cipher.h"
74 
75 #ifdef __cplusplus
76 extern "C" {
77 #endif
78 
79 typedef enum
80 {
84 
85 #if !defined(MBEDTLS_NIST_KW_ALT)
86 // Regular implementation
87 //
88 
96 typedef struct {
99 
100 #else /* MBEDTLS_NIST_key wrapping_ALT */
101 #include "nist_kw_alt.h"
102 #endif /* MBEDTLS_NIST_KW_ALT */
103 
113 
131  mbedtls_cipher_id_t cipher,
132  const unsigned char *key,
133  unsigned int keybits,
134  const int is_wrap );
135 
143 
166  const unsigned char *input, size_t in_len,
167  unsigned char *output, size_t* out_len, size_t out_size );
168 
193  const unsigned char *input, size_t in_len,
194  unsigned char *output, size_t* out_len, size_t out_size);
195 
196 
197 #if defined(MBEDTLS_SELF_TEST) && defined(MBEDTLS_AES_C)
198 
204 int mbedtls_nist_kw_self_test( int verbose );
205 #endif /* MBEDTLS_SELF_TEST && MBEDTLS_AES_C */
206 
207 #ifdef __cplusplus
208 }
209 #endif
210 
211 #endif /* MBEDTLS_NIST_KW_H */
MBEDTLS_KW_MODE_KW
@ MBEDTLS_KW_MODE_KW
Definition: nist_kw.h:81
mbedtls_nist_kw_context
The key wrapping context-type definition. The key wrapping context is passed to the APIs called.
Definition: nist_kw.h:96
mbedtls_nist_kw_init
void mbedtls_nist_kw_init(mbedtls_nist_kw_context *ctx)
This function initializes the specified key wrapping context to make references valid and prepare the...
mbedtls_cipher_id_t
mbedtls_cipher_id_t
Supported cipher types.
Definition: cipher.h:111
mbedtls_nist_kw_wrap
int mbedtls_nist_kw_wrap(mbedtls_nist_kw_context *ctx, mbedtls_nist_kw_mode_t mode, const unsigned char *input, size_t in_len, unsigned char *output, size_t *out_len, size_t out_size)
This function encrypts a buffer using key wrapping.
cipher.h
This file contains an abstraction interface for use with the cipher primitives provided by the librar...
mbedtls_nist_kw_mode_t
mbedtls_nist_kw_mode_t
Definition: nist_kw.h:80
MBEDTLS_KW_MODE_KWP
@ MBEDTLS_KW_MODE_KWP
Definition: nist_kw.h:82
mbedtls_nist_kw_context::cipher_ctx
mbedtls_cipher_context_t cipher_ctx
Definition: nist_kw.h:97
mbedtls_nist_kw_self_test
int mbedtls_nist_kw_self_test(int verbose)
The key wrapping checkup routine.
mbedtls_cipher_context_t
Definition: cipher.h:312
mbedtls_nist_kw_unwrap
int mbedtls_nist_kw_unwrap(mbedtls_nist_kw_context *ctx, mbedtls_nist_kw_mode_t mode, const unsigned char *input, size_t in_len, unsigned char *output, size_t *out_len, size_t out_size)
This function decrypts a buffer using key wrapping.
config.h
Configuration options (set of defines)
mbedtls_nist_kw_setkey
int mbedtls_nist_kw_setkey(mbedtls_nist_kw_context *ctx, mbedtls_cipher_id_t cipher, const unsigned char *key, unsigned int keybits, const int is_wrap)
This function initializes the key wrapping context set in the ctx parameter and sets the encryption k...
mbedtls_nist_kw_free
void mbedtls_nist_kw_free(mbedtls_nist_kw_context *ctx)
This function releases and clears the specified key wrapping context and underlying cipher sub-contex...