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


Java ECKey.setK方法代码示例

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


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

示例1: setCommonCurveParameters

import javacard.security.ECKey; //导入方法依赖的package包/类
protected static boolean setCommonCurveParameters(ECKey key) {
    try {
        key.setA(SECP256R1_A, (short)0, (short)SECP256R1_A.length);
        key.setB(SECP256R1_B, (short)0, (short)SECP256R1_B.length);
        key.setFieldFP(SECP256R1_FP, (short)0, (short)SECP256R1_FP.length);
        key.setG(SECP256R1_G, (short)0, (short)SECP256R1_G.length);
        key.setR(SECP256R1_R, (short)0, (short)SECP256R1_R.length);
        key.setK(SECP256R1_K);
        return true;
    }
    catch(Exception e) {
        return false;
    }

}
 
开发者ID:tsenger,项目名称:CCU2F,代码行数:16,代码来源:Secp256r1.java

示例2: setCommonCurveParameters

import javacard.security.ECKey; //导入方法依赖的package包/类
public static void setCommonCurveParameters(ECKey eckey){
	eckey.setFieldFP( SECP256K1, OFFSET_SECP256K1_P, (short)32);
	eckey.setA( SECP256K1, OFFSET_SECP256K1_a, (short)32);
	eckey.setB( SECP256K1, OFFSET_SECP256K1_b, (short)32);
	eckey.setR( SECP256K1, OFFSET_SECP256K1_R, (short)32);
	eckey.setG( SECP256K1, OFFSET_SECP256K1_G, (short)65);
	eckey.setK( SECP256K1_K);
}
 
开发者ID:Toporin,项目名称:SatoChipApplet,代码行数:9,代码来源:Secp256k1.java

示例3: initializeECPoint

import javacard.security.ECKey; //导入方法依赖的package包/类
public static void initializeECPoint(ECKey ecPoint) {
	ecPoint.setFieldFP(CurveConstants.P, BAS, CurveConstants.MODULUS_SIZE);
	ecPoint.setA(CurveConstants.A, BAS, CurveConstants.MODULUS_SIZE);
	ecPoint.setB(CurveConstants.B, BAS, CurveConstants.MODULUS_SIZE);
	ecPoint.setG(CurveConstants.G, BAS, (short) (CurveConstants.MODULUS_SIZE * 2 + 1));
	ecPoint.setK(CurveConstants.H);
	ecPoint.setR(CurveConstants.N, BAS, CurveConstants.MODULUS_SIZE);
}
 
开发者ID:mobilesec,项目名称:secure-channel-ec-srp-applet,代码行数:9,代码来源:SRP5Utils.java

示例4: setCommonCurveParameters

import javacard.security.ECKey; //导入方法依赖的package包/类
protected static boolean setCommonCurveParameters(ECKey key) {
	try {
		key.setA(SECP256K1_A, (short)0, (short)SECP256K1_A.length);
		key.setB(SECP256K1_B, (short)0, (short)SECP256K1_B.length);
		key.setFieldFP(SECP256K1_FP, (short)0, (short)SECP256K1_FP.length);
		key.setG(SECP256K1_G, (short)0, (short)SECP256K1_G.length);
		key.setR(SECP256K1_R, (short)0, (short)SECP256K1_R.length);
		key.setK(SECP256K1_K);
		return true;
	}
	catch(Exception e) {
		return false;
	}
	
}
 
开发者ID:LedgerHQ,项目名称:ledger-javacard-eligibility,代码行数:16,代码来源:Secp256k1.java

示例5: initEcParams

import javacard.security.ECKey; //导入方法依赖的package包/类
/**
 * \brief Initialize an EC key with the curve parameters from buf.
 *
 * \param buf The buffer containing the EC curve parameters. It must be TLV with the following format:
 * 				81 - prime
 * 				82 - coefficient A
 * 				83 - coefficient B
 * 				84 - base point G
 * 				85 - order
 * 				87 - cofactor
 *
 * \param bOff The offset at where the first entry is located.
 *
 * \param bLen The remaining length of buf.
 *
 * \param key The EC key to initialize.
 *
 * \throw NotFoundException Parts of the data needed to fully initialize
 *                          the key were missing.
 *
 * \throw InvalidArgumentsException The ASN.1 sequence was malformatted.
 */
private void initEcParams(byte[] buf, short bOff, short bLen, ECKey key) throws NotFoundException, InvalidArgumentsException {
    short pos = bOff;
    short len;

    /* Search for the prime */
    pos = UtilTLV.findTag(buf, bOff, bLen, (byte) 0x81);
    pos++;
    len = UtilTLV.decodeLengthField(buf, pos);
    pos += UtilTLV.getLengthFieldLength(len);
    key.setFieldFP(buf, pos, len); // "p"

    /* Search for coefficient A */
    pos = UtilTLV.findTag(buf, bOff, bLen, (byte) 0x82);
    pos++;
    len = UtilTLV.decodeLengthField(buf, pos);
    pos += UtilTLV.getLengthFieldLength(len);
    key.setA(buf, pos, len);

    /* Search for coefficient B */
    pos = UtilTLV.findTag(buf, bOff, bLen, (byte) 0x83);
    pos++;
    len = UtilTLV.decodeLengthField(buf, pos);
    pos += UtilTLV.getLengthFieldLength(len);
    key.setB(buf, pos, len);

    /* Search for base point G */
    pos = UtilTLV.findTag(buf, bOff, bLen, (byte) 0x84);
    pos++;
    len = UtilTLV.decodeLengthField(buf, pos);
    pos += UtilTLV.getLengthFieldLength(len);
    key.setG(buf, pos, len); // G(x,y)

    /* Search for order */
    pos = UtilTLV.findTag(buf, bOff, bLen, (byte) 0x85);
    pos++;
    len = UtilTLV.decodeLengthField(buf, pos);
    pos += UtilTLV.getLengthFieldLength(len);
    key.setR(buf, pos, len); // Order of G - "q"

    /* Search for cofactor */
    pos = UtilTLV.findTag(buf, bOff, bLen, (byte) 0x87);
    pos++;
    len = UtilTLV.decodeLengthField(buf, pos);
    pos += UtilTLV.getLengthFieldLength(len);
    if(len == 2) {
        key.setK(Util.getShort(buf, pos));
    } else if(len == 1) {
        key.setK(buf[pos]);
    } else {
        throw InvalidArgumentsException.getInstance();
    }
}
 
开发者ID:philipWendland,项目名称:IsoApplet,代码行数:75,代码来源:IsoApplet.java


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