• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java APDU类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_EC_SETCURVE_G

import javacard.framework.APDU; //导入依赖的package包/类
void test_EC_SETCURVE_G(APDU apdu, short dataLen) {
     byte[] apdubuf = apdu.getBuffer();
     
     Util.arrayCopyNonAtomic(apdubuf, ISO7816.OFFSET_CDATA, m_customG, (short) 0, dataLen);
     PM.check(PM.TRAP_EC_SETCURVE_1);

     if (apdubuf[ISO7816.OFFSET_P2] == 1) { // If required, complete new custom curve and point is allocated
         m_testCurveCustom = new ECCurve(false, SecP256r1.p, SecP256r1.a, SecP256r1.b, m_customG, SecP256r1.r);
         m_testPointCustom = new ECPoint(m_testCurveCustom, m_ecc.ech);
         PM.check(PM.TRAP_EC_SETCURVE_2);
         // Release unused previous objects
         if (!bIsSimulator) {
             JCSystem.requestObjectDeletion();
         }
     }
     else {
         // Otherwise, only G is set and relevant objects are updated
         m_testCurveCustom.setG(apdubuf, (short) ISO7816.OFFSET_CDATA, m_testCurveCustom.POINT_SIZE);
         m_testPointCustom.updatePointObjects(); // After changing curve parameters, internal objects needs to be actualized
     }
}
 
开发者ID:OpenCryptoProject,项目名称:JCMathLib,代码行数:22,代码来源:OCUnitTests.java


示例2: test_EC_MUL

import javacard.framework.APDU; //导入依赖的package包/类
void test_EC_MUL(APDU apdu) {
    byte[] apdubuf = apdu.getBuffer();
    short p1_len = (short) (apdubuf[ISO7816.OFFSET_P1] & 0x00FF);

    PM.check(PM.TRAP_EC_MUL_1);
    Bignat scalar = m_testBN1;
    scalar.set_size(p1_len);
    scalar.from_byte_array(p1_len, (short) 0, apdubuf, ISO7816.OFFSET_CDATA);
    PM.check(PM.TRAP_EC_MUL_2);
    m_testPoint1.setW(apdubuf, (short) (ISO7816.OFFSET_CDATA + p1_len), m_testCurve.POINT_SIZE);
    PM.check(PM.TRAP_EC_MUL_3);
    m_testPoint1.multiplication(scalar);
    PM.check(PM.TRAP_EC_MUL_4);

    short len = m_testPoint1.getW(apdubuf, (short) 0);
    PM.check(PM.TRAP_EC_MUL_5);
    apdu.setOutgoingAndSend((short) 0, len);
}
 
开发者ID:OpenCryptoProject,项目名称:JCMathLib,代码行数:19,代码来源:OCUnitTests.java


示例3: test_BN_ADD

import javacard.framework.APDU; //导入依赖的package包/类
void test_BN_ADD(APDU apdu, short dataLen) {
    byte[] apdubuf = apdu.getBuffer();
    short p1 = (short) (apdubuf[ISO7816.OFFSET_P1] & 0x00FF);

    PM.check(PM.TRAP_BN_ADD_1);
    Bignat num1 = m_testBN1;
    num1.set_size(p1);
    PM.check(PM.TRAP_BN_ADD_2);
    Bignat num2 = m_testBN2;
    num2.set_size((short) (dataLen - p1));
    PM.check(PM.TRAP_BN_ADD_3);
    Bignat sum = m_testBN3;
    sum.set_size((short) (p1 + 1));

    PM.check(PM.TRAP_BN_ADD_4);
    num1.from_byte_array(p1, (short)0, apdubuf, ISO7816.OFFSET_CDATA);
    num2.from_byte_array((short) (dataLen - p1), (short)0, apdubuf, (short)(ISO7816.OFFSET_CDATA+p1));
    PM.check(PM.TRAP_BN_ADD_5);
    sum.copy(num1);
    PM.check(PM.TRAP_BN_ADD_6);
    sum.add(num2);
    PM.check(PM.TRAP_BN_ADD_7);
    short len = sum.copy_to_buffer(apdubuf, (short) 0);
    apdu.setOutgoingAndSend((short) 0, len);    
}
 
开发者ID:OpenCryptoProject,项目名称:JCMathLib,代码行数:26,代码来源:OCUnitTests.java


示例4: test_BN_SUB

import javacard.framework.APDU; //导入依赖的package包/类
void test_BN_SUB(APDU apdu, short dataLen) {
    byte[] apdubuf = apdu.getBuffer();
    short p1 = (short) (apdubuf[ISO7816.OFFSET_P1] & 0x00FF);

    PM.check(PM.TRAP_BN_SUB_1);
    Bignat sub1 = m_testBN1;
    sub1.set_size(p1);
    PM.check(PM.TRAP_BN_SUB_2);
    Bignat sub2 = m_testBN2;
    sub2.set_size((short) (dataLen - p1));
    PM.check(PM.TRAP_BN_SUB_3);
    Bignat result = m_testBN3;
    result.set_size((short) (p1 + 1));
    PM.check(PM.TRAP_BN_SUB_4);
    sub1.from_byte_array(dataLen, (short)0, apdubuf, ISO7816.OFFSET_CDATA);
    sub2.from_byte_array(dataLen, (short)0, apdubuf, (short)(ISO7816.OFFSET_CDATA+p1));
    PM.check(PM.TRAP_BN_SUB_5);
    result.copy(sub1);
    PM.check(PM.TRAP_BN_SUB_6);
    result.subtract(sub2);
    PM.check(PM.TRAP_BN_SUB_7);
    short len = result.copy_to_buffer(apdubuf, (short) 0);
    apdu.setOutgoingAndSend((short) 0, len);
}
 
开发者ID:OpenCryptoProject,项目名称:JCMathLib,代码行数:25,代码来源:OCUnitTests.java


示例5: test_BN_EXP

import javacard.framework.APDU; //导入依赖的package包/类
void test_BN_EXP(APDU apdu, short dataLen) {
    byte[] apdubuf = apdu.getBuffer();
    short p1 = (short) (apdubuf[ISO7816.OFFSET_P1] & 0x00FF);
    short p2 = (short) (apdubuf[ISO7816.OFFSET_P2] & 0x00FF);

    PM.check(PM.TRAP_BN_EXP_1);    
    Bignat base = m_testBN1;
    base.set_size(p1);
    PM.check(PM.TRAP_BN_EXP_2);
    Bignat exp = m_testBN2;
    exp.set_size((short) (dataLen - p1));
    PM.check(PM.TRAP_BN_EXP_3);
    Bignat res = m_testBN3;
    res.set_size((short) (m_ecc.MAX_BIGNAT_SIZE / 2));
    PM.check(PM.TRAP_BN_EXP_4);
    base.from_byte_array(p1, (short) 0, apdubuf, ISO7816.OFFSET_CDATA);
    exp.from_byte_array((short) (dataLen - p1), (short) 0, apdubuf, (short)(ISO7816.OFFSET_CDATA+p1));
    PM.check(PM.TRAP_BN_EXP_5);
    res.exponentiation(base, exp);
    PM.check(PM.TRAP_BN_EXP_6);
    short len = res.copy_to_buffer(apdubuf, (short) 0);
    apdu.setOutgoingAndSend((short) 0, len);
}
 
开发者ID:OpenCryptoProject,项目名称:JCMathLib,代码行数:24,代码来源:OCUnitTests.java


示例6: test_BN_MOD

import javacard.framework.APDU; //导入依赖的package包/类
void test_BN_MOD(APDU apdu, short dataLen) {
    byte[] apdubuf = apdu.getBuffer();
    short p1 = (short) (apdubuf[ISO7816.OFFSET_P1] & 0x00FF);

    PM.check(PM.TRAP_BN_MOD_1);
    Bignat num = m_testBN1;
    num.set_size(p1);
    PM.check(PM.TRAP_BN_MOD_2);
    Bignat mod = m_testBN2;
    mod.set_size((short) (dataLen - p1));
    PM.check(PM.TRAP_BN_MOD_3);
    num.from_byte_array(p1, (short)0, apdubuf, ISO7816.OFFSET_CDATA);
    mod.from_byte_array((short)(dataLen-p1), (short)0, apdubuf, (short)(ISO7816.OFFSET_CDATA+p1));
    PM.check(PM.TRAP_BN_MOD_4);
    num.mod(mod);
    PM.check(PM.TRAP_BN_MOD_5);
    short len = num.copy_to_buffer(apdubuf, (short) 0);
    apdu.setOutgoingAndSend((short) 0, len);
}
 
开发者ID:OpenCryptoProject,项目名称:JCMathLib,代码行数:20,代码来源:OCUnitTests.java


示例7: test_BN_ADD_MOD

import javacard.framework.APDU; //导入依赖的package包/类
void test_BN_ADD_MOD(APDU apdu, short dataLen) {
    byte[] apdubuf = apdu.getBuffer();
    short p1 = (short) (apdubuf[ISO7816.OFFSET_P1] & 0x00FF);
    short p2 = (short) (apdubuf[ISO7816.OFFSET_P2] & 0x00FF);

    PM.check(PM.TRAP_BN_ADD_MOD_1);    
    Bignat num1 = m_testBN1;
    num1.set_size(p1);
    PM.check(PM.TRAP_BN_ADD_MOD_2);
    Bignat num2 = m_testBN2;
    num2.set_size(p2);
    PM.check(PM.TRAP_BN_ADD_MOD_3);
    Bignat mod = m_testBN3;
    mod.set_size((short) (dataLen - p1 - p2));
    PM.check(PM.TRAP_BN_ADD_MOD_4);
    num1.from_byte_array(p1, (short)0, apdubuf, ISO7816.OFFSET_CDATA);
    num2.from_byte_array(p2, (short)0, apdubuf, (short)(ISO7816.OFFSET_CDATA+p1));
    PM.check(PM.TRAP_BN_ADD_MOD_5);
    mod.from_byte_array((short)(dataLen-p1-p2), (short)0, apdubuf, (short)(ISO7816.OFFSET_CDATA+p1+p2));
    PM.check(PM.TRAP_BN_ADD_MOD_6);
    num1.mod_add(num2, mod);
    PM.check(PM.TRAP_BN_ADD_MOD_7);
    short len = num1.copy_to_buffer(apdubuf, (short) 0);
    apdu.setOutgoingAndSend((short) 0, len);
}
 
开发者ID:OpenCryptoProject,项目名称:JCMathLib,代码行数:26,代码来源:OCUnitTests.java


示例8: test_BN_SUB_MOD

import javacard.framework.APDU; //导入依赖的package包/类
void test_BN_SUB_MOD(APDU apdu, short dataLen) {
    byte[] apdubuf = apdu.getBuffer();
    short p1 = (short) (apdubuf[ISO7816.OFFSET_P1] & 0x00FF);
    short p2 = (short) (apdubuf[ISO7816.OFFSET_P2] & 0x00FF);

    PM.check(PM.TRAP_BN_SUB_MOD_1);    
    Bignat num1 = m_testBN1;
    num1.set_size(p1);
    PM.check(PM.TRAP_BN_SUB_MOD_2);
    Bignat num2 = m_testBN2;
    num2.set_size(p2);
    PM.check(PM.TRAP_BN_SUB_MOD_3);
    Bignat mod = m_testBN3;
    mod.set_size((short) (dataLen - p1 - p2));
    PM.check(PM.TRAP_BN_SUB_MOD_4);
    num1.from_byte_array(p1, (short)0, apdubuf, ISO7816.OFFSET_CDATA);
    num2.from_byte_array(p2, (short)0, apdubuf, (short)(ISO7816.OFFSET_CDATA+p1));
    mod.from_byte_array((short)(dataLen-p1-p2), (short)0, apdubuf, (short)(ISO7816.OFFSET_CDATA+p1+p2));
    PM.check(PM.TRAP_BN_SUB_MOD_5);
    num1.mod_sub(num2, mod);
    PM.check(PM.TRAP_BN_SUB_MOD_6);
    short len = num1.copy_to_buffer(apdubuf, (short) 0);
    apdu.setOutgoingAndSend((short) 0, len);
}
 
开发者ID:OpenCryptoProject,项目名称:JCMathLib,代码行数:25,代码来源:OCUnitTests.java


示例9: test_BN_MUL_MOD

import javacard.framework.APDU; //导入依赖的package包/类
void test_BN_MUL_MOD(APDU apdu, short dataLen) {
    byte[] apdubuf = apdu.getBuffer();
    short p1 = (short) (apdubuf[ISO7816.OFFSET_P1] & 0x00FF);
    short p2 = (short) (apdubuf[ISO7816.OFFSET_P2] & 0x00FF);

    PM.check(PM.TRAP_BN_MUL_MOD_1);    
    Bignat num1 = m_testBN1;
    num1.set_size(p1);
    PM.check(PM.TRAP_BN_MUL_MOD_2);
    Bignat num2 = m_testBN2;
    num2.set_size(p2);
    PM.check(PM.TRAP_BN_MUL_MOD_3);
    Bignat mod = m_testBN3;
    mod.set_size((short) (dataLen - p1 - p2));
    PM.check(PM.TRAP_BN_MUL_MOD_4);
    num1.from_byte_array(p1, (short)0, apdubuf, ISO7816.OFFSET_CDATA);
    num2.from_byte_array(p2, (short)0, apdubuf, (short)(ISO7816.OFFSET_CDATA+p1));
    mod.from_byte_array((short)(dataLen-p1-p2), (short)0, apdubuf, (short)(ISO7816.OFFSET_CDATA+p1+p2));
    PM.check(PM.TRAP_BN_MUL_MOD_5);
    num1.mod_mult(num1, num2, mod);
    PM.check(PM.TRAP_BN_MUL_MOD_6);
    short len = num1.copy_to_buffer(apdubuf, (short) 0);
    apdu.setOutgoingAndSend((short) 0, len);
}
 
开发者ID:OpenCryptoProject,项目名称:JCMathLib,代码行数:25,代码来源:OCUnitTests.java


示例10: test_BN_EXP_MOD

import javacard.framework.APDU; //导入依赖的package包/类
void test_BN_EXP_MOD(APDU apdu, short dataLen) {
    byte[] apdubuf = apdu.getBuffer();
    short p1 = (short) (apdubuf[ISO7816.OFFSET_P1] & 0x00FF);
    short p2 = (short) (apdubuf[ISO7816.OFFSET_P2] & 0x00FF);

    PM.check(PM.TRAP_BN_EXP_MOD_1);    
    Bignat num1 = m_testBN1;
    num1.set_size(p1);
    PM.check(PM.TRAP_BN_EXP_MOD_2);
    Bignat num2 = m_testBN2;
    num2.set_size(p2);
    PM.check(PM.TRAP_BN_EXP_MOD_3);
    Bignat mod = m_testBN3;
    mod.set_size((short) (dataLen - p1 - p2));
    PM.check(PM.TRAP_BN_EXP_MOD_4);
    num1.from_byte_array(p1, (short)0, apdubuf, ISO7816.OFFSET_CDATA);
    num2.from_byte_array(p2, (short)0, apdubuf, (short)(ISO7816.OFFSET_CDATA+p1));
    mod.from_byte_array((short)(dataLen-p1-p2), (short)0, apdubuf, (short)(ISO7816.OFFSET_CDATA+p1+p2));
    PM.check(PM.TRAP_BN_EXP_MOD_5);
    num1.mod_exp(num2, mod);
    PM.check(PM.TRAP_BN_EXP_MOD_6);
    short len = num1.copy_to_buffer(apdubuf, (short) 0);
    apdu.setOutgoingAndSend((short) 0, len);
}
 
开发者ID:OpenCryptoProject,项目名称:JCMathLib,代码行数:25,代码来源:OCUnitTests.java


示例11: test_BN_POW2_MOD

import javacard.framework.APDU; //导入依赖的package包/类
void test_BN_POW2_MOD(APDU apdu, short dataLen) {
    byte[] apdubuf = apdu.getBuffer();
    short p1 = (short) (apdubuf[ISO7816.OFFSET_P1] & 0x00FF);
    short p2 = (short) (apdubuf[ISO7816.OFFSET_P2] & 0x00FF);

    PM.check(PM.TRAP_BN_POW2_MOD_1);
    Bignat num1 = m_testBN1;
    num1.set_size(p1);
    Bignat mod = m_testBN3;
    mod.set_size((short) (dataLen - p1));
    num1.from_byte_array(p1, (short) 0, apdubuf, ISO7816.OFFSET_CDATA);
    mod.from_byte_array((short) (dataLen - p1), (short) 0, apdubuf, (short) (ISO7816.OFFSET_CDATA + p1));
    PM.check(PM.TRAP_BN_POW2_MOD_2);
    //num1.pow2Mod_RSATrick(mod);
    num1.mod_exp2(mod);
    PM.check(PM.TRAP_BN_POW2_MOD_3);
    short len = num1.copy_to_buffer(apdubuf, (short) 0);
    apdu.setOutgoingAndSend((short) 0, len);
}
 
开发者ID:OpenCryptoProject,项目名称:JCMathLib,代码行数:20,代码来源:OCUnitTests.java


示例12: test_BN_INV_MOD

import javacard.framework.APDU; //导入依赖的package包/类
void test_BN_INV_MOD(APDU apdu, short dataLen) {
    byte[] apdubuf = apdu.getBuffer();
    short p1 = (short) (apdubuf[ISO7816.OFFSET_P1] & 0x00FF);

    PM.check(PM.TRAP_BN_INV_MOD_1);
    Bignat num1 = m_testBN1;
    num1.set_size(p1);
    PM.check(PM.TRAP_BN_INV_MOD_2);
    Bignat mod = m_testBN2;
    mod.set_size((short) (dataLen - p1));
    PM.check(PM.TRAP_BN_INV_MOD_3);
    num1.from_byte_array(p1, (short)0, apdubuf, ISO7816.OFFSET_CDATA);
    mod.from_byte_array((short)(dataLen-p1), (short)0, apdubuf, (short)(ISO7816.OFFSET_CDATA+p1));
    PM.check(PM.TRAP_BN_INV_MOD_4);
    num1.mod_inv(mod);
    PM.check(PM.TRAP_BN_INV_MOD_5);
    short len = num1.copy_to_buffer(apdubuf, (short) 0);
    apdu.setOutgoingAndSend((short) 0, len);
}
 
开发者ID:OpenCryptoProject,项目名称:JCMathLib,代码行数:20,代码来源:OCUnitTests.java


示例13: test_INT_ADD

import javacard.framework.APDU; //导入依赖的package包/类
void test_INT_ADD(APDU apdu, short dataLen) {
    byte[] apdubuf = apdu.getBuffer();
    short p1 = (short) (apdubuf[ISO7816.OFFSET_P1] & 0x00FF);

    PM.check(PM.TRAP_INT_ADD_1);    
    //Integer num_add_1 = new Integer(dataLen, (short) 0, apdubuf, ISO7816.OFFSET_CDATA);
    Integer num_add_1 = m_testINT1;
    num_add_1.fromByteArray(apdubuf, ISO7816.OFFSET_CDATA, p1);
    PM.check(PM.TRAP_INT_ADD_2);
    //Integer num_add_2 = new Integer((short) (dataLen - p1), (short) 0, apdubuf, (short) (ISO7816.OFFSET_CDATA + p1));
    Integer num_add_2 = m_testINT2;
    num_add_2.fromByteArray(apdubuf, (short) (ISO7816.OFFSET_CDATA + p1), p1);
    PM.check(PM.TRAP_INT_ADD_3);
    num_add_1.add(num_add_2);
    PM.check(PM.TRAP_INT_ADD_4);
    short len = num_add_1.toByteArray(apdubuf, (short) 0);
    apdu.setOutgoingAndSend((short) 0, len);
}
 
开发者ID:OpenCryptoProject,项目名称:JCMathLib,代码行数:19,代码来源:OCUnitTests.java


示例14: test_INT_SUB

import javacard.framework.APDU; //导入依赖的package包/类
void test_INT_SUB(APDU apdu, short dataLen) {
    byte[] apdubuf = apdu.getBuffer();
    short p1 = (short) (apdubuf[ISO7816.OFFSET_P1] & 0x00FF);

    PM.check(PM.TRAP_INT_SUB_1);               
    Integer num_sub_1 = m_testINT1;
    num_sub_1.fromByteArray(apdubuf, ISO7816.OFFSET_CDATA, p1);
    Integer num_sub_2 = m_testINT2;
    num_sub_2.fromByteArray(apdubuf, (short) (ISO7816.OFFSET_CDATA + p1), p1);
    PM.check(PM.TRAP_INT_SUB_2);

    num_sub_1.subtract(num_sub_2);
    PM.check(PM.TRAP_INT_SUB_3);
    short len = num_sub_1.toByteArray(apdubuf, (short) 0);
    apdu.setOutgoingAndSend((short) 0, len);
}
 
开发者ID:OpenCryptoProject,项目名称:JCMathLib,代码行数:17,代码来源:OCUnitTests.java


示例15: test_INT_MUL

import javacard.framework.APDU; //导入依赖的package包/类
void test_INT_MUL(APDU apdu, short dataLen) {
    byte[] apdubuf = apdu.getBuffer();
    short p1 = (short) (apdubuf[ISO7816.OFFSET_P1] & 0x00FF);

    PM.check(PM.TRAP_INT_MUL_1);    
    Integer num_mul_1 = m_testINT1;
    num_mul_1.fromByteArray(apdubuf, ISO7816.OFFSET_CDATA, p1);
    Integer num_mul_2 = m_testINT2;
    num_mul_2.fromByteArray(apdubuf, (short) (ISO7816.OFFSET_CDATA + p1), p1);
    PM.check(PM.TRAP_INT_MUL_2);

    num_mul_1.multiply(num_mul_2);
    PM.check(PM.TRAP_INT_MUL_3);
    short len = num_mul_1.toByteArray(apdubuf, (short) 0);
    apdu.setOutgoingAndSend((short) 0, len);
}
 
开发者ID:OpenCryptoProject,项目名称:JCMathLib,代码行数:17,代码来源:OCUnitTests.java


示例16: test_INT_DIV

import javacard.framework.APDU; //导入依赖的package包/类
void test_INT_DIV(APDU apdu, short dataLen) {
    byte[] apdubuf = apdu.getBuffer();
    short p1 = (short) (apdubuf[ISO7816.OFFSET_P1] & 0x00FF);

    PM.check(PM.TRAP_INT_DIV_1);    
    Integer num_div_1 = m_testINT1;
    num_div_1.fromByteArray(apdubuf, ISO7816.OFFSET_CDATA, p1);
    Integer num_div_2 = m_testINT2;
    num_div_2.fromByteArray(apdubuf, (short) (ISO7816.OFFSET_CDATA + p1), p1);
    PM.check(PM.TRAP_INT_DIV_2);

    num_div_1.divide(num_div_2);
    PM.check(PM.TRAP_INT_DIV_3);

    short len = num_div_1.toByteArray(apdubuf, (short) 0);
    apdu.setOutgoingAndSend((short) 0, len);
}
 
开发者ID:OpenCryptoProject,项目名称:JCMathLib,代码行数:18,代码来源:OCUnitTests.java


示例17: test_INT_MOD

import javacard.framework.APDU; //导入依赖的package包/类
void test_INT_MOD(APDU apdu, short dataLen) {
    byte[] apdubuf = apdu.getBuffer();
    short p1 = (short) (apdubuf[ISO7816.OFFSET_P1] & 0x00FF);
    
    PM.check(PM.TRAP_INT_MOD_1);
    Integer num_mod_1 = m_testINT1;
    num_mod_1.fromByteArray(apdubuf, ISO7816.OFFSET_CDATA, p1);
    Integer num_mod_2 = m_testINT2;
    num_mod_2.fromByteArray(apdubuf, (short) (ISO7816.OFFSET_CDATA + p1), p1);
    PM.check(PM.TRAP_INT_MOD_2);

    num_mod_1.modulo(num_mod_2);
    PM.check(PM.TRAP_INT_MOD_3);
    short len = num_mod_1.toByteArray(apdubuf, (short) 0);
    apdu.setOutgoingAndSend((short) 0, len);
}
 
开发者ID:OpenCryptoProject,项目名称:JCMathLib,代码行数:17,代码来源:OCUnitTests.java


示例18: process

import javacard.framework.APDU; //导入依赖的package包/类
public void process(APDU apdu) {
	// Good practice: Return 9000 on SELECT
	if (selectingApplet()) {
		return;
	}

	byte[] buf = apdu.getBuffer();
	switch (buf[ISO7816.OFFSET_INS]) {
	case (byte) 0x00:
		handleGetPRand(apdu);
		break;
	case (byte) 0x01:
		handleGetCmac(apdu);
		break;
	default:
		// good practice: If you don't know the INStruction, say so:
		ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
	}
}
 
开发者ID:tsenger,项目名称:CCU2F,代码行数:20,代码来源:PRNGTest.java


示例19: test_EC_SETCURVE_G

import javacard.framework.APDU; //导入依赖的package包/类
void test_EC_SETCURVE_G(APDU apdu, short dataLen) {
     byte[] apdubuf = apdu.getBuffer();
     
     Util.arrayCopyNonAtomic(apdubuf, ISO7816.OFFSET_CDATA, m_customG, (short) 0, dataLen);
     PM.check(PM.TRAP_EC_SETCURVE_1);

     if (apdubuf[ISO7816.OFFSET_P2] == 1) { // If required, complete new custom curve and point is allocated
         m_testCurveCustom = new ECCurve(false, SecP256r1.p, SecP256r1.a, SecP256r1.b, m_customG, SecP256r1.r, m_ecc);
         m_testPointCustom = new ECPoint(m_testCurveCustom, m_ecc);
         PM.check(PM.TRAP_EC_SETCURVE_2);
         // Release unused previous objects
         if (!bIsSimulator) {
             JCSystem.requestObjectDeletion();
         }
     }
     else {
         // Otherwise, only G is set and relevant objects are updated
         m_testCurveCustom.setG(apdubuf, (short) ISO7816.OFFSET_CDATA, m_testCurveCustom.POINT_SIZE);
         m_testPointCustom.updatePointObjects(); // After changing curve parameters, internal objects needs to be actualized
     }
}
 
开发者ID:OpenCryptoProject,项目名称:JCProfiler,代码行数:22,代码来源:OCUnitTests.java


示例20: KeyGen_StoreCommitment

import javacard.framework.APDU; //导入依赖的package包/类
/**
 * Upon the generation of the triplet, the members perform a pairwise
 * exchange of their commitments by the end of which, they all hold a
 * set H = {h1,h2, ..,ht }. The commitment exchange terminates when |Hq | =
 * t ∀q ∈ Q
 * @param apdu 
 */
void KeyGen_StoreCommitment(APDU apdu) {
    byte[] apdubuf = apdu.getBuffer();
    short len = apdu.getIncomingLength();
    
    short paramsOffset = GetOperationParamsOffset(Consts.INS_KEYGEN_STORE_COMMITMENT, apdu);
    // Parse incoming apdu to obtain target quorum context
    QuorumContext quorumCtx = GetTargetQuorumContext(apdubuf, paramsOffset);
    // Verify authorization
    quorumCtx.VerifyCallerAuthorization(apdu, StateModel.FNC_QuorumContext_StoreCommitment);
    
    // Store provided commitment
    short playerId = Util.getShort(apdubuf, (short) (paramsOffset + Consts.PACKET_PARAMS_KEYGENSTORECOMMITMENT_PLAYERID_OFFSET));
    short commitmentLen = Util.getShort(apdubuf, (short) (paramsOffset + Consts.PACKET_PARAMS_KEYGENSTORECOMMITMENT_COMMITMENTLENGTH_OFFSET));
    quorumCtx.StoreCommitment(playerId, apdubuf, (short) (paramsOffset + Consts.PACKET_PARAMS_KEYGENSTORECOMMITMENT_COMMITMENT_OFFSET), commitmentLen);
}
 
开发者ID:OpenCryptoProject,项目名称:Myst,代码行数:23,代码来源:MPCApplet.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IRecordProcessorFactory类代码示例发布时间:2022-05-21
下一篇:
Java DefaultParameterHandler类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap