mirror of
https://github.com/servalproject/serval-dna.git
synced 2024-12-30 18:07:01 +00:00
bf9710fd5a
This only affects build_android, if nacl-gcc-prep is run then build/`uname -s` will be created.
25 lines
605 B
C++
25 lines
605 B
C++
#include <string>
|
|
using std::string;
|
|
#include "crypto_sign.h"
|
|
|
|
string crypto_sign_open(const string &sm_string, const string &pk_string)
|
|
{
|
|
if (pk_string.size() != crypto_sign_PUBLICKEYBYTES) throw "incorrect public-key length";
|
|
size_t smlen = sm_string.size();
|
|
unsigned char m[smlen];
|
|
unsigned long long mlen;
|
|
for (int i = 0;i < smlen;++i) m[i] = sm_string[i];
|
|
if (crypto_sign_open(
|
|
m,
|
|
&mlen,
|
|
m,
|
|
smlen,
|
|
(const unsigned char *) pk_string.c_str()
|
|
) != 0)
|
|
throw "ciphertext fails verification";
|
|
return string(
|
|
(char *) m,
|
|
mlen
|
|
);
|
|
}
|