summaryrefslogtreecommitdiff
path: root/nacl/crypto_sign/wrapper-sign.cpp
blob: f0624b76bc5ad5cbaea9593644d8cbe6d94748e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <string>
using std::string;
#include "crypto_sign.h"

string crypto_sign(const string &m_string, const string &sk_string)
{
  if (sk_string.size() != crypto_sign_SECRETKEYBYTES) throw "incorrect secret-key length";
  size_t mlen = m_string.size();
  unsigned char m[mlen+crypto_sign_BYTES];
  unsigned long long smlen;
  for (int i = 0;i < mlen;++i) m[i] = m_string[i];
  crypto_sign(
      m, 
      &smlen, 
      m, 
      mlen, 
      (const unsigned char *) sk_string.c_str()
      );
  return string(
      (char *) m,
      smlen
  );
}