Implement RSASSA-PKCS1-v1_5 sign/verify
authorap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Nov 2013 18:26:36 +0000 (18:26 +0000)
committerap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Nov 2013 18:26:36 +0000 (18:26 +0000)
commit398b8f9906783658e35fe6f30cca236ad0dc1616
treeda0e8c2d2fed7ed514e7b69430bd628bcc16d070
parent91419d4727b588f704bbb3f978f22a10aa483405
Implement RSASSA-PKCS1-v1_5 sign/verify
https://bugs.webkit.org/show_bug.cgi?id=124335

Reviewed by Sam Weinig.

Source/WebCore:

Test: crypto/subtle/rsassa-pkcs1-v1_5-sign-verify.html

* WebCore.xcodeproj/project.pbxproj: Added new files, removed Mac SHA algorithm files.

* crypto/CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp:
(WebCore::getCommonCryptoDigestAlgorithm):
(WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::sign):
(WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::verify):
Implemented. These take two steps, first a digest is computed, and then it's signed.

* crypto/CryptoDigest.h: Added.
* crypto/mac/CryptoDigestMac.cpp: Added.
(WebCore::CryptoDigest::CryptoDigest):
(WebCore::CryptoDigest::~CryptoDigest):
(WebCore::CryptoDigest::create):
(WebCore::CryptoDigest::addBytes):
(WebCore::CryptoDigest::computeHash):
Added a cross-platform interface and Mac implementation to compute a digest. It
should be possible to use it outside WebCrypto if we need to (perhaps even merge
with  WTF SHA-1 class).
The Mac implementation is kind of ugly, but at least it encapsulates the ugliness.

* crypto/algorithms/CryptoAlgorithmSHA1.cpp: (WebCore::CryptoAlgorithmSHA1::digest):
* crypto/algorithms/CryptoAlgorithmSHA224.cpp: (WebCore::CryptoAlgorithmSHA224::digest):
* crypto/algorithms/CryptoAlgorithmSHA256.cpp: (WebCore::CryptoAlgorithmSHA256::digest):
* crypto/algorithms/CryptoAlgorithmSHA384.cpp: (WebCore::CryptoAlgorithmSHA384::digest):
* crypto/algorithms/CryptoAlgorithmSHA512.cpp: (WebCore::CryptoAlgorithmSHA512::digest):
* crypto/mac/CryptoAlgorithmSHA1Mac.cpp: Removed.
* crypto/mac/CryptoAlgorithmSHA224Mac.cpp: Removed.
* crypto/mac/CryptoAlgorithmSHA256Mac.cpp: Removed.
* crypto/mac/CryptoAlgorithmSHA384Mac.cpp: Removed.
* crypto/mac/CryptoAlgorithmSHA512Mac.cpp: Removed.
These are all cross-platform now.

LayoutTests:

* crypto/subtle/rsassa-pkcs1-v1_5-sign-verify-expected.txt: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-sign-verify.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@159292 268f45cc-cd09-0410-ab3c-d52691b4dbfc
17 files changed:
LayoutTests/ChangeLog
LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-sign-verify-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-sign-verify.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/crypto/CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp
Source/WebCore/crypto/CryptoDigest.h [moved from Source/WebCore/crypto/mac/CryptoAlgorithmSHA1Mac.cpp with 70% similarity]
Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA1.cpp
Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA224.cpp
Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA256.cpp
Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA384.cpp
Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA512.cpp
Source/WebCore/crypto/mac/CryptoAlgorithmSHA224Mac.cpp [deleted file]
Source/WebCore/crypto/mac/CryptoAlgorithmSHA256Mac.cpp [deleted file]
Source/WebCore/crypto/mac/CryptoAlgorithmSHA384Mac.cpp [deleted file]
Source/WebCore/crypto/mac/CryptoAlgorithmSHA512Mac.cpp [deleted file]
Source/WebCore/crypto/mac/CryptoDigestMac.cpp [new file with mode: 0644]