1. Rhys !
  2. toycrypto

Commits

rimmington  committed 66b0ebe Draft

added NamedAlgorithm.identifier; some renaming for clarification/specification

  • Participants
  • Parent commits 57d54cf
  • Branches default

Comments (0)

Files changed (3)

File ecdh.ceylon

View file
 import toycrypto.primitives { randomBytes, newKeysFromSharedSecret, randomKeyParts, ECDHKeyParts, combineToSharedSecret }
 import toycrypto.math { Point, Domain }
-import toycrypto.spec { SharedKey, aes256, hmacSha1, ByteSerialisable }
+import toycrypto.spec { SharedKey, aes256Ofb, hmacSha1, ByteSerialisable }
 import toycrypto.asn1 { ECPublicKeyInfo, asn1ECPublicKeyInfo, ASN1Sequence, asn1Decodable, OctetString, ASN1Representable }
 import toycrypto.util { compareSequences }
 
 
 shared abstract class EphemeralKey([Integer+] sharedSecret, [Integer+] sharedNonce) {
     value keys = newKeysFromSharedSecret {
-        algorithms = [aes256, hmacSha1];
+        algorithms = [aes256Ofb, hmacSha1];
         sharedSecret = sharedSecret;
         info = "EphemeralKey";
         sharedNonce = sharedNonce;

File spec/algorithms.ceylon

View file
+import toycrypto.asn1 { ObjectIdentifier }
+
 shared interface NamedAlgorithm {
-    shared formal String name;
+    shared formal String javaKeyName;
+    shared formal ObjectIdentifier identifier;
 }
 
 shared interface FixedKeySizeAlgorithm
         satisfies NamedAlgorithm {}
 
 shared interface AES
-        of aes256
+        of aes256Ofb
         satisfies SymmetricEncryptionAlgorithm & FixedKeySizeAlgorithm {}
 
-shared object aes256
+shared object aes256Ofb
         satisfies AES {
-    shared actual String name = "AES";
+    shared actual String javaKeyName = "AES";
     shared actual Integer keyByteSize = 256 / 8;
+    shared actual ObjectIdentifier identifier =
+        ObjectIdentifier([2, 16, 840, 1, 101, 3, 4, 1, 43]);
 }
 
 shared interface HmacAlgorithm
 
 shared object hmacSha1
         satisfies HmacAlgorithm & FixedKeySizeAlgorithm {
-    shared actual String name = "HmacSHA1";
+    shared actual String javaKeyName = "HmacSHA1";
     shared actual Integer keyByteSize = 256 / 8; // TODO: check
+    shared actual ObjectIdentifier identifier =
+        ObjectIdentifier([2, 16, 840, 113549, 2, 7]);
 }

File spec/keys.ceylon

View file
 
 shared class SharedKey([Integer+] bytes, algorithm)
         satisfies Key {
-    shared JavaSecretKey javaKey = SecretKeySpec(arrays.toByteArray(bytes), algorithm.name);
+    shared JavaSecretKey javaKey = SecretKeySpec(arrays.toByteArray(bytes), algorithm.javaKeyName);
     
     shared actual FixedKeySizeAlgorithm algorithm;