Problem 44963. Mask Generation Function (MGF1) for PKCS #1 Standard utilizing Optimal Asymmetric Encryption Padding for RSA Cryptography
Create Mask Generation Function (MGF1) from PKCS #1 v2.2 standard (B.2.1) at below link. Input will be character array (mgfSeed) which will need to be converted to octet array using UTF-8 representation. Output must be octet array (uint8) of length, maskLen (input). Hashing must use SHA-1 (160 - 20 byte).
For example:
mgfSeed = 'I like to swim.';%input
maskLen = 20;%input
mask = [170,251,101,210,23,101,10,242,193,163,174,148,104,138,228,245,52,234,0,195];%output
See: https://www.foo.be/docs/opensst/ref/pkcs/pkcs-1/pkcs-1v2-1d1.pdf
Solution Stats
Problem Comments
-
1 Comment
Rafael S.T. Vieira
on 24 Oct 2020
For anyone trying this problem, you will probably have to implemment I2OSP too from the documentation, which is a function to convert a decimal number to base 256 of fixed length. Follow the specs to the letter.
Solution Comments
Show commentsGroup

Advanced Cryptography Algorithms and Mathematics
- 21 Problems
- 0 Finishers
- Determine RSA keys (public and private) given two prime number character strings (p and q)
- Create State Array for initiating SHA-3-224 Hash
- RSA encryption using public key
- RSA decryption
- Mask Generation Function (MGF1) for PKCS #1 Standard utilizing Optimal Asymmetric Encryption Padding for RSA Cryptography
- Optimal Asymmetric Encryption Padding of message for RSA Cryptography
- Optimal Asymmetric Encryption Padding decoding of message for RSA Cryptography
- Find R*Rp-N*Np=1 given gcd(R,N)=1
- Montgomery Reduction Algorithm (REDC)
- Inverse Number Theoretic Transform (iNTT)
- Number Theoretic Transform (NTT)
- Montgomery Multiplication
- Output the Montgomery Form of the Input Matrix
- RIPEMD160 Hash
- SHA256 Hashing
- Binary Array to Hex Representation
- String to Binary Representation
- AES-256 KeyExpansion()
- AES SubBytes() Transformation
- Elliptic Curve Cryptography (ECC) Point Addition
- Obtain the Bitcoin address associated to a given private key
Problem Recent Solvers3
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!