summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/ocsp/ocsp_ht.c
diff options
context:
space:
mode:
authordjm <>2010-10-01 22:59:01 +0000
committerdjm <>2010-10-01 22:59:01 +0000
commitfe047d8b632246cb2db3234a0a4f32e5c318857b (patch)
tree939b752540947d33507b3acc48d76a8bfb7c3dc3 /src/lib/libcrypto/ocsp/ocsp_ht.c
parent2ea67f4aa254b09ded62e6e14fc893bbe6381579 (diff)
downloadopenbsd-fe047d8b632246cb2db3234a0a4f32e5c318857b.tar.gz
openbsd-fe047d8b632246cb2db3234a0a4f32e5c318857b.tar.bz2
openbsd-fe047d8b632246cb2db3234a0a4f32e5c318857b.zip
resolve conflicts, fix local changes
Diffstat (limited to 'src/lib/libcrypto/ocsp/ocsp_ht.c')
-rw-r--r--src/lib/libcrypto/ocsp/ocsp_ht.c56
1 files changed, 41 insertions, 15 deletions
diff --git a/src/lib/libcrypto/ocsp/ocsp_ht.c b/src/lib/libcrypto/ocsp/ocsp_ht.c
index 6abb30b2c0..12bbfcffd1 100644
--- a/src/lib/libcrypto/ocsp/ocsp_ht.c
+++ b/src/lib/libcrypto/ocsp/ocsp_ht.c
@@ -118,39 +118,65 @@ void OCSP_REQ_CTX_free(OCSP_REQ_CTX *rctx)
118 OPENSSL_free(rctx); 118 OPENSSL_free(rctx);
119 } 119 }
120 120
121OCSP_REQ_CTX *OCSP_sendreq_new(BIO *io, char *path, OCSP_REQUEST *req, 121int OCSP_REQ_CTX_set1_req(OCSP_REQ_CTX *rctx, OCSP_REQUEST *req)
122 int maxline)
123 { 122 {
124 static char post_hdr[] = "POST %s HTTP/1.0\r\n" 123 static const char req_hdr[] =
125 "Content-Type: application/ocsp-request\r\n" 124 "Content-Type: application/ocsp-request\r\n"
126 "Content-Length: %d\r\n\r\n"; 125 "Content-Length: %d\r\n\r\n";
126 if (BIO_printf(rctx->mem, req_hdr, i2d_OCSP_REQUEST(req, NULL)) <= 0)
127 return 0;
128 if (i2d_OCSP_REQUEST_bio(rctx->mem, req) <= 0)
129 return 0;
130 rctx->state = OHS_ASN1_WRITE;
131 rctx->asn1_len = BIO_get_mem_data(rctx->mem, NULL);
132 return 1;
133 }
134
135int OCSP_REQ_CTX_add1_header(OCSP_REQ_CTX *rctx,
136 const char *name, const char *value)
137 {
138 if (!name)
139 return 0;
140 if (BIO_puts(rctx->mem, name) <= 0)
141 return 0;
142 if (value)
143 {
144 if (BIO_write(rctx->mem, ": ", 2) != 2)
145 return 0;
146 if (BIO_puts(rctx->mem, value) <= 0)
147 return 0;
148 }
149 if (BIO_write(rctx->mem, "\r\n", 2) != 2)
150 return 0;
151 return 1;
152 }
153
154OCSP_REQ_CTX *OCSP_sendreq_new(BIO *io, char *path, OCSP_REQUEST *req,
155 int maxline)
156 {
157 static const char post_hdr[] = "POST %s HTTP/1.0\r\n";
127 158
128 OCSP_REQ_CTX *rctx; 159 OCSP_REQ_CTX *rctx;
129 rctx = OPENSSL_malloc(sizeof(OCSP_REQ_CTX)); 160 rctx = OPENSSL_malloc(sizeof(OCSP_REQ_CTX));
130 rctx->state = OHS_FIRSTLINE; 161 rctx->state = OHS_ERROR;
131 rctx->mem = BIO_new(BIO_s_mem()); 162 rctx->mem = BIO_new(BIO_s_mem());
132 rctx->io = io; 163 rctx->io = io;
164 rctx->asn1_len = 0;
133 if (maxline > 0) 165 if (maxline > 0)
134 rctx->iobuflen = maxline; 166 rctx->iobuflen = maxline;
135 else 167 else
136 rctx->iobuflen = OCSP_MAX_LINE_LEN; 168 rctx->iobuflen = OCSP_MAX_LINE_LEN;
137 rctx->iobuf = OPENSSL_malloc(rctx->iobuflen); 169 rctx->iobuf = OPENSSL_malloc(rctx->iobuflen);
170 if (!rctx->iobuf)
171 return 0;
138 if (!path) 172 if (!path)
139 path = "/"; 173 path = "/";
140 174
141 if (BIO_printf(rctx->mem, post_hdr, path, 175 if (BIO_printf(rctx->mem, post_hdr, path) <= 0)
142 i2d_OCSP_REQUEST(req, NULL)) <= 0)
143 {
144 rctx->state = OHS_ERROR;
145 return 0; 176 return 0;
146 } 177
147 if (i2d_OCSP_REQUEST_bio(rctx->mem, req) <= 0) 178 if (req && !OCSP_REQ_CTX_set1_req(rctx, req))
148 {
149 rctx->state = OHS_ERROR;
150 return 0; 179 return 0;
151 }
152 rctx->state = OHS_ASN1_WRITE;
153 rctx->asn1_len = BIO_get_mem_data(rctx->mem, NULL);
154 180
155 return rctx; 181 return rctx;
156 } 182 }