aboutsummaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2014-07-01 11:02:51 -0400
committerDavid Howells <dhowells@redhat.com>2014-07-09 09:58:37 -0400
commit3968280c7699f11e27a21aeafacf50bc86c2ed25 (patch)
treee99fad99fa424ff38b38ae18d480b81df31ae401 /crypto
parent09dacbbda935895a4898e517e1248c11ca493216 (diff)
pefile: Parse the presumed PKCS#7 content of the certificate blob
Parse the content of the certificate blob, presuming it to be PKCS#7 format. Signed-off-by: David Howells <dhowells@redhat.com> Acked-by: Vivek Goyal <vgoyal@redhat.com> Reviewed-by: Kees Cook <keescook@chromium.org>
Diffstat (limited to 'crypto')
-rw-r--r--crypto/asymmetric_keys/verify_pefile.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/crypto/asymmetric_keys/verify_pefile.c b/crypto/asymmetric_keys/verify_pefile.c
index 2f5268cb843d..13f3b44b5046 100644
--- a/crypto/asymmetric_keys/verify_pefile.c
+++ b/crypto/asymmetric_keys/verify_pefile.c
@@ -216,7 +216,10 @@ static int pefile_strip_sig_wrapper(const void *pebuf,
216int verify_pefile_signature(const void *pebuf, unsigned pelen, 216int verify_pefile_signature(const void *pebuf, unsigned pelen,
217 struct key *trusted_keyring, bool *_trusted) 217 struct key *trusted_keyring, bool *_trusted)
218{ 218{
219 struct pkcs7_message *pkcs7;
219 struct pefile_context ctx; 220 struct pefile_context ctx;
221 const void *data;
222 size_t datalen;
220 int ret; 223 int ret;
221 224
222 kenter(""); 225 kenter("");
@@ -230,5 +233,21 @@ int verify_pefile_signature(const void *pebuf, unsigned pelen,
230 if (ret < 0) 233 if (ret < 0)
231 return ret; 234 return ret;
232 235
233 return -ENOANO; // Not yet complete 236 pkcs7 = pkcs7_parse_message(pebuf + ctx.sig_offset, ctx.sig_len);
237 if (IS_ERR(pkcs7))
238 return PTR_ERR(pkcs7);
239 ctx.pkcs7 = pkcs7;
240
241 ret = pkcs7_get_content_data(ctx.pkcs7, &data, &datalen, false);
242 if (ret < 0 || datalen == 0) {
243 pr_devel("PKCS#7 message does not contain data\n");
244 ret = -EBADMSG;
245 goto error;
246 }
247
248 ret = -ENOANO; // Not yet complete
249
250error:
251 pkcs7_free_message(ctx.pkcs7);
252 return ret;
234} 253}