LibreSocial · Documentation

Security (identity, login/keys, access control, encryption)

Purpose

The security component provides the cryptographic foundation of LibreSocial (formerly LifeSocial.KOM):

The design intent, first published in 2009, was "practical security": low overhead, fine-grained ACLs on DHT-stored data, and decentralised registration/login, rather than formal or anonymity-grade security.

Current implementation (as of 2026)

Source root: Source/com.p2pframework/src/com/p2pframework/ unless noted.

Key abstraction — com.p2pframework.security

Elliptic-curve backend — com.p2pframework.security.ellipticcurves

Login, identity and node ID

Access control

Message, DDS and join protection

Notable parameters (current code)

Parameter Value Where
Curve BrainpoolP160r1 ECAsymmetricKey, ECPublicKey
Asymmetric algorithms ECIES (enc), SHA1withECDSA (sig) ECAsymmetricKey via BC
Node/ID space 160 bit, compressed point without prefix byte ECPublicKey.toByteArray, PastryNetwork
Seed re-hash loop SHA-1 until compressed prefix 0x02 ECAsymmetricKey.createKey
Symmetric cipher AES-128 (default provider mode = ECB) AESSymmetricKey, KeyFactory
Credential pre-hash SHA-256(password+username) LoginComponent.hash
Random seed strings 130-bit BigInteger, base-32 RandomStringKey

Design options and decision

The papers state some alternatives explicitly; for the rest the rationale below is reconstructed from the cited publications and marked as such.

Technical details

Login/registration protocol (current): 1. UI/OSGi calls LoginComponent.login(...) → hash = SHA-256(password + username) (UTF-8). 2. PastryNetwork.createNodeAndBoot(user, hash) → ECAsymmetricKey(user, hash); seed = user+hash, then SHA-1-chained deterministic EC keygen on BrainpoolP160r1 until prefix 0x02; nodeID = 20-byte compressed point. 3. Boot Pastry with that ID (stock FreePastry join protocol; the optional SecureJoinProtocol variant is not wired in the current build). 4. Login path: UserManager.getUserID(ownID) must find an ID2UserIDStorageItem in PAST, else UserNotRegisteredException. Register path: UserManager.createUser(username, ownID) stores ID2UserIDStorageItem and up to N sharded UserID2IDStorageItems (userID + "_" + i). 5. Password reference is dropped after ID derivation.

Data-at-rest envelope (SecureStorageItem): ciphertext = AES-128(item); AES key stored once per authorized user as ECIES(pubKey_user) inside the serialized AccessControlList; signature = ECDSA_owner(ACL_bytes || ciphertext). Readers locate the item by ID in PAST, unwrap their AES copy, decrypt, and verify against the owner's public key (recoverable from the item ID itself via new ECPublicKey(idBytes)).

DDS write protocol (2014, implemented in DDS/): lists/trees are bucketed (bucket key = h(listName + floor(i/splitsize)), evaluated splitsize 20), mutations are remote operations executed by the bucket's home node; elements are AES-encrypted and carry both author and group ECDSA signatures with key versions; deletion inserts a DeletedDistributedItem marker and the consolidation protocol shifts it one bucket per call. SecureDistributedDataItem.verifyGroup/verifyUser implement the storage node's checks without decryption.

Group keys: Group stores key histories (indexed by version) so old ciphertexts remain attributable; member sets are ArrayList<UserID> keys into the symmetric-key map, enabling subgroup caching; GroupKeysRetriever + RemoteOperation.{getPublicKey, getEncryptedPrivateKey, getEncryptedSymmetricKey, getAllKeys, revokeUserRights, getOwnRoles, getReferingRoles, …} are the RPC surface to a group's home node.

Identity layer: UserID is stable across identity-key changes; UserManager.changeID republishes mappings; challenge/response protection of mapping items is described in the 2020 dissertation (partly outside this package).

Integration points: Framework.java exposes getKeyFactory() (created through PastryClassFactory.createKeyFactory()), though most call sites construct ECAsymmetricKey/AESSymmetricKey directly. Also: rice.freepastry (rice.pastry.Id, ConsistentJoinProtocol, PAST Id requirements), com.p2pframework.storage.past (PastryStorageItem/PastryStorageDispatcher wrap SecureStorageItem), com.p2pframework.storagedispatcher, com.p2pframework.messagedispatcher (SecureMessage transport), DDS (SecureDistributedDataItem, RemoteOperationClient), users (UserManager/Group), plugins: org.lifesocial.plugin.loginplugin (login UI flow), groups, forum, photosplugin, filestorage, messagingplugin, livechatplugin (all construct SecureStorageItem/SecureMessage through framework APIs), org.lifesocial.core.main (SecureSharedItemPayload, HashKeyBuilder for storage keys).

Weaknesses visible in current code (stated as of 2026): AES without an explicit IV/mode (ECB default); SHA-1 for signatures and seed chaining; single unsalted-round SHA-256 password pre-hash; deterministic PRNG construction for key derivation is not a KDF (no iteration count, no per-user salt beyond the username); password and key material occasionally logged (System.out.println("password= …")). These are legacy choices preserved for compatibility of existing DHT data.

Evolution and supersession