summaryrefslogtreecommitdiffstats
path: root/crypto/cmp
diff options
context:
space:
mode:
authorDr. David von Oheimb <David.von.Oheimb@siemens.com>2020-07-11 12:26:22 +0200
committerDr. David von Oheimb <David.von.Oheimb@siemens.com>2020-07-30 20:14:51 +0200
commit1202de4481df88d63a2a5cc1e9e0450a7e72f4ac (patch)
tree11e10160191b44e573f792531e811fbda5d8df6c /crypto/cmp
parentExport ossl_cmp_msg_load() as OSSL_CMP_MSG_read(), use it in apps/cmp.c (diff)
downloadopenssl-1202de4481df88d63a2a5cc1e9e0450a7e72f4ac.tar.xz
openssl-1202de4481df88d63a2a5cc1e9e0450a7e72f4ac.zip
Add OSSL_CMP_MSG_write(), use it in apps/cmp.c
Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/12421)
Diffstat (limited to 'crypto/cmp')
-rw-r--r--crypto/cmp/cmp_msg.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/crypto/cmp/cmp_msg.c b/crypto/cmp/cmp_msg.c
index 2e24f49f3c..6d6e3bd2b6 100644
--- a/crypto/cmp/cmp_msg.c
+++ b/crypto/cmp/cmp_msg.c
@@ -1025,6 +1025,24 @@ OSSL_CMP_MSG *OSSL_CMP_MSG_read(const char *file)
return msg;
}
+int OSSL_CMP_MSG_write(const char *file, const OSSL_CMP_MSG *msg)
+{
+ BIO *bio;
+ int res;
+
+ if (file == NULL || msg == NULL) {
+ CMPerr(0, CMP_R_NULL_ARGUMENT);
+ return -1;
+ }
+
+ bio = BIO_new_file(file, "wb");
+ if (bio == NULL)
+ return -2;
+ res = i2d_OSSL_CMP_MSG_bio(bio, msg);
+ BIO_free(bio);
+ return res;
+}
+
OSSL_CMP_MSG *d2i_OSSL_CMP_MSG_bio(BIO *bio, OSSL_CMP_MSG **msg)
{
return ASN1_d2i_bio_of(OSSL_CMP_MSG, OSSL_CMP_MSG_new,