Add EVP_AEAD_CTX_aead.

Code acting generically on an EVP_AEAD_CTX may wish to get at the
underlying EVP_AEAD.

Change-Id: I9cc905522ba76402bda4c255aa1488158323b02c
Reviewed-on: https://boringssl-review.googlesource.com/11085
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Matt Braithwaite <mab@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
diff --git a/crypto/cipher/aead.c b/crypto/cipher/aead.c
index 4c881f8..2d56715 100644
--- a/crypto/cipher/aead.c
+++ b/crypto/cipher/aead.c
@@ -144,6 +144,8 @@
   return 0;
 }
 
+const EVP_AEAD *EVP_AEAD_CTX_aead(const EVP_AEAD_CTX *ctx) { return ctx->aead; }
+
 int EVP_AEAD_CTX_get_iv(const EVP_AEAD_CTX *ctx, const uint8_t **out_iv,
                         size_t *out_len) {
   if (ctx->aead->get_iv == NULL) {
diff --git a/include/openssl/aead.h b/include/openssl/aead.h
index 458d73b..af81fa6 100644
--- a/include/openssl/aead.h
+++ b/include/openssl/aead.h
@@ -256,6 +256,10 @@
                                      const uint8_t *in, size_t in_len,
                                      const uint8_t *ad, size_t ad_len);
 
+/* EVP_AEAD_CTX_aead returns the underlying AEAD for |ctx|, or NULL if one has
+ * not been set. */
+OPENSSL_EXPORT const EVP_AEAD *EVP_AEAD_CTX_aead(const EVP_AEAD_CTX *ctx);
+
 
 /* TLS-specific AEAD algorithms.
  *