Exemplo n.º 1
0
    bool generate_keys( char* pubkey, fc::vector<char>& privkey, uint32_t key_size, uint32_t pe )
    {
        static bool init = true;
        if( init ) { ERR_load_crypto_strings(); init = false; }

        RSA* rsa = RSA_generate_key( key_size, pe, NULL, NULL );
        BN_bn2bin( rsa->n, (unsigned char*)pubkey );

        BIO *mem = BIO_new(BIO_s_mem());
        int e = PEM_write_bio_RSAPrivateKey(mem, rsa,  NULL, NULL, 0, NULL, NULL ); 
        if( e != 1 )
        {
            BIO_free(mem);
            RSA_free(rsa);
		        FC_THROW(generic_exception("Error writing PrivateKey") );
        }

        char* dat;
        uint32_t l = BIO_get_mem_data( mem, &dat );
        privkey.resize(l);
        memcpy( &privkey.front(), dat, l );

        BIO_free(mem);
        RSA_free(rsa);
        return true;
    }
Exemplo n.º 2
0
 virtual expr visit_macro(expr const & e) override {
     buffer<expr> new_args;
     for (unsigned i = 0; i < macro_num_args(e); i++)
         new_args.push_back(visit(macro_arg(e, i)));
     auto def = macro_def(e);
     expr r = update_macro(e, new_args.size(), new_args.data());
     if (!m_trust_lvl || def.trust_level() >= *m_trust_lvl) {
         if (optional<expr> new_r = m_ctx.expand_macro(r)) {
             return visit(*new_r);
         } else {
             throw generic_exception(e, "failed to expand macro");
         }
     } else {
         return r;
     }
 }
Exemplo n.º 3
0
 [[ noreturn ]] void throw_error(sstream const & strm) {
     throw generic_exception(m_ref, strm);
 }