Sha256: 08d5907bbe8d3e009ca6a2c0a79cf76211b558c6affd39a389b44a89936c0dd5

Contents?: true

Size: 1.44 KB

Versions: 1

Compression:

Stored size: 1.44 KB

Contents

require 'rubygems'

module NetPGP

class PublicKeyAlgorithm
  NONE = 0
  RSA = 1
  RSA_ENCRYPT_ONLY = 2
  RSA_SIGN_ONLY = 3
  ELGAMAL = 16
  DSA = 17
  ECDH = 18
  ECDSA = 19
  FORMERLY_ELGAMAL = 20

  def self.from_native(alg)
    raise if alg.class != Symbol
    LibNetPGP::PGP_PUBKEY_ALG_T[alg]
  end

  def self.to_native(alg)
    # avoid a warning on newer versions of ruby
    if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.4.0')
      raise if alg.class != Integer
    else
      raise if alg.class != Fixnum
    end
    LibNetPGP::PGP_PUBKEY_ALG_T[alg]
  end

end

class HashAlgorithm
  MD5 = 1
  SHA1 = 2
  RIPEMD = 3
  SHA256 = 8
  SHA384 = 9
  SHA512 = 10
  SHA224 = 11

  # see pgp_str_to_hash_alg
  STRING_MAPPING = {
    MD5 => 'md5',
    SHA1 => 'sha1',
    SHA256 => 'sha256',
    SHA384 => 'sha384',
    SHA512 => 'sha512'
  }

  def self.to_s(alg)
    STRING_MAPPING[alg]
  end

end

class SymmetricKeyAlgorithm
  PLAINTEXT = 0
  IDEA = 1
  TRIPLEDES = 2
  CAST5 = 3
  BLOWFISH = 4
  AES128 = 7
  AES192 = 8
  AES256 = 9
  TWOFISH256 = 10

  # see pgp_str_to_cipher
  STRING_MAPPING = {
    IDEA => 'idea',
    TRIPLEDES => 'tripledes',
    CAST5 => 'cast5',
    AES128 => 'aes128',
    AES256 => 'aes256'
  }

  def self.to_s(alg)
    STRING_MAPPING[alg]
  end

end

class StringToKeyUsage
  NONE = 0
  ENCRYPTED_AND_HASHED = 254
  ENCRYPTED = 255
end

class StringToKeySpecifier
  SIMPLE = 0
  SALTED = 1
  ITERATED_AND_SALTED = 3
end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
netpgp-0.0.1 lib/netpgp/highlevel/constants.rb