mbed TLS v3.1.0
nist_kw.h
Go to the documentation of this file.
1 
18 /*
19  * Copyright The Mbed TLS Contributors
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 
35 #ifndef MBEDTLS_NIST_KW_H
36 #define MBEDTLS_NIST_KW_H
37 #include "mbedtls/private_access.h"
38 
39 #include "mbedtls/build_info.h"
40 
41 #include "mbedtls/cipher.h"
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
47 typedef enum
48 {
52 
53 #if !defined(MBEDTLS_NIST_KW_ALT)
54 // Regular implementation
55 //
56 
64 typedef struct {
66 } mbedtls_nist_kw_context;
67 
68 #else /* MBEDTLS_NIST_key wrapping_ALT */
69 #include "nist_kw_alt.h"
70 #endif /* MBEDTLS_NIST_KW_ALT */
71 
80 void mbedtls_nist_kw_init( mbedtls_nist_kw_context *ctx );
81 
98 int mbedtls_nist_kw_setkey( mbedtls_nist_kw_context *ctx,
99  mbedtls_cipher_id_t cipher,
100  const unsigned char *key,
101  unsigned int keybits,
102  const int is_wrap );
103 
110 void mbedtls_nist_kw_free( mbedtls_nist_kw_context *ctx );
111 
133 int mbedtls_nist_kw_wrap( mbedtls_nist_kw_context *ctx, mbedtls_nist_kw_mode_t mode,
134  const unsigned char *input, size_t in_len,
135  unsigned char *output, size_t* out_len, size_t out_size );
136 
160 int mbedtls_nist_kw_unwrap( mbedtls_nist_kw_context *ctx, mbedtls_nist_kw_mode_t mode,
161  const unsigned char *input, size_t in_len,
162  unsigned char *output, size_t* out_len, size_t out_size);
163 
164 
165 #if defined(MBEDTLS_SELF_TEST) && defined(MBEDTLS_AES_C)
166 
172 int mbedtls_nist_kw_self_test( int verbose );
173 #endif /* MBEDTLS_SELF_TEST && MBEDTLS_AES_C */
174 
175 #ifdef __cplusplus
176 }
177 #endif
178 
179 #endif /* MBEDTLS_NIST_KW_H */
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.
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...
int mbedtls_nist_kw_self_test(int verbose)
The key wrapping checkup routine.
#define MBEDTLS_PRIVATE(member)
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.
mbedtls_nist_kw_mode_t
Definition: nist_kw.h:47
mbedtls_cipher_id_t
Supported cipher types.
Definition: cipher.h:83
Macro wrapper for struct's memebrs.
This file contains an abstraction interface for use with the cipher primitives provided by the librar...
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...
Build-time configuration info.
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...