Moving crypto stuff to libp2p
This commit is contained in:
parent
cba5d5cf20
commit
eb2ed30a24
151 changed files with 80 additions and 85349 deletions
|
@ -1,41 +0,0 @@
|
|||
//
|
||||
// base64.h
|
||||
// c-ipfs
|
||||
//
|
||||
// Created by John Jones on 10/31/16.
|
||||
// Copyright © 2016 JMJAtlanta. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef base64_h
|
||||
#define base64_h
|
||||
|
||||
#include <stdio.h>
|
||||
#include "mbedtls/base64.h"
|
||||
|
||||
/**
|
||||
* encode using base64
|
||||
* @param input_data the data to be encoded
|
||||
* @param input_length the length of the input data
|
||||
* @param output_data where the data is to be stored
|
||||
* @param max_output_length the max size of the output_data
|
||||
* @param bytes_written the number of bytes written to output_data
|
||||
* @returns true(1) on success, otherwise false
|
||||
*/
|
||||
int base64_encode(const unsigned char* input_data, size_t input_length, unsigned char* output_data, size_t max_output_length, size_t* bytes_written);
|
||||
|
||||
size_t base64_encode_length(const unsigned char* input_data, size_t input_length);
|
||||
|
||||
/**
|
||||
* decode something that was encoded as base64
|
||||
* @param input_data the data to decode
|
||||
* @param input_length the length of the input data
|
||||
* @param output_data the buffer to store the output
|
||||
* @param max_output_length the length of the output buffer
|
||||
* @param bytes_written the number of bytes written to output_data
|
||||
* @returns a pointer to the decoded data
|
||||
*/
|
||||
int base64_decode(const unsigned char* input_data, size_t input_length, unsigned char* output_data, size_t max_output_length, size_t* bytes_written);
|
||||
|
||||
size_t base64_decode_length(const unsigned char* input_data, size_t input_length);
|
||||
|
||||
#endif /* base64_h */
|
|
@ -9,35 +9,11 @@
|
|||
#ifndef __REPO_CONFIG_IDENTITY_H__
|
||||
#define __REPO_CONFIG_IDENTITY_H__
|
||||
|
||||
struct PublicKey {
|
||||
unsigned long long modulus;
|
||||
unsigned long long exponent;
|
||||
};
|
||||
|
||||
struct CRTValue {
|
||||
unsigned long long exponent;
|
||||
unsigned long long coefficient;
|
||||
unsigned long long r;
|
||||
};
|
||||
|
||||
struct PrecomputedValues {
|
||||
unsigned long long dp;
|
||||
unsigned long long dq;
|
||||
unsigned long long q_inv;
|
||||
struct CRTValue** crt_values;
|
||||
};
|
||||
|
||||
struct PrivateKey {
|
||||
struct PublicKey public_key;
|
||||
unsigned long long private_exponent;
|
||||
unsigned long long prime1;
|
||||
unsigned long long prime2;
|
||||
struct PrecomputedValues precomputed_values;
|
||||
};
|
||||
#include "libp2p/crypto/rsa.h"
|
||||
|
||||
struct Identity {
|
||||
char* peer_id; // a pretty-printed hash of the public key
|
||||
struct PrivateKey private_key; // a private key
|
||||
struct RsaPrivateKey private_key; // a private key
|
||||
};
|
||||
|
||||
/***
|
||||
|
|
21
include/ipfs/repo/config/peer.h
Normal file
21
include/ipfs/repo/config/peer.h
Normal file
|
@ -0,0 +1,21 @@
|
|||
//
|
||||
// peer.h
|
||||
// c-ipfs
|
||||
//
|
||||
// Created by John Jones on 11/3/16.
|
||||
// Copyright © 2016 JMJAtlanta. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef peer_h
|
||||
#define peer_h
|
||||
|
||||
|
||||
/***
|
||||
* given a public key, find the peer id
|
||||
* @param public_key the public key in bytes
|
||||
* @param id the resultant peer id
|
||||
* @returns true(1) on success
|
||||
*/
|
||||
int repo_config_peer_id_from_public_key(char* public_key, char* id);
|
||||
|
||||
#endif /* peer_h */
|
Loading…
Add table
Add a link
Reference in a new issue