数字证书编码ASN.1
任务详情
0. 参考附件中图书p223 中13.2的实验指导,完成DER编码
1. 序列号=1174(0x0496),证书签发者 DN="CN=Virtual CA,C=CN",证书持有者DN="CN=你的名字拼音, OU=Person,C=CN",证书有效期=20200222000000-20220222000000。
2. 用echo -n -e "编码" > 你的学号.der中,用OpenSSL asn1parse 分析编码的正确性
3. 提交编码过程文档(推荐markdown格式)
对Extension进行DER编码:
对TBSCertificate进行DER编码:
TBSCertificate | 标识串 | 长度串 | 内容串 |
---|---|---|---|
version | A0 | 03 | 02 01 02 |
serialNumber | 02 | 02 | 04 96 |
signature | 30 | 0D | 06 09 2A 86 48 86 F7 0D 01 01 05 05 00 |
issuer | 30 | 22 | 31 0B 30 09 06 03 55 04 06 13 02 43 4E 31 13 30 11 06 03 55 04 03 13 0A 56 69 72 74 75 61 6C 20 43 41 |
validity | 30 | 1E | 17 0D 32 30 30 32 32 31 31 36 30 30 30 30 5A(2020)17 0D 32 32 30 32 32 31 31 36 30 30 30 30 5A(2022) |
subject | 30 | 31 | 31 0B 30 09 06 03 55 04 06 13 02 43 4E(CN)31 0F 30 0D 06 03 55 04 0B 13 06 50 65 72 73 6F 6E(Person) 31 15 30 13 06 03 55 04 03 13 0B 57 75 20 5a 68 75 6f 68 61 6e 67(Wu Zhuohang) |
查看自己的姓名学号16进制ASCII编码
echo -n "Wu Zhuohang" | od -tc -tx1
echo -n "20201224" | od -tc -tx1
对应的DER 编码值为:
"\x32\x30\x32\x30\x31\x32\x32\x34" ("20201224")
"\x57\x75\x20\x5a\x68\x75\x6f\x68\x61\x6e\x67" ("Wu Zhuohang")
下面采用的OpenSSL asn1parse 分析编码的代码为:
openssl asn1parse -inform der -in ./20201224.der
序列号1174(0x0496)
echo -n -e "\xA0\x03\x02\x01\x02\x02\x02\x04\x96\x30\x0D\x06\x09\x2A\x86\x48\x86\xF7\x0D\x01\x01\x05\x05\x00" > 20201224.der
证书签发者DN="CN=Virtual CA
echo -n -e "\x30\x22\x31\x0B\x30\x09\x06\x03\x55\x04\x06\x13\x02\x43\x4E\x31\x13\x30\x11\x06\x03\x55\x04\x03\x13\x0A\x56\x69\x72\x74\x75\x61\x6C\x20\x43\x41" >> 20201224.der
证书有效期=20200222000000-20220222000000
echo -n -e "\x17\x0D\x32\x30\x32\x30\x30\x32\x32\x32\x30\x30\x30\x30\x5A\x17\x0D\x32\x30\x32\x32\x30\x32\x32\x32\x30\x30\x30\x30\x5A" >> 20201224.der
证书持有者DN=CN=Wu Zhuohang, OU=Person
echo -n -e "\x30\x37\x31\x0B\x30\x09\x06\x03\x55\x04\x06\x13\x02\x43\x4E\x31\x11\x30\x0F\x06\x03\x55\x04\x0A\x13\x08\x32\x30\x32\x30\x31\x32\x32\x34\x31\x15\x30\x13\x06\x03\x55\x04\x03\x13\x0C\x57\x75\x20\x5a\x68\x75\x6f\x68\x61\x6e\x67" >> 20201224.der