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

Java OtrCryptoEngineImpl类代码示例

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

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



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

示例1: getOtrFingerprint

import net.java.otr4j.crypto.OtrCryptoEngineImpl; //导入依赖的package包/类
public String getOtrFingerprint() {
	if (this.otrFingerprint == null) {
		try {
			if (this.mOtrService == null) {
				return null;
			}
			final PublicKey publicKey = this.mOtrService.getPublicKey();
			if (publicKey == null || !(publicKey instanceof DSAPublicKey)) {
				return null;
			}
			this.otrFingerprint = new OtrCryptoEngineImpl().getFingerprint(publicKey).toLowerCase(Locale.US);
			return this.otrFingerprint;
		} catch (final OtrCryptoException ignored) {
			return null;
		}
	} else {
		return this.otrFingerprint;
	}
}
 
开发者ID:syntafin,项目名称:TenguChat,代码行数:20,代码来源:Account.java


示例2: getOtrFingerprint

import net.java.otr4j.crypto.OtrCryptoEngineImpl; //导入依赖的package包/类
public String getOtrFingerprint() {
	if (this.otrFingerprint == null) {
		try {
			if (this.mOtrService == null) {
				return null;
			}
			final PublicKey publicKey = this.mOtrService.getPublicKey();
			if (publicKey == null || !(publicKey instanceof DSAPublicKey)) {
				return null;
			}
			this.otrFingerprint = new OtrCryptoEngineImpl().getFingerprint(publicKey);
			return this.otrFingerprint;
		} catch (final OtrCryptoException ignored) {
			return null;
		}
	} else {
		return this.otrFingerprint;
	}
}
 
开发者ID:xavierle,项目名称:messengerxmpp,代码行数:20,代码来源:Account.java


示例3: getOtrFingerprint

import net.java.otr4j.crypto.OtrCryptoEngineImpl; //导入依赖的package包/类
public String getOtrFingerprint() {
    if (this.otrFingerprint == null) {
        try {
            if (this.mOtrService == null) {
                return null;
            }
            final PublicKey publicKey = this.mOtrService.getPublicKey();
            if (publicKey == null || !(publicKey instanceof DSAPublicKey)) {
                return null;
            }
            this.otrFingerprint = new OtrCryptoEngineImpl().getFingerprint(publicKey).toLowerCase(Locale.US);
            return this.otrFingerprint;
        } catch (final OtrCryptoException ignored) {
            return null;
        }
    } else {
        return this.otrFingerprint;
    }
}
 
开发者ID:kriztan,项目名称:Pix-Art-Messenger,代码行数:20,代码来源:Account.java


示例4: rotateLocalSessionKeys

import net.java.otr4j.crypto.OtrCryptoEngineImpl; //导入依赖的package包/类
private void rotateLocalSessionKeys() throws OtrException {

        if (DEBUG_ENABLED) Log.d(LOG_TAG,"Rotating local keys.");
        SessionKeys sess1 = getSessionKeysByIndex(SessionKeys.Previous, SessionKeys.Current);
        if (sess1.getIsUsedReceivingMACKey()) {
            if (DEBUG_ENABLED) Log.d(LOG_TAG,"Detected used Receiving MAC key. Adding to old MAC keys to reveal it.");
            getOldMacKeys().add(sess1.getReceivingMACKey());
        }

        SessionKeys sess2 = getSessionKeysByIndex(SessionKeys.Previous, SessionKeys.Previous);
        if (sess2.getIsUsedReceivingMACKey()) {
            if (DEBUG_ENABLED) Log.d(LOG_TAG,"Detected used Receiving MAC key. Adding to old MAC keys to reveal it.");
            getOldMacKeys().add(sess2.getReceivingMACKey());
        }

        SessionKeys sess3 = getSessionKeysByIndex(SessionKeys.Current, SessionKeys.Current);
        sess1.setLocalPair(sess3.getLocalPair(), sess3.getLocalKeyID());
        SessionKeys sess4 = getSessionKeysByIndex(SessionKeys.Current, SessionKeys.Previous);
        sess2.setLocalPair(sess4.getLocalPair(), sess4.getLocalKeyID());

        KeyPair newPair = new OtrCryptoEngineImpl().generateDHKeyPair();
        sess3.setLocalPair(newPair, sess3.getLocalKeyID() + 1);
        sess4.setLocalPair(newPair, sess4.getLocalKeyID() + 1);
    }
 
开发者ID:zom,项目名称:Zom-Android,代码行数:25,代码来源:SessionImpl.java


示例5: getRevealSignatureMessage

import net.java.otr4j.crypto.OtrCryptoEngineImpl; //导入依赖的package包/类
private RevealSignatureMessage getRevealSignatureMessage() throws OtrException {
    try {
        SignatureM m = new SignatureM((DHPublicKey) getLocalDHKeyPair().getPublic(),
                getRemoteDHPublicKey(), getLocalLongTermKeyPair().getPublic(),
                getLocalDHKeyPairID());

        OtrCryptoEngine otrCryptoEngine = new OtrCryptoEngineImpl();
        byte[] mhash = otrCryptoEngine.sha256Hmac(SerializationUtils.toByteArray(m),
                getM1());
        byte[] signature = otrCryptoEngine.sign(mhash, getLocalLongTermKeyPair()
                .getPrivate());

        SignatureX mysteriousX = new SignatureX(getLocalLongTermKeyPair().getPublic(),
                getLocalDHKeyPairID(), signature);
        byte[] xEncrypted = otrCryptoEngine.aesEncrypt(getC(), null,
                SerializationUtils.toByteArray(mysteriousX));

        byte[] tmp = SerializationUtils.writeData(xEncrypted);

        byte[] xEncryptedHash = otrCryptoEngine.sha256Hmac160(tmp, getM2());
        return new RevealSignatureMessage(getProtocolVersion(), xEncrypted, xEncryptedHash,
                getR());
    } catch (IOException e) {
        throw new OtrException(e);
    }
}
 
开发者ID:zom,项目名称:Zom-Android,代码行数:27,代码来源:AuthContextImpl.java


示例6: testIOBigInt

import net.java.otr4j.crypto.OtrCryptoEngineImpl; //导入依赖的package包/类
public void testIOBigInt() throws Exception {

        KeyPair pair = new OtrCryptoEngineImpl().generateDHKeyPair();
        BigInteger source = ((DHPublicKey) pair.getPublic()).getY();

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        OtrOutputStream oos = new OtrOutputStream(out);
        oos.writeBigInt(source);
        oos.close();

        byte[] converted = out.toByteArray();

        ByteArrayInputStream bin = new ByteArrayInputStream(converted);
        OtrInputStream ois = new OtrInputStream(bin);
        BigInteger result = ois.readBigInt();
        ois.close();

        assertTrue(source.compareTo(result) == 0);
    }
 
开发者ID:zom,项目名称:Zom-Android,代码行数:20,代码来源:IOTest.java


示例7: testIODHPublicKey

import net.java.otr4j.crypto.OtrCryptoEngineImpl; //导入依赖的package包/类
public void testIODHPublicKey() throws Exception {
    KeyPair pair = new OtrCryptoEngineImpl().generateDHKeyPair();

    DHPublicKey source = (DHPublicKey) pair.getPublic();

    ByteArrayOutputStream out = new ByteArrayOutputStream();
    OtrOutputStream oos = new OtrOutputStream(out);
    oos.writeDHPublicKey(source);
    oos.close();

    byte[] converted = out.toByteArray();

    ByteArrayInputStream bin = new ByteArrayInputStream(converted);
    OtrInputStream ois = new OtrInputStream(bin);
    DHPublicKey result = ois.readDHPublicKey();
    ois.close();

    assertTrue(source.getY().compareTo(result.getY()) == 0);
}
 
开发者ID:zom,项目名称:Zom-Android,代码行数:20,代码来源:IOTest.java


示例8: getOtrFingerprint

import net.java.otr4j.crypto.OtrCryptoEngineImpl; //导入依赖的package包/类
public String getOtrFingerprint() {
	if (this.otrFingerprint == null) {
		try {
			if (this.otrEngine == null) {
				return null;
			}
			final PublicKey publicKey = this.otrEngine.getPublicKey();
			if (publicKey == null || !(publicKey instanceof DSAPublicKey)) {
				return null;
			}
			this.otrFingerprint = new OtrCryptoEngineImpl().getFingerprint(publicKey);
			return this.otrFingerprint;
		} catch (final OtrCryptoException ignored) {
			return null;
		}
	} else {
		return this.otrFingerprint;
	}
}
 
开发者ID:juanignaciomolina,项目名称:txtr,代码行数:20,代码来源:Account.java


示例9: getOtrFingerprint

import net.java.otr4j.crypto.OtrCryptoEngineImpl; //导入依赖的package包/类
public String getOtrFingerprint() {
	if (this.otrFingerprint == null) {
		try {
			DSAPublicKey remotePubKey = (DSAPublicKey) getOtrSession()
					.getRemotePublicKey();
			StringBuilder builder = new StringBuilder(
					new OtrCryptoEngineImpl().getFingerprint(remotePubKey));
			builder.insert(8, " ");
			builder.insert(17, " ");
			builder.insert(26, " ");
			builder.insert(35, " ");
			this.otrFingerprint = builder.toString();
		} catch (OtrCryptoException e) {

		}
	}
	return this.otrFingerprint;
}
 
开发者ID:GitESS,项目名称:SyncChatAndroid,代码行数:19,代码来源:Conversation.java


示例10: getOtrFingerprint

import net.java.otr4j.crypto.OtrCryptoEngineImpl; //导入依赖的package包/类
public String getOtrFingerprint() {
	if (this.otrFingerprint == null) {
		try {
			DSAPublicKey pubkey = (DSAPublicKey) this.otrEngine.getPublicKey();
			if (pubkey == null) {
				return null;
			}
			StringBuilder builder = new StringBuilder(new OtrCryptoEngineImpl().getFingerprint(pubkey));
			builder.insert(8, " ");
			builder.insert(17, " ");
			builder.insert(26, " ");
			builder.insert(35, " ");
			this.otrFingerprint = builder.toString();
		} catch (OtrCryptoException e) {
			
		}
	}
	return this.otrFingerprint;
}
 
开发者ID:GitESS,项目名称:SyncChatAndroid,代码行数:20,代码来源:Account.java


示例11: getRemoteFingerprint

import net.java.otr4j.crypto.OtrCryptoEngineImpl; //导入依赖的package包/类
public String getRemoteFingerprint(String fullUserId) {

        //if (!Address.hasResource(fullUserId))
          //  return null;
        
        byte[] fingerprint = this.store.getPropertyHexBytes(fullUserId + ".fingerprint");
        if (fingerprint != null) {
            // If we have a fingerprint stashed, assume it is correct.
            return new String(Hex.encode(fingerprint, 0, fingerprint.length));
        }
        
        PublicKey remotePublicKey = loadRemotePublicKeyFromStore(fullUserId);
        if (remotePublicKey == null)
            return null;
        try {
            // Store the fingerprint, for posterity.
            String fingerprintString = new OtrCryptoEngineImpl().getFingerprint(remotePublicKey);
            this.store.setPropertyHex(fullUserId + ".fingerprint", Hex.decode(fingerprintString));

            store.save();
            return fingerprintString;
        } catch (OtrCryptoException e) {
            OtrDebugLogger.log("OtrCryptoException getting remote fingerprint",e);
            return null;
        }
    }
 
开发者ID:prive,项目名称:prive-android,代码行数:27,代码来源:OtrAndroidKeyManagerImpl.java


示例12: savePublicKey

import net.java.otr4j.crypto.OtrCryptoEngineImpl; //导入依赖的package包/类
public void savePublicKey(SessionID sessionID, PublicKey pubKey) {
    if (sessionID == null)
        return;

    X509EncodedKeySpec x509EncodedKeySpec = new X509EncodedKeySpec(pubKey.getEncoded());

    String fullUserId = sessionID.getFullUserID();
  //  if (!Address.hasResource(fullUserId))
    //    return;
    
    this.store.setProperty(fullUserId + ".publicKey", x509EncodedKeySpec.getEncoded());
    // Stash the associated fingerprint.  This saves calculating it in the future
    // and is useful for transferring rosters to other apps.
    try {
        String fingerprintString = new OtrCryptoEngineImpl().getFingerprint(pubKey);
        String verifiedToken = buildPublicKeyVerifiedId(fullUserId, fingerprintString.toLowerCase());
        if (!this.store.hasProperty(verifiedToken))
            this.store.setProperty(verifiedToken, false);
        
        this.store.setPropertyHex(fullUserId + ".fingerprint", Hex.decode(fingerprintString));
        store.save();
    } catch (OtrCryptoException e) {
        e.printStackTrace();
    }
}
 
开发者ID:prive,项目名称:prive-android,代码行数:26,代码来源:OtrAndroidKeyManagerImpl.java


示例13: rotateLocalSessionKeys

import net.java.otr4j.crypto.OtrCryptoEngineImpl; //导入依赖的package包/类
private void rotateLocalSessionKeys() throws OtrException {

        logger.finest("Rotating local keys.");
        SessionKeys sess1 = getSessionKeysByIndex(SessionKeys.Previous, SessionKeys.Current);
        if (sess1.getIsUsedReceivingMACKey()) {
            logger.finest("Detected used Receiving MAC key. Adding to old MAC keys to reveal it.");
            getOldMacKeys().add(sess1.getReceivingMACKey());
        }

        SessionKeys sess2 = getSessionKeysByIndex(SessionKeys.Previous, SessionKeys.Previous);
        if (sess2.getIsUsedReceivingMACKey()) {
            logger.finest("Detected used Receiving MAC key. Adding to old MAC keys to reveal it.");
            getOldMacKeys().add(sess2.getReceivingMACKey());
        }

        SessionKeys sess3 = getSessionKeysByIndex(SessionKeys.Current, SessionKeys.Current);
        sess1.setLocalPair(sess3.getLocalPair(), sess3.getLocalKeyID());
        SessionKeys sess4 = getSessionKeysByIndex(SessionKeys.Current, SessionKeys.Previous);
        sess2.setLocalPair(sess4.getLocalPair(), sess4.getLocalKeyID());

        KeyPair newPair = new OtrCryptoEngineImpl().generateDHKeyPair();
        sess3.setLocalPair(newPair, sess3.getLocalKeyID() + 1);
        sess4.setLocalPair(newPair, sess4.getLocalKeyID() + 1);
    }
 
开发者ID:prive,项目名称:prive-android,代码行数:25,代码来源:SessionImpl.java


示例14: testIOBigInt

import net.java.otr4j.crypto.OtrCryptoEngineImpl; //导入依赖的package包/类
public void testIOBigInt() throws Exception {

        KeyPair pair = new OtrCryptoEngineImpl().generateDHKeyPair();
        BigInteger source = ((DHPublicKey) pair.getPublic()).getY();

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        OtrOutputStream oos = new OtrOutputStream(out);
        oos.writeBigInt(source);

        byte[] converted = out.toByteArray();

        ByteArrayInputStream bin = new ByteArrayInputStream(converted);
        OtrInputStream ois = new OtrInputStream(bin);
        BigInteger result = ois.readBigInt();

        assertTrue(source.compareTo(result) == 0);
    }
 
开发者ID:prive,项目名称:prive-android,代码行数:18,代码来源:IOTest.java


示例15: testIODHPublicKey

import net.java.otr4j.crypto.OtrCryptoEngineImpl; //导入依赖的package包/类
public void testIODHPublicKey() throws Exception {
    KeyPair pair = new OtrCryptoEngineImpl().generateDHKeyPair();

    DHPublicKey source = (DHPublicKey) pair.getPublic();

    ByteArrayOutputStream out = new ByteArrayOutputStream();
    OtrOutputStream oos = new OtrOutputStream(out);
    oos.writeDHPublicKey(source);

    byte[] converted = out.toByteArray();

    ByteArrayInputStream bin = new ByteArrayInputStream(converted);
    OtrInputStream ois = new OtrInputStream(bin);
    DHPublicKey result = ois.readDHPublicKey();

    assertTrue(source.getY().compareTo(result.getY()) == 0);
}
 
开发者ID:prive,项目名称:prive-android,代码行数:18,代码来源:IOTest.java


示例16: getLocalFingerprint

import net.java.otr4j.crypto.OtrCryptoEngineImpl; //导入依赖的package包/类
/**
 * 
 * Returns the local finger print for specified session. If there is no
 * finger print you might generate one.
 * 
 * @return the local finger print for this sessionID
 */
public String getLocalFingerprint(SessionID sessionID) {
    KeyPair keyPair = loadLocalKeyPair(sessionID);

    if (keyPair == null)
        return null;

    PublicKey pubKey = keyPair.getPublic();

    try {
        return new OtrCryptoEngineImpl().getFingerprint(pubKey);
    } catch (OtrCryptoException e) {
        e.printStackTrace();
        return null;
    }
}
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:23,代码来源:MyOtrKeyManager.java


示例17: getLocalFingerprintRaw

import net.java.otr4j.crypto.OtrCryptoEngineImpl; //导入依赖的package包/类
/**
 * @param sessionID
 * @return -- Given a SessionID, return the local fingerprint
 */

@Override
public byte[] getLocalFingerprintRaw(SessionID sessionID) {
    try {
        return new OtrCryptoEngineImpl()
                .getFingerprintRaw(getLocalKeyPair(sessionID)
                        .getPublic());
    } catch (OtrCryptoException e) {
        e.printStackTrace();
    }
    return null;
}
 
开发者ID:DanielKrawisz,项目名称:Shufflepuff,代码行数:17,代码来源:OtrChannel.java


示例18: getRemoteFingerprint

import net.java.otr4j.crypto.OtrCryptoEngineImpl; //导入依赖的package包/类
public String getRemoteFingerprint(String fullUserId) {

        String fingerprint = this.store.getProperty(fullUserId + ".fingerprint");
        if (fingerprint != null) {
            // If we have a fingerprint stashed, assume it is correct.
            return fingerprint;
        }

        //if we can't find an exact match, let's show the first one that matches the id sans resource
        for (Object fpKey : store.getKeySet().toArray())
        {
            String fpKeyString = (String)fpKey;
            if (fpKeyString.startsWith(fullUserId) && fpKeyString.endsWith(".fingerprint")) {
                fingerprint = store.getProperty(fpKeyString);
                if (fingerprint != null)
                    return fingerprint;
            }
        }

        PublicKey remotePublicKey = loadRemotePublicKeyFromStore(fullUserId);
        if (remotePublicKey == null)
            return null;

        try {
            // Store the fingerprint, for posterity.
            String fingerprintString = new OtrCryptoEngineImpl().getFingerprint(remotePublicKey);
            this.store.setProperty(fullUserId + ".fingerprint", fingerprintString);
            
            return fingerprintString;
        } catch (OtrCryptoException e) {
            throw new RuntimeException("OtrCryptoException getting remote fingerprint",e);

        }
    }
 
开发者ID:zom,项目名称:Zom-Android,代码行数:35,代码来源:OtrAndroidKeyManagerImpl.java


示例19: savePublicKey

import net.java.otr4j.crypto.OtrCryptoEngineImpl; //导入依赖的package包/类
public void savePublicKey(SessionID sessionID, PublicKey pubKey) {
    if (sessionID == null)
        return;

    X509EncodedKeySpec x509EncodedKeySpec = new X509EncodedKeySpec(pubKey.getEncoded());

  //  if (!Address.hasResource(sessionID.getRemoteUserId()))
    //    return;

    String fullUserId = sessionID.getRemoteUserId();

    this.store.setProperty(fullUserId + ".publicKey", x509EncodedKeySpec.getEncoded());
    // Stash the associated fingerprint.  This saves calculating it in the future
    // and is useful for transferring rosters to other apps.
    try {
        String fingerprintString = new OtrCryptoEngineImpl().getFingerprint(pubKey);
        String verifiedToken = buildPublicKeyVerifiedId(sessionID.getRemoteUserId(), fingerprintString);
        String fingerprintKey = fullUserId + ".fingerprint";

        //if a fingerprint for this userid exists, then check if the key is verified
        if (this.store.hasProperty(fingerprintKey)) {
            if (!this.store.hasProperty(verifiedToken))
                this.store.setProperty(verifiedToken, false);
        }
        else
        {
            //if there is no key, then we can "trust on first use"!
            this.store.setProperty(fingerprintKey, fingerprintString);
            this.store.setProperty(verifiedToken, true);
        }

        
    } catch (OtrCryptoException e) {
        Log.e(ImApp.LOG_TAG,"otr error: " + e.getMessage(),e);
    }
}
 
开发者ID:zom,项目名称:Zom-Android,代码行数:37,代码来源:OtrAndroidKeyManagerImpl.java


示例20: getLocalFingerprint

import net.java.otr4j.crypto.OtrCryptoEngineImpl; //导入依赖的package包/类
public String getLocalFingerprint(SessionID sessionID) {
    KeyPair keyPair = loadLocalKeyPair(sessionID);

    if (keyPair == null)
        return null;

    PublicKey pubKey = keyPair.getPublic();

    try {
        return new OtrCryptoEngineImpl().getFingerprint(pubKey);
    } catch (OtrCryptoException e) {
        e.printStackTrace();
        return null;
    }
}
 
开发者ID:zom,项目名称:Zom-Android,代码行数:16,代码来源:OtrKeyManagerDefaultImpl.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java Layer类代码示例发布时间:2022-05-21
下一篇:
Java AttributeValueUpdate类代码示例发布时间: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