OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
| 2 <html> |
| 3 <head> |
| 4 <script src="../../resources/js-test.js"></script> |
| 5 </head> |
| 6 <body> |
| 7 <script> |
| 8 description("Tests RTCPeerConnection.generateCertificate RSA/ECDSA."); |
| 9 |
| 10 // Signature of the last generateCertificate call. |
| 11 var generateCallString = null; |
| 12 // Global certificate variables so that the "should..." methods can evaluate the
m. |
| 13 var certRSA = null; |
| 14 var certECDSA = null; |
| 15 |
| 16 // 1: RSA-2048 using public exponent = 65537. |
| 17 function generate1RSA() |
| 18 { |
| 19 generateCallString = 'generateCertificate({ name: "RSASSA-PKCS1-v1_5", mod
ulusLength: 2048, publicExponent: 65537 })'; |
| 20 webkitRTCPeerConnection.generateCertificate({ name: "RSASSA-PKCS1-v1_5", mod
ulusLength: 2048, publicExponent: 65537 }) |
| 21 .then(generate1RSASuccessful, generate1RSAFailed); |
| 22 } |
| 23 function generate1RSASuccessful(certificate) |
| 24 { |
| 25 certRSA = certificate; |
| 26 testPassed(generateCallString); |
| 27 certificateSanityCheck(certificate, 'certRSA'); |
| 28 generate2ECDSA(); |
| 29 } |
| 30 function generate1RSAFailed() |
| 31 { |
| 32 testFailed(generateCallString); |
| 33 generate2ECDSA(); |
| 34 } |
| 35 |
| 36 // 2: ECDSA using NIST P-256. |
| 37 function generate2ECDSA() |
| 38 { |
| 39 generateCallString = 'generateCertificate({ name: "ECDSA", namedCurve: "P-
256" })'; |
| 40 webkitRTCPeerConnection.generateCertificate({ name: "ECDSA", namedCurve: "P-
256" }) |
| 41 .then(generate2ECDSASuccessful, generate2ECDSAFailed); |
| 42 } |
| 43 function generate2ECDSASuccessful(certificate) |
| 44 { |
| 45 certECDSA = certificate; |
| 46 testPassed(generateCallString); |
| 47 certificateSanityCheck(certificate, 'certECDSA'); |
| 48 finishJSTest(); |
| 49 } |
| 50 function generate2ECDSAFailed() |
| 51 { |
| 52 testFailed(generateCallString); |
| 53 finishJSTest(); |
| 54 } |
| 55 |
| 56 // Helper methods. |
| 57 function certificateSanityCheck(cert, certVariableName) |
| 58 { |
| 59 shouldBeNonNull(certVariableName); |
| 60 // TODO(hbos): Check cert.expires when WebRTC certificates have reasonable e
xpires values. |
| 61 } |
| 62 |
| 63 // Run each generate test sequentially. The ith generate method will make sure |
| 64 // the (i+1)st generate method is executed when its promise's callbacks are |
| 65 // invoked. generate2ECDSA's callback methods mark the end of the async tests. |
| 66 generate1RSA(); |
| 67 |
| 68 window.jsTestIsAsync = true; |
| 69 window.successfullyParsed = true; |
| 70 </script> |
| 71 </body> |
| 72 </html> |
OLD | NEW |