mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-23 17:22:16 -05:00
allow lists to be subkeys or keyrings
This commit is contained in:
parent
e7b3dd64f4
commit
68f035ff88
@ -59,13 +59,30 @@ public class PgpConversionHelper {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static ArrayList<PGPSecretKey> BytesToPGPSecretKeyList(byte[] keysBytes) {
|
public static ArrayList<PGPSecretKey> BytesToPGPSecretKeyList(byte[] keysBytes) {
|
||||||
PGPSecretKeyRing keyRing = (PGPSecretKeyRing) BytesToPGPKeyRing(keysBytes);
|
PGPObjectFactory factory = new PGPObjectFactory(keysBytes);
|
||||||
|
Object obj = null;
|
||||||
ArrayList<PGPSecretKey> keys = new ArrayList<PGPSecretKey>();
|
ArrayList<PGPSecretKey> keys = new ArrayList<PGPSecretKey>();
|
||||||
|
try {
|
||||||
@SuppressWarnings("unchecked")
|
while ((obj = factory.nextObject()) != null) {
|
||||||
Iterator<PGPSecretKey> itr = keyRing.getSecretKeys();
|
PGPSecretKey secKey = null;
|
||||||
while (itr.hasNext()) {
|
if(obj instanceof PGPSecretKey) {
|
||||||
keys.add(itr.next());
|
if ((secKey = (PGPSecretKey)obj ) == null) {
|
||||||
|
Log.e(Constants.TAG, "No keys given!");
|
||||||
|
}
|
||||||
|
keys.add(secKey);
|
||||||
|
} else if(obj instanceof PGPSecretKeyRing) { //master keys are sent as keyrings
|
||||||
|
PGPSecretKeyRing keyRing = null;
|
||||||
|
if ((keyRing = (PGPSecretKeyRing)obj) == null) {
|
||||||
|
Log.e(Constants.TAG, "No keys given!");
|
||||||
|
}
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
Iterator<PGPSecretKey> itr = keyRing.getSecretKeys();
|
||||||
|
while (itr.hasNext()) {
|
||||||
|
keys.add(itr.next());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return keys;
|
return keys;
|
||||||
|
Loading…
Reference in New Issue
Block a user