/** * Decrypts an encrypted value into a string using an alternative secret. * * @return {String} Decrypted string value * @memberOf EcEncryptedValue * @method decryptIntoString */ public String decryptIntoStringUsingSecret(EbacEncryptedSecret decryptSecret) { if (decryptSecret != null) { return EcAesCtr.decrypt(payload, decryptSecret.secret, decryptSecret.iv); } return null; }
/** * Helper function to encrypt a contact into an encrypted contact (storable * version of a contact) * * @param {String} secret * AES secret used to encrypt the contact. * @return {EbacContact} * Encrypted contact object. * @memberOf EcContact * @method toEncryptedContact */ public EbacContact toEncryptedContact(String secret) { EbacContact c = new EbacContact(); c.iv = EcAes.newIv(32); c.pk = EcAesCtr.encrypt(pk.toPem(), secret, c.iv); c.displayNameIv = EcAes.newIv(16); c.displayName = EcAesCtr.encrypt(displayName, secret, c.iv); c.sourceIv = EcAes.newIv(16); c.source = EcAesCtr.encrypt(source, secret, c.iv); return c; } }
/** * Helper function to encrypt an identity into a credential (storable * version of an identity) * * @param {String} secret * AES secret used to encrypt the credential. * @return {EbacCredential} * Encrypted credential object. * @memberOf EcIdentity * @method toCredential */ public EbacCredential toCredential(String secret) { EbacCredential c = new EbacCredential(); c.iv = EcAes.newIv(16); c.ppk = EcAesCtr.encrypt(ppk.toPem(), secret, c.iv); c.displayNameIv = EcAes.newIv(16); c.displayName = EcAesCtr.encrypt(displayName, secret, c.iv); return c; }
/** * Decrypts an encrypted value into a string * * @return {String} Decrypted string value * @memberOf EcEncryptedValue * @method decryptIntoString */ public String decryptIntoString() { EbacEncryptedSecret decryptSecret = decryptSecret(); if (decryptSecret != null) { return EcAesCtr.decrypt(payload, decryptSecret.secret, decryptSecret.iv); } return null; }
v.payload = EcAesCtr.encrypt(text, newSecret, newIv); v.addOwner(owner);
/** * Helper function to decrypt a credential (storable version of an identity) * into an identity) * * @param {EbacCredential} credential * Credential to decrypt. * @param {String} secret * AES secret used to decrypt the credential. * @param {String} source * Source of the credential, used to track where a credential * came from. * @return {EcIdentity} * Decrypted identity object, ready for use. * @memberOf EcIdentity * @method fromCredential * @static */ public static EcIdentity fromCredential(EbacCredential credential, String secret, String source) { EcIdentity i = new EcIdentity(); i.ppk = EcPpk.fromPem(EcAesCtr.decrypt(credential.ppk, secret, credential.iv)); i.source = source; if (credential.displayName != null && credential.displayNameIv != null) i.displayName = EcAesCtr.decrypt(credential.displayName, secret, credential.iv); return i; }
EcEncryptedValue v = new EcEncryptedValue(); v.payload = EcAesCtr.encrypt(text, secret, iv); if (owners != null) { for (int i = 0; i < owners.$length(); i++) {
/** * Helper function to decrypt an encrypted contact (storable version of an contact) * into an contact * * @param {EbacContact} contact * Contact to decrypt. * @param {String} secret * AES secret used to decrypt the credential. * @param {String} source * Source of the credential, used to track where a contact * came from. * @return {EcContact} * Decrypted identity object, ready for use. * @memberOf EcContact * @method fromEncryptedContact * @static */ public static EcContact fromEncryptedContact(EbacContact contact, String secret, String source) { EcContact i = new EcContact(); i.pk = EcPk.fromPem(EcAesCtr.decrypt(contact.pk, secret, contact.iv)); i.source = source; if (contact.displayName != null && contact.displayNameIv != null) i.displayName = EcAesCtr.decrypt(contact.displayName, secret, contact.iv); return i; }
v.payload = EcAesCtr.encrypt(d.toJson(), newSecret, newIv); v.owner = d.owner; v.reader = d.reader;
v.payload = EcAesCtr.encrypt(text, newSecret, newIv); if (owners != null) { for (int i = 0; i < owners.$length(); i++) {