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


Java MacAlg类代码示例

本文整理汇总了Java中sun.security.ssl.CipherSuite.MacAlg的典型用法代码示例。如果您正苦于以下问题:Java MacAlg类的具体用法?Java MacAlg怎么用?Java MacAlg使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: MAC

import sun.security.ssl.CipherSuite.MacAlg; //导入依赖的package包/类
/**
 * Set up, configured for the given SSL/TLS MAC type and version.
 */
MAC(MacAlg macAlg, ProtocolVersion protocolVersion, SecretKey key)
        throws NoSuchAlgorithmException, InvalidKeyException {
    super(protocolVersion);
    this.macAlg = macAlg;

    String algorithm;
    boolean tls = (protocolVersion.v >= ProtocolVersion.TLS10.v);

    if (macAlg == M_MD5) {
        algorithm = tls ? "HmacMD5" : "SslMacMD5";
    } else if (macAlg == M_SHA) {
        algorithm = tls ? "HmacSHA1" : "SslMacSHA1";
    } else if (macAlg == M_SHA256) {
        algorithm = "HmacSHA256";    // TLS 1.2+
    } else if (macAlg == M_SHA384) {
        algorithm = "HmacSHA384";    // TLS 1.2+
    } else {
        throw new RuntimeException("Unknown Mac " + macAlg);
    }

    mac = JsseJce.getMac(algorithm);
    mac.init(key);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:27,代码来源:MAC.java

示例2: MAC

import sun.security.ssl.CipherSuite.MacAlg; //导入依赖的package包/类
/**
 * Set up, configured for the given MAC type and version.
 */
MAC(MacAlg macAlg, ProtocolVersion protocolVersion, SecretKey key)
        throws NoSuchAlgorithmException, InvalidKeyException {
    super(protocolVersion);
    this.macAlg = macAlg;

    String algorithm;

    // using SSL MAC computation?
    boolean useSSLMac = (protocolVersion.v < ProtocolVersion.TLS10.v);

    if (macAlg == M_MD5) {
        algorithm = useSSLMac ? "SslMacMD5" : "HmacMD5";
    } else if (macAlg == M_SHA) {
        algorithm = useSSLMac ? "SslMacSHA1" : "HmacSHA1";
    } else if (macAlg == M_SHA256) {
        algorithm = "HmacSHA256";    // TLS 1.2+
    } else if (macAlg == M_SHA384) {
        algorithm = "HmacSHA384";    // TLS 1.2+
    } else {
        throw new RuntimeException("Unknown Mac " + macAlg);
    }

    mac = JsseJce.getMac(algorithm);
    mac.init(key);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:29,代码来源:MAC.java

示例3: MAC

import sun.security.ssl.CipherSuite.MacAlg; //导入依赖的package包/类
/**
 * Set up, configured for the given SSL/TLS MAC type and version.
 */
MAC(MacAlg macAlg, ProtocolVersion protocolVersion, SecretKey key)
        throws NoSuchAlgorithmException, InvalidKeyException {
    this.macAlg = macAlg;
    this.macSize = macAlg.size;

    String algorithm;
    boolean tls = (protocolVersion.v >= ProtocolVersion.TLS10.v);

    if (macAlg == M_MD5) {
        algorithm = tls ? "HmacMD5" : "SslMacMD5";
    } else if (macAlg == M_SHA) {
        algorithm = tls ? "HmacSHA1" : "SslMacSHA1";
    } else if (macAlg == M_SHA256) {
        algorithm = "HmacSHA256";    // TLS 1.2+
    } else if (macAlg == M_SHA384) {
        algorithm = "HmacSHA384";    // TLS 1.2+
    } else {
        throw new RuntimeException("Unknown Mac " + macAlg);
    }

    mac = JsseJce.getMac(algorithm);
    mac.init(key);

    if (tls) {
        block = new byte[BLOCK_SIZE_TLS];
        block[BLOCK_OFFSET_VERSION]   = protocolVersion.major;
        block[BLOCK_OFFSET_VERSION+1] = protocolVersion.minor;
    } else {
        block = new byte[BLOCK_SIZE_SSL];
    }
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:35,代码来源:MAC.java


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