Functions | Variables
gsec.cc File Reference
#include <grpc/support/port_platform.h>
#include "src/core/tsi/alts/crypt/gsec.h"
#include <stdio.h>
#include <string.h>
#include <grpc/support/alloc.h>
Include dependency graph for gsec.cc:

Go to the source code of this file.

Functions

grpc_status_code gsec_aead_crypter_decrypt (gsec_aead_crypter *crypter, const uint8_t *nonce, size_t nonce_length, const uint8_t *aad, size_t aad_length, const uint8_t *ciphertext_and_tag, size_t ciphertext_and_tag_length, uint8_t *plaintext, size_t plaintext_length, size_t *bytes_written, char **error_details)
 
grpc_status_code gsec_aead_crypter_decrypt_iovec (gsec_aead_crypter *crypter, const uint8_t *nonce, size_t nonce_length, const struct iovec *aad_vec, size_t aad_vec_length, const struct iovec *ciphertext_vec, size_t ciphertext_vec_length, struct iovec plaintext_vec, size_t *plaintext_bytes_written, char **error_details)
 
void gsec_aead_crypter_destroy (gsec_aead_crypter *crypter)
 
grpc_status_code gsec_aead_crypter_encrypt (gsec_aead_crypter *crypter, const uint8_t *nonce, size_t nonce_length, const uint8_t *aad, size_t aad_length, const uint8_t *plaintext, size_t plaintext_length, uint8_t *ciphertext_and_tag, size_t ciphertext_and_tag_length, size_t *bytes_written, char **error_details)
 
grpc_status_code gsec_aead_crypter_encrypt_iovec (gsec_aead_crypter *crypter, const uint8_t *nonce, size_t nonce_length, const struct iovec *aad_vec, size_t aad_vec_length, const struct iovec *plaintext_vec, size_t plaintext_vec_length, struct iovec ciphertext_vec, size_t *ciphertext_bytes_written, char **error_details)
 
grpc_status_code gsec_aead_crypter_key_length (const gsec_aead_crypter *crypter, size_t *key_length_to_return, char **error_details)
 
grpc_status_code gsec_aead_crypter_max_ciphertext_and_tag_length (const gsec_aead_crypter *crypter, size_t plaintext_length, size_t *max_ciphertext_and_tag_length_to_return, char **error_details)
 
grpc_status_code gsec_aead_crypter_max_plaintext_length (const gsec_aead_crypter *crypter, size_t ciphertext_and_tag_length, size_t *max_plaintext_length_to_return, char **error_details)
 
grpc_status_code gsec_aead_crypter_nonce_length (const gsec_aead_crypter *crypter, size_t *nonce_length_to_return, char **error_details)
 
grpc_status_code gsec_aead_crypter_tag_length (const gsec_aead_crypter *crypter, size_t *tag_length_to_return, char **error_details)
 
static void maybe_copy_error_msg (const char *src, char **dst)
 

Variables

static const char vtable_error_msg []
 

Function Documentation

◆ gsec_aead_crypter_decrypt()

grpc_status_code gsec_aead_crypter_decrypt ( gsec_aead_crypter crypter,
const uint8_t nonce,
size_t  nonce_length,
const uint8_t aad,
size_t  aad_length,
const uint8_t ciphertext_and_tag,
size_t  ciphertext_and_tag_length,
uint8_t plaintext,
size_t  plaintext_length,
size_t *  bytes_written,
char **  error_details 
)

This method performs an AEAD decrypt operation.

  • crypter: AEAD crypter instance.
  • nonce: buffer containing a nonce with its size equal to nonce_length.
  • nonce_length: size of nonce buffer, and must be equal to the value returned from method gsec_aead_crypter_nonce_length.
  • aad: buffer containing data that needs to be authenticated only.
  • aad_length: size of aad buffer, which should be zero if the buffer is nullptr.
  • ciphertext_and_tag: buffer containing ciphertext and tag.
  • ciphertext_and_tag_length: length of ciphertext and tag. It should be zero if any of plaintext, ciphertext_and_tag, or bytes_written is nullptr. Also, ciphertext_and_tag_length should be at least as large as the tag length set at AEAD crypter instance construction time.
  • plaintext: buffer containing decrypted and authenticated data the method produced. The buffer should not overlap with the ciphertext+tag buffer, and pointers to those buffers should not be equal.
  • plaintext_length: size of plaintext buffer, which should be at least as long as the one returned from gsec_aead_crypter_max_plaintext_length method.
  • bytes_written: the actual number of bytes written to the plaintext buffer.
  • error_details: a buffer containing an error message if the method does not function correctly. It is legal to pass nullptr into error_details, and otherwise, the parameter should be freed with gpr_free.

On the success of decryption, the method returns GRPC_STATUS_OK. Otherwise, it returns an error status code along with its details specified in error_details (if error_details is not nullptr).

Definition at line 78 of file gsec.cc.

◆ gsec_aead_crypter_decrypt_iovec()

grpc_status_code gsec_aead_crypter_decrypt_iovec ( gsec_aead_crypter crypter,
const uint8_t nonce,
size_t  nonce_length,
const struct iovec aad_vec,
size_t  aad_vec_length,
const struct iovec ciphertext_vec,
size_t  ciphertext_vec_length,
struct iovec  plaintext_vec,
size_t *  plaintext_bytes_written,
char **  error_details 
)

This method performs an AEAD decrypt operation.

  • crypter: AEAD crypter instance.
  • nonce: buffer containing a nonce with its size equal to nonce_length.
  • nonce_length: size of nonce buffer, and must be equal to the value returned from method gsec_aead_crypter_nonce_length.
  • aad_vec: an iovec array containing data that needs to be authenticated but not encrypted.
  • aad_vec_length: the array length of aad_vec.
  • ciphertext_vec: an iovec array containing the ciphertext and tag.
  • ciphertext_vec_length: the array length of ciphertext_vec.
  • plaintext_vec: an iovec containing a plaintext buffer. The buffer should not overlap the ciphertext buffer.
  • plaintext_bytes_written: the actual number of bytes written to plaintext_vec.
  • error_details: a buffer containing an error message if the method does not function correctly. It is legal to pass nullptr into error_details, and otherwise, the parameter should be freed with gpr_free.

On the success of decryption, the method returns GRPC_STATUS_OK. Otherwise, it returns an error status code along with its details specified in error_details (if error_details is not nullptr).

Definition at line 98 of file gsec.cc.

◆ gsec_aead_crypter_destroy()

void gsec_aead_crypter_destroy ( gsec_aead_crypter crypter)

This method destroys an AEAD crypter instance by de-allocating all of its occupied memory.

  • crypter: AEAD crypter instance that needs to be destroyed.

Definition at line 183 of file gsec.cc.

◆ gsec_aead_crypter_encrypt()

grpc_status_code gsec_aead_crypter_encrypt ( gsec_aead_crypter crypter,
const uint8_t nonce,
size_t  nonce_length,
const uint8_t aad,
size_t  aad_length,
const uint8_t plaintext,
size_t  plaintext_length,
uint8_t ciphertext_and_tag,
size_t  ciphertext_and_tag_length,
size_t *  bytes_written,
char **  error_details 
)

This method performs an AEAD encrypt operation.

  • crypter: AEAD crypter instance.
  • nonce: buffer containing a nonce with its size equal to nonce_length.
  • nonce_length: size of nonce buffer, and must be equal to the value returned from method gsec_aead_crypter_nonce_length.
  • aad: buffer containing data that needs to be authenticated but not encrypted with its size equal to aad_length.
  • aad_length: size of aad buffer, which should be zero if the buffer is nullptr.
  • plaintext: buffer containing data that needs to be both encrypted and authenticated with its size equal to plaintext_length.
  • plaintext_length: size of plaintext buffer, which should be zero if plaintext is nullptr.
  • ciphertext_and_tag: buffer that will contain ciphertext and tags the method produced. The buffer should not overlap the plaintext buffer, and pointers to those buffers should not be equal. Also if the ciphertext+tag buffer is nullptr, the plaintext_length should be zero.
  • ciphertext_and_tag_length: size of ciphertext+tag buffer, which should be at least as long as the one returned from method gsec_aead_crypter_max_ciphertext_and_tag_length.
  • bytes_written: the actual number of bytes written to the ciphertext+tag buffer. If bytes_written is nullptr, the plaintext_length should be zero.
  • error_details: a buffer containing an error message if the method does not function correctly. It is legal to pass nullptr into error_details, and otherwise, the parameter should be freed with gpr_free.

On the success of encryption, the method returns GRPC_STATUS_OK. Otherwise, it returns an error status code along with its details specified in error_details (if error_details is not nullptr).

Definition at line 38 of file gsec.cc.

◆ gsec_aead_crypter_encrypt_iovec()

grpc_status_code gsec_aead_crypter_encrypt_iovec ( gsec_aead_crypter crypter,
const uint8_t nonce,
size_t  nonce_length,
const struct iovec aad_vec,
size_t  aad_vec_length,
const struct iovec plaintext_vec,
size_t  plaintext_vec_length,
struct iovec  ciphertext_vec,
size_t *  ciphertext_bytes_written,
char **  error_details 
)

This method performs an AEAD encrypt operation.

  • crypter: AEAD crypter instance.
  • nonce: buffer containing a nonce with its size equal to nonce_length.
  • nonce_length: size of nonce buffer, and must be equal to the value returned from method gsec_aead_crypter_nonce_length.
  • aad_vec: an iovec array containing data that needs to be authenticated but not encrypted.
  • aad_vec_length: the array length of aad_vec.
  • plaintext_vec: an iovec array containing data that needs to be both encrypted and authenticated.
  • plaintext_vec_length: the array length of plaintext_vec.
  • ciphertext_vec: an iovec containing a ciphertext buffer. The buffer should not overlap the plaintext buffer.
  • ciphertext_bytes_written: the actual number of bytes written to ciphertext_vec.
  • error_details: a buffer containing an error message if the method does not function correctly. It is legal to pass nullptr into error_details, and otherwise, the parameter should be freed with gpr_free.

On the success of encryption, the method returns GRPC_STATUS_OK. Otherwise, it returns an error status code along with its details specified in error_details (if error_details is not nullptr).

Definition at line 60 of file gsec.cc.

◆ gsec_aead_crypter_key_length()

grpc_status_code gsec_aead_crypter_key_length ( const gsec_aead_crypter crypter,
size_t *  key_length_to_return,
char **  error_details 
)

This method returns a valid size of key array used at the construction of AEAD crypter instance. It is also the size that should be passed to encrypt and decrypt methods executed on the instance.

  • crypter: AEAD crypter instance.
  • key_length_to_return: the length of key array the method returns.
  • error_details: a buffer containing an error message if the method does not function correctly. It is legal to pass nullptr into error_details, and otherwise, the parameter should be freed with gpr_free.

On the success of execution, the method returns GRPC_STATUS_OK. Otherwise, it returns an error status code along with its details specified in error_details (if error_details is not nullptr).

Definition at line 157 of file gsec.cc.

◆ gsec_aead_crypter_max_ciphertext_and_tag_length()

grpc_status_code gsec_aead_crypter_max_ciphertext_and_tag_length ( const gsec_aead_crypter crypter,
size_t  plaintext_length,
size_t *  max_ciphertext_and_tag_length_to_return,
char **  error_details 
)

This method computes the size of ciphertext+tag buffer that must be passed to gsec_aead_crypter_encrypt function to ensure correct encryption of a plaintext. The actual size of ciphertext+tag written to the buffer could be smaller.

  • crypter: AEAD crypter instance.
  • plaintext_length: length of plaintext.
  • max_ciphertext_and_tag_length_to_return: the size of ciphertext+tag buffer the method returns.
  • error_details: a buffer containing an error message if the method does not function correctly. It is legal to pass nullptr into error_details, and otherwise, the parameter should be freed with gpr_free.

On the success of execution, the method returns GRPC_STATUS_OK. Otherwise, it returns an error status code along with its details specified in error_details (if error_details is not nullptr).

Definition at line 116 of file gsec.cc.

◆ gsec_aead_crypter_max_plaintext_length()

grpc_status_code gsec_aead_crypter_max_plaintext_length ( const gsec_aead_crypter crypter,
size_t  ciphertext_and_tag_length,
size_t *  max_plaintext_length_to_return,
char **  error_details 
)

This method computes the size of plaintext buffer that must be passed to gsec_aead_crypter_decrypt function to ensure correct decryption of a ciphertext. The actual size of plaintext written to the buffer could be smaller.

  • crypter: AEAD crypter instance.
  • ciphertext_and_tag_length: length of ciphertext and tag.
  • max_plaintext_length_to_return: the size of plaintext buffer the method returns.
  • error_details: a buffer containing an error message if the method does not function correctly. It is legal to pass nullptr into error_details, and otherwise, the parameter should be freed with gpr_free.

On the success of execution, the method returns GRPC_STATUS_OK. Otherwise, it returns an error status code along with its details specified in error_details (if error_details is not nullptr).

Definition at line 130 of file gsec.cc.

◆ gsec_aead_crypter_nonce_length()

grpc_status_code gsec_aead_crypter_nonce_length ( const gsec_aead_crypter crypter,
size_t *  nonce_length_to_return,
char **  error_details 
)

This method returns a valid size of nonce array used at the construction of AEAD crypter instance. It is also the size that should be passed to encrypt and decrypt methods executed on the instance.

  • crypter: AEAD crypter instance.
  • nonce_length_to_return: the length of nonce array the method returns.
  • error_details: a buffer containing an error message if the method does not function correctly. It is legal to pass nullptr into error_details, and otherwise, the parameter should be freed with gpr_free.

On the success of execution, the method returns GRPC_STATUS_OK. Otherwise, it returns an error status code along with its details specified in error_details (if error_details is not nullptr).

Definition at line 144 of file gsec.cc.

◆ gsec_aead_crypter_tag_length()

grpc_status_code gsec_aead_crypter_tag_length ( const gsec_aead_crypter crypter,
size_t *  tag_length_to_return,
char **  error_details 
)

This method returns a valid size of tag array used at the construction of AEAD crypter instance. It is also the size that should be passed to encrypt and decrypt methods executed on the instance.

  • crypter: AEAD crypter instance.
  • tag_length_to_return: the length of tag array the method returns.
  • error_details: a buffer containing an error message if the method does not function correctly. It is legal to pass nullptr into error_details, and otherwise, the parameter should be freed with gpr_free.

On the success of execution, the method returns GRPC_STATUS_OK. Otherwise, it returns an error status code along with its details specified in error_details (if error_details is not nullptr).

Definition at line 170 of file gsec.cc.

◆ maybe_copy_error_msg()

static void maybe_copy_error_msg ( const char *  src,
char **  dst 
)
static

Definition at line 31 of file gsec.cc.

Variable Documentation

◆ vtable_error_msg

const char vtable_error_msg[]
static
Initial value:
=
"crypter or crypter->vtable has not been initialized properly"

Definition at line 28 of file gsec.cc.



grpc
Author(s):
autogenerated on Fri May 16 2025 03:01:17