当前位置: 首页>>代码示例>>Java>>正文


Java ByteUtil.combine方法代码示例

本文整理汇总了Java中org.whispersystems.libsignal.util.ByteUtil.combine方法的典型用法代码示例。如果您正苦于以下问题:Java ByteUtil.combine方法的具体用法?Java ByteUtil.combine怎么用?Java ByteUtil.combine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.whispersystems.libsignal.util.ByteUtil的用法示例。


在下文中一共展示了ByteUtil.combine方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getFingerprint

import org.whispersystems.libsignal.util.ByteUtil; //导入方法依赖的package包/类
private byte[] getFingerprint(int iterations, String stableIdentifier, List<IdentityKey> unsortedIdentityKeys) {
  try {
    MessageDigest digest    = MessageDigest.getInstance("SHA-512");
    byte[]        publicKey = getLogicalKeyBytes(unsortedIdentityKeys);
    byte[]        hash      = ByteUtil.combine(ByteUtil.shortToByteArray(FINGERPRINT_VERSION),
                                               publicKey, stableIdentifier.getBytes());

    for (int i=0;i<iterations;i++) {
      digest.update(hash);
      hash = digest.digest(publicKey);
    }

    return hash;
  } catch (NoSuchAlgorithmException e) {
    throw new AssertionError(e);
  }
}
 
开发者ID:signalapp,项目名称:libsignal-protocol-java,代码行数:18,代码来源:NumericFingerprintGenerator.java

示例2: SenderKeyMessage

import org.whispersystems.libsignal.util.ByteUtil; //导入方法依赖的package包/类
public SenderKeyMessage(int keyId, int iteration, byte[] ciphertext, ECPrivateKey signatureKey) {
  byte[] version = {ByteUtil.intsToByteHighAndLow(CURRENT_VERSION, CURRENT_VERSION)};
  byte[] message = SignalProtos.SenderKeyMessage.newBuilder()
                                                .setId(keyId)
                                                .setIteration(iteration)
                                                .setCiphertext(ByteString.copyFrom(ciphertext))
                                                .build().toByteArray();

  byte[] signature = getSignature(signatureKey, ByteUtil.combine(version, message));

  this.serialized       = ByteUtil.combine(version, message, signature);
  this.messageVersion   = CURRENT_VERSION;
  this.keyId            = keyId;
  this.iteration        = iteration;
  this.ciphertext       = ciphertext;
}
 
开发者ID:signalapp,项目名称:libsignal-protocol-java,代码行数:17,代码来源:SenderKeyMessage.java

示例3: SignalMessage

import org.whispersystems.libsignal.util.ByteUtil; //导入方法依赖的package包/类
public SignalMessage(int messageVersion, SecretKeySpec macKey, ECPublicKey senderRatchetKey,
                     int counter, int previousCounter, byte[] ciphertext,
                     IdentityKey senderIdentityKey,
                     IdentityKey receiverIdentityKey)
{
  byte[] version = {ByteUtil.intsToByteHighAndLow(messageVersion, CURRENT_VERSION)};
  byte[] message = SignalProtos.SignalMessage.newBuilder()
                                             .setRatchetKey(ByteString.copyFrom(senderRatchetKey.serialize()))
                                             .setCounter(counter)
                                             .setPreviousCounter(previousCounter)
                                             .setCiphertext(ByteString.copyFrom(ciphertext))
                                             .build().toByteArray();

  byte[] mac     = getMac(senderIdentityKey, receiverIdentityKey, macKey, ByteUtil.combine(version, message));

  this.serialized       = ByteUtil.combine(version, message, mac);
  this.senderRatchetKey = senderRatchetKey;
  this.counter          = counter;
  this.previousCounter  = previousCounter;
  this.ciphertext       = ciphertext;
  this.messageVersion   = messageVersion;
}
 
开发者ID:signalapp,项目名称:libsignal-protocol-java,代码行数:23,代码来源:SignalMessage.java

示例4: SenderKeyDistributionMessage

import org.whispersystems.libsignal.util.ByteUtil; //导入方法依赖的package包/类
public SenderKeyDistributionMessage(int id, int iteration, byte[] chainKey, ECPublicKey signatureKey) {
  byte[] version = {ByteUtil.intsToByteHighAndLow(CURRENT_VERSION, CURRENT_VERSION)};
  byte[] protobuf = SignalProtos.SenderKeyDistributionMessage.newBuilder()
                                                             .setId(id)
                                                             .setIteration(iteration)
                                                             .setChainKey(ByteString.copyFrom(chainKey))
                                                             .setSigningKey(ByteString.copyFrom(signatureKey.serialize()))
                                                             .build().toByteArray();

  this.id           = id;
  this.iteration    = iteration;
  this.chainKey     = chainKey;
  this.signatureKey = signatureKey;
  this.serialized   = ByteUtil.combine(version, protobuf);
}
 
开发者ID:signalapp,项目名称:libsignal-protocol-java,代码行数:16,代码来源:SenderKeyDistributionMessage.java

示例5: PreKeySignalMessage

import org.whispersystems.libsignal.util.ByteUtil; //导入方法依赖的package包/类
public PreKeySignalMessage(int messageVersion, int registrationId, Optional<Integer> preKeyId,
                           int signedPreKeyId, ECPublicKey baseKey, IdentityKey identityKey,
                           SignalMessage message)
{
  this.version        = messageVersion;
  this.registrationId = registrationId;
  this.preKeyId       = preKeyId;
  this.signedPreKeyId = signedPreKeyId;
  this.baseKey        = baseKey;
  this.identityKey    = identityKey;
  this.message        = message;

  SignalProtos.PreKeySignalMessage.Builder builder =
      SignalProtos.PreKeySignalMessage.newBuilder()
                                      .setSignedPreKeyId(signedPreKeyId)
                                      .setBaseKey(ByteString.copyFrom(baseKey.serialize()))
                                      .setIdentityKey(ByteString.copyFrom(identityKey.serialize()))
                                      .setMessage(ByteString.copyFrom(message.serialize()))
                                      .setRegistrationId(registrationId);

  if (preKeyId.isPresent()) {
    builder.setPreKeyId(preKeyId.get());
  }

  byte[] versionBytes = {ByteUtil.intsToByteHighAndLow(this.version, CURRENT_VERSION)};
  byte[] messageBytes = builder.build().toByteArray();

  this.serialized = ByteUtil.combine(versionBytes, messageBytes);
}
 
开发者ID:signalapp,项目名称:libsignal-protocol-java,代码行数:30,代码来源:PreKeySignalMessage.java

示例6: serialize

import org.whispersystems.libsignal.util.ByteUtil; //导入方法依赖的package包/类
@Override
public byte[] serialize() {
  byte[] type = {Curve.DJB_TYPE};
  return ByteUtil.combine(type, publicKey);
}
 
开发者ID:signalapp,项目名称:libsignal-protocol-java,代码行数:6,代码来源:DjbECPublicKey.java


注:本文中的org.whispersystems.libsignal.util.ByteUtil.combine方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。