plebble
us::gov::crypto::symmetric_encryption Class Reference

#include <symmetric_encryption.h>

Collaboration diagram for us::gov::crypto::symmetric_encryption:

Public Types

typedef ec::keys keys
 
typedef unsigned char byte
 

Public Member Functions

ko init (const keys::priv_t &sk, const keys::pub_t &pub_other)
 
ko encrypt (const vector< unsigned char > &src, vector< unsigned char > &dest)
 
ko decrypt (const unsigned char *p, size_t sz, vector< unsigned char > &dest)
 
ko decrypt (const vector< unsigned char > &ciphertext, vector< unsigned char > &clear)
 
 symmetric_encryption ()
 
ko init (PrivateKey priv_a, PublicKey pub_b)
 
int get_key_size ()
 
pair< ko, byte[]> encrypt (byte[] plaintext)
 
pair< ko, byte[]> decrypt (byte[] encrypted, int offset, int length)
 
pair< ko, byte[]> decrypt (byte[] encrypted)
 

Static Public Member Functions

static int encmsg_ratio (const size_t plaintext_sz)
 
static size_t encmsg_max_sz (const size_t plaintext_sz)
 
static boolean test ()
 
static boolean test (String plaintext)
 
static boolean test (String plaintext_string, PrivateKey priv_a, PublicKey pub_b, PrivateKey priv_b, PublicKey pub_a)
 

Public Attributes

AutoSeededRandomPool prng_
 
byte key_ [key_size]
 
byte iv_ [iv_size]
 
GCM< AES >::Encryption enc
 
GCM< AES >::Decryption dec
 

Static Public Attributes

static constexpr size_t key_size = 16
 
static constexpr size_t iv_size = 12
 
static constexpr int tag_size = 16
 
static final int iv_size = 12
 
static final int key_size = 16
 
static final ko KO_89601 =new ko("KO 89601 Invalid length.")
 
static final ko KO_40751 =new ko("KO 40751 Unable to decrypt.")
 
static final ko KO_44302 =new ko("KO 40751 Unable to encrypt.")
 

Package Attributes

Cipher enc
 
Cipher dec
 
byte[] key
 
byte[] iv = new byte[iv_size]
 

Static Package Attributes

static final SecureRandom random = new SecureRandom()
 

Member Typedef Documentation

◆ byte

◆ keys

Constructor & Destructor Documentation

◆ symmetric_encryption()

us.gov.crypto.symmetric_encryption.symmetric_encryption ( )
inline

Member Function Documentation

◆ decrypt() [1/4]

pair<ko, byte[]> us.gov.crypto.symmetric_encryption.decrypt ( byte[]  encrypted)
inline

References decrypt().

Here is the call graph for this function:

◆ decrypt() [2/4]

pair<ko, byte[]> us.gov.crypto.symmetric_encryption.decrypt ( byte[]  encrypted,
int  offset,
int  length 
)
inline

References dec, iv_size, key, KO_40751, KO_89601, us.ok, and random.

◆ decrypt() [3/4]

ko us::gov::crypto::symmetric_encryption::decrypt ( const unsigned char *  p,
size_t  sz,
vector< unsigned char > &  dest 
)

Referenced by decrypt(), and us::gov::socket::datagram::decrypt().

Here is the caller graph for this function:

◆ decrypt() [4/4]

ko us::gov::crypto::symmetric_encryption::decrypt ( const vector< unsigned char > &  ciphertext,
vector< unsigned char > &  clear 
)

◆ encmsg_max_sz()

static size_t us::gov::crypto::symmetric_encryption::encmsg_max_sz ( const size_t  plaintext_sz)
static

◆ encmsg_ratio()

static int us::gov::crypto::symmetric_encryption::encmsg_ratio ( const size_t  plaintext_sz)
static

◆ encrypt() [1/2]

pair<ko, byte[]> us.gov.crypto.symmetric_encryption.encrypt ( byte[]  plaintext)
inline

References enc, iv, key, KO_44302, us.ok, and random.

◆ encrypt() [2/2]

ko us::gov::crypto::symmetric_encryption::encrypt ( const vector< unsigned char > &  src,
vector< unsigned char > &  dest 
)

Referenced by us::gov::socket::datagram::encrypt().

Here is the caller graph for this function:

◆ get_key_size()

int us.gov.crypto.symmetric_encryption.get_key_size ( )
inline

References key_size.

◆ init() [1/2]

ko us::gov::crypto::symmetric_encryption::init ( const keys::priv_t sk,
const keys::pub_t pub_other 
)

Referenced by us::gov::id::peer_t::turn_on_encryption().

Here is the caller graph for this function:

◆ init() [2/2]

ko us.gov.crypto.symmetric_encryption.init ( PrivateKey  priv_a,
PublicKey  pub_b 
)
inline

References dec, enc, us::gov::crypto::ec.generate_shared_key(), us::gov::crypto::ec.instance, key, key_size, and us.ok.

Here is the call graph for this function:

◆ test() [1/3]

static boolean us.gov.crypto.symmetric_encryption.test ( )
inlinestatic

Referenced by us.gov.crypto.test.symmetric_encryption.main(), us.wallet.cli.hmi.test(), and test().

Here is the caller graph for this function:

◆ test() [2/3]

static boolean us.gov.crypto.symmetric_encryption.test ( String  plaintext)
inlinestatic

References us::gov::crypto::ec.generate_keypair(), us::gov::crypto::ec.instance, and test().

Here is the call graph for this function:

◆ test() [3/3]

static boolean us.gov.crypto.symmetric_encryption.test ( String  plaintext_string,
PrivateKey  priv_a,
PublicKey  pub_b,
PrivateKey  priv_b,
PublicKey  pub_a 
)
inlinestatic

References us.pair< f, s >.first, us.ko.is_ko(), us.ok, and us.pair< f, s >.second.

Here is the call graph for this function:

Member Data Documentation

◆ dec [1/2]

GCM<AES>::Decryption us::gov::crypto::symmetric_encryption::dec

Referenced by decrypt(), and init().

◆ dec [2/2]

Cipher us.gov.crypto.symmetric_encryption.dec
package

◆ enc [1/2]

GCM<AES>::Encryption us::gov::crypto::symmetric_encryption::enc

Referenced by encrypt(), and init().

◆ enc [2/2]

Cipher us.gov.crypto.symmetric_encryption.enc
package

◆ iv

byte [] us.gov.crypto.symmetric_encryption.iv = new byte[iv_size]
package

Referenced by encrypt().

◆ iv_

byte us::gov::crypto::symmetric_encryption::iv_[iv_size]

◆ iv_size [1/2]

constexpr size_t us::gov::crypto::symmetric_encryption::iv_size = 12
staticconstexpr

◆ iv_size [2/2]

final int us.gov.crypto.symmetric_encryption.iv_size = 12
static

◆ key

byte [] us.gov.crypto.symmetric_encryption.key
package

Referenced by decrypt(), encrypt(), and init().

◆ key_

byte us::gov::crypto::symmetric_encryption::key_[key_size]

◆ key_size [1/2]

constexpr size_t us::gov::crypto::symmetric_encryption::key_size = 16
staticconstexpr

Referenced by get_key_size(), and init().

◆ key_size [2/2]

final int us.gov.crypto.symmetric_encryption.key_size = 16
static

◆ KO_40751

final ko us.gov.crypto.symmetric_encryption.KO_40751 =new ko("KO 40751 Unable to decrypt.")
static

◆ KO_44302

final ko us.gov.crypto.symmetric_encryption.KO_44302 =new ko("KO 40751 Unable to encrypt.")
static

Referenced by encrypt().

◆ KO_89601

final ko us.gov.crypto.symmetric_encryption.KO_89601 =new ko("KO 89601 Invalid length.")
static

◆ prng_

AutoSeededRandomPool us::gov::crypto::symmetric_encryption::prng_

◆ random

final SecureRandom us.gov.crypto.symmetric_encryption.random = new SecureRandom()
staticpackage

Referenced by decrypt(), and encrypt().

◆ tag_size

constexpr int us::gov::crypto::symmetric_encryption::tag_size = 16
staticconstexpr

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