opsick
util.h
Go to the documentation of this file.
1/*
2 Copyright 2020 Raphael Beck
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 OPSICK_UTIL_H
18#define OPSICK_UTIL_H
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
30#include <stdint.h>
31#include <stddef.h>
32#include <stdbool.h>
33#include <http.h>
34
38#define OPSICK_MIN(x, y) (((x) < (y)) ? (x) : (y))
39
43#define OPSICK_MAX(x, y) (((x) > (y)) ? (x) : (y))
44
51
56
61
72int opsick_hexstr2bin(const char* hexstr, size_t hexstr_length, uint8_t* output, size_t output_size, size_t* output_length);
73
85int opsick_bin2hexstr(const uint8_t* bin, size_t bin_length, char* output, size_t output_size, size_t* output_length, uint8_t uppercase);
86
94int opsick_strncmpic(const char* str1, const char* str2, size_t n);
95
102void opsick_sign(const char* string, size_t string_length, char* out);
103
111void opsick_sign_and_send(http_s* request, char* body, size_t body_length);
112
118int opsick_request_has_signature(http_s* request);
119
126
133int opsick_verify_request_signature(http_s* request, const char* public_key);
134
141int opsick_decrypt(http_s* request, char** out);
142
143#ifdef __cplusplus
144} // extern "C"
145#endif
146
147#endif // OPSICK_UTIL_H
void opsick_sign(const char *string, size_t string_length, char *out)
int opsick_decrypt(http_s *request, char **out)
int opsick_strncmpic(const char *str1, const char *str2, size_t n)
void opsick_util_init()
int opsick_request_has_signature(http_s *request)
void opsick_sign_and_send(http_s *request, char *body, size_t body_length)
int opsick_hexstr2bin(const char *hexstr, size_t hexstr_length, uint8_t *output, size_t output_size, size_t *output_length)
int opsick_bin2hexstr(const uint8_t *bin, size_t bin_length, char *output, size_t output_size, size_t *output_length, uint8_t uppercase)
int opsick_verify_request_signature(http_s *request, const char *public_key)
void opsick_util_free()
int opsick_verify_api_request_signature(http_s *request)
FIOBJ opsick_get_preallocated_string(uint32_t id)