Exemple #1
0
 public StorageKey createStorageKey()
     throws ClassCastException, ClassNotFoundException, InstantiationException,
         IllegalAccessException, TrustedComputingException {
   KeyManager km = getKeyManager();
   StorageRootKey srk = km.loadStorageRootKey(Secret.WELL_KNOWN_SECRET);
   StorageKey storageKey =
       km.createStorageKey(srk, Secret.WELL_KNOWN_SECRET, null, false, false, false, null);
   km.storeTPMKey(srk, storageKey, storageKey.getUUID());
   return storageKey;
 }
Exemple #2
0
 public TPMKey findKeyByUUID(UUID uuid)
     throws TrustedComputingException, ClassCastException, ClassNotFoundException,
         InstantiationException, IllegalAccessException, InvalidInputException {
   KeyManager km = getKeyManager();
   UUID[] keys = km.getStoredTPMKeys();
   StorageRootKey srk = km.loadStorageRootKey(Secret.WELL_KNOWN_SECRET);
   for (UUID u : keys) {
     // System.out.print("Does key : " + uuid + " match with " + u.toString());
     if (u.equals(uuid)) {
       // System.out.println("... yes.");
       TPMKey key = km.loadTPMKey(srk, u, Secret.WELL_KNOWN_SECRET);
       closeContext();
       return key;
     } else {
       // System.out.println("... no.");
     }
   }
   throw new InvalidInputException("Key with this UUID: " + uuid.toString() + " not found");
 }
Exemple #3
0
  public SigningKey createSigningKey()
      throws ClassCastException, ClassNotFoundException, InstantiationException,
          IllegalAccessException, TrustedComputingException {
    KeyManager km = getKeyManager();
    StorageRootKey srk = km.loadStorageRootKey(Secret.WELL_KNOWN_SECRET);
    SigningKey signingKey =
        km.createSigningKey(srk, Secret.WELL_KNOWN_SECRET, null, false, false, false, 1024, null);
    km.storeTPMKey(srk, signingKey, signingKey.getUUID());
    return signingKey;

    //		Signer signer = context.getSigner();
    //		byte[] data = "Hello World".getBytes();
    //		byte[] signedData = signer.sign(data, signingKey);
    //		if ( signer.validate(signedData, data, signingKey.getPublicKey()) ) {
    //			System.out.println("Validated signed data");
    //		} else {
    //			System.out.println("Failed to validate signed data");
    //		}
    //		context.close();

  }