本文整理匯總了Java中com.sun.spot.security.KeyException類的典型用法代碼示例。如果您正苦於以下問題:Java KeyException類的具體用法?Java KeyException怎麽用?Java KeyException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
KeyException類屬於com.sun.spot.security包,在下文中一共展示了KeyException類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: serializeECPrivateKey
import com.sun.spot.security.KeyException; //導入依賴的package包/類
/** Serializes ECPrivateKey
*/
private static byte[] serializeECPrivateKey(ECPrivateKeyImpl key,
int headerSize) throws KeyException, IOException {
byte[] s = new byte[(key.getSize() + 7) >>> 3];
int sLen = key.getS(s, 0);
if (sLen == 0)
throw new IOException("Serialization of EC Key failed");
/* [curveId][sLength][s] */
/* allocate space for the header, curve id, s length, s */
byte[] rawKey = new byte[headerSize + 1 + 1 + sLen];
int strAddr = headerSize;
rawKey[strAddr] = (byte)key.getCurve();
strAddr ++;
rawKey[strAddr] = (byte)sLen;
strAddr ++;
System.arraycopy(s, 0, rawKey, strAddr, sLen);
return rawKey;
}
示例2: getS
import com.sun.spot.security.KeyException; //導入依賴的package包/類
public int getS(byte[] buffer, int offset) throws KeyException {
if (!initOk) {
throw new KeyException("Key not initialized");
}
ffa.toByteArray(buffer, offset, keyLength, keyData);
return keyLength;
}