Skip to content

Commit

Permalink
EC updated to 2.8.2, CASS updated to 1.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Lomilar committed Apr 15, 2019
1 parent 0d0f121 commit 2008e8b
Show file tree
Hide file tree
Showing 16 changed files with 4,370 additions and 3,830 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
<groupId>org.cassproject</groupId>
<artifactId>cass</artifactId>
<packaging>war</packaging>
<version>1.2.0</version>
<version>1.2.1</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<ec-version>2.8.0</ec-version>
<ec-version>2.8.2</ec-version>
<ew-version>5.15.1</ew-version>
</properties>

Expand Down
159 changes: 146 additions & 13 deletions src/main/js/cass.js
Original file line number Diff line number Diff line change
Expand Up @@ -88868,6 +88868,56 @@ EcEncryptedValue = stjs.extend(EcEncryptedValue, EbacEncryptedValue, [], functio
}
return v;
};
/**
* Encrypts a text value with the owners and readers provided
*
* @param {String} text Text to encrypt
* @param {String} id ID of the value to encrypt
* @param {String[]} owners Owner keys to encrypt value with
* @param {String[]} readers Reader keys to encrypt value with
* @return {EcEncryptedValue} Encrypted value
* @memberOf EcEncryptedValue
* @method encryptValue
* @static
*/
constructor.encryptValueAsync = function(text, id, owners, readers, success, failure) {
var v = new EcEncryptedValue();
var newIv = EcAes.newIv(16);
var newSecret = EcAes.newIv(16);
v.payload = EcAesCtr.encrypt(text, newSecret, newIv);
if (owners != null) {
for (var i = 0; i < owners.length; i++) {
v.addOwner(EcPk.fromPem(owners[i]));
}
}
if (readers != null) {
for (var i = 0; i < readers.length; i++) {
v.addReaderBasic(EcPk.fromPem(readers[i]));
}
}
var pks = new Array();
if (owners != null)
if (v.owner != null)
pks = pks.concat(v.owner);
if (readers != null)
if (v.reader != null)
pks = pks.concat(v.reader);
new EcAsyncHelper().each(pks, function(pk, callback0) {
var eSecret = new EbacEncryptedSecret();
eSecret.id = forge.util.encode64(forge.pkcs5.pbkdf2(id, "", 1, 8));
eSecret.iv = newIv;
eSecret.secret = newSecret;
if (v.secret == null) {
v.secret = new Array();
}
EcRsaOaepAsync.encrypt(EcPk.fromPem(pk), eSecret.toEncryptableJson(), function(s) {
v.secret.push(s);
callback0();
}, callback0);
}, function(pks) {
success(v);
});
};
/**
* Encrypt a value with a specific IV and secret
*
Expand Down Expand Up @@ -89319,6 +89369,22 @@ EcEncryptedValue = stjs.extend(EcEncryptedValue, EbacEncryptedValue, [], functio
* @method addReader
*/
prototype.addReader = function(newReader) {
this.addReaderBasic(newReader);
var payloadSecret = this.decryptSecret();
if (payloadSecret == null) {
console.error("Cannot add a Reader if you don't know the secret");
return;
}
EcArray.setAdd(this.secret, EcRsaOaep.encrypt(newReader, payloadSecret.toEncryptableJson()));
};
/**
* Adds a reader to the object, if the reader does not exist.
*
* @param {EcPk} newReader PK of the new reader.
* @memberOf EcEncryptedValue
* @method addReader
*/
prototype.addReaderBasic = function(newReader) {
var pem = newReader.toPem();
if (this.reader == null) {
this.reader = new Array();
Expand All @@ -89329,12 +89395,6 @@ EcEncryptedValue = stjs.extend(EcEncryptedValue, EbacEncryptedValue, [], functio
if (EcArray.has(this.owner, pem))
return;
EcArray.setAdd(this.reader, pem);
var payloadSecret = this.decryptSecret();
if (payloadSecret == null) {
console.error("Cannot add a Reader if you don't know the secret");
return;
}
EcArray.setAdd(this.secret, EcRsaOaep.encrypt(newReader, payloadSecret.toEncryptableJson()));
};
/**
* Removes a reader from the object, if the reader does exist.
Expand Down Expand Up @@ -91339,6 +91399,28 @@ EcAssertion = stjs.extend(EcAssertion, Assertion, [], function(constructor, prot
readers.push(pk.toPem());
this.subject = EcEncryptedValue.encryptValue(pk.toPem(), this.id, owners, readers);
};
prototype.setSubjectAsync = function(pk, success, failure) {
var me = this;
var owners = new Array();
var readers = null;
if (this.reader == null)
readers = new Array();
else
readers = JSON.parse(JSON.stringify(this.reader));
if (this.subject != null) {
if (this.subject.owner != null)
owners.concat(this.subject.owner);
if (this.subject.reader != null)
readers.concat(this.subject.reader);
}
if (this.owner != null)
owners = owners.concat(this.owner);
readers.push(pk.toPem());
EcEncryptedValue.encryptValueAsync(pk.toPem(), this.id, owners, readers, function(subject) {
me.subject = subject;
success();
}, failure);
};
prototype.getSubjectAsync = function(success, failure) {
if (this.subject == null) {
success(null);
Expand Down Expand Up @@ -91377,6 +91459,13 @@ EcAssertion = stjs.extend(EcAssertion, Assertion, [], function(constructor, prot
prototype.setAgent = function(pk) {
this.agent = EcEncryptedValue.encryptValue(pk.toPem(), this.id, this.subject.owner, this.subject.reader);
};
prototype.setAgentAsync = function(pk, success, failure) {
var me = this;
EcEncryptedValue.encryptValueAsync(pk.toPem(), this.id, this.subject.owner, this.subject.reader, function(agent) {
me.agent = agent;
success();
}, failure);
};
prototype.getAgentAsync = function(success, failure) {
if (this.agent == null) {
success(null);
Expand Down Expand Up @@ -91533,6 +91622,13 @@ EcAssertion = stjs.extend(EcAssertion, Assertion, [], function(constructor, prot
prototype.setAssertionDate = function(assertionDateMs) {
this.assertionDate = EcEncryptedValue.encryptValue(assertionDateMs.toString(), this.id, this.subject.owner, this.subject.reader);
};
prototype.setAssertionDateAsync = function(assertionDateMs, success, failure) {
var me = this;
EcEncryptedValue.encryptValueAsync(assertionDateMs.toString(), this.id, this.subject.owner, this.subject.reader, function(assertionDate) {
me.assertionDate = assertionDate;
success();
}, failure);
};
prototype.getAssertionDateAsync = function(success, failure) {
if (this.assertionDate == null) {
success(null);
Expand Down Expand Up @@ -91571,6 +91667,13 @@ EcAssertion = stjs.extend(EcAssertion, Assertion, [], function(constructor, prot
prototype.setExpirationDate = function(expirationDateMs) {
this.expirationDate = EcEncryptedValue.encryptValue(expirationDateMs.toString(), this.id, this.subject.owner, this.subject.reader);
};
prototype.setExpirationDateAsync = function(expirationDateMs, success, failure) {
var me = this;
EcEncryptedValue.encryptValueAsync(expirationDateMs.toString(), this.id, this.subject.owner, this.subject.reader, function(expirationDate) {
me.expirationDate = expirationDate;
success();
}, failure);
};
prototype.getExpirationDateAsync = function(success, failure) {
if (this.expirationDate == null) {
success(null);
Expand Down Expand Up @@ -91611,14 +91714,17 @@ EcAssertion = stjs.extend(EcAssertion, Assertion, [], function(constructor, prot
};
prototype.getEvidencesAsync = function(success, failure) {
var results = new Array();
new EcAsyncHelper().each(this.evidence, function(e, callback0) {
e.decryptIntoStringAsync(function(str) {
results.push(str);
callback0();
}, callback0);
}, function(strings) {
if (this.evidence != null)
new EcAsyncHelper().each(this.evidence, function(e, callback0) {
e.decryptIntoStringAsync(function(str) {
results.push(str);
callback0();
}, callback0);
}, function(strings) {
success(results);
});
else
success(results);
});
};
prototype.getEvidenceAsync = function(index, success, failure) {
if (this.evidence[index] == null) {
Expand Down Expand Up @@ -91658,6 +91764,13 @@ EcAssertion = stjs.extend(EcAssertion, Assertion, [], function(constructor, prot
prototype.setDecayFunction = function(decayFunctionText) {
this.decayFunction = EcEncryptedValue.encryptValue(decayFunctionText.toString(), this.id, this.subject.owner, this.subject.reader);
};
prototype.setDecayFunctionAsync = function(decayFunctionText, success, failure) {
var me = this;
EcEncryptedValue.encryptValueAsync(decayFunctionText, this.id, this.subject.owner, this.subject.reader, function(decayFunction) {
me.decayFunction = decayFunction;
success();
}, failure);
};
prototype.getDecayFunctionAsync = function(success, failure) {
if (this.decayFunction == null) {
success(null);
Expand Down Expand Up @@ -91696,6 +91809,13 @@ EcAssertion = stjs.extend(EcAssertion, Assertion, [], function(constructor, prot
prototype.setNegative = function(negativeB) {
this.negative = EcEncryptedValue.encryptValue(negativeB.toString(), this.id, this.subject.owner, this.subject.reader);
};
prototype.setNegativeAsync = function(negativeB, success, failure) {
var me = this;
EcEncryptedValue.encryptValueAsync(negativeB.toString(), this.id, this.subject.owner, this.subject.reader, function(negative) {
me.negative = negative;
success();
}, failure);
};
prototype.getNegativeAsync = function(success, failure) {
if (this.negative == null) {
success(null);
Expand Down Expand Up @@ -91734,6 +91854,19 @@ EcAssertion = stjs.extend(EcAssertion, Assertion, [], function(constructor, prot
encryptedValues.push(EcEncryptedValue.encryptValue(evidences[i], this.id, this.subject.owner, this.subject.reader));
this.evidence = encryptedValues;
};
prototype.setEvidenceAsync = function(evidences, success, failure) {
var me = this;
var encryptedValues = new Array();
new EcAsyncHelper().each(evidences, function(s, callback0) {
EcEncryptedValue.encryptValueAsync(s, this.id, this.subject.owner, this.subject.reader, function(ecEncryptedValue) {
encryptedValues.push(ecEncryptedValue);
callback0();
}, callback0);
}, function(strings) {
me.evidence = encryptedValues;
success();
});
};
prototype.save = function(success, failure, repo) {
if (this.competency == null || this.competency == "") {
var msg = "Failing to save: Competency cannot be missing";
Expand Down
Loading

0 comments on commit 2008e8b

Please sign in to comment.