Module: Botan::PK

Defined in:
lib/botan/pk/mceies.rb,
lib/botan/pk/op/sign.rb,
lib/botan/pk/op/verify.rb,
lib/botan/pk/publickey.rb,
lib/botan/pk/op/decrypt.rb,
lib/botan/pk/op/encrypt.rb,
lib/botan/pk/privatekey.rb,
lib/botan/pk/op/keyagreement.rb

Defined Under Namespace

Classes: Decrypt, Encrypt, KeyAgreement, PrivateKey, PublicKey, Sign, Verify

Class Method Summary collapse

Class Method Details

.mceies_decrypt(private_key:, ciphertext:, ad:, aead: DEFAULT_AEAD) ⇒ String

Decrypts with McEliece.

Parameters:

  • private_key (Botan::PK::PrivateKey)

    the private key

  • ciphertext (String)

    the data to decrypt

  • ad (String)

    the associated data

  • aead (String) (defaults to: DEFAULT_AEAD)

    the (AEAD) cipher+mode

Returns:

  • (String)

    the decrypted data



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/botan/pk/mceies.rb', line 45

def self.mceies_decrypt(private_key:, ciphertext:, ad:,
                        aead: DEFAULT_AEAD)
  ct_buf = FFI::MemoryPointer.from_data(ciphertext)
  ad_buf = FFI::MemoryPointer.from_data(ad)
  Botan.call_ffi_with_buffer(lambda { |b, bl|
    LibBotan.botan_mceies_decrypt(private_key.ptr,
                                  aead,
                                  ct_buf,
                                  ct_buf.size,
                                  ad_buf,
                                  ad.size,
                                  b,
                                  bl)
  })
end

.mceies_encrypt(public_key:, plaintext:, ad:, aead: DEFAULT_AEAD, rng: Botan::RNG.new) ⇒ String

Encrypts with McEliece.

Parameters:

  • public_key (Botan::PK::PublicKey)

    the public key

  • plaintext (String)

    the data to encrypt

  • ad (String)

    the associated data

  • aead (String) (defaults to: DEFAULT_AEAD)

    the (AEAD) cipher+mode

  • rng (Botan::RNG) (defaults to: Botan::RNG.new)

    the RNG to use

Returns:

  • (String)

    the encrypted data



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/botan/pk/mceies.rb', line 20

def self.mceies_encrypt(public_key:, plaintext:, ad:,
                        aead: DEFAULT_AEAD,
                        rng: Botan::RNG.new)
  pt_buf = FFI::MemoryPointer.from_data(plaintext)
  ad_buf = FFI::MemoryPointer.from_data(ad)
  Botan.call_ffi_with_buffer(lambda { |b, bl|
    LibBotan.botan_mceies_encrypt(public_key.ptr,
                                  rng.ptr,
                                  aead,
                                  pt_buf,
                                  pt_buf.size,
                                  ad_buf,
                                  ad_buf.size,
                                  b,
                                  bl)
  })
end