2016-10-31 16:13:42 +00:00
|
|
|
//
|
|
|
|
// identity.h
|
|
|
|
// c-ipfs
|
|
|
|
//
|
|
|
|
// Created by John Jones on 10/27/16.
|
|
|
|
// Copyright © 2016 JMJAtlanta. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef __REPO_CONFIG_IDENTITY_H__
|
|
|
|
#define __REPO_CONFIG_IDENTITY_H__
|
|
|
|
|
2016-11-03 15:22:17 +00:00
|
|
|
#include "libp2p/crypto/rsa.h"
|
2016-10-31 22:19:27 +00:00
|
|
|
|
2016-10-31 16:13:42 +00:00
|
|
|
struct Identity {
|
2016-10-31 22:19:27 +00:00
|
|
|
char* peer_id; // a pretty-printed hash of the public key
|
2016-11-03 15:22:17 +00:00
|
|
|
struct RsaPrivateKey private_key; // a private key
|
2016-10-31 16:13:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/***
|
|
|
|
* initializes a new keypair, and puts it in the Identity struct
|
|
|
|
*/
|
2016-11-17 20:07:59 +00:00
|
|
|
int repo_config_identity_init(struct Identity* identity, unsigned long num_bits_for_keypair);
|
|
|
|
|
|
|
|
/***
|
|
|
|
* Build a RsaPrivateKey struct from a base64 string of the private key
|
|
|
|
* @param identity where to put the new struct
|
|
|
|
* @param base64 the base 64 encoded private key in DER format
|
|
|
|
* @returns true(1) on success
|
|
|
|
*/
|
|
|
|
int repo_config_identity_build_private_key(struct Identity* identity, const char* base64);
|
2016-10-31 16:13:42 +00:00
|
|
|
|
2016-11-10 13:28:51 +00:00
|
|
|
/***
|
|
|
|
* Frees resources held by Identity
|
|
|
|
* @param identity the identity that we're cleaning up
|
|
|
|
* @returns true(0)
|
|
|
|
*/
|
|
|
|
int repo_config_identity_free(struct Identity* identity);
|
|
|
|
|
2016-11-17 20:07:59 +00:00
|
|
|
/***
|
|
|
|
* Initializes a new identity struct that will need to be identity_free'd
|
|
|
|
* @param identity the identity to allocate memory for
|
|
|
|
* @returns true(1) on success
|
|
|
|
*/
|
|
|
|
int repo_config_identity_new(struct Identity** identity);
|
|
|
|
|
2016-10-31 16:13:42 +00:00
|
|
|
#endif /* identity_h */
|