在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:signalapp/libsignal-protocol-java开源软件地址:https://github.com/signalapp/libsignal-protocol-java开源编程语言:Java 100.0%开源软件介绍:OverviewA ratcheting forward secrecy protocol that works in synchronous and asynchronous messaging environments. PreKeysThis protocol uses a concept called 'PreKeys'. A PreKey is an ECPublicKey and an associated unique ID which are stored together by a server. PreKeys can also be signed. At install time, clients generate a single signed PreKey, as well as a large list of unsigned PreKeys, and transmit all of them to the server. SessionsSignal Protocol is session-oriented. Clients establish a "session," which is then used for all subsequent encrypt/decrypt operations. There is no need to ever tear down a session once one has been established. Sessions are established in one of three ways:
StateAn established session encapsulates a lot of state between two clients. That state is maintained in durable records which need to be kept for the life of the session. State is kept in the following places:
Using libsignal-protocolConfigurationOn Android: dependencies {
compile 'org.whispersystems:signal-protocol-android:(latest version number)'
} For pure Java apps: <dependency>
<groupId>org.whispersystems</groupId>
<artifactId>signal-protocol-java</artifactId>
<version>(latest version number)</version>
</dependency> Install timeAt install time, a libsignal client needs to generate its identity keys, registration id, and prekeys. IdentityKeyPair identityKeyPair = KeyHelper.generateIdentityKeyPair();
int registrationId = KeyHelper.generateRegistrationId();
List<PreKeyRecord> preKeys = KeyHelper.generatePreKeys(startId, 100);
SignedPreKeyRecord signedPreKey = KeyHelper.generateSignedPreKey(identityKeyPair, 5);
// Store identityKeyPair somewhere durable and safe.
// Store registrationId somewhere durable and safe.
// Store preKeys in PreKeyStore.
// Store signed prekey in SignedPreKeyStore. Building a sessionA libsignal client needs to implement four interfaces: IdentityKeyStore, PreKeyStore, SignedPreKeyStore, and SessionStore. These will manage loading and storing of identity, prekeys, signed prekeys, and session state. Once those are implemented, building a session is fairly straightforward: SessionStore sessionStore = new MySessionStore();
PreKeyStore preKeyStore = new MyPreKeyStore();
SignedPreKeyStore signedPreKeyStore = new MySignedPreKeyStore();
IdentityKeyStore identityStore = new MyIdentityKeyStore();
// Instantiate a SessionBuilder for a remote recipientId + deviceId tuple.
SessionBuilder sessionBuilder = new SessionBuilder(sessionStore, preKeyStore, signedPreKeyStore,
identityStore, recipientId, deviceId);
// Build a session with a PreKey retrieved from the server.
sessionBuilder.process(retrievedPreKey);
SessionCipher sessionCipher = new SessionCipher(sessionStore, recipientId, deviceId);
CiphertextMessage message = sessionCipher.encrypt("Hello world!".getBytes("UTF-8"));
deliver(message.serialize()); Legal thingsCryptography NoticeThis distribution includes cryptographic software. The country in which you currently reside may have restrictions on the import, possession, use, and/or re-export to another country, of encryption software. BEFORE using any encryption software, please check your country's laws, regulations and policies concerning the import, possession, or use, and re-export of encryption software, to see if this is permitted. See http://www.wassenaar.org/ for more information. The U.S. Government Department of Commerce, Bureau of Industry and Security (BIS), has classified this software as Export Commodity Control Number (ECCN) 5D002.C.1, which includes information security software using or performing cryptographic functions with asymmetric algorithms. The form and manner of this distribution makes it eligible for export under the License Exception ENC Technology Software Unrestricted (TSU) exception (see the BIS Export Administration Regulations, Section 740.13) for both object code and source code. LicenseCopyright 2013-2019 Open Whisper Systems Licensed under the GPLv3: http://www.gnu.org/licenses/gpl-3.0.html |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论