Module: OpenPGP

Includes:
OpenPGP::Armor::Markers
Defined in:
lib/openpgp.rb,
lib/openpgp/s2k.rb,
lib/openpgp/util.rb,
lib/openpgp/armor.rb,
lib/openpgp/random.rb,
lib/openpgp/buffer.rb,
lib/openpgp/engine.rb,
lib/openpgp/packet.rb,
lib/openpgp/cipher.rb,
lib/openpgp/digest.rb,
lib/openpgp/version.rb,
lib/openpgp/message.rb,
lib/openpgp/algorithm.rb,
lib/openpgp/cipher/aes.rb,
lib/openpgp/digest/md5.rb,
lib/openpgp/digest/sha2.rb,
lib/openpgp/cipher/idea.rb,
lib/openpgp/digest/sha1.rb,
lib/openpgp/cipher/3des.rb,
lib/openpgp/client/gnupg.rb,
lib/openpgp/engine/gnupg.rb,
lib/openpgp/cipher/cast5.rb,
lib/openpgp/digest/rmd160.rb,
lib/openpgp/cipher/twofish.rb,
lib/openpgp/engine/openssl.rb,
lib/openpgp/cipher/blowfish.rb

Defined Under Namespace

Modules: Algorithm, Armor, Client, Random, VERSION Classes: Buffer, Cipher, Digest, Engine, Message, Packet, S2K

Constant Summary

CRC24_INIT =
0x00b704ce
CRC24_POLY =
0x01864cfb

Constants included from OpenPGP::Armor::Markers

ARMORED_FILE, MESSAGE, PRIVATE_KEY_BLOCK, PUBLIC_KEY_BLOCK, SIGNATURE

Class Method Summary (collapse)

Class Method Details

+ (Integer) bitlength(data)

Returns the bit length of a multiprecision integer (MPI).

Parameters:

  • (String) data

Returns:

  • (Integer)

See Also:



66
67
68
# File 'lib/openpgp/util.rb', line 66

def self.bitlength(data)
  data.empty? ? 0 : (data.size - 1) * 8 + (Math.log(data[0].ord) / Math.log(2)).floor + 1
end

+ (Integer) crc24(data)



48
49
50
51
52
53
54
55
56
57
58
# File 'lib/openpgp/util.rb', line 48

def self.crc24(data)
  crc = CRC24_INIT
  data.each_byte do |octet|
    crc ^= octet << 16
    8.times do
      crc <<= 1
      crc ^= CRC24_POLY if (crc & 0x01000000).nonzero?
    end
  end
  crc &= 0x00ffffff
end

+ (Object) dearmor(text, marker = nil, options = {})

Alias for Armor.decode.



10
11
12
# File 'lib/openpgp/util.rb', line 10

def self.dearmor(text, marker = nil, options = {})
  Armor.decode(text, marker, options)
end

+ (Object) decrypt(data, options = {})

Alias for Message.decrypt.

Raises:

  • (NotImplementedError)


22
23
24
# File 'lib/openpgp/util.rb', line 22

def self.decrypt(data, options = {})
  raise NotImplementedError # TODO
end

+ (Object) enarmor(data, marker = :message, options = {})

Alias for Armor.encode.



4
5
6
# File 'lib/openpgp/util.rb', line 4

def self.enarmor(data, marker = :message, options = {})
  Armor.encode(data, marker, options)
end

+ (Object) encrypt(data, options = {})

Alias for Message.encrypt.



16
17
18
# File 'lib/openpgp/util.rb', line 16

def self.encrypt(data, options = {})
  (msg = Message.encrypt(data, options)) ? msg.to_s : nil
end

+ (Object) sign

Alias for sign.

Raises:

  • (NotImplementedError)


28
29
30
# File 'lib/openpgp/util.rb', line 28

def self.sign
  raise NotImplementedError # TODO
end

+ (Object) verify

Alias for verify.

Raises:

  • (NotImplementedError)


34
35
36
# File 'lib/openpgp/util.rb', line 34

def self.verify
  raise NotImplementedError # TODO
end