Exemplo n.º 1
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();

  }