Module: OpenPGP

Includes:
Armor::Markers
Defined in:
lib/openpgp.rb,
lib/openpgp/s2k.rb,
lib/openpgp/util.rb,
lib/openpgp/armor.rb,
lib/openpgp/buffer.rb,
lib/openpgp/cipher.rb,
lib/openpgp/digest.rb,
lib/openpgp/engine.rb,
lib/openpgp/packet.rb,
lib/openpgp/random.rb,
lib/openpgp/message.rb,
lib/openpgp/version.rb,
lib/openpgp/algorithm.rb,
lib/openpgp/cipher/aes.rb,
lib/openpgp/digest/md5.rb,
lib/openpgp/cipher/3des.rb,
lib/openpgp/cipher/idea.rb,
lib/openpgp/digest/sha1.rb,
lib/openpgp/digest/sha2.rb,
lib/openpgp/cipher/cast5.rb,
lib/openpgp/client/gnupg.rb,
lib/openpgp/engine/gnupg.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 collapse

CRC24_INIT =
0x00b704ce
CRC24_POLY =
0x01864cfb

Constants included from Armor::Markers

Armor::Markers::ARMORED_FILE, Armor::Markers::MESSAGE, Armor::Markers::PRIVATE_KEY_BLOCK, Armor::Markers::PUBLIC_KEY_BLOCK, Armor::Markers::SIGNATURE

Class Method Summary collapse

Class Method Details

.bitlength(data) ⇒ Object

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



62
63
64
# File 'lib/openpgp/util.rb', line 62

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

.crc24(data) ⇒ Object



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

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

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

Alias for OpenPGP::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

.decrypt(data, options = {}) ⇒ Object

Alias for OpenPGP::Message.decrypt().

Raises:

  • (NotImplementedError)


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

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

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

Alias for OpenPGP::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

.encrypt(data, options = {}) ⇒ Object

Alias for OpenPGP::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

.signObject

Alias for OpenPGP::Message.sign().

Raises:

  • (NotImplementedError)


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

def self.sign
  raise NotImplementedError # TODO
end

.verifyObject

Alias for OpenPGP::Message.verify().

Raises:

  • (NotImplementedError)


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

def self.verify
  raise NotImplementedError # TODO
end