Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
util.h
Go to the documentation of this file.
1/*
2 * Copyright 2015-2018 Yubico AB
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef YUBICOM_UTIL_H
18#define YUBICOM_UTIL_H
19
20#include <openssl/bn.h>
21#include <openssl/evp.h>
22#include <stdbool.h>
23#include <stdint.h>
24
25#include <yubihsm.h>
26
27typedef enum {
31} format_t;
32
33#ifndef __WIN32
34#define YH_INTERNAL __attribute__((visibility("hidden")))
35#else
36#define YH_INTERNAL
37#endif
38
40 int32_t element_len);
42 uint8_t *bytes, size_t *bytes_len,
43 bool internal_repr);
44void YH_INTERNAL format_digest(uint8_t *digest, char *str, uint16_t len);
47void YH_INTERNAL parse_NID(uint8_t *data, uint16_t data_len,
48 const EVP_MD **md_type, int *digestinfo_len);
49bool YH_INTERNAL read_file(FILE *fp, uint8_t *buf, size_t *buf_len);
50bool YH_INTERNAL write_file(const uint8_t *buf, size_t buf_len, FILE *fp,
53 size_t *out_len);
54bool YH_INTERNAL write_ed25519_key(uint8_t *buf, size_t buf_len, FILE *fp,
55 bool b64_encode);
56
57bool YH_INTERNAL base64_decode(const char *in, uint8_t *out, size_t *len);
58bool YH_INTERNAL hex_decode(const char *in, uint8_t *out, size_t *len);
59
61 size_t in_len, uint8_t *out, size_t *out_len);
62
63#endif
bignum_st BIGNUM
Definition bigint.hpp:7
Definition bn.h:56
unsigned short uint16_t
Definition stdint.h:125
signed int int32_t
Definition stdint.h:123
unsigned char uint8_t
Definition stdint.h:124
cmd_format format
bool YH_INTERNAL write_ed25519_key(uint8_t *buf, size_t buf_len, FILE *fp, bool b64_encode)
Definition util.c:622
bool YH_INTERNAL hex_decode(const char *in, uint8_t *out, size_t *len)
Definition util.c:524
bool YH_INTERNAL write_file(const uint8_t *buf, size_t buf_len, FILE *fp, format_t format)
Definition util.c:559
bool YH_INTERNAL algo2type(yh_algorithm algorithm, yh_object_type *type)
Definition util.c:374
void YH_INTERNAL format_digest(uint8_t *digest, char *str, uint16_t len)
Definition util.c:326
format_t
Definition util.h:27
@ _base64
Definition util.h:28
@ _binary
Definition util.h:29
@ _hex
Definition util.h:30
bool YH_INTERNAL base64_decode(const char *in, uint8_t *out, size_t *len)
Definition util.c:503
void YH_INTERNAL parse_NID(uint8_t *data, uint16_t data_len, const EVP_MD **md_type, int *digestinfo_len)
Definition util.c:452
#define YH_INTERNAL
Definition util.h:34
bool YH_INTERNAL read_ed25519_key(uint8_t *in, size_t in_len, uint8_t *out, size_t *out_len)
Definition util.c:77
bool YH_INTERNAL set_component(uint8_t *in_ptr, const BIGNUM *bn, int32_t element_len)
int YH_INTERNAL algo2nid(yh_algorithm algo)
Definition util.c:335
bool YH_INTERNAL read_file(FILE *fp, uint8_t *buf, size_t *buf_len)
Definition util.c:476
bool YH_INTERNAL split_hmac_key(yh_algorithm algorithm, uint8_t *in, size_t in_len, uint8_t *out, size_t *out_len)
Definition util.c:653
bool YH_INTERNAL read_private_key(uint8_t *buf, size_t len, yh_algorithm *algo, uint8_t *bytes, size_t *bytes_len, bool internal_repr)
Definition util.c:116
yh_object_type
Definition yubihsm.h:359
yh_algorithm
Definition yubihsm.h:390
yh_algorithm algorithm
Definition yubihsm.h:619
size_t out_len
size_t len
uint8_t buf[2048]
size_t in_len