Ejemplo n.º 1
0
int evp_aead_chacha20_poly1305_init(void *ctx_buf, size_t ctx_buf_len,
                                    const uint8_t *key, size_t key_len) {
  aead_assert_init_preconditions(alignof(struct aead_chacha20_poly1305_ctx),
                                 sizeof(struct aead_chacha20_poly1305_ctx),
                                 ctx_buf, ctx_buf_len, key);
  struct aead_chacha20_poly1305_ctx *c20_ctx = ctx_buf;
  memcpy(c20_ctx->key, key, key_len);
  return 1;
}
Ejemplo n.º 2
0
int evp_aead_aes_gcm_init(void *ctx_buf, size_t ctx_buf_len, const uint8_t *key,
                          size_t key_len) {
  aead_assert_init_preconditions(alignof(struct aead_aes_gcm_ctx),
                                 sizeof(struct aead_aes_gcm_ctx), ctx_buf,
                                 ctx_buf_len, key);

  struct aead_aes_gcm_ctx *gcm_ctx = ctx_buf;
  gcm_ctx->ctr =
      aes_ctr_set_key(&gcm_ctx->ks.ks, &gcm_ctx->gcm, NULL, key, key_len);
  return 1;
}