Certificate Public Key resolution

Source: Internet
Author: User

1.RSA algorithm
Prime number P Q
E1 and (p-1) * (q-1) coprime
E2*e1mod (p-1) * (q-1) =1
(N, E1) is a public key
(n, E2) is the private key

2.A is plaintext B is ciphertext
A=B^E1 mod n
B=A^E1 mod n

Such as:

The Bay of Bayi in the Bay of Bayi Bayi xx e3 8d 9f BD 9a C0 e5
6a 5d B3 CF CA 8e C1 4a 6c F9 C2 E0
8a 5f e5 8f D3 fb A5 3f
BC D7 6e 5e F2 a6 + 8e 4d 1d 3d ad
D4 9c c5 9d F1 BB 4c B7 6c B0
PNS E3 8f C3 A2 BF A2 E1 DB 99
5f 9b a5 f5 7a D4 35 86
F3 C6 C7-F2 2c, ed 89
4a AE E1 9d 3e A1 02 03 01 00 01

This is the information for the certificate's public key (the value of the public key is bound to the identity of the person, device, or service holding the corresponding private key)

ASN.1 uses Tag,lenth,value, encoding method, which will be the whole as a sequence, can be understood as the structure, with 30 as the starting sign,
The second digit 81 represents the 1 bytes behind the length, that is, 89 for the length (if 82 means the following two bytes for length, and so on),
Converted to decimal 137, exactly the number of bytes in the back, starting from the fourth bit 02 is the connotation of this sequence, equivalent to the elements of the structure,
Generally speaking, sequence often require nesting, which is equivalent to a struct-embedded structure, but for the sequence of the public key, there is only one layer here.
The fourth bit 02 represents a bit stream, the same immediately followed by the 81 representing a byte representing the length, the sixth bit of the 81 for the length of 129,
That is, starting from 00 until the last line A1 this is 129 bytes, minus the previous 00, the remaining 128 bits (the number of bits occupied, that is, the so-called key length) is the n value of the RSA public key,
The last 5 bytes are also bit streams,
Starting at 02, 03 indicates a length of 3, and the last 01 00 01 is the E value of the RSA public key.
about why to fill 00 before the value of N, which may be ASN.1, if the first four bit of bit stream hexadecimal value is less than 8 in the first 0, see the following example
The Bay of Bayi in the 8d 9f BD 9a c0 e5 6a
5d B3 CF CA 8e C1 4a 6c F9 C2 E0 89
8a 5f e5 8f D3 fb a5 3f BC
D7 6e 5e F2 a6 + 8e 4d 1d 3d ad d4
9c c5 9d F1 BB 4c B7 6c B0 37
E3 FB 8f C3 A2 BF A2 E1 DB 99 54
5f 9b a5 f5 7a D4 35 86 14
F3 C6 C7 one F2 2c, Ed 4a
AE E1 9d 3e A1 02 03 01 00 01
The first four bits of n are 0x3 less than 8, so there is no need to fill 0.
about what to do after the tag value with 8X marked with a few representative length, I understand that if the first four bit of length is greater than 8 or more than one byte,
It must be marked with 8X, otherwise not.

Certificate Public Key resolution

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.