Botan 3.5.0
Crypto and TLS for C&
Botan::Ciphertext Class Reference

#include <kyber_structures.h>

Public Member Functions

PolynomialVectorb ()
 
 Ciphertext ()=delete
 
 Ciphertext (PolynomialVector b, const Polynomial &v, KyberConstants mode)
 
KyberCompressedCiphertext to_bytes ()
 
void to_bytes (StrongSpan< KyberCompressedCiphertext > out)
 
Polynomialv ()
 

Static Public Member Functions

static Ciphertext from_bytes (StrongSpan< const KyberCompressedCiphertext > buffer, const KyberConstants &mode)
 

Detailed Description

Definition at line 554 of file kyber_structures.h.

Constructor & Destructor Documentation

◆ Ciphertext() [1/2]

Botan::Ciphertext::Ciphertext ( )
delete

Referenced by from_bytes().

◆ Ciphertext() [2/2]

Botan::Ciphertext::Ciphertext ( PolynomialVector b,
const Polynomial & v,
KyberConstants mode )
inline

Definition at line 558 of file kyber_structures.h.

558 :
559 m_mode(std::move(mode)), m_b(std::move(b)), m_v(v) {}
PolynomialVector & b()

Member Function Documentation

◆ b()

PolynomialVector & Botan::Ciphertext::b ( )
inline

Definition at line 590 of file kyber_structures.h.

590{ return m_b; }

Referenced by Botan::Kyber_PrivateKeyInternal::indcpa_decrypt().

◆ from_bytes()

static Ciphertext Botan::Ciphertext::from_bytes ( StrongSpan< const KyberCompressedCiphertext > buffer,
const KyberConstants & mode )
inlinestatic

Definition at line 561 of file kyber_structures.h.

561 {
562 const size_t pvb = mode.polynomial_vector_compressed_bytes();
563 const size_t pcb = mode.polynomial_compressed_bytes();
564
565 if(buffer.size() != pvb + pcb) {
566 throw Decoding_Error("Kyber: unexpected ciphertext length");
567 }
568
569 BufferSlicer bs(buffer);
570 auto pv = bs.take(pvb);
571 auto p = bs.take(pcb);
572 BOTAN_ASSERT_NOMSG(bs.empty());
573
574 return Ciphertext(decompress_polynomial_vector(pv, mode), decompress_polynomial(p, mode), mode);
575 }
#define BOTAN_ASSERT_NOMSG(expr)
Definition assert.h:59

References BOTAN_ASSERT_NOMSG, Ciphertext(), Botan::BufferSlicer::empty(), Botan::KyberConstants::polynomial_compressed_bytes(), Botan::KyberConstants::polynomial_vector_compressed_bytes(), Botan::StrongSpan< T >::size(), and Botan::BufferSlicer::take().

Referenced by Botan::Kyber_KEM_Decryptor::decapsulate().

◆ to_bytes() [1/2]

KyberCompressedCiphertext Botan::Ciphertext::to_bytes ( )
inline

Definition at line 584 of file kyber_structures.h.

584 {
586 to_bytes(r);
587 return r;
588 }
KyberCompressedCiphertext to_bytes()
size_t encapsulated_key_length() const
Strong< std::vector< uint8_t >, struct KyberCompressedCiphertext_ > KyberCompressedCiphertext
Definition kyber_types.h:54

References Botan::KyberConstants::encapsulated_key_length(), and to_bytes().

Referenced by to_bytes().

◆ to_bytes() [2/2]

void Botan::Ciphertext::to_bytes ( StrongSpan< KyberCompressedCiphertext > out)
inline

Definition at line 577 of file kyber_structures.h.

577 {
578 BufferStuffer bs(out);
579 compress(bs.next(m_mode.polynomial_vector_compressed_bytes()), m_b, m_mode);
580 compress(bs.next(m_mode.polynomial_compressed_bytes()), m_v, m_mode);
581 BOTAN_ASSERT_NOMSG(bs.full());
582 }
size_t polynomial_vector_compressed_bytes() const
size_t polynomial_compressed_bytes() const

References BOTAN_ASSERT_NOMSG, Botan::BufferStuffer::full(), Botan::BufferStuffer::next(), Botan::KyberConstants::polynomial_compressed_bytes(), and Botan::KyberConstants::polynomial_vector_compressed_bytes().

◆ v()

Polynomial & Botan::Ciphertext::v ( )
inline

Definition at line 592 of file kyber_structures.h.

592{ return m_v; }

Referenced by Botan::Kyber_PrivateKeyInternal::indcpa_decrypt().


The documentation for this class was generated from the following file: