blob: 346e9400e586b1268b9a7fceac5676eb681d0e73 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#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
);
}
|