812 lines
52 KiB
Objective-C
812 lines
52 KiB
Objective-C
//
|
|
// STDSDirectoryServerCertificateTests.m
|
|
// Stripe3DS2Tests
|
|
//
|
|
// Created by Cameron Sabol on 3/28/19.
|
|
// Copyright © 2019 Stripe. All rights reserved.
|
|
//
|
|
|
|
#import <XCTest/XCTest.h>
|
|
|
|
#import "STDSDirectoryServerCertificate+Internal.h"
|
|
#import "STDSJSONWebSignature.h"
|
|
#import "NSString+JWEHelpers.h"
|
|
|
|
@interface STDSDirectoryServerCertificateTests : XCTestCase
|
|
|
|
@end
|
|
|
|
@implementation STDSDirectoryServerCertificateTests
|
|
|
|
- (void)testCertificateForDirectoryServer {
|
|
NSArray<NSNumber *> *directoryServers = @[
|
|
@(STDSDirectoryServerULTestRSA),
|
|
@(STDSDirectoryServerULTestEC),
|
|
@(STDSDirectoryServerSTPTestRSA),
|
|
@(STDSDirectoryServerSTPTestEC),
|
|
@(STDSDirectoryServerAmex),
|
|
@(STDSDirectoryServerDiscover),
|
|
@(STDSDirectoryServerMastercard),
|
|
@(STDSDirectoryServerVisa),
|
|
@(STDSDirectoryServerCustom),
|
|
@(STDSDirectoryServerUnknown),
|
|
];
|
|
|
|
for (NSNumber *directoryServerNum in directoryServers) {
|
|
STDSDirectoryServer directoryServer = (STDSDirectoryServer)[directoryServerNum integerValue];
|
|
switch (directoryServer) {
|
|
case STDSDirectoryServerULTestRSA:
|
|
case STDSDirectoryServerULTestEC:
|
|
case STDSDirectoryServerSTPTestRSA:
|
|
case STDSDirectoryServerSTPTestEC:
|
|
case STDSDirectoryServerAmex:
|
|
case STDSDirectoryServerCartesBancaires:
|
|
case STDSDirectoryServerDiscover:
|
|
case STDSDirectoryServerMastercard:
|
|
case STDSDirectoryServerVisa:
|
|
XCTAssertNotNil([STDSDirectoryServerCertificate certificateForDirectoryServer:directoryServer], @"Failed creating certificate for type %@", directoryServerNum);
|
|
break;
|
|
|
|
case STDSDirectoryServerCustom:
|
|
case STDSDirectoryServerUnknown:
|
|
XCTAssertNil([STDSDirectoryServerCertificate certificateForDirectoryServer:directoryServer], @"Should return nil for STDSDirectoryServerUnknown");
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
- (void)testKeyType {
|
|
NSArray<NSNumber *> *directoryServers = @[
|
|
@(STDSDirectoryServerULTestRSA),
|
|
@(STDSDirectoryServerULTestEC),
|
|
@(STDSDirectoryServerSTPTestRSA),
|
|
@(STDSDirectoryServerSTPTestEC),
|
|
@(STDSDirectoryServerAmex),
|
|
@(STDSDirectoryServerCartesBancaires),
|
|
@(STDSDirectoryServerDiscover),
|
|
@(STDSDirectoryServerMastercard),
|
|
@(STDSDirectoryServerVisa),
|
|
@(STDSDirectoryServerCustom),
|
|
@(STDSDirectoryServerUnknown),
|
|
];
|
|
|
|
for (NSNumber *directoryServerNum in directoryServers) {
|
|
STDSDirectoryServer directoryServer = (STDSDirectoryServer)[directoryServerNum integerValue];
|
|
STDSDirectoryServerCertificate *certificate = [STDSDirectoryServerCertificate certificateForDirectoryServer:directoryServer];
|
|
switch (directoryServer) {
|
|
case STDSDirectoryServerULTestRSA:
|
|
XCTAssertEqual(certificate.keyType, STDSDirectoryServerKeyTypeRSA, @"Incorrect key type for STDSDirectoryServerULTestRSA");
|
|
break;
|
|
|
|
case STDSDirectoryServerULTestEC:
|
|
XCTAssertEqual(certificate.keyType, STDSDirectoryServerKeyTypeEC, @"Incorrect key type for STDSDirectoryServerULTestEC");
|
|
break;
|
|
|
|
case STDSDirectoryServerSTPTestRSA:
|
|
XCTAssertEqual(certificate.keyType, STDSDirectoryServerKeyTypeRSA, @"Incorrect key type for STDSDirectoryServerSTPTestRSA");
|
|
break;
|
|
|
|
case STDSDirectoryServerSTPTestEC:
|
|
XCTAssertEqual(certificate.keyType, STDSDirectoryServerKeyTypeEC, @"Incorrect key type for STDSDirectoryServerSTPTestEC");
|
|
break;
|
|
|
|
case STDSDirectoryServerAmex:
|
|
XCTAssertEqual(certificate.keyType, STDSDirectoryServerKeyTypeRSA, @"Incorrect key type for STDSDirectoryServerAmex");
|
|
break;
|
|
|
|
case STDSDirectoryServerCartesBancaires:
|
|
XCTAssertEqual(certificate.keyType, STDSDirectoryServerKeyTypeRSA, @"Incorrect key type for STDSDirectoryServerCartesBancaires");
|
|
break;
|
|
|
|
case STDSDirectoryServerDiscover:
|
|
XCTAssertEqual(certificate.keyType, STDSDirectoryServerKeyTypeRSA, @"Incorrect key type for STDSDirectoryServerDiscover");
|
|
break;
|
|
|
|
case STDSDirectoryServerMastercard:
|
|
XCTAssertEqual(certificate.keyType, STDSDirectoryServerKeyTypeRSA, @"Incorrect key type for STDSDirectoryServerMastercard");
|
|
break;
|
|
|
|
case STDSDirectoryServerVisa:
|
|
XCTAssertEqual(certificate.keyType, STDSDirectoryServerKeyTypeRSA, @"Incorrect key type for STDSDirectoryServerVisa");
|
|
break;
|
|
|
|
case STDSDirectoryServerCustom:
|
|
case STDSDirectoryServerUnknown:
|
|
// asserts
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
- (void)testRSA_OAEP_SHA256Encryption {
|
|
STDSDirectoryServerCertificate *certificate = [STDSDirectoryServerCertificate certificateForDirectoryServer:STDSDirectoryServerSTPTestRSA];
|
|
if (certificate != nil) {
|
|
|
|
XCTAssertNotNil([certificate encryptDataUsingRSA_OAEP_SHA256:[@"In nature's infinite book of secrecy a little I can read." dataUsingEncoding:NSUTF8StringEncoding]]);
|
|
} else {
|
|
XCTFail(@"Failed loading certificate for %@", NSStringFromSelector(_cmd));
|
|
}
|
|
}
|
|
|
|
- (void)testCustomCertificate {
|
|
NSString *certificateString = @"MIIDXTCCAkWgAwIBAgIQbS4C4BSig7uuJ5uDpeT4VjANBgkqhkiG9w0BAQsFADBH"
|
|
"MRMwEQYKCZImiZPyLGQBGRYDY29tMRcwFQYKCZImiZPyLGQBGRYHZXhhbXBsZTEX"
|
|
"MBUGA1UEAwwOUlNBIEV4YW1wbGUgRFMwHhcNMTcxMTIxMTE0ODQ5WhcNMjcxMjMx"
|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30x"
|
|
"Fg==";
|
|
|
|
STDSDirectoryServerCertificate *certificate = [STDSDirectoryServerCertificate customCertificateWithData:[[NSData alloc] initWithBase64EncodedString:certificateString options:0]];
|
|
XCTAssertNotNil(certificate, @"Failed to create certificate from string.");
|
|
XCTAssertEqual(certificate.keyType, STDSDirectoryServerKeyTypeRSA, @"Parsed incorrect key type from custom certificate");
|
|
}
|
|
|
|
- (void)testCustomCertificateWithString {
|
|
// Using ds-amex.pm.PEM
|
|
NSString *certificateString = @"MIIE0TCCA7mgAwIBAgIUXbeqM1duFcHk4dDBwT8o7Ln5wX8wDQYJKoZIhvcNAQEL"
|
|
"BQAwXjELMAkGA1UEBhMCVVMxITAfBgNVBAoTGEFtZXJpY2FuIEV4cHJlc3MgQ29t"
|
|
"cGFueTEsMCoGA1UEAxMjQW1lcmljYW4gRXhwcmVzcyBTYWZla2V5IElzc3Vpbmcg"
|
|
"Q0EwHhcNMTgwMjIxMjM0OTMxWhcNMjAwMjIxMjM0OTMwWjCB0DELMAkGA1UEBhMC"
|
|
"VVMxETAPBgNVBAgTCE5ldyBZb3JrMREwDwYDVQQHEwhOZXcgWW9yazE/MD0GA1UE"
|
|
"ChM2QW1lcmljYW4gRXhwcmVzcyBUcmF2ZWwgUmVsYXRlZCBTZXJ2aWNlcyBDb21w"
|
|
"YW55LCBJbmMuMTkwNwYDVQQLEzBHbG9iYWwgTmV0d29yayBUZWNobm9sb2d5IC0g"
|
|
"TmV0d29yayBBUEkgUGxhdGZvcm0xHzAdBgNVBAMTFlNESy5TYWZlS2V5LkVuY3J5"
|
|
"cHRLZXkwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDSFF9kTYbwRrxX"
|
|
"C6WcJJYio5TZDM62+CnjQRfggV3GMI+xIDtMIN8LL/jbWBTycu97vrNjNNv+UPhI"
|
|
"WzhFDdUqyRfrY337A39uE8k1xhdDI3dNeZz6xgq8r9hn2NBou78YPBKidpN5oiHn"
|
|
"TxcFq1zudut2fm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SDirectoryServerCertificate customCertificateWithString:certificateString];
|
|
XCTAssertNotNil(certificate, @"Failed to create certificate from string.");
|
|
XCTAssertEqual(certificate.keyType, STDSDirectoryServerKeyTypeRSA, @"Parsed incorrect key type from custom certificate");
|
|
|
|
// 3ds2.rsa.encryption.crt
|
|
certificateString = @"-----BEGIN CERTIFICATE-----"
|
|
"MIIFrjCCBJagAwIBAgIQB2rJmsHVwbONd36WP9QPrTANBgkqhkiG9w0BAQsFADBx"
|
|
"MQswCQYDVQQGEwJVUzENMAsGA1UEChMEVklTQTEvMC0GA1UECxMmVmlzYSBJbnRl"
|
|
"cm5hdGlvbmFsIFNlcnZpY2UgQXNzb2NpYXRpb24xIjAgBgNVBAMTGVZpc2EgZUNv"
|
|
"bW1lcmNlIElzc3VpbmcgQ0EwHhcNMTcxMTAyMjIyMzEwWhcNMjAxMTAzMDAyMzEw"
|
|
"WjCBoTEYMBYGA1UEBxMPSGlnaGxhbmRzIFJhbmNoMREwDwYDVQQIEwhDb2xvcmFk"
|
|
"bzELMAkGA1UEBhMCVVMxDTALBgNVBAoTBFZJU0ExLzAtBgNVBAsTJlZpc2EgSW50"
|
|
"ZXJuYXRpb25hbCBTZXJ2aWNlIEFzc29jaWF0aW9uMSUwIwYDVQQDExwzZHMyLnJz"
|
|
"YS5lbmNyeXB0aW9uLnZpc2EuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB"
|
|
"CgKCAQEAst+HGfPPsX3p6HHEQ9YzourlQj16Nscmm13Cp7cZe4dZB2oWnJqZ7oh/"
|
|
"pEoEoOAxBw1x4NFgXKTKdHAeu3VBNVw8SwMTdIC+X16VV+3VIyPbUvJXFp3QoR8W"
|
|
"UwPB3F1Lb9SMFNS95boYDZKIOdPW0cP1dRi7pFugsBUZDCP/H3nFfBFHMCBoga+P"
|
|
"3AHGj5y8RVpv0hS9jaIsYjX+i58B61OGCB7D0AiADNZJuFzw2+xpNkt6NJJF66FP"
|
|
"O8qIh8xR2xGVDf7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7KnHUDuLXqwSuzC8lWWCcEqPRgPPzY3mgBUg9ya0p+v7QF2BG77tpygK\n"
|
|
"E2yDPkOE8trzYeMi7TCuvKgZvUXDSOka8SId9QleMBlo2pzNi0vKKBG8+E7qmGaf\n"
|
|
"etQHVaoFvhg24/e7y8q89VYNKfLXn8TWMUOJdTQoNP+4bHcCnBvWWUcI2LlyEog1\n"
|
|
"2FDSG8hgP3cpw+0B2Hace9BQGR7ZgTIJAANEHZ54QGOYdxZEcDS5IEpKZlN8INs/\n"
|
|
"NKJyCkqP09VA4NO/WHaGFAXtgoLmjlA9Kal+4ieJPKijVDxcHVv/uPSfVQJ0/vCa\n"
|
|
"udJGOXV9q4VteupwLxfOGW8w\n"
|
|
"-----END CERTIFICATE-----\n";
|
|
certificate = [STDSDirectoryServerCertificate customCertificateWithString:certificateString];
|
|
XCTAssertNotNil(certificate, @"Failed to create certificate from string.");
|
|
XCTAssertEqual(certificate.keyType, STDSDirectoryServerKeyTypeRSA, @"Parsed incorrect key type from custom certificate");
|
|
|
|
certificateString = @"-----BEGIN CERTIFICATE-----"
|
|
"-----END CERTIFICATE-----";
|
|
certificate = [STDSDirectoryServerCertificate customCertificateWithString:certificateString];
|
|
XCTAssertNil(certificate, @"Should not return a valid value with only anchors");
|
|
XCTAssertEqual(certificate.keyType, STDSDirectoryServerKeyTypeRSA, @"Parsed incorrect key type from custom certificate");
|
|
certificateString = @"-----END CERTIFICATE-----";
|
|
|
|
certificate = [STDSDirectoryServerCertificate customCertificateWithString:certificateString];
|
|
XCTAssertNil(certificate, @"Should not return a valid value with only suffix anchor");
|
|
XCTAssertEqual(certificate.keyType, STDSDirectoryServerKeyTypeRSA, @"Parsed incorrect key type from custom certificate");
|
|
}
|
|
|
|
- (void)testCertificateChainValidation {
|
|
// ref. EMVCo_3DS_-AppBased_CryptoExamples_082018.pdf
|
|
NSString *certificateString = @"MIIDXTCCAkWgAwIBAgIQbS4C4BSig7uuJ5uDpeT4VjANBgkqhkiG9w0BAQsFAD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AOiYy4NarhB3hV"
|
|
"ftkZBmCzi2Qw50KWIgTFYcIVeRTx3Js/F0IuEdgZHBK2gmO7fdM7+QKYm83401vl"
|
|
"YRNCXfIZ0H9E1V3NddqJuqIutdUajckSzMhXdNCJqfI4FAQAymTWGL3/lZyr/30x"
|
|
"Fg==";
|
|
|
|
#pragma clang diagnostic push
|
|
#pragma clang diagnostic ignored "-Wobjc-string-concatenation"
|
|
// ref. EMVCo_3DS_-AppBased_CryptoExamples_082018.pdf
|
|
NSArray<NSString *> *certChain = @[@"MIIDeTCCAmGgAwIBAgIQbS4C4BSig7uuJ5uDpeT4WDANB"
|
|
"gkqhkiG9w0BAQsFADBHMRMwEQYKCZImiZPyLGQBGRYDY29tMRcwFQYKCZImiZPyLGQBG"
|
|
"RYHZXhhbXBsZTEXMBUGA1UEAwwOUlNBIEV4YW1wbGUgRFMwHhcNMTcxMTIxMTE1NDAyW"
|
|
"hcNMjcxMjMxMTMzMDAwWjBIMRMwEQYKCZImiZPyLGQBGRYDY29tMRcwFQYKCZImiZPyL"
|
|
"GQBGRYHZXhhbXBsZTEYMBYGA1UEAwwPUlNBIEV4YW1wbGUgQUNTMIIBIjANBgkqhkiG9"
|
|
"w0BAQEFAAOCAQ8AMIIBCgKCAQEAkNrPIBDXMU6fcyv5i+QHQAQ+K8gsC3HJb7FYhYaw8"
|
|
"hXbNJa+t8q0lDKwLZgQXYV+ffWxXJv5GGrlZE4GU52lfMEegTDzYTrRQ3tepgKFjMGg6"
|
|
"Iy6fkl1ZNsx2gEonsnlShfzA9GJwRTmtKPbk1s+hwx1IU5AT+AIelNqBgcF2vE5W25/S"
|
|
"GGBoaROVdUYxqETDggM1z5cKV4ZjDZ8+lh4oVB07bkac6LQdHpJUUySH/Er20DXx30Ky"
|
|
"i97PciXKTS+QKXnmm8ivyRCmux22ZoPUind2BKC5OiG4MwALhaL2Z2k8CsRdfy+7dg7z"
|
|
"41Rp6D0ZeEvtaUp4bX4aKraL4rTfwIDAQABo2AwXjAMBgNVHRMBAf8EAjAAMA4GA1UdD"
|
|
"wEB/wQEAwIHgDAdBgNVHQ4EFgQUktwf6ZpTCxjYKw/BLW6PeiNX4swwHwYDVR0jBBgwF"
|
|
"oAUw4MCnbwD6m2wpnoQ2sND8GryPN4wDQYJKoZIhvcNAQELBQADggEBAGuNHxv/BR6j7"
|
|
"lCPysm1uhrbjBOqdrhJMR/Id4dB2GtdEScl3irGPmXyQ2SncTWhNfsgsKDZWp5Bk7+Ot"
|
|
"nty0eNUMk3hZEqgYjxhzau048XHbsfGvoJaMGZZNTwUvTUz2hkkhgpx9yQAKIA2LzFKc"
|
|
"gYhelPu4GW5rtEuxu3IS6WYy3D1GtF3naEWkjUra8hQOhOl2S+CYHmRd6lGkXykVDajM"
|
|
"gd2AJFzXdKLxTt0OYrWDGlUSzGACRBCd5xbRmATIldtccaGqDN1cNWv0I/bPN8EpKS6B"
|
|
"0WaZcPasItKWpDC85Jw1GrDxdhwoKHoxtSG+odiTwB5zLbrn2OsRE5bV7E="];
|
|
#pragma clang diagnostic pop
|
|
|
|
XCTAssertTrue([STDSDirectoryServerCertificate _verifyCertificateChain:certChain withRootCertificates:@[certificateString]], @"Failed to verify certificate chain.");
|
|
certChain = @[@"junk_data", @"more_junk"];
|
|
XCTAssertFalse([STDSDirectoryServerCertificate _verifyCertificateChain:certChain withRootCertificates:@[certificateString]], @"Verified certificate chain with invalid certificates.");
|
|
#pragma clang diagnostic push
|
|
#pragma clang diagnostic ignored "-Wobjc-string-concatenation"
|
|
// Test with valid certificates in the chain, but that are not related to the root certificate
|
|
// ref. https://tools.ietf.org/html/rfc7515
|
|
certChain = @[
|
|
@"MIIE3jCCA8agAwIBAgICAwEwDQYJKoZIhvcNAQEFBQAwYzELMAkGA1UEBhMCVVM"
|
|
"xITAfBgNVBAoTGFRoZSBHbyBEYWRkeSBHcm91cCwgSW5jLjExMC8GA1UECxMoR2"
|
|
"8gRGFkZHkgQ2xhc3MgMiBDZXJ0aWZpY2F0aW9uIEF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dUYxqETDggM1z5cKV4ZjDZ8+lh4oVB07bkac6LQdHpJUUySH/Er20DXx30Ky"
|
|
"i97PciXKTS+QKXnmm8ivyRCmux22ZoPUind2BKC5OiG4MwALhaL2Z2k8CsRdfy+7dg7z"
|
|
"41Rp6D0ZeEvtaUp4bX4aKraL4rTfwIDAQABo2AwXjAMBgNVHRMBAf8EAjAAMA4GA1UdD"
|
|
"wEB/wQEAwIHgDAdBgNVHQ4EFgQUktwf6ZpTCxjYKw/BLW6PeiNX4swwHwYDVR0jBBgwF"
|
|
"oAUw4MCnbwD6m2wpnoQ2sND8GryPN4wDQYJKoZIhvcNAQELBQADggEBAGuNHxv/BR6j7"
|
|
"lCPysm1uhrbjBOqdrhJMR/Id4dB2GtdEScl3irGPmXyQ2SncTWhNfsgsKDZWp5Bk7+Ot"
|
|
"nty0eNUMk3hZEqgYjxhzau048XHbsfGvoJaMGZZNTwUvTUz2hkkhgpx9yQAKIA2LzFKc"
|
|
"gYhelPu4GW5rtEuxu3IS6WYy3D1GtF3naEWkjUra8hQOhOl2S+CYHmRd6lGkXykVDajM"
|
|
"gd2AJFzXdKLxTt0OYrWDGlUSzGACRBCd5xbRmATIldtccaGqDN1cNWv0I/bPN8EpKS6B"
|
|
"0WaZcPasItKWpDC85Jw1GrDxdhwoKHoxtSG+odiTwB5zLbrn2OsRE5bV7E=",];
|
|
XCTAssertFalse([STDSDirectoryServerCertificate _verifyCertificateChain:certChain withRootCertificates:@[certificateString]], @"Verified invalid certificate chain.");
|
|
|
|
// stripe.com's cert chain retrieved by https://whatsmychaincert.com/
|
|
// If below test cases start failing, the certs may have expired and should be replaced with newer ones
|
|
// from whatsmychaincert.com, select Generate Cert Chain, include root for stripe.com
|
|
// print the entire certificate chain with `openssl crl2pkcs7 -nocrl -certfile <cert file> | openssl pkcs7 -print_certs -text`
|
|
// The root is the last printed certificate and the cert chain should be ordered with the top most at the end of certChain
|
|
|
|
certChain = @[
|
|
@"MIIEtjCCA56gAwIBAgIQDHmpR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Q8JWaCbuMA0GCSqGSIb3DQEBCwUAA4ICAQAtwW8siyCi"
|
|
"mhon1WUAUmufZ7bbegf3cTOafQh77NvA0xgVeloELUNCwsSSZgcOIa4Zgpsa0xi5"
|
|
"fYxXsPLgVPLM0mBhTOD1DnPu1AAm32QVelHe6oB98XxbkQlHGXeOLs62PLtDZd94"
|
|
"7pm08QMVb+MoCnHLaBLV6eKhKK+SNrfcxr33m0h3v2EMoiJ6zCvp8HgIHEhVpleU"
|
|
"8H2Uo5YObatb/KUHgtp2z0vEfyGhZR7hrr48vUQpfVGBABsCV0aqUkPxtAXWfQo9"
|
|
"1N9B7H3EIcSjbiUz5vkj9YeDSyJIi0Y/IZbzuNMsz2cRi1CWLl37w2fe128qWxYq"
|
|
"Y/k+Y4HX7uYchB8xPaZR4JczCvg1FV2JrkOcFvElVXWSMpBbe2PS6OMr3XxrHjzp"
|
|
"DyM9qvzge0Ai9+rq8AyGoG1dP2Ay83Ndlgi42X3yl1uEUW2feGojCQQCFFArazEj"
|
|
"LUkSlrB2kA12SWAhsqqQwnBLGSTp7PqPZeWkluQVXS0sbj0878kTra6TjG3U+KqO"
|
|
"JCj8v6G380qIkAXe1xMHHNQ6GS59HZMeBPYkK2y5hmh/JVo4bRfK7Ya3blBSBfB8"
|
|
"AVWQ5GqVWklvXZsQLN7FH/fMIT3y8iE1W19Ua4whlhvn7o/aYWOkHr1G2xyh8BHj"
|
|
"7H63A2hjcPlW/ZAJSTuBZUClAhsNohH2Jg==";
|
|
|
|
XCTAssertTrue([STDSDirectoryServerCertificate _verifyCertificateChain:certChain withRootCertificates:@[rootCertificateString]], @"Failed to verify w/ root certificate.");
|
|
XCTAssertFalse([STDSDirectoryServerCertificate _verifyCertificateChain:certChain withRootCertificates:@[dsCertificateString]], @"Should not verify w/ DS certificate.");
|
|
NSArray<NSString *> *bothCertificateStrings = @[dsCertificateString, rootCertificateString];
|
|
XCTAssertTrue([STDSDirectoryServerCertificate _verifyCertificateChain:certChain withRootCertificates:bothCertificateStrings], @"Failed to verify w/ root certificate and ds certificate.");
|
|
}
|
|
|
|
- (void)testVerifyPS256Signature {
|
|
// ref. EMVCo_3DS_-AppBased_CryptoExamples_082018.pdf
|
|
NSString *jwsString = @"eyJhbGciOiJQUzI1NiIsIng1YyI6WyJNSUlEZVRDQ0FtR2dBd0lCQWdJUWJTNEM0QlNp"
|
|
"Zzd1dUo1dURwZVQ0V0RBTkJna3Foa2lHOXcwQkFRc0ZBREJITVJNd0VRWUtDWkltaVpQ"
|
|
"eUxHUUJHUllEWTI5dE1SY3dGUVlLQ1pJbWlaUHlMR1FCR1JZSFpYaGhiWEJzWlRFWE1C"
|
|
"VUdBMVVFQXd3T1VsTkJJRVY0WVcxd2JHVWdSRk13SGhjTk1UY3hNVEl4TVRFMU5EQXlX"
|
|
"aGNOTWpjeE1qTXhNVE16TURBd1dqQklNUk13RVFZS0NaSW1pWlB5TEdRQkdSWURZMjl0"
|
|
"TVJjd0ZRWUtDWkltaVpQeUxHUUJHUllIWlhoaGJYQnNaVEVZTUJZR0ExVUVBd3dQVWxO"
|
|
"QklFVjRZVzF3YkdVZ1FVTlRNSUlCSWpBTkJna3Foa2lHOXcwQkFRRUZBQU9DQVE4QU1J"
|
|
"SUJDZ0tDQVFFQWtOclBJQkRYTVU2ZmN5djVpK1FIUUFRK0s4Z3NDM0hKYjdGWWhZYXc4"
|
|
"aFhiTkphK3Q4cTBsREt3TFpnUVhZVitmZld4WEp2NUdHcmxaRTRHVTUybGZNRWVnVER6"
|
|
"WVRyUlEzdGVwZ0tGak1HZzZJeTZma2wxWk5zeDJnRW9uc25sU2hmekE5R0p3UlRtdEtQ"
|
|
"Ymsxcytod3gxSVU1QVQrQUllbE5xQmdjRjJ2RTVXMjUvU0dHQm9hUk9WZFVZeHFFVERn"
|
|
"Z00xejVjS1Y0WmpEWjgrbGg0b1ZCMDdia2FjNkxRZEhwSlVVeVNIL0VyMjBEWHgzMEt5"
|
|
"aTk3UGNpWEtUUytRS1hubW04aXZ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QXNJbUdlQVM0NmZ5V3c1TWhmR1RUMElqQnBGdzJTUzM0RHY0"
|
|
"SXJzIix9LCJTREsgRXBoZW1lcmFsIFB1YmxpYyBLZXkgKFFDKSI6eyJrdHkiOiJFQyIs"
|
|
"ImNydiI6IlAtMjU2IiwieCI6IlplMmxvU1Yzd3Jyb0tVTl80emh3R2hDcW8zWGh1MXRk"
|
|
"NFFqZVE1d0lWUjAiLCJ5IjoiSGxMdGRYQVJZX2Y1NUEzZm56UWJQY202aGdyMzRNcDhw"
|
|
"LW51elFDRTBadyIsfSwiQUNTIFVSTCI6Imh0dHA6Ly9hY3NzZXJ2ZXIuZG9tYWlubmFt"
|
|
"ZS5jb20ifQ"
|
|
"."
|
|
"OiiD5pbwe_0wrG_j61LmUxidBzTbUHyZXrKE9efRylEgMJy0axYJLOUshIloiKMexPdo"
|
|
"yDdpZV5pMQR588q-"
|
|
"uuUfssKpDXj3dCrIlUCEwgs4yfIBAUwd2NHoDg20w25ek0NPH9RV_T867DAXIjDWyd2I"
|
|
"y0ZFvJeHSrRskyPY75PA_mAUIpahaW20rxJHHMyGuWx2byKxnIx6G14vXCOPp1xEv49K"
|
|
"xKWrgFLS3_GtVYuNDqQC5pleHd4drLKSbq1bjwqEM1osYEZvw9y-"
|
|
"f1vQYxAQ8GJEti9F_309GVCZSWe1oyNDY51mo-"
|
|
"BwiyojoCDPxQDOTp6g4lp656tUQNW16g";
|
|
STDSJSONWebSignature *jws = [[STDSJSONWebSignature alloc] initWithString:jwsString];
|
|
|
|
// ref. EMVCo_3DS_-AppBased_CryptoExamples_082018.pdf
|
|
NSString *certificateString = @"MIIDXTCCAkWgAwIBAgIQbS4C4BSig7uuJ5uDpeT4VjANBgkqhkiG9w0BAQsFADBH"
|
|
"MRMwEQYKCZImiZPyLGQBGRYDY29tMRcwFQYKCZImiZPyLGQBGRYHZXhhbXBsZTEX"
|
|
"MBUGA1UEAwwOUlNBIEV4YW1wbGUgRFMwHhcNMTcxMTIxMTE0ODQ5W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QAymTWGL3/lZyr/30x"
|
|
"Fg==";
|
|
|
|
XCTAssertTrue([STDSDirectoryServerCertificate verifyJSONWebSignature:jws withRootCertificates:@[certificateString]], @"Failed to validate correct PS256 signature.");
|
|
}
|
|
|
|
- (void)testVerifyPS256SignatureFail {
|
|
// ref. EMVCo_3DS_-AppBased_CryptoExamples_082018.pdf
|
|
NSString *jwsString = @"eyJhbGciOiJQUzI1NiIsIng1YyI6WyJNSUlEZVRDQ0FtR2dBd0lCQWdJUWJTNEM0QlNp"
|
|
"Zzd1dUo1dURwZVQ0V0RBTkJna3Foa2lHOXcwQkFRc0ZBREJITVJNd0VRWUtDWkltaVpQ"
|
|
"eUxHUUJHUllEWTI5dE1SY3dGUVlLQ1pJbWlaUHlMR1FCR1JZSFpYaGhiWEJzWlRFWE1C"
|
|
"VUdBMVVFQXd3T1VsTkJJRVY0WVcxd2JHVWdSRk13SGhjTk1UY3hNVEl4TVRFMU5EQXlX"
|
|
"aGNOTWpjeE1qTXhNVE16TURBd1dqQklNUk13RVFZS0NaSW1pWlB5TEdRQkdSWURZMjl0"
|
|
"TVJjd0ZRWUtDWkltaVpQeUxHUUJHUllIWlhoaGJYQnNaVEVZTUJZR0ExVUVBd3dQVWxO"
|
|
"QklFVjRZVzF3YkdVZ1FVTlRNSUlCSWpBTkJna3Foa2lHOXcwQkFRRUZBQU9DQVE4QU1J"
|
|
"SUJDZ0tDQVFFQWtOclBJQkRYTVU2ZmN5djVpK1FIUUFRK0s4Z3NDM0hKYjdGWWhZYXc4"
|
|
"aFhiTkphK3Q4cTBsREt3TFpnUVhZVitmZld4WEp2NUdHcmxaRTRHVTUybGZNRWVnVER6"
|
|
"WVRyUlEzdGVwZ0tGak1HZzZJeTZma2wxWk5zeDJnRW9uc25sU2hmekE5R0p3UlRtdEtQ"
|
|
"Ymsxcytod3gxSVU1QVQrQUllbE5xQmdjRjJ2RTVXMjUvU0dHQm9hUk9WZFVZeHFFVERn"
|
|
"Z00xejVjS1Y0WmpEWjg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6Im1QVUtUX2JBV0dISWhnMFRwampxVnNQMXJYV1F1X3Z3Vk9ISHRO"
|
|
"a2RZb0EiLCJ5IjoiOEJRQXNJbUdlQVM0NmZ5V3c1TWhmR1RUMElqQnBGdzJTUzM0RHY0"
|
|
"SXJzIix9LCJTREsgRXBoZW1lcmFsIFB1YmxpYyBLZXkgKFFDKSI6eyJrdHkiOiJFQyIs"
|
|
"ImNydiI6IlAtMjU2IiwieCI6IlplMmxvU1Yzd3Jyb0tVTl80emh3R2hDcW8zWGh1MXRk"
|
|
"NFFqZVE1d0lWUjAiLCJ5IjoiSGxMdGRYQVJZX2Y1NUEzZm56UWJQY202aGdyMzRNcDhw"
|
|
"LW51elFDRTBadyIsfSwiQUNTIFVSTCI6Imh0dHA6Ly9hY3NzZXJ2ZXIuZG9tYWlubmFt"
|
|
"ZS5jb20ifQ"
|
|
"."
|
|
"OiiD5pbwe_0wrG_j61LmUxidBzTbUHyZXrKE9efRylEgMJy0axYJLOUshIloiKMexPdo"
|
|
"yDdpZV5pMQR588q-"
|
|
"uuUfssKpDXj3dCrIlUCEwgs4yfIBAUwd2NHoDg20w25ek0NPH9RV_T867DAXIjDWyd2I"
|
|
"y0ZFvJeHSrRskyPY75PA_mAUIpahaW20rxJHHMyGuWx2byKxnIx6G14vXCOPp1xEv49K"
|
|
"xKWrgFLS3_GtVYuNDqQC5pleHd4drLKSbq1bjwqEM1osYEZvw9y-"
|
|
"f1vQYxAQ8GJEti9F_309GVCZSWe1oyNEY51mo-" // This is all the same as testVerifyPS256Signature, except this line where "NDY51mo-" became "NEY51mo-"
|
|
"BwiyojoCDPxQDOTp6g4lp656tUQNW16g";
|
|
STDSJSONWebSignature *jws = [[STDSJSONWebSignature alloc] initWithString:jwsString];
|
|
|
|
// ref. EMVCo_3DS_-AppBased_CryptoExamples_082018.pdf
|
|
NSString *certificateString = @"MIIDXTCCAkWgAwIBAgIQbS4C4BSig7uuJ5uDpeT4VjANBgkqhkiG9w0BAQsFADBH"
|
|
"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B3hV"
|
|
"ftkZBmCzi2Qw50KWIgTFYcIVeRTx3Js/F0IuEdgZHBK2gmO7fdM7+QKYm83401vl"
|
|
"YRNCXfIZ0H9E1V3NddqJuqIutdUajckSzMhXdNCJqfI4FAQAymTWGL3/lZyr/30x"
|
|
"Fg==";
|
|
|
|
XCTAssertFalse([STDSDirectoryServerCertificate verifyJSONWebSignature:jws withRootCertificates:@[certificateString]], @"Incorrectly validated PS256 signature.");
|
|
}
|
|
|
|
- (void)testVerifyES256Signature {
|
|
// ref. EMVCo_3DS_-AppBased_CryptoExamples_082018.pdf
|
|
NSString *jwsString = @"eyJhbGciOiJFUzI1NiIsIng1YyI6WyJNSUlDclRDQ0FaV2dBd0lCQWdJUWJTNEM0QlNp"
|
|
"Zzd1dUo1dURwZVQ0V1RBTkJna3Foa2lHOXcwQkFRc0ZBREJITVJNd0VRWUtDWkltaVpQ"
|
|
"eUxHUUJHUllEWTI5dE1SY3dGUVlLQ1pJbWlaUHlMR1FCR1JZSFpYaGhiWEJzWlRFWE1C"
|
|
"VUdBMVVFQXd3T1VsTkJJRVY0WVcxd2JHVWdSRk13SGhjTk1UY3hNVEl4TVRVME16STNX"
|
|
"aGNOTWpjeE1qTXhNVE16TURBd1dqQkhNUk13RVFZS0NaSW1pWlB5TEdRQkdSWURZMjl0"
|
|
"TVJjd0ZRWUtDWkltaVpQeUxHUUJHUllIWlhoaGJYQnNaVEVYTUJVR0ExVUVBd3dPUlVN"
|
|
"Z1JYaGhiWEJzWlNCQlExTXdXVEFUQmdjcWhrak9QUUlCQmdncWhrak9QUU1CQndOQ0FB"
|
|
"VGZvZml3YzZBaXUxWWc1dkc5ZUtYSGVEQ1ZoOWgzVk1xTjIveUoxQ1dHVWlwOEJqOHEr"
|
|
"ZXJPbzc0dHQ2akVUTXpBYVRwekxaNW9HRFpjZVpmR21NN2RvMkF3WGpBTUJnTlZIUk1C"
|
|
"QWY4RUFqQUFNQTRHQTFVZER3RUIvd1FFQXdJSGdEQWRCZ05W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zWGh1MXRk"
|
|
"NFFqZVE1d0lWUjAiLCJ5IjoiSGxMdGRYQVJZX2Y1NUEzZm56UWJQY202aGdyMzRNcDhw"
|
|
"LW51elFDRTBadyIsfSwiQUNTIFVSTCI6Imh0dHA6Ly9hY3NzZXJ2ZXIuZG9tYWlubmFt"
|
|
"ZS5jb20ifQ"
|
|
"."
|
|
"KMNtxy3eZMDnVRK_UZvFtRY8fDuAAHJXHCaKncoViB3dy56u5VOT0XnB8K-"
|
|
"0nWwFhwWmwU1xGVwimBcfxNplCA";
|
|
STDSJSONWebSignature *jws = [[STDSJSONWebSignature alloc] initWithString:jwsString];
|
|
|
|
// ref. EMVCo_3DS_-AppBased_CryptoExamples_082018.pdf
|
|
NSString *certificateString = @"MIIDXTCCAkWgAwIBAgIQbS4C4BSig7uuJ5uDpeT4VjANBgkqhkiG9w0BAQsFADBH"
|
|
"MRMwEQYKCZImiZPyLGQBGRYDY29tMRcwFQYKCZImiZPyLGQBGRYHZXhhbXBsZTEX"
|
|
"MBUGA1UEAwwOUlNBIEV4YW1wbGUgRFMwHhcNMTcxMTIxMTE0ODQ5WhcNMjcxMjMx"
|
|
"MTQwMDAwWjBHMRMwEQYKCZImiZPyLGQBGRYDY29tMRcwFQYKCZImiZPyLGQBGRYH"
|
|
"ZXhhbXBsZTEXMBUGA1UEAwwOUlNBIEV4YW1wbGUgRFMwggEiMA0GCSqGSIb3DQEB"
|
|
"AQUAA4IBDwAwggEKAoIBAQCfgQ+0A4Jz0CWR5Ac/MdK2ABuCzttNkvBQFl1Hz8q4"
|
|
"o8Qct3isdVN5P475dXaNGiN02HElZMO813uepDRUSJlAfP8AmZIKkxokxEFIUqsp"
|
|
"vbCpXAZT82xg5gv5C2JY3aVvNwR7pcLR0CmvnJ1AuseqQceKDdEGit1pnoCP6gEe"
|
|
"oUQdik97tOl7459V8d3UTpxLozUVlwPU00tgPmUUek8j1tPAmWx17e6EaoLRkK4Q"
|
|
"eDyWHPA4eu0hBtLQVVtv2Tf61VNTh+D/cv++eJQUArC4IuoqdLYFjB2r+bNKdstj"
|
|
"uH+qLGhHuOKDf/+RGG5rHBSRHPmJqJCSqBzmAd2s0/nPAgMBAAGjRTBDMBIGA1Ud"
|
|
"EwEB/wQIMAYBAf8CAQAwDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBTDgwKdvAPq"
|
|
"bbCmehDaw0PwavI83jANBgkqhkiG9w0BAQsFAAOCAQEAOUcKqpzNQ6lr0PbDSsns"
|
|
"D6onfi+8j3TD0xG0zBSf+8G4zs8Zb6vzzQ5qHKgfr4aeen8Pw0cw2KKUJ2dFaBqj"
|
|
"n3/6/MIZbgaBvXKUbmY8xCxKQ+tOFc3KWIu4pSaO50tMPJjU/lP35bv19AA9vs9M"
|
|
"TKY2qLf88bmoNYT3W8VSDcB58KBHa7HVIPx7BUUtSyb2N2Jqx5AOiYy4NarhB3hV"
|
|
"ftkZBmCzi2Qw50KWIgTFYcIVeRTx3Js/F0IuEdgZHBK2gmO7fdM7+QKYm83401vl"
|
|
"YRNCXfIZ0H9E1V3NddqJuqIutdUajckSzMhXdNCJqfI4FAQAymTWGL3/lZyr/30x"
|
|
"Fg==";
|
|
|
|
XCTAssertTrue([STDSDirectoryServerCertificate verifyJSONWebSignature:jws withRootCertificates:@[certificateString]], @"Failed to verify valid ES256 signature.");
|
|
}
|
|
|
|
- (void)testVerifyES256SignatureFail {
|
|
// ref. EMVCo_3DS_-AppBased_CryptoExamples_082018.pdf
|
|
NSString *jwsString = @"eyJhbGciOiJFUzI1NiIsIng1YyI6WyJNSUlDclRDQ0FaV2dBd0lCQWdJUWJTNEM0QlNp"
|
|
"Zzd1dUo1dURwZVQ0V1RBTkJna3Foa2lHOXcwQkFRc0ZBREJITVJNd0VRWUtDWkltaVpQ"
|
|
"eUxHUUJHUllEWTI5dE1SY3dGUVlLQ1pJbWlaUHlMR1FCR1JZSFpYaGhiWEJzWlRFWE1C"
|
|
"VUdBMVVFQXd3T1VsTkJJRVY0WVcxd2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FZdnl4SHE5WCthNjRJaFhjbFhuZ1BRTXJVcU1vTFdJ"
|
|
"MTY2Z1JKU3ZRRVdzSUxJVXR4MndzaVlzPSJdfQ"
|
|
"."
|
|
"eyJBQ1MgRXBoZW1lcmFsIFB1YmxpYyBLZXkgKFFUKSI6eyJrdHkiOiJFQyIsImNydiI6"
|
|
"IlAtMjU2IiwieCI6Im1QVUtUX2JBV0dISWhnMFRwampxVnNQMXJYV1F1X3Z3Vk9ISHRO"
|
|
"a2RZb0EiLCJ5IjoiOEJRQXNJbUdlQVM0NmZ5V3c1TWhmR1RUMElqQnBGdzJTUzM0RHY0"
|
|
"SXJzIix9LCJTREsgRXBoZW1lcmFsIFB1YmxpYyBLZXkgKFFDKSI6eyJrdHkiOiJFQyIs"
|
|
"ImNydiI6IlAtMjU2IiwieCI6IlplMmxvU1Yzd3Jyb0tVTl80emh3R2hDcW8zWGh1MXRk"
|
|
"NFFqZVE1d0lWUjAiLCJ5IjoiSGxMdGRYQVJZX2Y1NUEzZm56UWJQY202aGdyMzRNcDhw"
|
|
"LW51elFDRTBadyIsfSwiQUNTIFVSTCI6Imh0dHA6Ly9hY3NzZXJ2ZXIuZG9tYWlubMFt" // This is all the same as testVerifyPS256Signature, except this line where "bmFt" became "bMFt"
|
|
"ZS5jb20ifQ"
|
|
"."
|
|
"KMNtxy3eZMDnVRK_UZvFtRY8fDuAAHJXHCaKncoViB3dy56u5VOT0XnB8K-"
|
|
"0nWwFhwWmwU1xGVwimBcfxNplCA";
|
|
STDSJSONWebSignature *jws = [[STDSJSONWebSignature alloc] initWithString:jwsString];
|
|
|
|
// ref. EMVCo_3DS_-AppBased_CryptoExamples_082018.pdf
|
|
NSString *certificateString = @"MIIDXTCCAkWgAwIBAgIQbS4C4BSig7uuJ5uDpeT4VjANBgkqhkiG9w0BAQsFADBH"
|
|
"MRMwEQYKCZImiZPyLGQBGRYDY29tMRcwFQYKCZImiZPyLGQBGRYHZXhhbXBsZTEX"
|
|
"MBUGA1UEAww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YRNCXfIZ0H9E1V3NddqJuqIutdUajckSzMhXdNCJqfI4FAQAymTWGL3/lZyr/30x"
|
|
"Fg==";
|
|
|
|
XCTAssertFalse([STDSDirectoryServerCertificate verifyJSONWebSignature:jws withRootCertificates:@[certificateString]], @"Verified invalid ES256 signature.");
|
|
}
|
|
|
|
@end
|