MINISTRY OF INFORMATION AND COMMUNICATIONS POSTS AND TELECOMMUNICATIONS INSTITUTE OF TECHNOLOGY REPORT PROJECT Fundamentals of Information Security DIGITAL SIGNATURE GENERATION ALGORITHM
Trang 1MINISTRY OF INFORMATION AND COMMUNICATIONS POSTS AND TELECOMMUNICATIONS INSTITUTE OF
TECHNOLOGY
REPORT PROJECT Fundamentals of Information Security
DIGITAL SIGNATURE GENERATION ALGORITHM USING
RSA
Class: E21CQCN03-B Group: 03
Group of student: Mã sinh viên
Lê Minh Tiến B21DCCN704 Dương Kim Tùng B21DCDT235 Phan Hoàng Trung B21DCCN735 Nguyễn Văn Thắng B21DCDT206
Hà Nội – 2024
Trang 2I Introduction 3
II Description 5
1 Architecture 5
1.1 Idea 5
1.2 Architecture 6
2 Algorithm 7
2.1 Key generation, digital signature creation, and signature verification 7
2.2 Use a hash function to map data into fixed-size values 9
3 Weakness 12
3.1 Execution speed: 12
3.2 Cost 12
3.3 Performance 12
4 Attacker 12
4.1 Find the private key 12
4.2 Forgery of signatures (without directly computing the private key 13
5 Applications 14
III Conclusion 15
IV References 16
Trang 3I Introduction
With so many articles being published that highlight how important encryption is nowadays, we must stay aware of every possible route to enforce such standards The RSA algorithm has been a reliable source of security since the early days of computing, and it keeps solidifying itself as a definitive weapon in the line of cybersecurity
Before moving forward with the algorithm, let’s get a refresher on asymmetric encryption since it verifies digital signatures according to
asymmetric cryptography architecture, also known as public-key cryptography architecture
The first question is: “ What does a digital signature mean and how does the RSA algorithm relate to it? ”
A digital signature is a cryptographic technique used to validate the authenticity and integrity of digital messages, documents, or transactions It functions similarly to a handwritten signature or a stamped seal on a physical document but in the digital realm
Also, the RSA algorithm is a widely used asymmetric cryptographic algorithm, named after its inventors Ron Rivest, Adi Shamir, and Leonard Adleman It is used for secure data transmission, digital signatures, and encryption of sensitive information over networks RSA is based on the mathematical properties of large prime numbers and the difficulty of factoring the product of two large prime numbers
For many of those questions, we should continue with: “How does Asymmetric Encryption work in digital signature with RSA algorithm ?”
In Asymmetric Encryption algorithms, you use two different keys, one for encryption and the other for decryption The key used for encryption is the
3
Trang 4public key, and the key used for decryption is the private key But, of course, both the keys must belong to the receiver
RSA encryption relies on a few basic assets and quite a bit of math These elements are required:
A public key (e)
A private key (d)
Two prime numbers (p and q), multiplied (n)
The RSA algorithm for creating digital signatures also involves using a hash function
A hash function is a mathematical function that converts a message of any length into a fixed-length sequence of bits This sequence of bits is called a message digest or hash value, which represents the original message
In some cases, the information being sent may be encrypted or vulnerable to unsafe values In practical RSA implementations, there's often a random transformation involved, such as:
Utilizing standards like PKCS (Public Key Cryptography Standards)
Trang 5 PKCS standards also incorporate additional features to ensure the security
of RSA signatures, such as the Probabilistic Signature Scheme for RSA (RSA-PSS)
5
Trang 6II Description
1 Architecture
1.1 Idea
Example: Alice has two keys, one public key, and one private key Alice provides her public key to Bob but keeps her private key for herself When Alice wants to transfer documents to Bob, she can sign these documents using her private key and send them to Bob Bob can then use Alice's public key to verify that the documents she received were indeed sent by Alice
Trang 71.2 Architecture
Signing Phase:
Compute the message digest (hash value) of the message using a SHA-1 hashing algorithm
Sign the message digest using the sender's private key and the RSA signature generation algorithm The result obtained is the digital signature
S of the message
The original message is concatenated with the digital signature to M S
form the signed message S
The signed message + is sent to the recipient.S M
Verification Phase:
Separate the RSA digital signature and the original message from the signed message for individual processing
7
Trang 8 Compute the message digest of the original message using the hashing D
algorithm SHA-1 used during signing
Use the sender's public key to decrypt the RSA digital signature, we obtained the message digest
Compare and D :
o If , the signature verification is successful The message ensures integrity and genuinely originates from the sender (since the public key is authenticated)
o If , the signature is invalid The message may have been tampered with or does not genuinely originate from the sender
2 Algorithm
2.1 Key generation, digital signature creation, and signature verification Schema
Key Generation:
Trang 9 Consider two prime numbers and p q
Compute ,
Choose e such that
Calculate d such that mod
Public Key ; Private Key
Digital signature creation:
Convert the message into the integer such that P M
Compute
Send and to BobS M
Verification:
Correctly authenticate Alice's public key as and , S M
Check mod n
Confirm Alice’s signature
Example for a key generation:
Generating public key:
Select two prime no's Suppose = 53 and = 59.p q
Now the first part of the Public key: = n p q = 3127
We also need a small exponent say e
But Must be e
o An integer
o Not be a factor of n
o
9
Trang 10 Let us now consider to be equal to 3e
The public key has been made of and n e
Generating private key:
We need to calculate
o Such that so, Φ(n) = 3016
Now calculate : d
o for some integer x
o For = 2, the value of is 2011x d
The private key has been made of d
2.2 Use a hash function to map data into fixed-size values
In practice, to create a digital signature using RSA, it's common to use a hash function of the data instead of directly using the data itself
For example: Alice wants to send Bob a document with her signature To do this, Alice generates a hash value of the document to be signed and computes its value mod The final value is the electronic signature of the documentn
under consideration When Bob receives the document along with the electronic signature, he calculates mod of the signature while also computing n
the hash value of the document If these two values are equal, Bob knows that the signer knows Alice's private key and the document has not been altered since signing This approach offers many benefits such as:
Hash functions are one-way functions, so even if you have the hash, you cannot determine the original message
The hash length is fixed and usually very small, so it won't take up much space
Trang 11 The hash value can also be used to verify whether the received message is intact or not
2.3 Install algorithm in Java
Using BigInteger in the java.math.* package provides most constructors and arithmetic functions to conveniently manipulate large integers
Some functions include:
Constructor BigInteger(int bitLength, int certainty, Random rnd): Generate a random prime integer with the specified bit length
Method BigInteger add(BigInteger val): Add two large integers
Method BigInteger subtract(BigInteger val): Subtract two large integers Method BigInteger multiply(BigInteger val): Multiply two large integers Method gcd(BigInteger val): Find the greatest common divisor (GCD) of two large integers
Method mod(BigInteger m): Calculate the modulo (remainder) of integer division
Method BigInteger modInverse(BigInteger m): Calculate the modular
multiplicative inverse (this^-1 mod m)
Method BigInteger modPow(BigInteger exponent, BigInteger m): Calculate (this^exponent mod m)
For example, RSA encryption can be implemented using these functionalities
Generating keys:
11
Trang 12Encryption: (This code is used in RSA, while in digital signatures, d is privately encrypted)
Decryption: (This code is used in RSA, while in digital signatures, e is publicly encrypted)
Demo’s interface:
Trang 133 Weakness
3.1 Execution speed:
The execution speed of the RSA algorithm is one of its weaknesses compared to symmetric-key cryptography systems
According to estimates, RSA key generation is slower by more than 100 times compared to the symmetric-key DES system when performed using software Additionally, it is slower by more than 1000 times compared to DES when performed using hardware
→ This method also introduces new security challenges One example is the necessity of generating truly random symmetric keys Otherwise, attackers may bypass RSA and focus on guessing the symmetric keys
13
Trang 143.2 Cost
To perform the RSA algorithm, the majority of the computational cost lies
in basic operations such as key generation, encryption, and decryption
The process of signing and verifying signatures is equivalent to the cost of performing exponentiation modulo of n
To ensure the security of the private key, it is common to choose a public exponent much smaller than the secret exponent e d
3.3 Performance
Due to the relatively slow speed of RSA, it is not commonly used for signing large volumes of data Instead, RSA is often used in conjunction with hashing algorithms to enhance flexibility in signing and verifying signatures
4 Attacker
4.1 Find the private key
One of the values , or is leaked:p q, n
During the key generation process, an attacker can easily calculate the private key using the formula: mod
Knowing the private key, an attacker can forge the user's signature
Solution: Ensure the secrecy of p q,, and during the key generation n
process
Attack based on the public key and of the signer:n e
The attacker will attempt to factorize the value of into two prime n
factors, and From there, they can calculate p q and ultimately compute the private key d
Solution: To prevent this attack, it's essential to choose prime numbers p
and large enough to make factoring into the product of two prime q n
Trang 15factors computationally infeasible in real-time In practice, large numbers (at least 100 digits) are typically generated and then checked for primality
Using small prime factors in or :
If we are careless in selecting parameters and such that p q or
has small prime factors, the security of the signature scheme becomes compromised When or has small prime factors,
we can easily use Pollard's algorithm to factorize the modulo of into its n
prime factors
Solution: Choose parameters p and q so that and have large prime factors
4.2 Forgery of signatures (without directly computing the private key
We have: With being a valid signature of , it's possible to S m
construct a pair of valid messages/signatures without knowing the private key
With two signatures, we can create a third signature without knowing the private key
Solution: Encrypt first, sign later
First, encrypt using an encryption function m
Then sign
Where the encryption function mentioned has two types:
o Encodings for this type of attack (Ad-hoc encodings)
PKCS#1 v1.5, ISO 9796-1, ISO 9796-2
Designed to prevent specific attacks but may reveal some weaknesses
o Encodings that ensure security (Provably secure encodings)
15
Trang 16 RSA-FDH, RSA-PSS
Proven to be secure under defined assumptions
5 Applications
Used to ensure data integrity: Signatures, official documents, files, sent over the Internet environment of individuals, organizations, etc Specifically, in: Communication (Email, SMS): When writing an email, we do not need to trust the email provider regarding privacy and forgery We can encrypt the email with the recipient's public key and sign it alongside This way, the sender is assured that there is no forgery, and the message is from the right sender The only issue that may occur is if the provider doesn't deliver the message at all Open-source contributions: Many codes are written in the form of open-source by various individuals They may be users of that open-source code or may be paid for those contributions Maintainers of projects need to ensure that all contributions are useful, but they may lack time to check each contribution They need to be able to trust some people Usually, the first few people are thoroughly checked, but over time, even anyone can become a contributor Everyone trusts each other But they need to be sure it's the same person They need to ensure that each person's contribution doesn't change For this reason, every contribution needs to be signed
Software updates: Think about Smart TVs / Alexa / FritzBox All these devices need updates Suppose we can plug in a USB with an update file into the device As a manufacturer, they want to ensure that the update file is not tampered with They want to ensure that the device will continue to operate So, they share the company's public key in the device When the device finds the update file, it verifies that the company is the source by checking the signature
of the update
Digital certificates: When applying for a job, potential new employers of the candidate may want to see the candidate's reference letters and diplomas
Trang 17Especially when the coronavirus is raging worldwide, those documents are being delivered digitally How do labor users verify if a diploma is valid? Digital signatures can help The candidate will need a digitally signed version of the diploma and may share the public key in a trustworthy manner with the candidate's employer
Cryptocurrency: To prove that someone owns Bitcoin, the system uses asymmetric cryptography From the beginning, someone is assured to be the legitimate owner of the coin Then, the legitimate owner is identified as the owner of the private key, corresponding to a certain public key Please note that digital signatures only prove ownership at a specific point in time They do not solve the problem where the owner can spend the coin twice - the double-spending problem
III Conclusion
The report has introduced the architecture, implementation of the algorithm, weaknesses, and various types of attacks on digital signatures using the RSA algorithm
Creating and verifying digital signatures
Implementation of experiments and verification of digital signatures to ensure data integrity
IV References
https://www.cs.cornell.edu/courses/cs5430/2015sp/notes/rsa_sign_vs_dec php https://geeklaunch.net/blog/what-does-my-rsa-public-key-actually-mean/ http://www2.lawrence.edu/fast/GREGGJ/CMSC510/Ch31/RSA.html
https://cp-algorithms.com/algebra/module-inverse.html
https://www.geeksforgeeks.org/rsa-and-digital-signatures/
17