Roxen.git / server / etc / modules / License.pmod

version» Context lines:

Roxen.git/server/etc/modules/License.pmod:1:   // Roxen License framework.   //   // Created 2002-02-18 by Marcus Wellhardh.   // - // $Id: License.pmod,v 1.27 2008/08/15 12:33:54 mast Exp $ + // $Id$      #if constant(roxen)   #define INSIDE_ROXEN   #endif      constant have_feature_locking = 1;      int is_active(string license_dir)   // Returns true if the license system is enabled.   {
Roxen.git/server/etc/modules/License.pmod:167:    if(!d)    error("Malformed %s.\n", key_name);    return Gmp.mpz(d);    }       protected string encrypt(string msg)    {    Crypto.RSA rsa = Crypto.RSA()->    set_public_key(@read_public_key())->    set_private_key(read_private_key()); -  string sign = rsa->sha_sign(msg); -  return sprintf("%d:%s%s", sizeof(sign), msg, sign); +  // Emulate Crypto.RSA.sha_sign from earlier Pikes. +  string(8bit) digest = sprintf("%c%s%1H", 4, "sha1", Crypto.SHA1->hash(msg)); +  return rsa->raw_sign(digest)->digits(256);    }       protected string decrypt(string gibberish)    {    string s;    int size;       if(sscanf(gibberish, "%d:%s", size, s) != 2)    return 0;       string msg = s[..sizeof(s)-size-1];    string sign = s[sizeof(msg)..];       Crypto.RSA rsa = Crypto.RSA()->set_public_key(@read_public_key()); -  return rsa->sha_verify(msg, sign) && msg; +  // Emulate Crypto.RSA.sha_verify from earlier Pikes. +  string(8bit) digest = sprintf("%c%s%1H", 4, "sha1", Crypto.SHA1->hash(msg)); +  return rsa->raw_verify(digest, Gmp.mpz (sign, 256)) && msg;    }       int write()    {    string license_name = Stdio.append_path(license_dir, _filename);    string s = sprintf("Roxen License:\n %O\n-START-\n%s\n-END-\n",    content,    MIME.encode_base64(encrypt(encode_value(content))));    int bytes = Stdio.write_file(license_name, s);    chmod(license_name, 384);