Skip to content

Commit

Permalink
add sample intermediate to new deflate dictionary
Browse files Browse the repository at this point in the history
  • Loading branch information
thestinger committed Mar 18, 2018
1 parent 9448deb commit 145490e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class AttestationProtocol {
// the outer signature and the rest of the chain for pinning the expected chain. It enforces
// downgrade protection for the OS version/patch (bootloader/TEE enforced) and app version (OS
// enforced) by keeping them updated.
private static final byte PROTOCOL_VERSION = 0;
private static final byte PROTOCOL_VERSION = 1;
// can become longer in the future, but this is the minimum length
private static final byte CHALLENGE_MESSAGE_LENGTH = 1 + CHALLENGE_LENGTH * 2;
private static final int MAX_ENCODED_CHAIN_LENGTH = 3000;
Expand Down Expand Up @@ -670,7 +670,8 @@ static VerificationResult verifySerialized(final Context context, final byte[] a
final byte[] chain = new byte[MAX_ENCODED_CHAIN_LENGTH];
final Inflater inflater = new Inflater(true);
inflater.setInput(compressedChain);
try (final InputStream stream = context.getResources().openRawResource(R.raw.deflate_dictionary)) {
final int deflateDictionary = version > 0 ? R.raw.deflate_dictionary_1 : R.raw.deflate_dictionary;
try (final InputStream stream = context.getResources().openRawResource(deflateDictionary)) {
inflater.setDictionary(ByteStreams.toByteArray(stream));
}
final int chainLength = inflater.inflate(chain);
Expand Down Expand Up @@ -871,7 +872,8 @@ static AttestationResult generateSerialized(final Context context, final byte[]

final ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
final Deflater deflater = new Deflater(Deflater.DEFAULT_COMPRESSION, true);
try (final InputStream stream = context.getResources().openRawResource(R.raw.deflate_dictionary)) {
final int deflateDictionary = maxVersion > 0 ? R.raw.deflate_dictionary_1 : R.raw.deflate_dictionary;
try (final InputStream stream = context.getResources().openRawResource(deflateDictionary)) {
deflater.setDictionary(ByteStreams.toByteArray(stream));
}
final DeflaterOutputStream deflaterStream = new DeflaterOutputStream(byteStream, deflater);
Expand Down
Binary file added app/src/main/res/raw/deflate_dictionary_1.bin
Binary file not shown.
Binary file added samples/taimen_intermediate.der.x509
Binary file not shown.

0 comments on commit 145490e

Please sign in to comment.