revert to std types
This commit is contained in:
parent
ac7ca49af5
commit
e4fbbe52b0
4 changed files with 20 additions and 19 deletions
|
|
@ -1,10 +1,10 @@
|
||||||
#ifndef _FC_BASE64_HPP
|
#ifndef _FC_BASE64_HPP
|
||||||
#define _FC_BASE64_HPP
|
#define _FC_BASE64_HPP
|
||||||
#include <fc/string.hpp>
|
#include <string>
|
||||||
|
|
||||||
namespace fc {
|
namespace fc {
|
||||||
fc::string base64_encode(unsigned char const* bytes_to_encode, unsigned int in_len);
|
std::string base64_encode(unsigned char const* bytes_to_encode, unsigned int in_len);
|
||||||
fc::string base64_encode( const fc::string& enc );
|
std::string base64_encode( const std::string& enc );
|
||||||
fc::string base64_decode( const fc::string& encoded_string);
|
std::string base64_decode( const std::string& encoded_string);
|
||||||
} // namespace fc
|
} // namespace fc
|
||||||
#endif // _FC_BASE64_HPP
|
#endif // _FC_BASE64_HPP
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#ifndef _FC_DH_HPP_
|
#ifndef _FC_DH_HPP_
|
||||||
#define _FC_DH_HPP_
|
#define _FC_DH_HPP_
|
||||||
#include <fc/vector.hpp>
|
//#include <fc/vector.hpp>
|
||||||
|
#include <vector>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
namespace fc {
|
namespace fc {
|
||||||
|
|
@ -10,13 +11,13 @@ namespace fc {
|
||||||
bool generate_params( int s, uint8_t g );
|
bool generate_params( int s, uint8_t g );
|
||||||
bool generate_pub_key();
|
bool generate_pub_key();
|
||||||
bool compute_shared_key( const char* buf, uint32_t s );
|
bool compute_shared_key( const char* buf, uint32_t s );
|
||||||
bool compute_shared_key( const fc::vector<char>& pubk);
|
bool compute_shared_key( const std::vector<char>& pubk);
|
||||||
bool validate();
|
bool validate();
|
||||||
|
|
||||||
fc::vector<char> p;
|
std::vector<char> p;
|
||||||
fc::vector<char> pub_key;
|
std::vector<char> pub_key;
|
||||||
fc::vector<char> priv_key;
|
std::vector<char> priv_key;
|
||||||
fc::vector<char> shared_key;
|
std::vector<char> shared_key;
|
||||||
bool valid;
|
bool valid;
|
||||||
uint8_t g;
|
uint8_t g;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -29,9 +29,9 @@
|
||||||
|
|
||||||
namespace fc {
|
namespace fc {
|
||||||
|
|
||||||
inline const fc::string& base64_chars()
|
inline const std::string& base64_chars()
|
||||||
{
|
{
|
||||||
static const fc::string m_base64_chars =
|
static const std::string m_base64_chars =
|
||||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||||
"abcdefghijklmnopqrstuvwxyz"
|
"abcdefghijklmnopqrstuvwxyz"
|
||||||
"0123456789+/";
|
"0123456789+/";
|
||||||
|
|
@ -42,15 +42,15 @@ static inline bool is_base64(unsigned char c) {
|
||||||
return (isalnum(c) || (c == '+') || (c == '/'));
|
return (isalnum(c) || (c == '+') || (c == '/'));
|
||||||
}
|
}
|
||||||
|
|
||||||
fc::string base64_encode(unsigned char const* bytes_to_encode, unsigned int in_len);
|
std::string base64_encode(unsigned char const* bytes_to_encode, unsigned int in_len);
|
||||||
|
|
||||||
fc::string base64_encode( const fc::string& enc ) {
|
std::string base64_encode( const std::string& enc ) {
|
||||||
char const* s = enc.c_str();
|
char const* s = enc.c_str();
|
||||||
return base64_encode( (unsigned char const*)s, enc.size() );
|
return base64_encode( (unsigned char const*)s, enc.size() );
|
||||||
}
|
}
|
||||||
fc::string base64_encode(unsigned char const* bytes_to_encode, unsigned int in_len) {
|
std::string base64_encode(unsigned char const* bytes_to_encode, unsigned int in_len) {
|
||||||
|
|
||||||
fc::string ret;
|
std::string ret;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int j = 0;
|
int j = 0;
|
||||||
unsigned char char_array_3[3];
|
unsigned char char_array_3[3];
|
||||||
|
|
@ -93,13 +93,13 @@ fc::string base64_encode(unsigned char const* bytes_to_encode, unsigned int in_l
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fc::string base64_decode(fc::string const& encoded_string) {
|
std::string base64_decode(std::string const& encoded_string) {
|
||||||
int in_len = encoded_string.size();
|
int in_len = encoded_string.size();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int j = 0;
|
int j = 0;
|
||||||
int in_ = 0;
|
int in_ = 0;
|
||||||
unsigned char char_array_4[4], char_array_3[3];
|
unsigned char char_array_4[4], char_array_3[3];
|
||||||
fc::string ret;
|
std::string ret;
|
||||||
|
|
||||||
while (in_len-- && ( encoded_string[in_] != '=') && is_base64(encoded_string[in_])) {
|
while (in_len-- && ( encoded_string[in_] != '=') && is_base64(encoded_string[in_])) {
|
||||||
char_array_4[i++] = encoded_string[in_]; in_++;
|
char_array_4[i++] = encoded_string[in_]; in_++;
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ namespace fc {
|
||||||
DH_free(dh);
|
DH_free(dh);
|
||||||
return valid = true;
|
return valid = true;
|
||||||
}
|
}
|
||||||
bool diffie_hellman::compute_shared_key( const fc::vector<char>& pubk ) {
|
bool diffie_hellman::compute_shared_key( const std::vector<char>& pubk ) {
|
||||||
return compute_shared_key( &pubk.front(), pubk.size() );
|
return compute_shared_key( &pubk.front(), pubk.size() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue