]>
nmode's Git Repositories - signal-cli/blob - src/main/java/org/asamk/signal/manager/util/KeyUtils.java
3f9ec08fd55d92f91d7a99a4dc37605d917cf8c1
1 package org
.asamk
.signal
.manager
.util
;
3 import org
.asamk
.signal
.util
.RandomUtils
;
4 import org
.signal
.zkgroup
.InvalidInputException
;
5 import org
.signal
.zkgroup
.profiles
.ProfileKey
;
6 import org
.whispersystems
.signalservice
.api
.kbs
.MasterKey
;
7 import org
.whispersystems
.util
.Base64
;
9 public class KeyUtils
{
14 public static String
createSignalingKey() {
18 public static ProfileKey
createProfileKey() {
20 return new ProfileKey(getSecretBytes(32));
21 } catch (InvalidInputException e
) {
22 throw new AssertionError("Profile key is guaranteed to be 32 bytes here");
26 public static String
createPassword() {
30 public static byte[] createStickerUploadKey() {
31 return getSecretBytes(32);
34 public static MasterKey
createMasterKey() {
35 return MasterKey
.createNew(RandomUtils
.getSecureRandom());
38 private static String
getSecret(int size
) {
39 byte[] secret
= getSecretBytes(size
);
40 return Base64
.encodeBytes(secret
);
43 public static byte[] getSecretBytes(int size
) {
44 byte[] secret
= new byte[size
];
45 RandomUtils
.getSecureRandom().nextBytes(secret
);