mbed TLS v2.23.0

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
21 *
22 * Licensed under the Apache License, Version 2.0 (the "License"); you may
23 * not use this file except in compliance with the License.
24 * You may obtain a copy of the License at
25 *
26 * http://www.apache.org/licenses/LICENSE-2.0
27 *
28 * Unless required by applicable law or agreed to in writing, software
29 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
30 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31 * See the License for the specific language governing permissions and
32 * limitations under the License.
33 *
34 * This file is part of Mbed TLS (https://tls.mbed.org)
35 */
36
37 #ifndef MBEDTLS_NIST_KW_H
38 #define MBEDTLS_NIST_KW_H
39
40 #if !defined(MBEDTLS_CONFIG_FILE)
41 #include "mbedtls/config.h"
42 #else
43 #include MBEDTLS_CONFIG_FILE
44 #endif
45
46 #include "mbedtls/cipher.h"
47
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51
52 typedef enum
53 {
54 MBEDTLS_KW_MODE_KW = 0,
55 MBEDTLS_KW_MODE_KWP = 1
56 } mbedtls_nist_kw_mode_t;
57
58 #if !defined(MBEDTLS_NIST_KW_ALT)
59 // Regular implementation
60 //
61
69 typedef struct {
70 mbedtls_cipher_context_t cipher_ctx;
71 } mbedtls_nist_kw_context;
72
73 #else /* MBEDTLS_NIST_key wrapping_ALT */
74 #include "nist_kw_alt.h"
75 #endif /* MBEDTLS_NIST_KW_ALT */
76
85 void mbedtls_nist_kw_init( mbedtls_nist_kw_context *ctx );
86
103 int mbedtls_nist_kw_setkey( mbedtls_nist_kw_context *ctx,
104 mbedtls_cipher_id_t cipher,
105 const unsigned char *key,
106 unsigned int keybits,
107 const int is_wrap );
108
115 void mbedtls_nist_kw_free( mbedtls_nist_kw_context *ctx );
116
138 int mbedtls_nist_kw_wrap( mbedtls_nist_kw_context *ctx, mbedtls_nist_kw_mode_t mode,
139 const unsigned char *input, size_t in_len,
140 unsigned char *output, size_t* out_len, size_t out_size );
141
165 int mbedtls_nist_kw_unwrap( mbedtls_nist_kw_context *ctx, mbedtls_nist_kw_mode_t mode,
166 const unsigned char *input, size_t in_len,
167 unsigned char *output, size_t* out_len, size_t out_size);
168
169
170 #if defined(MBEDTLS_SELF_TEST) && defined(MBEDTLS_AES_C)
171
177 int mbedtls_nist_kw_self_test( int verbose );
178 #endif /* MBEDTLS_SELF_TEST && MBEDTLS_AES_C */
179
180 #ifdef __cplusplus
181 }
182 #endif
183
184 #endif /* MBEDTLS_NIST_KW_H */
MBEDTLS_KW_MODE_KW
@ MBEDTLS_KW_MODE_KW
Definition: nist_kw.h:54
mbedtls_nist_kw_context
The key wrapping context-type definition. The key wrapping context is passed to the APIs called.
Definition: nist_kw.h:69
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:84
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:53
MBEDTLS_KW_MODE_KWP
@ MBEDTLS_KW_MODE_KWP
Definition: nist_kw.h:55
mbedtls_nist_kw_context::cipher_ctx
mbedtls_cipher_context_t cipher_ctx
Definition: nist_kw.h:70
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:293
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...