Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
samr7
GitHub Repository: samr7/vanitygen
Path: blob/master/util.h
239 views
1
/*
2
* Vanitygen, vanity bitcoin address generator
3
* Copyright (C) 2011 <[email protected]>
4
*
5
* Vanitygen is free software: you can redistribute it and/or modify
6
* it under the terms of the GNU Affero General Public License as published by
7
* the Free Software Foundation, either version 3 of the License, or
8
* any later version.
9
*
10
* Vanitygen is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU Affero General Public License for more details.
14
*
15
* You should have received a copy of the GNU Affero General Public License
16
* along with Vanitygen. If not, see <http://www.gnu.org/licenses/>.
17
*/
18
19
#if !defined (__VG_UTIL_H__)
20
#define __VG_UTIL_H__
21
22
#include <stdio.h>
23
#include <stdint.h>
24
25
#include <openssl/bn.h>
26
#include <openssl/ec.h>
27
28
extern const char *vg_b58_alphabet;
29
extern const signed char vg_b58_reverse_map[256];
30
31
extern void fdumphex(FILE *fp, const unsigned char *src, size_t len);
32
extern void fdumpbn(FILE *fp, const BIGNUM *bn);
33
extern void dumphex(const unsigned char *src, size_t len);
34
extern void dumpbn(const BIGNUM *bn);
35
36
extern void vg_b58_encode_check(void *buf, size_t len, char *result);
37
extern int vg_b58_decode_check(const char *input, void *buf, size_t len);
38
39
extern void vg_encode_address(const EC_POINT *ppoint, const EC_GROUP *pgroup,
40
int addrtype, char *result);
41
extern void vg_encode_script_address(const EC_POINT *ppoint,
42
const EC_GROUP *pgroup,
43
int addrtype, char *result);
44
extern void vg_encode_privkey(const EC_KEY *pkey, int addrtype, char *result);
45
extern int vg_set_privkey(const BIGNUM *bnpriv, EC_KEY *pkey);
46
extern int vg_decode_privkey(const char *b58encoded,
47
EC_KEY *pkey, int *addrtype);
48
49
enum {
50
VG_PROTKEY_DEFAULT = -1,
51
VG_PROTKEY_BRIEF_PBKDF2_4096_HMAC_SHA256_AES_256_CBC = 0,
52
VG_PROTKEY_PKCS_PBKDF2_4096_HMAC_SHA256_AES_256_CBC = 16,
53
};
54
55
#define VG_PROTKEY_MAX_B58 128
56
57
extern int vg_protect_encode_privkey(char *out,
58
const EC_KEY *pkey, int keytype,
59
int parameter_group,
60
const char *pass);
61
extern int vg_protect_decode_privkey(EC_KEY *pkey, int *keytype,
62
const char *encoded, const char *pass);
63
64
extern int vg_pkcs8_encode_privkey(char *out, int outlen,
65
const EC_KEY *pkey,
66
const char *pass);
67
extern int vg_pkcs8_decode_privkey(EC_KEY *pkey, const char *pem_in,
68
const char *pass);
69
70
extern int vg_decode_privkey_any(EC_KEY *pkey, int *addrtype,
71
const char *input, const char *pass);
72
73
extern int vg_read_password(char *buf, size_t size);
74
extern int vg_check_password_complexity(const char *pass, int verbose);
75
76
extern int vg_read_file(FILE *fp, char ***result, int *rescount);
77
78
#endif /* !defined (__VG_UTIL_H__) */
79
80