Color Oled(SSD1331) connect to STMicroelectronics Nucleo-F466

Dependencies:   ssd1331

Committer:
kadonotakashi
Date:
Wed Oct 10 00:33:53 2018 +0000
Revision:
0:8fdf9a60065b
how to make mbed librry

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kadonotakashi 0:8fdf9a60065b 1 /*
kadonotakashi 0:8fdf9a60065b 2 * Copyright (c) , Arm Limited and affiliates.
kadonotakashi 0:8fdf9a60065b 3 * SPDX-License-Identifier: Apache-2.0
kadonotakashi 0:8fdf9a60065b 4 *
kadonotakashi 0:8fdf9a60065b 5 * Licensed under the Apache License, Version 2.0 (the "License");
kadonotakashi 0:8fdf9a60065b 6 * you may not use this file except in compliance with the License.
kadonotakashi 0:8fdf9a60065b 7 * You may obtain a copy of the License at
kadonotakashi 0:8fdf9a60065b 8 *
kadonotakashi 0:8fdf9a60065b 9 * http://www.apache.org/licenses/LICENSE-2.0
kadonotakashi 0:8fdf9a60065b 10 *
kadonotakashi 0:8fdf9a60065b 11 * Unless required by applicable law or agreed to in writing, software
kadonotakashi 0:8fdf9a60065b 12 * distributed under the License is distributed on an "AS IS" BASIS,
kadonotakashi 0:8fdf9a60065b 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
kadonotakashi 0:8fdf9a60065b 14 * See the License for the specific language governing permissions and
kadonotakashi 0:8fdf9a60065b 15 * limitations under the License.
kadonotakashi 0:8fdf9a60065b 16 */
kadonotakashi 0:8fdf9a60065b 17
kadonotakashi 0:8fdf9a60065b 18 #if !defined(MBEDTLS_CONFIG_FILE)
kadonotakashi 0:8fdf9a60065b 19 #include "mbedtls/config.h"
kadonotakashi 0:8fdf9a60065b 20 #else
kadonotakashi 0:8fdf9a60065b 21 #include MBEDTLS_CONFIG_FILE
kadonotakashi 0:8fdf9a60065b 22 #endif
kadonotakashi 0:8fdf9a60065b 23
kadonotakashi 0:8fdf9a60065b 24 #include "mbedtls/cipher.h"
kadonotakashi 0:8fdf9a60065b 25 #include "mbedtls/cipher_internal.h"
kadonotakashi 0:8fdf9a60065b 26 #include "mbedtls/platform_util.h"
kadonotakashi 0:8fdf9a60065b 27
kadonotakashi 0:8fdf9a60065b 28 #include <stdlib.h>
kadonotakashi 0:8fdf9a60065b 29 #include <string.h>
kadonotakashi 0:8fdf9a60065b 30
kadonotakashi 0:8fdf9a60065b 31 #if defined(MBEDTLS_GCM_C)
kadonotakashi 0:8fdf9a60065b 32 #include "mbedtls/gcm.h"
kadonotakashi 0:8fdf9a60065b 33 #endif
kadonotakashi 0:8fdf9a60065b 34
kadonotakashi 0:8fdf9a60065b 35 #if defined(MBEDTLS_CCM_C)
kadonotakashi 0:8fdf9a60065b 36 #include "mbedtls/ccm.h"
kadonotakashi 0:8fdf9a60065b 37 #endif
kadonotakashi 0:8fdf9a60065b 38
kadonotakashi 0:8fdf9a60065b 39 #if defined(MBEDTLS_CMAC_C)
kadonotakashi 0:8fdf9a60065b 40 #include "mbedtls/cmac.h"
kadonotakashi 0:8fdf9a60065b 41 #endif
kadonotakashi 0:8fdf9a60065b 42
kadonotakashi 0:8fdf9a60065b 43 #include "cipher_stub.h"
kadonotakashi 0:8fdf9a60065b 44
kadonotakashi 0:8fdf9a60065b 45 cipher_stub_def cipher_stub;
kadonotakashi 0:8fdf9a60065b 46
kadonotakashi 0:8fdf9a60065b 47 const int *mbedtls_cipher_list( void )
kadonotakashi 0:8fdf9a60065b 48 {
kadonotakashi 0:8fdf9a60065b 49 return cipher_stub.int_ptr;
kadonotakashi 0:8fdf9a60065b 50 }
kadonotakashi 0:8fdf9a60065b 51
kadonotakashi 0:8fdf9a60065b 52 const mbedtls_cipher_info_t *mbedtls_cipher_info_from_type( const mbedtls_cipher_type_t cipher_type )
kadonotakashi 0:8fdf9a60065b 53 {
kadonotakashi 0:8fdf9a60065b 54 return cipher_stub.info_value;
kadonotakashi 0:8fdf9a60065b 55 }
kadonotakashi 0:8fdf9a60065b 56
kadonotakashi 0:8fdf9a60065b 57 const mbedtls_cipher_info_t *mbedtls_cipher_info_from_string( const char *cipher_name )
kadonotakashi 0:8fdf9a60065b 58 {
kadonotakashi 0:8fdf9a60065b 59 return cipher_stub.info_value;
kadonotakashi 0:8fdf9a60065b 60 }
kadonotakashi 0:8fdf9a60065b 61
kadonotakashi 0:8fdf9a60065b 62 const mbedtls_cipher_info_t *mbedtls_cipher_info_from_values( const mbedtls_cipher_id_t cipher_id,
kadonotakashi 0:8fdf9a60065b 63 int key_bitlen,
kadonotakashi 0:8fdf9a60065b 64 const mbedtls_cipher_mode_t mode )
kadonotakashi 0:8fdf9a60065b 65 {
kadonotakashi 0:8fdf9a60065b 66 return cipher_stub.info_value;
kadonotakashi 0:8fdf9a60065b 67 }
kadonotakashi 0:8fdf9a60065b 68
kadonotakashi 0:8fdf9a60065b 69 void mbedtls_cipher_init( mbedtls_cipher_context_t *ctx )
kadonotakashi 0:8fdf9a60065b 70 {
kadonotakashi 0:8fdf9a60065b 71 }
kadonotakashi 0:8fdf9a60065b 72
kadonotakashi 0:8fdf9a60065b 73 void mbedtls_cipher_free( mbedtls_cipher_context_t *ctx )
kadonotakashi 0:8fdf9a60065b 74 {
kadonotakashi 0:8fdf9a60065b 75 }
kadonotakashi 0:8fdf9a60065b 76
kadonotakashi 0:8fdf9a60065b 77 int mbedtls_cipher_setup( mbedtls_cipher_context_t *ctx, const mbedtls_cipher_info_t *cipher_info )
kadonotakashi 0:8fdf9a60065b 78 {
kadonotakashi 0:8fdf9a60065b 79 if (cipher_stub.int_zero_counter) {
kadonotakashi 0:8fdf9a60065b 80 cipher_stub.int_zero_counter--;
kadonotakashi 0:8fdf9a60065b 81 return 0;
kadonotakashi 0:8fdf9a60065b 82 }
kadonotakashi 0:8fdf9a60065b 83 return cipher_stub.int_value;
kadonotakashi 0:8fdf9a60065b 84 }
kadonotakashi 0:8fdf9a60065b 85
kadonotakashi 0:8fdf9a60065b 86 int mbedtls_cipher_setkey( mbedtls_cipher_context_t *ctx, const unsigned char *key,
kadonotakashi 0:8fdf9a60065b 87 int key_bitlen, const mbedtls_operation_t operation )
kadonotakashi 0:8fdf9a60065b 88 {
kadonotakashi 0:8fdf9a60065b 89 if (cipher_stub.int_zero_counter) {
kadonotakashi 0:8fdf9a60065b 90 cipher_stub.int_zero_counter--;
kadonotakashi 0:8fdf9a60065b 91 return 0;
kadonotakashi 0:8fdf9a60065b 92 }
kadonotakashi 0:8fdf9a60065b 93 return cipher_stub.int_value;
kadonotakashi 0:8fdf9a60065b 94 }
kadonotakashi 0:8fdf9a60065b 95
kadonotakashi 0:8fdf9a60065b 96 int mbedtls_cipher_set_iv( mbedtls_cipher_context_t *ctx,
kadonotakashi 0:8fdf9a60065b 97 const unsigned char *iv, size_t iv_len )
kadonotakashi 0:8fdf9a60065b 98 {
kadonotakashi 0:8fdf9a60065b 99 if (cipher_stub.int_zero_counter) {
kadonotakashi 0:8fdf9a60065b 100 cipher_stub.int_zero_counter--;
kadonotakashi 0:8fdf9a60065b 101 return 0;
kadonotakashi 0:8fdf9a60065b 102 }
kadonotakashi 0:8fdf9a60065b 103 return cipher_stub.int_value;
kadonotakashi 0:8fdf9a60065b 104 }
kadonotakashi 0:8fdf9a60065b 105
kadonotakashi 0:8fdf9a60065b 106 int mbedtls_cipher_reset( mbedtls_cipher_context_t *ctx )
kadonotakashi 0:8fdf9a60065b 107 {
kadonotakashi 0:8fdf9a60065b 108 if (cipher_stub.int_zero_counter) {
kadonotakashi 0:8fdf9a60065b 109 cipher_stub.int_zero_counter--;
kadonotakashi 0:8fdf9a60065b 110 return 0;
kadonotakashi 0:8fdf9a60065b 111 }
kadonotakashi 0:8fdf9a60065b 112 return cipher_stub.int_value;
kadonotakashi 0:8fdf9a60065b 113 }
kadonotakashi 0:8fdf9a60065b 114
kadonotakashi 0:8fdf9a60065b 115 int mbedtls_cipher_update_ad( mbedtls_cipher_context_t *ctx,
kadonotakashi 0:8fdf9a60065b 116 const unsigned char *ad, size_t ad_len )
kadonotakashi 0:8fdf9a60065b 117 {
kadonotakashi 0:8fdf9a60065b 118 if (cipher_stub.int_zero_counter) {
kadonotakashi 0:8fdf9a60065b 119 cipher_stub.int_zero_counter--;
kadonotakashi 0:8fdf9a60065b 120 return 0;
kadonotakashi 0:8fdf9a60065b 121 }
kadonotakashi 0:8fdf9a60065b 122 return cipher_stub.int_value;
kadonotakashi 0:8fdf9a60065b 123 }
kadonotakashi 0:8fdf9a60065b 124
kadonotakashi 0:8fdf9a60065b 125 int mbedtls_cipher_update( mbedtls_cipher_context_t *ctx, const unsigned char *input,
kadonotakashi 0:8fdf9a60065b 126 size_t ilen, unsigned char *output, size_t *olen )
kadonotakashi 0:8fdf9a60065b 127 {
kadonotakashi 0:8fdf9a60065b 128 if (cipher_stub.int_zero_counter) {
kadonotakashi 0:8fdf9a60065b 129 cipher_stub.int_zero_counter--;
kadonotakashi 0:8fdf9a60065b 130 return 0;
kadonotakashi 0:8fdf9a60065b 131 }
kadonotakashi 0:8fdf9a60065b 132 return cipher_stub.int_value;
kadonotakashi 0:8fdf9a60065b 133 }
kadonotakashi 0:8fdf9a60065b 134
kadonotakashi 0:8fdf9a60065b 135 int mbedtls_cipher_finish( mbedtls_cipher_context_t *ctx,
kadonotakashi 0:8fdf9a60065b 136 unsigned char *output, size_t *olen )
kadonotakashi 0:8fdf9a60065b 137 {
kadonotakashi 0:8fdf9a60065b 138 if (cipher_stub.int_zero_counter) {
kadonotakashi 0:8fdf9a60065b 139 cipher_stub.int_zero_counter--;
kadonotakashi 0:8fdf9a60065b 140 return 0;
kadonotakashi 0:8fdf9a60065b 141 }
kadonotakashi 0:8fdf9a60065b 142 return cipher_stub.int_value;
kadonotakashi 0:8fdf9a60065b 143 }
kadonotakashi 0:8fdf9a60065b 144
kadonotakashi 0:8fdf9a60065b 145 int mbedtls_cipher_set_padding_mode( mbedtls_cipher_context_t *ctx, mbedtls_cipher_padding_t mode )
kadonotakashi 0:8fdf9a60065b 146 {
kadonotakashi 0:8fdf9a60065b 147 if (cipher_stub.int_zero_counter) {
kadonotakashi 0:8fdf9a60065b 148 cipher_stub.int_zero_counter--;
kadonotakashi 0:8fdf9a60065b 149 return 0;
kadonotakashi 0:8fdf9a60065b 150 }
kadonotakashi 0:8fdf9a60065b 151 return cipher_stub.int_value;
kadonotakashi 0:8fdf9a60065b 152 }
kadonotakashi 0:8fdf9a60065b 153
kadonotakashi 0:8fdf9a60065b 154 int mbedtls_cipher_write_tag( mbedtls_cipher_context_t *ctx,
kadonotakashi 0:8fdf9a60065b 155 unsigned char *tag, size_t tag_len )
kadonotakashi 0:8fdf9a60065b 156 {
kadonotakashi 0:8fdf9a60065b 157 if (cipher_stub.int_zero_counter) {
kadonotakashi 0:8fdf9a60065b 158 cipher_stub.int_zero_counter--;
kadonotakashi 0:8fdf9a60065b 159 return 0;
kadonotakashi 0:8fdf9a60065b 160 }
kadonotakashi 0:8fdf9a60065b 161 return cipher_stub.int_value;
kadonotakashi 0:8fdf9a60065b 162 }
kadonotakashi 0:8fdf9a60065b 163
kadonotakashi 0:8fdf9a60065b 164 int mbedtls_cipher_check_tag( mbedtls_cipher_context_t *ctx,
kadonotakashi 0:8fdf9a60065b 165 const unsigned char *tag, size_t tag_len )
kadonotakashi 0:8fdf9a60065b 166 {
kadonotakashi 0:8fdf9a60065b 167 if (cipher_stub.int_zero_counter) {
kadonotakashi 0:8fdf9a60065b 168 cipher_stub.int_zero_counter--;
kadonotakashi 0:8fdf9a60065b 169 return 0;
kadonotakashi 0:8fdf9a60065b 170 }
kadonotakashi 0:8fdf9a60065b 171 return cipher_stub.int_value;
kadonotakashi 0:8fdf9a60065b 172 }
kadonotakashi 0:8fdf9a60065b 173
kadonotakashi 0:8fdf9a60065b 174 int mbedtls_cipher_crypt( mbedtls_cipher_context_t *ctx,
kadonotakashi 0:8fdf9a60065b 175 const unsigned char *iv, size_t iv_len,
kadonotakashi 0:8fdf9a60065b 176 const unsigned char *input, size_t ilen,
kadonotakashi 0:8fdf9a60065b 177 unsigned char *output, size_t *olen )
kadonotakashi 0:8fdf9a60065b 178 {
kadonotakashi 0:8fdf9a60065b 179 if (cipher_stub.int_zero_counter) {
kadonotakashi 0:8fdf9a60065b 180 cipher_stub.int_zero_counter--;
kadonotakashi 0:8fdf9a60065b 181 return 0;
kadonotakashi 0:8fdf9a60065b 182 }
kadonotakashi 0:8fdf9a60065b 183 return cipher_stub.int_value;
kadonotakashi 0:8fdf9a60065b 184 }
kadonotakashi 0:8fdf9a60065b 185
kadonotakashi 0:8fdf9a60065b 186 int mbedtls_cipher_auth_encrypt( mbedtls_cipher_context_t *ctx,
kadonotakashi 0:8fdf9a60065b 187 const unsigned char *iv, size_t iv_len,
kadonotakashi 0:8fdf9a60065b 188 const unsigned char *ad, size_t ad_len,
kadonotakashi 0:8fdf9a60065b 189 const unsigned char *input, size_t ilen,
kadonotakashi 0:8fdf9a60065b 190 unsigned char *output, size_t *olen,
kadonotakashi 0:8fdf9a60065b 191 unsigned char *tag, size_t tag_len )
kadonotakashi 0:8fdf9a60065b 192 {
kadonotakashi 0:8fdf9a60065b 193 if (cipher_stub.int_zero_counter) {
kadonotakashi 0:8fdf9a60065b 194 cipher_stub.int_zero_counter--;
kadonotakashi 0:8fdf9a60065b 195 return 0;
kadonotakashi 0:8fdf9a60065b 196 }
kadonotakashi 0:8fdf9a60065b 197 return cipher_stub.int_value;
kadonotakashi 0:8fdf9a60065b 198 }
kadonotakashi 0:8fdf9a60065b 199
kadonotakashi 0:8fdf9a60065b 200 int mbedtls_cipher_auth_decrypt( mbedtls_cipher_context_t *ctx,
kadonotakashi 0:8fdf9a60065b 201 const unsigned char *iv, size_t iv_len,
kadonotakashi 0:8fdf9a60065b 202 const unsigned char *ad, size_t ad_len,
kadonotakashi 0:8fdf9a60065b 203 const unsigned char *input, size_t ilen,
kadonotakashi 0:8fdf9a60065b 204 unsigned char *output, size_t *olen,
kadonotakashi 0:8fdf9a60065b 205 const unsigned char *tag, size_t tag_len )
kadonotakashi 0:8fdf9a60065b 206 {
kadonotakashi 0:8fdf9a60065b 207 if (cipher_stub.int_zero_counter) {
kadonotakashi 0:8fdf9a60065b 208 cipher_stub.int_zero_counter--;
kadonotakashi 0:8fdf9a60065b 209 return 0;
kadonotakashi 0:8fdf9a60065b 210 }
kadonotakashi 0:8fdf9a60065b 211 return cipher_stub.int_value;
kadonotakashi 0:8fdf9a60065b 212 }
kadonotakashi 0:8fdf9a60065b 213