/** * Initializes the GuardedByteArray from the given clear text bytes. * * Caller is responsible for zeroing out the array of bytes after the call. * * @param clearBytes * The clear-text bytes */ public GuardedByteArray(byte[] clearBytes) { encryptBytes(clearBytes); }
/** * Initializes the GuardedByteArray from the given clear text bytes. * * Caller is responsible for zeroing out the array of bytes after the call. * * @param clearBytes * The clear-text bytes */ public GuardedByteArray(byte[] clearBytes) { encryptBytes(clearBytes); }
/** * Initializes the GuardedByteArray from the given clear text bytes. * Caller is responsible for zeroing out the array of bytes * after the call. * @param clearBytes The clear-text bytes */ public GuardedByteArray(byte[] clearBytes) { encryptBytes(clearBytes); }
/** * Appends a single clear-text byte to the secure byte array. * The in-memory data will be decrypted, the byte will be * appended, and then it will be re-encrypted. * @param b The byte to append. * @throws IllegalStateException If the byte array is read-only * @throws IllegalStateException If the byte array has been disposed */ public void appendByte(byte b) { checkNotDisposed(); checkWriteable(); byte[] clearBytes = null; byte[] clearBytes2 = null; try { clearBytes = decryptBytes(); clearBytes2 = new byte[clearBytes.length+1]; System.arraycopy(clearBytes, 0, clearBytes2, 0, clearBytes.length); clearBytes2[clearBytes2.length-1] = b; encryptBytes(clearBytes2); } finally { SecurityUtil.clear(clearBytes); SecurityUtil.clear(clearBytes2); } }
/** * Appends a single clear-text byte to the secure byte array. * * The in-memory data will be decrypted, the byte will be appended, and then * it will be re-encrypted. * * @param b * The byte to append. * @throws IllegalStateException * If the byte array is read-only * @throws IllegalStateException * If the byte array has been disposed */ public void appendByte(byte b) { checkNotDisposed(); checkWriteable(); byte[] clearBytes = null; byte[] clearBytes2 = null; try { clearBytes = decryptBytes(); clearBytes2 = new byte[clearBytes.length + 1]; System.arraycopy(clearBytes, 0, clearBytes2, 0, clearBytes.length); clearBytes2[clearBytes2.length - 1] = b; encryptBytes(clearBytes2); } finally { SecurityUtil.clear(clearBytes); SecurityUtil.clear(clearBytes2); } }
/** * Appends a single clear-text byte to the secure byte array. * * The in-memory data will be decrypted, the byte will be appended, and then * it will be re-encrypted. * * @param b * The byte to append. * @throws IllegalStateException * If the byte array is read-only * @throws IllegalStateException * If the byte array has been disposed */ public void appendByte(byte b) { checkNotDisposed(); checkWriteable(); byte[] clearBytes = null; byte[] clearBytes2 = null; try { clearBytes = decryptBytes(); clearBytes2 = new byte[clearBytes.length + 1]; System.arraycopy(clearBytes, 0, clearBytes2, 0, clearBytes.length); clearBytes2[clearBytes2.length - 1] = b; encryptBytes(clearBytes2); } finally { SecurityUtil.clear(clearBytes); SecurityUtil.clear(clearBytes2); } }