Changeset bf3a7d6 for core/java


Ignore:
Timestamp:
Dec 17, 2018 1:59:49 PM (19 months ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
20876ff
Parents:
35a771c7
Message:

Data: More work on Encrypted LS2 (proposal 123)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • core/java/src/net/i2p/data/EncryptedLeaseSet.java

    r35a771c7 rbf3a7d6  
    55import java.io.OutputStream;
    66
     7import net.i2p.crypto.SHA256Generator;
    78import net.i2p.crypto.SigType;
    89import net.i2p.util.Clock;
     
    1920    // includes IV and MAC
    2021    private byte[] _encryptedData;
     22    private LeaseSet2 _decryptedLS2;
     23    private Hash __calculatedHash;
    2124
    2225    private static final int MIN_ENCRYPTED_SIZE = 8 + 16;
     
    3235    public int getType() {
    3336        return KEY_TYPE_ENCRYPTED_LS2;
     37    }
     38
     39    /**
     40     *  @return 0-16, or 0 if not decrypted.
     41     */
     42    @Override
     43    public int getLeaseCount() {
     44        // TODO attempt decryption
     45        return _decryptedLS2 != null ? _decryptedLS2.getLeaseCount() : 0;
     46    }
     47
     48    /**
     49     *  @return null if not decrypted.
     50     */
     51    @Override
     52    public Lease getLease(int index) {
     53        // TODO attempt decryption
     54        return _decryptedLS2 != null ? _decryptedLS2.getLease(index) : null;
    3455    }
    3556
     
    157178    }
    158179
     180    /**
     181     *  Overridden because we have a blinded key, not a dest.
     182     *  This is the hash of the signing public key type and the signing public key.
     183     *  Throws IllegalStateException if not initialized.
     184     *
     185     *  @throws IllegalStateException
     186     */
     187    @Override
     188    public Hash getHash() {
     189        if (__calculatedHash == null) {
     190            if (_signingKey == null)
     191                throw new IllegalStateException();
     192            int len = _signingKey.length();
     193            byte[] b = new byte[2 + len];
     194            DataHelper.toLong(b, 0, 2, _signingKey.getType().getCode());
     195            System.arraycopy(_signingKey.getData(), 0, b, 2, len);
     196            __calculatedHash = SHA256Generator.getInstance().calculateHash(b);
     197        }
     198        return __calculatedHash;
     199    }
     200
    159201    // encrypt / decrypt TODO
    160202
Note: See TracChangeset for help on using the changeset viewer.