20211105李宜时DER

作业内容:

  1. 参考附件中图书p120 中7.1的实验指导,完成DER编码
  2. Name实例中,countryName改为“CN”,organization Name-"你的学号" commoaName="你的姓名拼音"
  3. 用echo -n -e "编码" > 你的学号.der中,用OpenSSL asn1parse 分析编码的正确性
  4. 提交编码过程文档(推荐markdown格式)

具体过程

1.查看自己的相关信息

echo -n "CN" | od -tc -tx1
echo -n "Li Yishi " | od -tc -tx1
echo -n "20211105" | od -tc -tx1

结果为
43 4e
4c 69 20 59 69 73 68 69
32 30 32 31 31 31 30 35

2.编码过程

7.1 DER 编码示例:X.501 Name 类型
7.1.1
ASN.1 描述与实例

  1. ASN.1 描述
    X.501 Name 类型用 ASN.I 描述如下:
    Name ::= CHOICE ( RDNSequence }
    RDNSequence ::= SEQUENCE OF RelativeDistinguishedName RelativeDistinguishedName := SET OF Attribute Value Assertion
    AttributeValueAssertion := SEQUENCE{
    Attribute lype,
    Attribute Value }
    Attribute Type ::= OBJECT IDENTIFIER
    Attribute Value ::= ANY
    Name 类型定义为CHOICE类型,目前只有1个选项 RDNSequence。RDNSequence 定义为 SEQUENCE OF 类型,由0个或多个 RelativeDistinguishedName 组成。RelativeDistinguished-Name 定义为 SET OF 类型,由0个或多个 AttributeValueAssertion 组成。AttributeValueAssertion
    定义为 SEQUENCE 类型,由2个成分组成:1个为 AttributeType 类型和 1 个 AttributeValue类型。AttributeType 定义 OBJECT IDENTIFIER 类型。AttributeValue 定义次ANY类型,具体内容由 AttributeType 决定。
    事实上,Name 类型可理解为分层或树形结构,即X.500目录树结构。
  2. Name 实例
    对于用户 Test User 1,其对应的Name类型采用分层结构描述为:
    (root)
    country Name = "US"
    organization Name = "Example Organization"
    commonName = "Test User 1"
    其中,每层对应一个 RelativeDistinguishedName; 每个 RelativeDistinguishedName 由
    1 1 Attribute Value Assertion 4 6k. 19 5 AÚ P % Attribute Type, 14 € 5 / 77% Attribute Value.
    用户 Test User 1 包含3个 AttributeType: countryName、organizationName、commonName,其 OID 定义如下:


3.具体的编码过程

(1)echo -n -e "\x31\x0B\x30\x09\x06\x03\x55\x04\x06\x13\x02\x43\x4E" > 20211105.der
openssl asn1parse -inform der -in ./20211105.der
(2)echo -n-e "\x31\x11\x30\xOF\x06\X03\x55\X04\XOA|x13\x08\x32\x30\x32\x31\x31\x31\x30\x35" >> 20211105. der
openssl asn1parse -inform der -in ./20211105.der
(3)echo -n-e "(x31\x15\x30\x13\x06\X03\x551X041X03\X13\X07\X0C|X4C\X69\x201x591x69\x73\x68\x69" >> 20211105. der
openssl asn1parse -inform der -in ./20211105.der
最后结果如下

posted @ 2024-03-30 15:49  李宜时  阅读(15)  评论(0)    收藏  举报