use of org.checkerframework.checker.nullness.qual.NonNull in project checker-framework by typetools.
the class NonNullMapValue method process_unmatched_procedure_entries.
public static void process_unmatched_procedure_entries() {
HashMap<Integer, Date> call_hashmap = new HashMap<Integer, Date>();
for (Integer i : call_hashmap.keySet()) {
@NonNull Date d = call_hashmap.get(i);
}
Set<@KeyFor("call_hashmap") Integer> keys = call_hashmap.keySet();
for (Integer i : keys) {
@NonNull Date d = call_hashmap.get(i);
}
Set<@KeyFor("call_hashmap") Integer> keys_sorted = new TreeSet<@KeyFor("call_hashmap") Integer>(call_hashmap.keySet());
for (Integer i : keys_sorted) {
@NonNull Date d = call_hashmap.get(i);
}
}
use of org.checkerframework.checker.nullness.qual.NonNull in project universa by UniversaBlockchain.
the class RSAOAEPPublicKey method checkSignature.
/**
* {@inheritDoc}
*/
@NonNull
@Override
public boolean checkSignature(InputStream input, byte[] signature, HashType hashType, int saltLength) throws IllegalStateException, IOException {
if (state == null) {
throw new IllegalStateException();
} else {
final Digest primaryDigest = hashType.makeDigest();
if (saltLength == MAX_SALT_LENGTH) {
saltLength = getMaxSaltLength(getBitStrength(), primaryDigest.getDigestSize());
}
if (saltLength < 0) {
throw new RuntimeException(String.format("Incorrect salt length %s", saltLength));
}
final Signer signatureChecker = new PSSSigner(RSAEngineFactory.make(), primaryDigest, state.mgf1HashType.makeDigest(), saltLength);
signatureChecker.init(false, new ParametersWithRandom(state.keyParameters, state.rng));
boolean done = false;
while (!done) {
int availableBytes = input.available();
if (availableBytes <= 0) {
done = true;
} else {
byte[] buffer = new byte[availableBytes];
int howManyBytesRead = input.read(buffer);
if (howManyBytesRead <= 0) {
done = true;
} else {
signatureChecker.update(buffer, 0, howManyBytesRead);
}
}
}
return signatureChecker.verifySignature(signature);
}
}
use of org.checkerframework.checker.nullness.qual.NonNull in project universa by UniversaBlockchain.
the class Capsule method prepareSigners.
@NonNull
private HashMap<String, AbstractKey> prepareSigners(Binder payload) {
HashMap<String, AbstractKey> sigIds = new HashMap<>();
if (signers != null && !signers.isEmpty()) {
ArrayList<Binder> s = payload.set("signers", new ArrayList<>());
int i = 0;
for (Binder b : signers.values()) {
final String id = b.getStringOrThrow("id");
final AbstractKey key = (AbstractKey) b.get("key");
sigIds.put(id, key);
Binder signerData = new Binder("id", id, "key", key.getPublicKey().pack(), "data", b.getBinder("data"));
s.add(signerData);
}
}
return sigIds;
}
use of org.checkerframework.checker.nullness.qual.NonNull in project universa by UniversaBlockchain.
the class Capsule method preparePayload.
@NonNull
private Binder preparePayload() throws EncryptionError {
Binder payload = new Binder();
// Private data
if (hasPrivate()) {
if (encryptingKeys == null || encryptingKeys.isEmpty()) {
throw new IllegalStateException("missing encryption keys");
}
SymmetricKey mainKey = new SymmetricKey();
byte[] packedMainKey = mainKey.pack();
Binder data = payload.set("private", new Binder());
ArrayList keys = data.set("keys", new ArrayList<Binder>());
for (AbstractKey k : encryptingKeys) {
if (k == null)
throw new IllegalStateException("null is forbidden in encryption keys");
Binder b = new Binder("keyInfo", k.packedInfo(), "key", k.encrypt(packedMainKey));
keys.add(b);
}
// Private data are packed with random filler. The way it is donne
// fill will simply not read
byte[] packedPrivate = Boss.dumpToArray(privateData, CTRTransformer.randomBytes(0, 117));
data.put("data", mainKey.etaEncrypt(packedPrivate));
}
// public data
if (hasPublic()) {
payload.put("public", publicData);
}
payload.put("type", "capsule");
return payload;
}
use of org.checkerframework.checker.nullness.qual.NonNull in project universa by UniversaBlockchain.
the class Capsule method unpackPayload.
@NonNull
private Binder unpackPayload(byte[] packedCoffer, boolean allowPartiallySigned) throws EncryptionError {
signed = false;
Binder outer = Boss.unpack(packedCoffer);
Collection<Binder> signatures = outer.getBinders("signatures");
final byte[] source = outer.getBinary("content");
Binder payload = Boss.unpack(source);
if (!payload.get("type").equals("capsule"))
throw new FormatException("not capsule/unknown type");
checkSignatures(source, signatures, payload, allowPartiallySigned);
publicData = payload.getBinder("public");
return payload;
}
Aggregations