Skip to content

Commit

Permalink
Remove okio dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
rockaport committed Dec 18, 2018
1 parent 599fbcb commit b5388eb
Show file tree
Hide file tree
Showing 27 changed files with 943 additions and 880 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ CI](https://circleci.com/gh/rockaport/alice.svg?style=shield)](https://circleci.
[![codecov](https://codecov.io/gh/rockaport/alice/branch/master/graph/badge.svg)](https://codecov.io/gh/rockaport/alice)

# alice
Alice is a Java AES encryption library for working with byte arrays, files, and streams. Various key lengths, block modes, padding schemes, key deriviation functions, and Message Authentication Codes (MAC) are available. See the [javadoc](https://rockaport.github.io/alice) for more information.
Alice is a Java AES/DES encryption library for working with byte arrays, files, and streams. Various key lengths, block modes, padding schemes, key deriviation functions, and Message Authentication Codes (MAC) are available. See the [javadoc](https://rockaport.github.io/alice) for more information.

Alice provides an easy wrapper around the javax.crypto cipher suite for symmetric key encryption. if a MAC algorithm is selected, additional [Authenticated Encryption](https://en.wikipedia.org/wiki/Authenticated_encryption) is performed using an [encrypt-then-mac](https://en.wikipedia.org/wiki/Authenticated_encryption#Encrypt-then-MAC_.28EtM.29) scheme.

Expand Down
4 changes: 1 addition & 3 deletions alice/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

dependencies {
compile 'com.squareup.okio:okio:1.11.0'

compile "org.codehaus.groovy:groovy-all:2.4.1"

testCompile 'org.spockframework:spock-core:1.1-groovy-2.4-rc-3'
Expand All @@ -33,7 +31,7 @@ task codeCoverageReport(type: JacocoReport) {

reports {
xml.enabled true
xml.destination "${buildDir}/reports/jacoco/report.xml"
xml.destination file("${buildDir}/reports/jacoco/report.xml")
html.enabled true
csv.enabled false
}
Expand Down
9 changes: 4 additions & 5 deletions alice/src/main/java/com/rockaport/alice/Alice.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.rockaport.alice;

import okio.Buffer;

import javax.crypto.*;
import javax.crypto.spec.GCMParameterSpec;
import javax.crypto.spec.IvParameterSpec;
Expand Down Expand Up @@ -159,9 +157,10 @@ private Mac getMac(AliceContext.MacAlgorithm macAlgorithm, char[] password) thro
* @param password the password
* @return an encrypted byte array
* @throws GeneralSecurityException if initialization or encryption fails
* @throws IOException if there's a problem constructing the result
*/
@SuppressWarnings("WeakerAccess")
public synchronized byte[] encrypt(byte[] input, char[] password) throws GeneralSecurityException {
public synchronized byte[] encrypt(byte[] input, char[] password) throws GeneralSecurityException, IOException {
if (input == null || input.length == 0) {
throw new IllegalArgumentException("Input is either null or empty");
}
Expand All @@ -182,7 +181,7 @@ public synchronized byte[] encrypt(byte[] input, char[] password) throws General
byte[] encryptedBytes = cipher.doFinal(input);

// construct the output (IV || CIPHER)
Buffer output = new Buffer();
ByteArrayOutputStream output = new ByteArrayOutputStream();

output.write(cipher.getIV());
output.write(encryptedBytes);
Expand All @@ -192,7 +191,7 @@ public synchronized byte[] encrypt(byte[] input, char[] password) throws General
output.write(getMac(context.getMacAlgorithm(), password).doFinal(encryptedBytes));
}

return output.readByteArray();
return output.toByteArray();
}

/**
Expand Down
4 changes: 2 additions & 2 deletions docs/allclasses-frame.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (1.8.0_111) on Sat Feb 18 08:27:39 EST 2017 -->
<!-- Generated by javadoc (1.8.0_191) on Tue Dec 18 05:46:48 EST 2018 -->
<title>All Classes (alice 0.5 API)</title>
<meta name="date" content="2017-02-18">
<meta name="date" content="2018-12-18">
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
<script type="text/javascript" src="script.js"></script>
</head>
Expand Down
4 changes: 2 additions & 2 deletions docs/allclasses-noframe.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (1.8.0_111) on Sat Feb 18 08:27:39 EST 2017 -->
<!-- Generated by javadoc (1.8.0_191) on Tue Dec 18 05:46:48 EST 2018 -->
<title>All Classes (alice 0.5 API)</title>
<meta name="date" content="2017-02-18">
<meta name="date" content="2018-12-18">
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
<script type="text/javascript" src="script.js"></script>
</head>
Expand Down
61 changes: 32 additions & 29 deletions docs/com/rockaport/alice/Alice.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,28 @@
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (1.8.0_111) on Sat Feb 18 08:27:39 EST 2017 -->
<!-- Generated by javadoc (1.8.0_191) on Tue Dec 18 05:46:47 EST 2018 -->
<title>Alice (alice 0.5 API)</title>
<meta name="date" content="2017-02-18">
<meta name="date" content="2018-12-18">
<link rel="stylesheet" type="text/css" href="../../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../../script.js"></script>
</head>
<body>
<script type="text/javascript"><!--
try {
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="Alice (alice 0.5 API)";
}
}
catch(err) {
try {
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title = "Alice (alice 0.5 API)";
}
} catch (err) {
}
//-->
var methods = {"i0":10,"i1":10,"i2":10,"i3":10,"i4":10,"i5":10,"i6":9};
var tabs = {65535:["t0","All Methods"],1:["t1","Static Methods"],2:["t2","Instance Methods"],8:["t4","Concrete Methods"]};
var methods = {"i0": 10, "i1": 10, "i2": 10, "i3": 10, "i4": 10, "i5": 10, "i6": 9};
var tabs = {
65535: ["t0", "All Methods"],
1: ["t1", "Static Methods"],
2: ["t2", "Instance Methods"],
8: ["t4", "Concrete Methods"]
};
var altColor = "altColor";
var rowColor = "rowColor";
var tableTab = "tableTab";
Expand Down Expand Up @@ -60,15 +64,13 @@
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->

allClassesLink = document.getElementById("allclasses_navbar_top");
if (window == top) {
allClassesLink.style.display = "block";
} else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
Expand Down Expand Up @@ -313,7 +315,8 @@ <h4>generateKey</h4>
<h4>encrypt</h4>
<pre>public&nbsp;byte[]&nbsp;encrypt(byte[]&nbsp;input,
char[]&nbsp;password)
throws java.security.GeneralSecurityException</pre>
throws java.security.GeneralSecurityException,
java.io.IOException</pre>
<div class="block">Encrypts a byte array using the supplied password</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
Expand All @@ -325,6 +328,8 @@ <h4>encrypt</h4>
<dd><code>java.security.GeneralSecurityException</code> - if initialization or
encryption fails
</dd>
<dd><code>java.io.IOException</code> - if there's a problem constructing the result
</dd>
</dl>
</li>
</ul>
Expand Down Expand Up @@ -498,15 +503,13 @@ <h4>decrypt</h4>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->

allClassesLink = document.getElementById("allclasses_navbar_bottom");
if (window == top) {
allClassesLink.style.display = "block";
} else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
Expand Down
62 changes: 32 additions & 30 deletions docs/com/rockaport/alice/AliceContext.Algorithm.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,28 @@
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (1.8.0_111) on Sat Feb 18 08:27:39 EST 2017 -->
<!-- Generated by javadoc (1.8.0_191) on Tue Dec 18 05:46:48 EST 2018 -->
<title>AliceContext.Algorithm (alice 0.5 API)</title>
<meta name="date" content="2017-02-18">
<meta name="date" content="2018-12-18">
<link rel="stylesheet" type="text/css" href="../../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../../script.js"></script>
</head>
<body>
<script type="text/javascript"><!--
try {
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="AliceContext.Algorithm (alice 0.5 API)";
}
}
catch(err) {
try {
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title = "AliceContext.Algorithm (alice 0.5 API)";
}
} catch (err) {
}
//-->
var methods = {"i0":10,"i1":9,"i2":9};
var tabs = {65535:["t0","All Methods"],1:["t1","Static Methods"],2:["t2","Instance Methods"],8:["t4","Concrete Methods"]};
var methods = {"i0": 10, "i1": 9, "i2": 9};
var tabs = {
65535: ["t0", "All Methods"],
1: ["t1", "Static Methods"],
2: ["t2", "Instance Methods"],
8: ["t4", "Concrete Methods"]
};
var altColor = "altColor";
var rowColor = "rowColor";
var tableTab = "tableTab";
Expand Down Expand Up @@ -61,15 +65,13 @@
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->

allClassesLink = document.getElementById("allclasses_navbar_top");
if (window == top) {
allClassesLink.style.display = "block";
} else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
Expand Down Expand Up @@ -102,7 +104,8 @@ <h2 title="Enum AliceContext.Algorithm" class="title">Enum AliceContext.Algorith
<li>
<ul class="inheritance">
<li>java.lang.Enum&lt;<a href="../../../com/rockaport/alice/AliceContext.Algorithm.html"
title="enum in com.rockaport.alice">AliceContext.Algorithm</a>&gt;</li>
title="enum in com.rockaport.alice">AliceContext.Algorithm</a>&gt;
</li>
<li>
<ul class="inheritance">
<li>com.rockaport.alice.AliceContext.Algorithm</li>
Expand All @@ -118,7 +121,8 @@ <h2 title="Enum AliceContext.Algorithm" class="title">Enum AliceContext.Algorith
<dt>All Implemented Interfaces:</dt>
<dd>java.io.Serializable, java.lang.Comparable&lt;<a
href="../../../com/rockaport/alice/AliceContext.Algorithm.html"
title="enum in com.rockaport.alice">AliceContext.Algorithm</a>&gt;</dd>
title="enum in com.rockaport.alice">AliceContext.Algorithm</a>&gt;
</dd>
</dl>
<dl>
<dt>Enclosing class:</dt>
Expand Down Expand Up @@ -418,15 +422,13 @@ <h4>toString</h4>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->

allClassesLink = document.getElementById("allclasses_navbar_bottom");
if (window == top) {
allClassesLink.style.display = "block";
} else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
Expand Down
Loading

0 comments on commit b5388eb

Please sign in to comment.