MYCryptoTest.m
changeset 21 2c300b15b381
parent 16 c409dbc4f068
child 23 39fec79de6e8
     1.1 --- a/MYCryptoTest.m	Tue Jun 02 13:16:28 2009 -0700
     1.2 +++ b/MYCryptoTest.m	Sat Jun 06 15:01:28 2009 -0700
     1.3 @@ -261,6 +261,14 @@
     1.4      Log(@"Public key = %@ (%u bytes)",pubKeyData,pubKeyData.length);
     1.5      CAssert(pubKeyData);
     1.6      
     1.7 +    NSData *modulus;
     1.8 +    unsigned exponent;
     1.9 +    CAssert([publicKey getModulus: &modulus exponent: &exponent]);
    1.10 +    Log(@"Modulus = %@", modulus);
    1.11 +    Log(@"Exponent = %u", exponent);
    1.12 +    CAssertEq(modulus.length, 2048U/8);
    1.13 +    CAssertEq(exponent,65537U); // this is what CDSA always seems to use
    1.14 +    
    1.15      MYSHA1Digest *pubKeyDigest = publicKey.publicKeyDigest;
    1.16      Log(@"Public key digest = %@",pubKeyDigest);
    1.17      CAssertEqual(pair.publicKeyDigest, pubKeyDigest);
    1.18 @@ -294,7 +302,14 @@
    1.19      CAssertEqual(pub.keyData, pubKeyData);
    1.20      CAssertEqual(pub.publicKeyDigest, pubKeyDigest);
    1.21      CAssert( [pub verifySignature: sig ofData: data] );
    1.22 +    [pub release];
    1.23      Log(@"Verified signature from reconstituted key.");
    1.24 +    
    1.25 +    // Test creating a public key from modulus+exponent:
    1.26 +    Log(@"Reconstituting public key from modulus+exponent...");
    1.27 +    pub = [[MYPublicKey alloc] initWithModulus: modulus exponent: exponent];
    1.28 +    CAssertEqual(pub.keyData, pubKeyData);
    1.29 +    [pub release];
    1.30  }
    1.31  
    1.32