本文整理汇总了Java中javacard.framework.Util.setShort方法的典型用法代码示例。如果您正苦于以下问题:Java Util.setShort方法的具体用法?Java Util.setShort怎么用?Java Util.setShort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javacard.framework.Util
的用法示例。
在下文中一共展示了Util.setShort方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: add
import javacard.framework.Util; //导入方法依赖的package包/类
/**
* Add short value to this bignat
* @param other short value to add
*/
public void add(short other) {
Util.setShort(bnh.tmp_array_short, (short) 0, other); // serialize other into array
this.add_carry(bnh.tmp_array_short, (short) 0, (short) 2); // add as array
}
示例2: shortToByteArray
import javacard.framework.Util; //导入方法依赖的package包/类
public byte[] shortToByteArray(short s) {
Util.setShort(m_shortByteArray, (short) 0, s);
return m_shortByteArray;
}
示例3: Personalize_GetCardInfo
import javacard.framework.Util; //导入方法依赖的package包/类
void Personalize_GetCardInfo(APDU apdu) {
byte[] buffer = apdu.getBuffer();
short offset = 0;
buffer[offset] = Consts.TLV_TYPE_CARDUNIQUEDID;
offset++;
Util.setShort(buffer, offset, (short) cardIDLong.length);
offset += 2;
Util.arrayCopyNonAtomic(cardIDLong, (short) 0, buffer, offset, (short) cardIDLong.length);
offset += cardIDLong.length;
buffer[offset] = Consts.TLV_TYPE_KEYPAIR_STATE;
offset++;
Util.setShort(buffer, offset, (short) 2);
offset += 2;
Util.setShort(buffer, offset, m_quorums[0].GetState()); // TODO: read states from all quorums
offset += 2;
buffer[offset] = Consts.TLV_TYPE_EPHIMERAL_STATE;
offset++;
Util.setShort(buffer, offset, (short) 2);
offset += 2;
//Util.setShort(buffer, offset, CryptoObjects.EphimeralKey.getState()); // TODO: read states from all quorums
offset += 2;
// Available memory
buffer[offset] = Consts.TLV_TYPE_MEMORY;
offset++;
Util.setShort(buffer, offset, (short) 6);
offset += 2;
Util.setShort(buffer, offset, JCSystem.getAvailableMemory(JCSystem.MEMORY_TYPE_PERSISTENT));
offset += 2;
Util.setShort(buffer, offset, JCSystem.getAvailableMemory(JCSystem.MEMORY_TYPE_TRANSIENT_RESET));
offset += 2;
Util.setShort(buffer, offset, JCSystem.getAvailableMemory(JCSystem.MEMORY_TYPE_TRANSIENT_DESELECT));
offset += 2;
// Used compile-time switches
buffer[offset] = Consts.TLV_TYPE_COMPILEFLAGS;
offset++;
Util.setShort(buffer, offset, (short) 4);
offset += 2;
Util.setShort(buffer, offset, Consts.MAX_NUM_PLAYERS);
offset += 2;
buffer[offset] = Consts.PLAYERS_IN_RAM ? (byte) 1 : (byte) 0;
offset++;
buffer[offset] = Consts.COMPUTE_Y_ONTHEFLY ? (byte) 1 : (byte) 0;
offset++;
// Git commit tag
buffer[offset] = Consts.TLV_TYPE_GITCOMMIT;
offset++;
Util.setShort(buffer, offset, (short) 4);
offset += 2;
Util.arrayCopyNonAtomic(Consts.GIT_COMMIT_MANUAL, (short) 0, buffer, offset, (short) Consts.GIT_COMMIT_MANUAL.length);
offset += (short) Consts.GIT_COMMIT_MANUAL.length;
// Flag about example demonstartion of beckdoored behavior
buffer[offset] = Consts.TLV_TYPE_EXAMPLEBACKDOOR;
offset++;
Util.setShort(buffer, offset, (short) 1);
offset += 2;
buffer[offset] = Consts.IS_BACKDOORED_EXAMPLE ? (byte) 1 : (byte) 0;
offset += 1;
apdu.setOutgoingAndSend((short) 0, offset);
}