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/ssl/ssl_lib.c b/ssl/ssl_lib.c index 46b9cb6..04f6c54 100644 --- a/ssl/ssl_lib.c +++ b/ssl/ssl_lib.c
@@ -3140,3 +3140,13 @@ const SSL_CIPHER *SSL_get_cipher_by_value(uint16_t value) { return ssl3_get_cipher_by_value(value); } + +int SSL_get_rc4_state(const SSL *ssl, const RC4_KEY **read_key, + const RC4_KEY **write_key) { + if (ssl->aead_read_ctx == NULL || ssl->aead_write_ctx == NULL) { + return 0; + } + + return EVP_AEAD_CTX_get_rc4_state(&ssl->aead_read_ctx->ctx, read_key) && + EVP_AEAD_CTX_get_rc4_state(&ssl->aead_write_ctx->ctx, write_key); +}