BSD License
For Conceal software
Copyright (c) 2014, Facebook, Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that...
If you think the Android project conceal listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
/*
* Copyright (c) 2014, Facebook, Inc./*fromwww.java2s.com*/
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/package com.facebook.crypto.benchmarks.mac.streams;
import javax.crypto.Mac;
import java.io.IOException;
import java.io.InputStream;
publicclass MacLayeredInputStream extends InputStream {
private Mac mMac;
private InputStream mIs;
public MacLayeredInputStream(Mac mac, InputStream is) {
mMac = mac;
mIs = is;
}
@Override
publicint available() throws IOException {
return mIs.available();
}
@Override
publicvoid close() throws IOException {
mIs.close();
}
@Override
publicvoid mark(int readlimit) {
mIs.mark(readlimit);
}
@Override
publicboolean markSupported() {
return mIs.markSupported();
}
@Override
publicint read() throws IOException {
int read = mIs.read();
if (read != -1) {
mMac.update((byte) read);
}
return read;
}
@Override
publicint read(byte[] buffer) throws IOException {
return read(buffer, 0, buffer.length);
}
@Override
publicint read(byte[] buffer, int offset, int length) throws IOException {
int read = mIs.read(buffer, offset, length);
if (read != -1) {
mMac.update(buffer, offset, read);
}
return read;
}
@Override
publicsynchronizedvoid reset() throws IOException {
mIs.reset();
}
@Override
publiclong skip(long byteCount) throws IOException {
return mIs.skip(byteCount);
}
}