diff options
author | Bill Richardson <wfrichar@chromium.org> | 2015-01-30 22:21:10 -0800 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2015-02-03 05:39:28 +0000 |
commit | 4805f1841de9d670aaed9bdaea21147ee1d59242 (patch) | |
tree | 97222f2af5b428ec931755b746014e691af7495b /futility/vb1_helper.c | |
parent | 04d98e399d034656770e0049613d09ef3ea6d2d0 (diff) | |
download | vboot-4805f1841de9d670aaed9bdaea21147ee1d59242.tar.gz |
futility: show .vbprivk files
BUG=none
BRANCH=none
TEST=make runtests
futility show tests/devkeys/*.vbprivk
Change-Id: Ic062a193c7ee3d7f9837698e1c8fc6bb1e3d7757
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/245503
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'futility/vb1_helper.c')
-rw-r--r-- | futility/vb1_helper.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/futility/vb1_helper.c b/futility/vb1_helper.c index 292a0f24..f40b7ac8 100644 --- a/futility/vb1_helper.c +++ b/futility/vb1_helper.c @@ -9,6 +9,7 @@ #include <stdio.h> #include <string.h> #include <unistd.h> +#include <openssl/rsa.h> #include "file_type.h" #include "futility.h" @@ -737,3 +738,24 @@ enum futil_file_type recognize_vblock1(uint8_t *buf, uint32_t len) return FILE_TYPE_UNKNOWN; } + +enum futil_file_type recognize_privkey(uint8_t *buf, uint32_t len) +{ + VbPrivateKey key; + const unsigned char *start; + + if (len < sizeof(key.algorithm)) + return FILE_TYPE_UNKNOWN; + + key.algorithm = *(typeof(key.algorithm) *)buf; + start = buf + sizeof(key.algorithm); + key.rsa_private_key = d2i_RSAPrivateKey(NULL, &start, + len - sizeof(key.algorithm)); + + if (key.rsa_private_key) { + RSA_free(key.rsa_private_key); + return FILE_TYPE_PRIVKEY; + } + + return FILE_TYPE_UNKNOWN; +} |