Add SSL_get_rc4_state.
This allows the current RC4 state of an SSL* to be extracted. We have
internal uses for this functionality.
Change-Id: Ic124c4b253c8325751f49e7a4c021768620ea4b7
Reviewed-on: https://boringssl-review.googlesource.com/3722
Reviewed-by: Adam Langley <agl@google.com>
diff --git a/include/openssl/aead.h b/include/openssl/aead.h
index 8aedb1b..4b8f6cd 100644
--- a/include/openssl/aead.h
+++ b/include/openssl/aead.h
@@ -286,6 +286,14 @@
const uint8_t *ad, size_t ad_len);
+/* Obscure functions. */
+
+/* EVP_AEAD_CTX_get_rc4_state sets |*out_key| to point to an RC4 key structure.
+ * It returns one on success or zero if |ctx| doesn't have an RC4 key. */
+OPENSSL_EXPORT int EVP_AEAD_CTX_get_rc4_state(const EVP_AEAD_CTX *ctx,
+ const RC4_KEY **out_key);
+
+
#if defined(__cplusplus)
} /* extern C */
#endif
diff --git a/include/openssl/base.h b/include/openssl/base.h
index 71223a0..37bca56 100644
--- a/include/openssl/base.h
+++ b/include/openssl/base.h
@@ -195,6 +195,7 @@
typedef struct pkcs8_priv_key_info_st PKCS8_PRIV_KEY_INFO;
typedef struct pkcs12_st PKCS12;
typedef struct rand_meth_st RAND_METHOD;
+typedef struct rc4_key_st RC4_KEY;
typedef struct rsa_meth_st RSA_METHOD;
typedef struct rsa_st RSA;
typedef struct sha256_state_st SHA256_CTX;
diff --git a/include/openssl/rc4.h b/include/openssl/rc4.h
index b5fc8ed..42a74f2 100644
--- a/include/openssl/rc4.h
+++ b/include/openssl/rc4.h
@@ -66,12 +66,10 @@
/* RC4. */
-
-typedef struct rc4_key_st {
+struct rc4_key_st {
uint32_t x, y;
uint32_t data[256];
-} RC4_KEY;
-
+} /* RC4_KEY */;
/* RC4_set_key performs an RC4 key schedule and initialises |rc4key| with |len|
* bytes of key material from |key|. */
diff --git a/include/openssl/ssl.h b/include/openssl/ssl.h
index 82d632a..3d854a1 100644
--- a/include/openssl/ssl.h
+++ b/include/openssl/ssl.h
@@ -2253,6 +2253,12 @@
* https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-parameters-4. */
OPENSSL_EXPORT const SSL_CIPHER *SSL_get_cipher_by_value(uint16_t value);
+/* SSL_get_rc4_state sets |*read_key| and |*write_key| to the RC4 states for
+ * the read and write directions. It returns one on success or zero if |ssl|
+ * isn't using an RC4-based cipher suite. */
+OPENSSL_EXPORT int SSL_get_rc4_state(const SSL *ssl, const RC4_KEY **read_key,
+ const RC4_KEY **write_key);
+
/* Android compatibility section.
*