More SSL_SESSION serialization functions.

Change-Id: I2dd8d073521a230b2b0c4e74ec3d6eeb4899623e
Reviewed-on: https://boringssl-review.googlesource.com/6303
Reviewed-by: Adam Langley <alangley@gmail.com>
This commit is contained in:
David Benjamin 2015-10-17 22:15:37 -04:00 committed by Adam Langley
parent 066fe0a679
commit 7227990ef1
2 changed files with 20 additions and 7 deletions

View File

@ -1327,6 +1327,7 @@ OPENSSL_EXPORT int SSL_CTX_add_server_custom_ext(
* different threads and must not be modified. */
DECLARE_LHASH_OF(SSL_SESSION)
DECLARE_PEM_rw(SSL_SESSION, SSL_SESSION)
/* SSL_SESSION_new returns a newly-allocated blank |SSL_SESSION| or NULL on
* error. This may be useful in writing tests but otherwise should not be
@ -2854,13 +2855,6 @@ OPENSSL_EXPORT void (*SSL_CTX_get_info_callback(SSL_CTX *ctx))(const SSL *ssl,
* for the peer, but |SSL_read| will require the handshake to be completed. */
OPENSSL_EXPORT int SSL_in_false_start(const SSL *s);
#define d2i_SSL_SESSION_bio(bp, s_id) \
ASN1_d2i_bio_of(SSL_SESSION, SSL_SESSION_new, d2i_SSL_SESSION, bp, s_id)
#define i2d_SSL_SESSION_bio(bp, s_id) \
ASN1_i2d_bio_of(SSL_SESSION, i2d_SSL_SESSION, bp, s_id)
DECLARE_PEM_rw(SSL_SESSION, SSL_SESSION)
OPENSSL_EXPORT const char *SSL_state_string(const SSL *ssl);
OPENSSL_EXPORT const char *SSL_state_string_long(const SSL *ssl);
@ -3047,6 +3041,15 @@ OPENSSL_EXPORT int i2d_SSL_SESSION(SSL_SESSION *in, uint8_t **pp);
OPENSSL_EXPORT SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a, const uint8_t **pp,
long length);
/* i2d_SSL_SESSION_bio serializes |session| and writes the result to |bio|. It
* returns the number of bytes written on success and <= 0 on error. */
OPENSSL_EXPORT int i2d_SSL_SESSION_bio(BIO *bio, const SSL_SESSION *session);
/* d2i_SSL_SESSION_bio reads a serialized |SSL_SESSION| from |bio| and returns a
* newly-allocated |SSL_SESSION| or NULL on error. If |out| is not NULL, it also
* frees |*out| and sets |*out| to the new |SSL_SESSION|. */
OPENSSL_EXPORT SSL_SESSION *d2i_SSL_SESSION_bio(BIO *bio, SSL_SESSION **out);
/* ERR_load_SSL_strings does nothing. */
OPENSSL_EXPORT void ERR_load_SSL_strings(void);

View File

@ -113,6 +113,7 @@
#include <errno.h>
#include <string.h>
#include <openssl/asn1.h>
#include <openssl/bio.h>
#include <openssl/err.h>
#include <openssl/mem.h>
@ -620,4 +621,13 @@ void SSL_CTX_set_default_passwd_cb_userdata(SSL_CTX *ctx, void *data) {
ctx->default_passwd_callback_userdata = data;
}
SSL_SESSION *d2i_SSL_SESSION_bio(BIO *bio, SSL_SESSION **out) {
return ASN1_d2i_bio_of(SSL_SESSION, SSL_SESSION_new, d2i_SSL_SESSION, bio,
out);
}
int i2d_SSL_SESSION_bio(BIO *bio, const SSL_SESSION *session) {
return ASN1_i2d_bio_of(SSL_SESSION, i2d_SSL_SESSION, bio, session);
}
IMPLEMENT_PEM_rw(SSL_SESSION, SSL_SESSION, PEM_STRING_SSL_SESSION, SSL_SESSION)