libsaltpack
Loading...
Searching...
No Matches
Utils.h
1/*
2 * Copyright 2016-2024 Luca Zanconato
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 SALTPACK_UTILS_H
18#define SALTPACK_UTILS_H
19
20#include "types.h"
21
22namespace saltpack {
23
27 class Utils {
28
29 public:
38 static void generateKeypair(BYTE_ARRAY &publickey, BYTE_ARRAY &secretkey);
39
48 static void generateSignKeypair(BYTE_ARRAY &publickey, BYTE_ARRAY &secretkey);
49
60
69 static int baseXblockSize(const std::string& alphabet, int size);
70
79 static std::string baseXencode(const BYTE_ARRAY& data, std::string alphabet);
80
90 static std::string baseXencode(BYTE_ARRAY data, size_t size, std::string alphabet);
91
102 static BYTE_ARRAY baseXdecode(std::string data, const std::string& alphabet);
103
113 static BYTE_ARRAY hexToBin(const std::string& hex);
114
124 static std::string binToHex(BYTE_ARRAY bin);
125
135 static BYTE_ARRAY generateRandomBytes(size_t size);
136
150 static BYTE_ARRAY deriveKeyFromPassword(unsigned long long int keySize, const std::string& password, BYTE_ARRAY salt,
151 unsigned long long int opsLimit, size_t memLimit);
152 };
153}
154
155#endif //SALTPACK_UTILS_H
Utilities class.
Definition Utils.h:27
static BYTE_ARRAY generateRandomBytes(size_t size)
static void generateSignKeypair(BYTE_ARRAY &publickey, BYTE_ARRAY &secretkey)
static std::string binToHex(BYTE_ARRAY bin)
static BYTE_ARRAY deriveKeyFromPassword(unsigned long long int keySize, const std::string &password, BYTE_ARRAY salt, unsigned long long int opsLimit, size_t memLimit)
static BYTE_ARRAY hexToBin(const std::string &hex)
static BYTE_ARRAY baseXdecode(std::string data, const std::string &alphabet)
static std::string baseXencode(BYTE_ARRAY data, size_t size, std::string alphabet)
static int baseXblockSize(const std::string &alphabet, int size)
static void generateKeypair(BYTE_ARRAY &publickey, BYTE_ARRAY &secretkey)
static std::string baseXencode(const BYTE_ARRAY &data, std::string alphabet)
static BYTE_ARRAY derivePublickey(BYTE_ARRAY secretkey)
The saltpack library namespace.
Definition ArmoredInputStream.h:24
std::vector< BYTE > BYTE_ARRAY
Definition types.h:30