Implementation of RSASSA-PSS in OpenSSL

Source: Internet
Author: User

1. EMSA-PSS Codec
Corresponds to functions in OpenSSLRsa_padding_add_pkcs1_pss,Rsa_verify_pkcs1_pss;
Rsa_padding_add_pkcs1_pss is not exactly equal to the EMSA-PSS code. The difference is that the former is not the input m, but the M hash value mhash. That is, the 2nd step of the latter (see pkcs_#1_v2.20.rsa_algorithm standard tutorial p34 ).
The input of rsa_padding_add_pkcs1_pss is RSA, mhash, hash method, and salt length, and the output is em.
Result of rsa_padding_add_pkcs1_pssEm LengthIs rsa_bytes, but the length of its true value is only rsa_bits-1. For example, when rsa_bits = 7, the EM value is like 00xx xxxx; When rsa_bits = 9, the EM value is like 0000 0000 XXXX.

2. rsasp1 and rsavp1
Corresponds to functions in OpenSSLRsa_sign,Rsa_verify;
Rsa_sign first converts the STR to be signed into DER encoding, and then performs rsa_private_encrypt. This function does not perform the hash operation before encrypt.

3. i2osp and os2ip
Corresponds to functions in OpenSSLBn_bn2bin,Bn_bin2bn;
This group of functions cannot specify the length of the Eight-bit group, so we need to package it again.

Bytes ---------------------------------------------------------------------------------------------------------------

4. rsasp1, rsavp1, i2osp, and os2ip
The above 2 and 3 points analysis error does not correspond to the corresponding functions in OpenSSL.
Rsa_sign has a limit on the input length: The length after conversion to DER encoding cannot be greater than rsa_byts-11. Rsa_verify only proves that it is inconsistent with the semantics of rsavp1.
Bn_bn2bin and bn_bin2bn. during conversion between octect string and big integer, big integer always uses little endian.

5. rsa_private_encrypt, rsa_verify_pkcs1_pss
Rsa_private_encryptWhen the padding is rsa_no_padding, the length of octect string to be encrypted must be rsa_bytes, And the encrypted length is rsa_bytes. The implementation process is: first call bn_bin2bn to convert to bn, then encrypt, then call bn_bn2bin to convert the encrypted result bn2 to octect string.
Rsa_public_decryptThe process is the opposite.

6. Current Implementation Method
Combination: rsa_padding_add_pkcs1_pss, rsa_verify_pkcs1_pss, rsa_private_encrypt, rsa_public_decrypt.
Encoding Process: First tune hash; then pass the hash value into rsa_padding_add_pkcs1_pss for encoding; then call rsa_private_encrypt to encrypt the encoded value.
Verification process: first call rsa_public_decrypt decoding; then hash decoding value; pass the hash value to rsa_verify_pkcs1_pss for verification.

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.