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


Java NativeLong类代码示例

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


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

示例1: cryptoPwhash

import com.sun.jna.NativeLong; //导入依赖的package包/类
public static byte[] cryptoPwhash(byte[] passwd, byte[] salt, long opsLimit, NativeLong memLimit, int algorithm) throws SodiumLibraryException
{
    byte[] key = new byte[sodium().crypto_box_seedbytes().intValue()];
    logger.info(">>> NavtiveLong size: " + NativeLong.SIZE * 8 + " bits");
    
    int rc = sodium().crypto_pwhash(key, key.length, 
            passwd, passwd.length,
            salt,
            opsLimit,
            memLimit,
            algorithm);
    
    logger.info("crypto_pwhash returned: " + rc);
    if (rc != 0)
    {
        throw new SodiumLibraryException("cryptoPwhash libsodium crypto_pwhash failed, returned " + rc + ", expected 0");
    }
    return key;

}
 
开发者ID:muquit,项目名称:libsodium-jna,代码行数:21,代码来源:SodiumLibrary.java

示例2: cryptoPwhashScryptSalsa208Sha256

import com.sun.jna.NativeLong; //导入依赖的package包/类
public static byte[] cryptoPwhashScryptSalsa208Sha256(byte[] passwd, byte[] salt,
        Long opsLimit,
        NativeLong memLimit) throws SodiumLibraryException
{
    NativeLong salt_length = sodium().crypto_pwhash_scryptsalsa208sha256_saltbytes();
    if (salt.length != salt_length.intValue())
    {
        throw new SodiumLibraryException("salt is " + salt.length + ", it must be" + salt_length + " bytes");
    }
    byte[] key = new byte[sodium().crypto_box_seedbytes().intValue()];
    int rc = sodium().crypto_pwhash_scryptsalsa208sha256(key, key.length, 
            passwd, passwd.length,
            salt,
            opsLimit, memLimit);
    
    logger.info("crypto_pwhash_scryptsalsa208sha256 returned: " + rc);
    if (rc != 0)
    {
        throw new SodiumLibraryException("libsodium crypto_pwhash_scryptsalsa208sha256() failed, returned " + rc + ", expected 0");
    }
    return key;

}
 
开发者ID:muquit,项目名称:libsodium-jna,代码行数:24,代码来源:SodiumLibrary.java

示例3: cryptoBoxEasy

import com.sun.jna.NativeLong; //导入依赖的package包/类
/**
* Encrypts a message with recipient's public key.
* 
* Usage: Alice encrypts a message with Bob's public key and creates authentication tag with her private key
* 
* @param message The message to encrypt
* @param nonce {@link SodiumLibrary#cryptoBoxNonceBytes()} bytes of nonce. It must be preserved  because it will be needed during decryption
* @param publicKey Recipient's public key for encrypting the message
* @param privateKey Sender's private key for creating authentication tag
* @throws SodiumLibraryException on error
* @return encrypted message as an array of bytes
*/    
public static byte[] cryptoBoxEasy(byte[] message, byte[] nonce,
        byte[] publicKey, byte[] privateKey) throws SodiumLibraryException
{
    NativeLong nonce_len = sodium().crypto_box_noncebytes();
    if (nonce.length != nonce_len.intValue())
    {
        throw new SodiumLibraryException("nonce is " + nonce.length + "bytes, it must be" + nonce_len + " bytes");
    }
    byte[] cipherText = new byte[(sodium().crypto_box_macbytes().intValue() + message.length)];
    int rc = sodium().crypto_box_easy(cipherText,
            message,message.length,
            nonce,
            publicKey, privateKey);
    if (rc != 0)
    {
        throw new SodiumLibraryException("libsodium crypto_box_easy() failed, returned " + rc + ", expected 0");
    }

    return cipherText;
}
 
开发者ID:muquit,项目名称:libsodium-jna,代码行数:33,代码来源:SodiumLibrary.java

示例4: cryptoBoxOpenEasy

import com.sun.jna.NativeLong; //导入依赖的package包/类
/**
* Recipient decrypts a message with his private key.
* 
* Usage: Bob (recipient) verifies the message with Alice's (sender) public key and 
* decrypts the message with his private key.
*
* @param cipherText Message to decrypt
* @param nonce Nonce used during encryption 
* @param publicKey Sender's (Alice) public key for verifying the message
* @param privateKey Recipient's (Bob)  Private key to decrypt the message
* @throws SodiumLibraryException on error
* @return Decrypted message as an array of bytes.
*/
public static byte[] cryptoBoxOpenEasy(byte[] cipherText, byte[]nonce, 
        byte[] publicKey, byte[] privateKey) throws SodiumLibraryException
{
    NativeLong nonce_len = sodium().crypto_box_noncebytes();
    if (nonce.length != nonce_len.intValue())
    {
        throw new SodiumLibraryException("nonce is " + nonce.length + "bytes, it must be" + nonce_len + " bytes");
    }
    byte[] decrypted = new byte[(int) (cipherText.length - sodium().crypto_box_macbytes().intValue())];
    int rc = sodium().crypto_box_open_easy(decrypted, cipherText, 
            cipherText.length, nonce, 
            publicKey, privateKey);
    if (rc != 0)
    {
        throw new SodiumLibraryException("libsodium crypto_box_open_easy() failed, returned " + rc + ", expected 0");
    }
    
    return decrypted;
}
 
开发者ID:muquit,项目名称:libsodium-jna,代码行数:33,代码来源:SodiumLibrary.java

示例5: stopRealPlay

import com.sun.jna.NativeLong; //导入依赖的package包/类
/** 
 * 停止实况浏览
 * 
 * @param handle 播放句柄
 * @return SDKErrorCode 领域层封装的返回码对象
 * @see [类、类#方法、类#成员]
 * @since  [eSDK IVS V100R005C30]
 */
public SDKErrorCode stopRealPlay(long handle)
{
    SDKErrorCode result = new SDKErrorCode();
    
    if (!checkHandle(handle))
    {
        result.setErrCode(1);
        return result;
    }
    
    int sessionId = CommonService.getSESSIONID();
    
    NativeLong nativaLong = new NativeLong(handle);
    
    int resultCode = BaseCablilityJNA.INSTANCE.IVS_SDK_StopRealPlay(sessionId, nativaLong);
    
    result.setErrCode(resultCode);
    return result;
}
 
开发者ID:Huawei,项目名称:eSDK_IVS_Java,代码行数:28,代码来源:RealPlayService.java

示例6: stopRealPlayByIPEx

import com.sun.jna.NativeLong; //导入依赖的package包/类
/**
 * 停止实况浏览
 * 
 * @param handle
 *            播放句柄
 * @return SDKErrorCode 领域层封装的返回码对象
 * @see [类、类#方法、类#成员]
 * @since [eSDK IVS V100R003C00]
 */
@Override
public SDKErrorCode stopRealPlayByIPEx(long handle) {
	SDKErrorCode result = new SDKErrorCode();

	if (!checkHandle(handle)) {
		result.setErrCode(ErrInfo.IVS_HANDLE_INVALID_ERROR);
		return result;
	}

	int sessionId = super.getIVSSessionId();

	NativeLong nativaLong = new NativeLong(handle);

	int resultCode = super.getBaseCablilityJNA().IVS_SDK_StopRealPlayByIPEx(sessionId, nativaLong);

	result.setErrCode(resultCode);
	return result;
}
 
开发者ID:Huawei,项目名称:eSDK_IVS_Java,代码行数:28,代码来源:BusinessMgrCability.java

示例7: stopPlatformPlayBackByIP

import com.sun.jna.NativeLong; //导入依赖的package包/类
/**
 * 停止平台录像播放
 *
 * @param handle
 *            播放句柄
 * @return SDKErrorCode 封装领域层的SDKErrorCode对象
 * @since eSDK IVS V100R003C00
 */
@Override
public SDKErrorCode stopPlatformPlayBackByIP(long handle) {
	SDKErrorCode result = new SDKErrorCode();
	if (!checkHandle(handle)) {
		result.setErrCode(ErrInfo.IVS_HANDLE_INVALID_ERROR);
		return result;
	}

	int sessionId = super.getIVSSessionId();

	NativeLong nativaLong = new NativeLong(handle);

	int resultCode = super.getBaseCablilityJNA().IVS_SDK_StopPlatformPlayBackByIP(sessionId, nativaLong);

	result.setErrCode(resultCode);

	return result;
}
 
开发者ID:Huawei,项目名称:eSDK_IVS_Java,代码行数:27,代码来源:BusinessMgrCability.java

示例8: platformPlayBackPauseByIP

import com.sun.jna.NativeLong; //导入依赖的package包/类
@Override
public SDKErrorCode platformPlayBackPauseByIP(long playHandle) {
	LOGGER.debug("platformPlayBackPauseByIP method start--->>>");
	SDKErrorCode result = new SDKErrorCode();
	if (!checkHandle(playHandle)) {
		result.setErrCode(ErrInfo.IVS_HANDLE_INVALID_ERROR);
		return result;
	}

	NativeLong nativaLong = new NativeLong(playHandle);

	int sessionId = super.getIVSSessionId();
	int resultCode = super.getBaseCablilityJNA().IVS_SDK_PlatformPlayBackPauseByIP(sessionId, nativaLong);

	result.setErrCode(resultCode);

	LOGGER.debug("platformPlayBackPauseByIP method result code:" + resultCode);
	LOGGER.debug("platformPlayBackPauseByIP method end--->>>");

	return result;
}
 
开发者ID:Huawei,项目名称:eSDK_IVS_Java,代码行数:22,代码来源:BusinessMgrCability.java

示例9: platformPlayBackResumeByIP

import com.sun.jna.NativeLong; //导入依赖的package包/类
@Override
public SDKErrorCode platformPlayBackResumeByIP(long playHandle) {
	LOGGER.debug("platformPlayBackResumeByIP method start--->>>");
	SDKErrorCode result = new SDKErrorCode();
	if (!checkHandle(playHandle)) {
		result.setErrCode(ErrInfo.IVS_HANDLE_INVALID_ERROR);
		return result;
	}

	NativeLong nativaLong = new NativeLong(playHandle);
	int sessionId = super.getIVSSessionId();
	int resultCode = super.getBaseCablilityJNA().IVS_SDK_PlatformPlayBackResumeByIP(sessionId, nativaLong);

	result.setErrCode(resultCode);

	LOGGER.debug("platformPlayBackResumeByIP method result code:" + resultCode);
	LOGGER.debug("platformPlayBackResumeByIP method end--->>>");

	return result;
}
 
开发者ID:Huawei,项目名称:eSDK_IVS_Java,代码行数:21,代码来源:BusinessMgrCability.java

示例10: setPlayBackTimeByIP

import com.sun.jna.NativeLong; //导入依赖的package包/类
/**
 * 设置平台录像码流回放时间
 * 
 * @param playHandle
 *            播放句柄
 * @param time
 *            回放时间
 * @return SDKErrorCode 领域层封装的返回码对象
 * @see
 * @since eSDK IVS V100R003C30SPC100
 */
@Override
public SDKErrorCode setPlayBackTimeByIP(long playHandle, int time) {
	LOGGER.debug("setPlayBackTimeByIP method start--->>>");

	SDKErrorCode result = new SDKErrorCode();

	if (!checkHandle(playHandle)) {
		result.setErrCode(ErrInfo.IVS_HANDLE_INVALID_ERROR);
		return result;
	}

	NativeLong nativaLong = new NativeLong(playHandle);
	int sessionId = super.getIVSSessionId();
	int resultCode = super.getBaseCablilityJNA().IVS_SDK_SetPlayBackTimeByIP(sessionId, nativaLong, time);

	result.setErrCode(resultCode);

	LOGGER.debug("setPlayBackTimeByIP method result code:" + resultCode);
	LOGGER.debug("setPlayBackTimeByIP method end--->>>");

	return result;
}
 
开发者ID:Huawei,项目名称:eSDK_IVS_Java,代码行数:34,代码来源:BusinessMgrCability.java

示例11: setPlayBackSpeedByIP

import com.sun.jna.NativeLong; //导入依赖的package包/类
/**
 * 设置平台录像码流回放速度
 * 
 * @param playHandle
 *            播放句柄
 * @param speed
 *            播放速度
 * @return SDKErrorCode 领域层封装的返回码对象
 * @see
 * @since eSDK IVS V100R003C30SPC100
 */
@Override
public SDKErrorCode setPlayBackSpeedByIP(long playHandle, float speed) {
	LOGGER.debug("setPlayBackSpeedByIP method start--->>>");

	SDKErrorCode result = new SDKErrorCode();

	if (!checkHandle(playHandle)) {
		result.setErrCode(ErrInfo.IVS_HANDLE_INVALID_ERROR);
		return result;
	}

	NativeLong nativaLong = new NativeLong(playHandle);
	int sessionId = super.getIVSSessionId();
	int resultCode = super.getBaseCablilityJNA().IVS_SDK_SetPlayBackSpeedByIP(sessionId, nativaLong, speed);

	result.setErrCode(resultCode);

	LOGGER.debug("setPlayBackSpeedByIP method result code:" + resultCode);
	LOGGER.debug("setPlayBackSpeedByIP method end--->>>");

	return result;
}
 
开发者ID:Huawei,项目名称:eSDK_IVS_Java,代码行数:34,代码来源:BusinessMgrCability.java

示例12: Token

import com.sun.jna.NativeLong; //导入依赖的package包/类
Token(NativeLong slotId) throws Pkcs11CallerException {
    RtPkcs11 pkcs11 = RtPkcs11Library.getInstance();
    synchronized (pkcs11) {
        mId = slotId;
        initTokenInfo();

        NativeLongByReference session = new NativeLongByReference();
        NativeLong rv = RtPkcs11Library.getInstance().C_OpenSession(mId,
                Pkcs11Constants.CKF_SERIAL_SESSION, null, null, session);

        if (!rv.equals(Pkcs11Constants.CKR_OK)) throw Pkcs11Exception.exceptionWithCode(rv);
        mSession = session.getValue();

        try {
            initCertificatesList(pkcs11);
        } catch (Pkcs11CallerException exception) {
            try {
                close();
            } catch (Pkcs11CallerException exception2) {
            }
            throw exception;
        }
    }
}
 
开发者ID:AktivCo,项目名称:rutoken-demobank-android,代码行数:25,代码来源:Token.java

示例13: slotEventHappened

import com.sun.jna.NativeLong; //导入依赖的package包/类
protected void slotEventHappened(NativeLong id) throws Pkcs11Exception {
    CK_SLOT_INFO slotInfo = new CK_SLOT_INFO();
    NativeLong rv;
    rv = RtPkcs11Library.getInstance().C_GetSlotInfo(id, slotInfo);

    if (!rv.equals(Pkcs11Constants.CKR_OK)) {
        throw Pkcs11Exception.exceptionWithCode(rv);
    }

    EventType event;
    if ((Pkcs11Constants.CKF_TOKEN_PRESENT.intValue() & slotInfo.flags.intValue()) != 0x00) {
        event = EventType.SD;
    } else {
        event = EventType.SR;
    }

    if (lastSlotEvent.get(id) == event) {
        mHandler.post(new EventRunnable(oppositeEvent(event), id));
        lastSlotEvent.put(id, oppositeEvent(event));
    }
    mHandler.post(new EventRunnable(event, id));
    lastSlotEvent.put(id, event);
}
 
开发者ID:AktivCo,项目名称:rutoken-demobank-android,代码行数:24,代码来源:EventHandler.java

示例14: processCurrentStateR1W0TIF

import com.sun.jna.NativeLong; //导入依赖的package包/类
AcceptableState processCurrentStateR1W0TIF(EventType event, NativeLong slotId, Token token) throws TokenManagerException {
    AcceptableState newState;
    switch (event) {
        case SD:
            newState = AcceptableState.R0W1SD;
            sendTWBA(slotId);
            startTilThread(slotId);
            break;
        case SR:
            newState = AcceptableState.R1W0SR;
            break;
        case TIL:
        case TIF:
            throw new TokenManagerException("Input not accepted by state");
        default:
            throw new TokenManagerException("Unexpected unfiltered incoming event");
    }
    return newState;
}
 
开发者ID:AktivCo,项目名称:rutoken-demobank-android,代码行数:20,代码来源:TokenManager.java

示例15: getPrivateKeyHandle

import com.sun.jna.NativeLong; //导入依赖的package包/类
public NativeLong getPrivateKeyHandle(RtPkcs11 pkcs11, NativeLong session)
        throws Pkcs11CallerException {
    CK_ATTRIBUTE[] template = (CK_ATTRIBUTE[]) (new CK_ATTRIBUTE()).toArray(2);

    final NativeLongByReference keyClass =
            new NativeLongByReference(Pkcs11Constants.CKO_PRIVATE_KEY);
    template[0].type = Pkcs11Constants.CKA_CLASS;
    template[0].pValue = keyClass.getPointer();
    template[0].ulValueLen = new NativeLong(NativeLong.SIZE);

    ByteBuffer idBuffer = ByteBuffer.allocateDirect(mKeyPairId.length);
    idBuffer.put(mKeyPairId);
    template[1].type = Pkcs11Constants.CKA_ID;
    template[1].pValue = Native.getDirectBufferPointer(idBuffer);
    template[1].ulValueLen = new NativeLong(mKeyPairId.length);

    return findObject(pkcs11, session, template);
}
 
开发者ID:AktivCo,项目名称:rutoken-demobank-android,代码行数:19,代码来源:Certificate.java


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