3 require 'opencorn/config'
15 @seed = OpenSSL::Random::random_bytes(128)
16 gpgdata = GPGME::Data.from_str(@seed)
17 gpgkeys = GPGME.list_keys(OpenCorn::Config['GPG_LOG_KEYID'])
18 raise "Too many keys for this KeyID" unless gpgkeys.size == 1
19 gpgout = GPGME.encrypt(gpgkeys,gpgdata)
20 #preceding 00 01 indicates a new seed for the prng encrypted with
21 writeLog("\x00\x01"+Base64::encode64(gpgout))
22 puts "OpenCorn::Log initialized"
27 [ctx.digest("0"+seed),ctx.digest("1"+seed)]
31 fp = File.open(OpenCorn::Config['LOG_FILE'],"a")
37 @seed,out = prng(@seed)
43 ctx = OpenSSL::Cipher::AES256.new("OFB")
44 ctx.iv = myrand[0..15] #128bit iv
45 ctx.key = myrand[16..47] #256bit key
46 ctext = ctx.update(msg)+ctx.final()
47 out = OpenSSL::HMAC.digest("SHA1",myrand[48..63],ctext)+ctext
48 #preceding 00 indicates that the base64 string is as symmetric
50 writeLog("\x00"+Base64::encode64(out))