fix: typo in challenge
authorFelix Dörre <felix@dogcraft.de>
Tue, 21 Feb 2017 00:10:10 +0000 (01:10 +0100)
committerFelix Dörre <felix@dogcraft.de>
Tue, 21 Feb 2017 23:44:54 +0000 (00:44 +0100)
Change-Id: I758d9d610b05a111381121e0bf46bd14febf5e4e

src/club/wpia/gigi/crypto/SPKAC.java
tests/club/wpia/gigi/crypto/TestSPKAC.java
tests/club/wpia/gigi/pages/account/TestCertificateAdd.java
util-testing/club/wpia/gigi/pages/Manager.java

index 77c7e2c..359f512 100644 (file)
@@ -73,9 +73,9 @@ public class SPKAC {
         return pubkey;
     }
 
-    public SPKAC(X509Key pubkey, String challange) {
+    public SPKAC(X509Key pubkey, String challenge) {
         this.pubkey = pubkey;
-        challenge = challange;
+        this.challenge = challenge;
     }
 
     public byte[] getEncoded(Signature sign) throws GeneralSecurityException, IOException {
index 7f72242..c12ffd1 100644 (file)
@@ -60,7 +60,7 @@ public class TestSPKAC {
         pkg.initialize(1024);
         KeyPair kp = pkg.generateKeyPair();
 
-        SPKAC s = new SPKAC((X509Key) kp.getPublic(), "this is a even bigger challange");
+        SPKAC s = new SPKAC((X509Key) kp.getPublic(), "this is a even bigger challenge");
         Signature sign = Signature.getInstance("SHA512withRSA");
         sign.initSign(kp.getPrivate());
 
index 9b3a763..854cca7 100644 (file)
@@ -289,7 +289,7 @@ public class TestCertificateAdd extends ClientTest {
         return uc;
     }
 
-    protected String testSPKAC(boolean correctChallange) throws GeneralSecurityException, IOException {
+    protected String testSPKAC(boolean correctChallenge) throws GeneralSecurityException, IOException {
         HttpURLConnection uc = (HttpURLConnection) ncert.openConnection();
         uc.setRequestProperty("Cookie", cookie);
         String s = IOUtils.readURL(uc);
@@ -297,13 +297,13 @@ public class TestCertificateAdd extends ClientTest {
         csrf = extractPattern(s, Pattern.compile("<input [^>]*name='csrf' [^>]*value='([^']*)'>"));
         String challenge = extractPattern(s, Pattern.compile("<keygen [^>]*name=\"SPKAC\" [^>]*challenge=\"([^\"]*)\"/>"));
 
-        SPKAC spk = new SPKAC((X509Key) kp.getPublic(), challenge + (correctChallange ? "" : "b"));
+        SPKAC spk = new SPKAC((X509Key) kp.getPublic(), challenge + (correctChallenge ? "" : "b"));
         Signature sign = Signature.getInstance("SHA512WithRSA");
         sign.initSign(kp.getPrivate());
         try {
             String[] res = fillOutFormDirect("SPKAC=" + URLEncoder.encode(Base64.getEncoder().encodeToString(spk.getEncoded(sign)), "UTF-8"));
-            if ( !correctChallange) {
-                fail("Should not succeed with wrong challange.");
+            if ( !correctChallenge) {
+                fail("Should not succeed with wrong challenge.");
             }
             assertArrayEquals(new String[] {
                     "client", CertificateRequest.DEFAULT_CN, "", Digest.SHA512.toString()
index af05ab4..bd254d5 100644 (file)
@@ -402,13 +402,13 @@ public class Manager extends Page {
                 KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA");
                 kpg.initialize(4096);
                 KeyPair kp = kpg.generateKeyPair();
-                SPKAC s = new SPKAC((X509Key) kp.getPublic(), "challange");
+                SPKAC s = new SPKAC((X509Key) kp.getPublic(), "challenge");
                 Signature sign = Signature.getInstance("SHA512withRSA");
                 sign.initSign(kp.getPrivate());
 
                 byte[] res = s.getEncoded(sign);
 
-                CertificateRequest cr = new CertificateRequest(new AuthorizationContext(u, u), Base64.getEncoder().encodeToString(res), "challange");
+                CertificateRequest cr = new CertificateRequest(new AuthorizationContext(u, u), Base64.getEncoder().encodeToString(res), "challenge");
                 cr.update(CertificateRequest.DEFAULT_CN, Digest.SHA512.toString(), "client", null, "", "email:" + u.getEmail());
                 Certificate draft = cr.draft();
                 draft.issue(null, "2y", u).waitFor(10000);