1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-12-26 12:58:02 +01:00

Add method to get keyflags from integer

This commit is contained in:
Paul Schaub 2018-06-19 17:13:57 +02:00
parent 365382b706
commit 47074e50b9
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -15,6 +15,9 @@
*/
package de.vanitasvitae.crypto.pgpainless.algorithm;
import java.util.ArrayList;
import java.util.List;
import org.bouncycastle.bcpg.sig.KeyFlags;
public enum KeyFlag {
@ -37,4 +40,14 @@ public enum KeyFlag {
public int getFlag() {
return flag;
}
public static KeyFlag[] fromInteger(int bitmask) {
List<KeyFlag> flags = new ArrayList<>();
for (KeyFlag f : KeyFlag.values()) {
if ((bitmask & f.flag) != 0) {
flags.add(f);
}
}
return flags.toArray(new KeyFlag[]{});
}
}