merge of '0c43ec8566a97f8ad57f17575db898b259932435'

and '662195feb3df61d6b5a84dea177727d94cedb8b6'
This commit is contained in:
HungryHobo
2011-03-03 21:23:00 +00:00
11 changed files with 34 additions and 12 deletions

View File

@@ -1,5 +1,5 @@
I2P-Bote Ver. 0.1
-----------------
I2P-Bote Technical Documentation
--------------------------------
1) Introduction
@@ -534,14 +534,14 @@ Here is a simplified diagram of how a Relay Return Packet is sent from one hop t
4.6. Replication
See comments at the beginning of src/i2p/bote/network/kademlia/ReplicateThread.java
See comments at the beginning of src/i2p/bote/network/kademlia/ReplicateThread.java
5. Algorithms Used By Nodes Locally
5.1. Retrieving Email via relays
see also http://forum.i2p/viewtopic.php?p=19927#19927 ff.
See also http://forum.i2p/viewtopic.php?p=19927#19927 ff.
1) Randomly choose a set of n relay nodes, R1...Rn (outgoing chain for request)
2) Randomly choose a set of m relay nodes, S1...Sm. (return chain / inbound mail chain)
@@ -573,15 +573,17 @@ See comments at the beginning of src/i2p/bote/network/kademlia/ReplicateThread.j
6.1. Encryption
The identities file, the address book, and all email files are encrypted with AES-256.
PBKDF2 with SHA1 is used to generate the AES key from the password.
To generate the AES key from the password, scrypt (http://www.tarsnap.com/scrypt.html) is used.
The file format is:
Field | #bytes | Description
-------+--------+------------------------------------------------------------------
SOF | 4 | Start of file, contains the characters "IBef"
VER | 1 | Format version, must be 1
ITER | 4 | Number of PBKDF2 iterations
SALT | 32 | Salt for PBKDF2
N | 4 | scrypt CPU cost parameter
r | 4 | scrypt memory cost parameter
p | 4 | scrypt parallelization parameter
SALT | 32 | Salt for scrypt
IV | 32 | IV for AES
DATA | | The encrypted data
@@ -598,6 +600,15 @@ The file format is:
Email Destination matches one of the identities, that identity is used as
the default.
6.3. Included .jar files and third-party source code
bcprov-ecc-jdk16-145.jar A stripped down version of the BouncyCastle library,
containing only the classes needed for ECC.
mailapi.jar Part of JavaMail
src/SevenZip/ An LZMA implementation from http://www.7-zip.org/sdk.html
src/net/sf/ntru An NTRU implementation from http://sf.net/projects/ntru/
src/com/lambdaworks/crypto/ An scrypt implementation from https://github.com/wg/scrypt/
7. Glossary of Terms

View File

@@ -42,8 +42,8 @@ import net.i2p.I2PAppContext;
/**
* Stores a password in memory so the user doesn't have to re-enter it.
* Also caches key derivation parameters (salt and #iterations) so the
* key derivation function only needs to run once.
* Also caches key derivation parameters (salt and <code>scrypt</code> parameters)
* so the key derivation function only needs to run once.
*/
public class PasswordCache extends I2PBoteThread implements PasswordHolder {
private byte[] password;
@@ -79,8 +79,8 @@ public class PasswordCache extends I2PBoteThread implements PasswordHolder {
}
/**
* Reads salt and number of iterations from the cache file, or chooses a new
* salt array if the file doesn't exist. The encryption key is then computed
* Reads salt and <code>scrypt</code> parameters from the cache file, or chooses
* a new salt array if the file doesn't exist. The encryption key is then computed
* and the variable <code>derivedKey</code> is populated.
* @throws IOException
* @throws GeneralSecurityException
@@ -89,7 +89,7 @@ public class PasswordCache extends I2PBoteThread implements PasswordHolder {
byte[] salt = null;
derivedKey = null;
// read salt + numIterations from file if available
// read salt + scrypt parameters from file if available
File derivParamFile = configuration.getKeyDerivationParametersFile();
if (derivParamFile.exists()) {
DataInputStream inputStream = null;

View File

@@ -21,12 +21,14 @@ import javax.servlet.ServletResponse;
public class CharsetFilter implements Filter {
private String encoding;
@Override
public void init(FilterConfig config) throws ServletException {
encoding = config.getInitParameter("requestEncoding");
if (encoding == null)
encoding = "UTF-8";
}
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain next) throws IOException, ServletException {
// Respect the client-specified character encoding
// (see HTTP specification section 3.4.1)
@@ -36,6 +38,7 @@ public class CharsetFilter implements Filter {
next.doFilter(request, response);
}
@Override
public void destroy() {
}
}

View File

@@ -27,6 +27,7 @@ import javax.servlet.jsp.tagext.SimpleTagSupport;
public class CheckMailTag extends SimpleTagSupport {
@Override
public void doTag() {
I2PBote.getInstance().checkForMail();
}

View File

@@ -27,6 +27,7 @@ import javax.servlet.jsp.tagext.SimpleTagSupport;
public class ConnectTag extends SimpleTagSupport {
@Override
public void doTag() {
I2PBote.getInstance().connectNow();
}

View File

@@ -40,6 +40,7 @@ public class FormatPlainTextTag extends SimpleTagSupport {
private Log log = new Log(FormatPlainTextTag.class);
private String text;
@Override
public void doTag() {
PageContext pageContext = (PageContext)getJspContext();
JspWriter out = pageContext.getOut();

View File

@@ -41,6 +41,7 @@ import net.i2p.util.Log;
public class PeerInfoTag extends SimpleTagSupport {
private Log log = new Log(PeerInfoTag.class);
@Override
public void doTag() {
PageContext pageContext = (PageContext) getJspContext();
JspWriter out = pageContext.getOut();

View File

@@ -36,6 +36,7 @@ public class QuoteTag extends SimpleTagSupport {
private Log log = new Log(QuoteTag.class);
private String text;
@Override
public void doTag() {
PageContext pageContext = (PageContext)getJspContext();
JspWriter out = pageContext.getOut();

View File

@@ -27,6 +27,7 @@ import javax.servlet.jsp.tagext.SimpleTagSupport;
public class SaveConfigurationTag extends SimpleTagSupport {
@Override
public void doTag() {
I2PBote.getInstance().getConfiguration().save();
}

View File

@@ -30,6 +30,7 @@ public class SetEmailReadTag extends SimpleTagSupport {
private String messageId;
private boolean read;
@Override
public void doTag() {
folder.setNew(messageId, !read);
}

View File

@@ -39,6 +39,7 @@ public class ShowAttachmentsTag extends SimpleTagSupport {
private Email email;
private String folder;
@Override
public void doTag() throws IOException, JspException {
PageContext pageContext = (PageContext)getJspContext();
JspWriter out = pageContext.getOut();