mbed TLS v2.14.1

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 #include "cipher.h"
41
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45
46 typedef enum
47 {
48 MBEDTLS_KW_MODE_KW = 0,
49 MBEDTLS_KW_MODE_KWP = 1
50 } mbedtls_nist_kw_mode_t;
51
52 #if !defined(MBEDTLS_NIST_KW_ALT)
53 // Regular implementation
54 //
55
63 typedef struct {
64 mbedtls_cipher_context_t cipher_ctx;
65 } mbedtls_nist_kw_context;
66
67 #else /* MBEDTLS_NIST_key wrapping_ALT */
68 #include "nist_kw_alt.h"
69 #endif /* MBEDTLS_NIST_KW_ALT */
70
79 void mbedtls_nist_kw_init( mbedtls_nist_kw_context *ctx );
80
97 int mbedtls_nist_kw_setkey( mbedtls_nist_kw_context *ctx,
98 mbedtls_cipher_id_t cipher,
99 const unsigned char *key,
100 unsigned int keybits,
101 const int is_wrap );
102
109 void mbedtls_nist_kw_free( mbedtls_nist_kw_context *ctx );
110
132 int mbedtls_nist_kw_wrap( mbedtls_nist_kw_context *ctx, mbedtls_nist_kw_mode_t mode,
133 const unsigned char *input, size_t in_len,
134 unsigned char *output, size_t* out_len, size_t out_size );
135
159 int mbedtls_nist_kw_unwrap( mbedtls_nist_kw_context *ctx, mbedtls_nist_kw_mode_t mode,
160 const unsigned char *input, size_t in_len,
161 unsigned char *output, size_t* out_len, size_t out_size);
162
163
164 #if defined(MBEDTLS_SELF_TEST) && defined(MBEDTLS_AES_C)
165
171 int mbedtls_nist_kw_self_test( int verbose );
172 #endif /* MBEDTLS_SELF_TEST && MBEDTLS_AES_C */
173
174 #ifdef __cplusplus
175 }
176 #endif
177
178 #endif /* MBEDTLS_NIST_KW_H */
MBEDTLS_KW_MODE_KW
Definition: nist_kw.h:48
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.
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_nist_kw_context
The key wrapping context-type definition. The key wrapping context is passed to the APIs called...
Definition: nist_kw.h:63
mbedtls_cipher_context_t
Definition: cipher.h:283
mbedtls_nist_kw_self_test
int mbedtls_nist_kw_self_test(int verbose)
The key wrapping checkup routine.
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.
mbedtls_nist_kw_mode_t
mbedtls_nist_kw_mode_t
Definition: nist_kw.h:46
MBEDTLS_KW_MODE_KWP
Definition: nist_kw.h:49
mbedtls_cipher_id_t
mbedtls_cipher_id_t
Supported cipher types.
Definition: cipher.h:83
cipher.h
This file contains an abstraction interface for use with the cipher primitives provided by the librar...
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...
mbedtls_nist_kw_context::cipher_ctx
mbedtls_cipher_context_t cipher_ctx
Definition: nist_kw.h:64