Sha256: 5ae96282d1dd28e39048650ca15224ba7d7a0758950ddd8d59bb2da204386abe

Contents?: true

Size: 605 Bytes

Versions: 3

Compression:

Stored size: 605 Bytes

Contents

#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
  );
}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ruby_nacl-0.1.2 ext/ruby_nacl/NaCl/crypto_sign/wrapper-sign-open.cpp
ruby_nacl-0.1.1 ext/ruby_nacl/NaCl/crypto_sign/wrapper-sign-open.cpp
ruby_nacl-0.1.0 ext/ruby_nacl/NaCl/crypto_sign/wrapper-sign-open.cpp