You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
83 lines
3.0 KiB
83 lines
3.0 KiB
10 years ago
|
/*
|
||
7 years ago
|
* This file is part of the TREZOR project, https://trezor.io/
|
||
10 years ago
|
*
|
||
|
* Copyright (C) 2014 Pavol Rusnak <stick@satoshilabs.com>
|
||
|
*
|
||
|
* This library is free software: you can redistribute it and/or modify
|
||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||
|
* the Free Software Foundation, either version 3 of the License, or
|
||
|
* (at your option) any later version.
|
||
|
*
|
||
|
* This library is distributed in the hope that it will be useful,
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
* GNU Lesser General Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU Lesser General Public License
|
||
|
* along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||
|
*/
|
||
|
|
||
|
#ifndef __CRYPTO_H__
|
||
|
#define __CRYPTO_H__
|
||
|
|
||
6 years ago
|
#include <bip32.h>
|
||
|
#include <ecdsa.h>
|
||
|
#include <pb.h>
|
||
|
#include <sha2.h>
|
||
10 years ago
|
#include <stdbool.h>
|
||
|
#include <stdint.h>
|
||
|
#include <stdlib.h>
|
||
7 years ago
|
#include "coins.h"
|
||
7 years ago
|
#include "hasher.h"
|
||
6 years ago
|
#include "messages-bitcoin.pb.h"
|
||
|
#include "messages-crypto.pb.h"
|
||
10 years ago
|
|
||
7 years ago
|
#define ser_length_size(len) ((len) < 253 ? 1 : (len) < 0x10000 ? 3 : 5)
|
||
|
|
||
10 years ago
|
uint32_t ser_length(uint32_t len, uint8_t *out);
|
||
|
|
||
7 years ago
|
uint32_t ser_length_hash(Hasher *hasher, uint32_t len);
|
||
10 years ago
|
|
||
6 years ago
|
int sshMessageSign(HDNode *node, const uint8_t *message, size_t message_len,
|
||
|
uint8_t *signature);
|
||
9 years ago
|
|
||
6 years ago
|
int gpgMessageSign(HDNode *node, const uint8_t *message, size_t message_len,
|
||
|
uint8_t *signature);
|
||
9 years ago
|
|
||
6 years ago
|
int cryptoMessageSign(const CoinInfo *coin, HDNode *node,
|
||
|
InputScriptType script_type, const uint8_t *message,
|
||
|
size_t message_len, uint8_t *signature);
|
||
10 years ago
|
|
||
6 years ago
|
int cryptoMessageVerify(const CoinInfo *coin, const uint8_t *message,
|
||
|
size_t message_len, const char *address,
|
||
|
const uint8_t *signature);
|
||
10 years ago
|
|
||
8 years ago
|
/* ECIES disabled
|
||
6 years ago
|
int cryptoMessageEncrypt(curve_point *pubkey, const uint8_t *msg, size_t
|
||
|
msg_size, bool display_only, uint8_t *nonce, size_t *nonce_len, uint8_t
|
||
|
*payload, size_t *payload_len, uint8_t *hmac, size_t *hmac_len, const uint8_t
|
||
|
*privkey, const uint8_t *address_raw);
|
||
|
|
||
|
int cryptoMessageDecrypt(curve_point *nonce, uint8_t *payload, size_t
|
||
|
payload_len, const uint8_t *hmac, size_t hmac_len, const uint8_t *privkey,
|
||
|
uint8_t *msg, size_t *msg_len, bool *display_only, bool *signing, uint8_t
|
||
|
*address_raw);
|
||
8 years ago
|
*/
|
||
10 years ago
|
|
||
6 years ago
|
const HDNode *cryptoMultisigPubkey(const CoinInfo *coin,
|
||
|
const MultisigRedeemScriptType *multisig,
|
||
|
uint32_t index);
|
||
6 years ago
|
|
||
|
uint32_t cryptoMultisigPubkeyCount(const MultisigRedeemScriptType *multisig);
|
||
10 years ago
|
|
||
6 years ago
|
int cryptoMultisigPubkeyIndex(const CoinInfo *coin,
|
||
|
const MultisigRedeemScriptType *multisig,
|
||
|
const uint8_t *pubkey);
|
||
10 years ago
|
|
||
6 years ago
|
int cryptoMultisigFingerprint(const MultisigRedeemScriptType *multisig,
|
||
|
uint8_t *hash);
|
||
10 years ago
|
|
||
10 years ago
|
int cryptoIdentityFingerprint(const IdentityType *identity, uint8_t *hash);
|
||
|
|
||
10 years ago
|
#endif
|