import java.lang.reflect.Constructor;
import java.io.File;
+import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.Console;
import java.io.FileInputStream;
private static final Map<String, String> ID_TO_ALG;
private static final Map<String, String> ALG_TO_ID;
+ private static String mKeyPath;
static {
ID_TO_ALG = new HashMap<String, String>();
return null;
}
- char[] password = System.console().readPassword("Password for the private key file: ");
+ char[] password = null;
+ if (System.console() == null) {
+ System.out.print("Enter password for " + mKeyPath + " (password will not be hidden): ");
+ System.out.flush();
+ BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
+ try {
+ password = stdin.readLine().toCharArray();
+ } catch (IOException ex) {
+ return null;
+ }
+ } else {
+ password = System.console().readPassword("Enter password for " + mKeyPath + " key>");
+ }
SecretKeyFactory skFactory = SecretKeyFactory.getInstance(epkInfo.getAlgName());
Key key = skFactory.generateSecret(new PBEKeySpec(password));
}
static PrivateKey loadPEMPrivateKeyFromFile(String keyFname) throws Exception {
+ mKeyPath = keyFname.replace(".pk8","");
return loadPEMPrivateKey(read(keyFname));
}
static PrivateKey loadDERPrivateKeyFromFile(String keyFname) throws Exception {
+ mKeyPath = keyFname.replace(".pk8","");
return loadDERPrivateKey(read(keyFname));
}
}
static PublicKey loadPEMPublicKeyFromFile(String keyFname) throws Exception {
+ mKeyPath = keyFname.replace(".x509.pem","");
return loadPEMPublicKey(read(keyFname));
}
static PublicKey loadDERPublicKeyFromFile(String keyFname) throws Exception {
+ mKeyPath = keyFname.replace(".x509.der","");
return loadDERPublicKey(read(keyFname));
}
import struct
import tempfile
import commands
+import subprocess
VERSION = 0
MAGIC_NUMBER = 0xb001b001
table_file.flush()
cmd = " ".join((signer_path, table_file.name, key_path, signature_file.name))
print cmd
- run(cmd)
+ runcmd = [signer_path, table_file.name, key_path, signature_file.name];
+ sp = subprocess.Popen(runcmd)
+ sp.wait()
return signature_file.read()
def build_verity_table(block_device, data_blocks, root_hash, salt):