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


Java SignatureUtil类代码示例

本文整理汇总了Java中com.digitalpetri.opcua.stack.core.util.SignatureUtil的典型用法代码示例。如果您正苦于以下问题:Java SignatureUtil类的具体用法?Java SignatureUtil怎么用?Java SignatureUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SignatureUtil类属于com.digitalpetri.opcua.stack.core.util包,在下文中一共展示了SignatureUtil类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getServerSignature

import com.digitalpetri.opcua.stack.core.util.SignatureUtil; //导入依赖的package包/类
private SignatureData getServerSignature(ByteString clientNonce,
                                         ByteString clientCertificate,
                                         SecurityPolicy securityPolicy,
                                         KeyPair keyPair) throws UaException {

    if (clientNonce.isNull() || clientCertificate.isNull() || keyPair == null) {
        return new SignatureData(null, null);
    }

    try {
        SecurityAlgorithm algorithm = securityPolicy.getAsymmetricSignatureAlgorithm();

        byte[] data = Bytes.concat(clientCertificate.bytes(), clientNonce.bytes());

        byte[] signature = SignatureUtil.sign(
                algorithm,
                keyPair.getPrivate(),
                ByteBuffer.wrap(data)
        );

        return new SignatureData(algorithm.getUri(), ByteString.of(signature));
    } catch (UaRuntimeException e) {
        throw new UaException(StatusCodes.Bad_SecurityChecksFailed);
    }
}
 
开发者ID:digitalpetri,项目名称:ua-server-sdk,代码行数:26,代码来源:SessionManager.java

示例2: verifyChunk

import com.digitalpetri.opcua.stack.core.util.SignatureUtil; //导入依赖的package包/类
@Override
public void verifyChunk(SecureChannel channel, ByteBuf chunkBuffer) throws UaException {
    SecurityAlgorithm securityAlgorithm = channel.getSecurityPolicy().getSymmetricSignatureAlgorithm();
    byte[] secretKey = channel.getDecryptionKeys(securitySecrets).getSignatureKey();
    int signatureSize = channel.getSymmetricSignatureSize();

    ByteBuffer chunkNioBuffer = chunkBuffer.nioBuffer(0, chunkBuffer.writerIndex());
    chunkNioBuffer.position(0).limit(chunkBuffer.writerIndex() - signatureSize);

    byte[] signature = SignatureUtil.hmac(securityAlgorithm, secretKey, chunkNioBuffer);

    byte[] signatureBytes = new byte[signatureSize];
    chunkNioBuffer.limit(chunkNioBuffer.position() + signatureSize);
    chunkNioBuffer.get(signatureBytes);

    if (!Arrays.equals(signature, signatureBytes)) {
        throw new UaException(StatusCodes.Bad_SecurityChecksFailed, "could not verify signature");
    }
}
 
开发者ID:digitalpetri,项目名称:opc-ua-stack,代码行数:20,代码来源:ChunkDecoder.java

示例3: signChunk

import com.digitalpetri.opcua.stack.core.util.SignatureUtil; //导入依赖的package包/类
@Override
public byte[] signChunk(SecureChannel channel, ByteBuffer chunkNioBuffer) throws UaException {
    return SignatureUtil.sign(
            channel.getSecurityPolicy().getAsymmetricSignatureAlgorithm(),
            channel.getKeyPair().getPrivate(),
            chunkNioBuffer
    );
}
 
开发者ID:digitalpetri,项目名称:opc-ua-stack,代码行数:9,代码来源:ChunkEncoder.java


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