Search in sources :

Example 6 with UniqueId

use of i2p.bote.UniqueId in project i2p.i2p-bote by i2p.

the class FolderTest method createEmailPacket.

EncryptedEmailPacket createEmailPacket(EmailDestination dest, String message) throws Exception {
    byte[] content = message.getBytes();
    byte[] messageIdBytes = new byte[] { -69, -24, -109, 1, 69, -122, -69, 113, -68, -90, 55, -28, 105, 97, 125, 70, 51, 58, 14, 2, -13, -53, 90, -29, 36, 67, 36, -94, -108, -125, 11, 123 };
    UniqueId messageId = new UniqueId(messageIdBytes, 0);
    int fragmentIndex = 0;
    UnencryptedEmailPacket plaintextPacket = new UnencryptedEmailPacket(new ByteArrayInputStream(content), messageId, fragmentIndex, I2PBotePacket.MAX_DATAGRAM_SIZE);
    plaintextPacket.setNumFragments(1);
    return new EncryptedEmailPacket(plaintextPacket, dest);
}
Also used : UniqueId(i2p.bote.UniqueId) ByteArrayInputStream(java.io.ByteArrayInputStream) EncryptedEmailPacket(i2p.bote.packet.dht.EncryptedEmailPacket) UnencryptedEmailPacket(i2p.bote.packet.dht.UnencryptedEmailPacket)

Example 7 with UniqueId

use of i2p.bote.UniqueId in project i2p.i2p-bote by i2p.

the class IndexPacketFolderTest method setUp.

@Before
public void setUp() throws Exception {
    File tempDir = new File(System.getProperty("java.io.tmpdir"));
    testDir = new File(tempDir, "IndexPacketFolderTest-" + System.currentTimeMillis());
    folderDir = new File(testDir, "dht_index_pkt");
    folder = new SettableStoreTimeIndexPacketFolder(folderDir);
    byte[] content1 = "test TEST test ABCDEFGH asdfsadfsadf 3487562384".getBytes();
    byte[] content2 = "fdlkhgjfljh test 123456".getBytes();
    byte[] messageIdBytes = new byte[] { -69, -24, -109, 1, 69, -122, -69, 113, -68, -90, 55, -28, 105, 97, 125, 70, 51, 58, 14, 2, -13, -53, 90, -29, 36, 67, 36, -94, -108, -125, 11, 123 };
    UniqueId messageId = new UniqueId(messageIdBytes, 0);
    int fragmentIndex = 0;
    unencryptedPacket1 = new UnencryptedEmailPacket(new ByteArrayInputStream(content1), messageId, fragmentIndex, I2PBotePacket.MAX_DATAGRAM_SIZE);
    unencryptedPacket1.setNumFragments(1);
    unencryptedPacket2 = new UnencryptedEmailPacket(new ByteArrayInputStream(content2), messageId, fragmentIndex, I2PBotePacket.MAX_DATAGRAM_SIZE);
    unencryptedPacket2.setNumFragments(1);
    destination1 = new EmailDestination("2XP9Ep3WWLk3-FTlMgUjgw4h8GYVBCvR6YrPyKdhP4xyQMSh8Da0VjZCmQGbD3PCeaGXAShBKbKjhJjQ7laekI");
    destination2 = new EmailDestination("m-5~1dZ0MrGdyAWu-C2ecNAB5LCCsHQpeSfjn-r~mqMfNvroR98~BRmReUDmb0la-r-pBHLMtflrJE7aTrGwDTBm5~AJFEm-9SJPZnyGs-ed5pOj4Db65yJml1y1n77qr1~mM4GITl6KuIoxg8YwvPrCIlXe2hiiDCoC-uY9-np9UY");
    destination3 = new EmailDestination("0XuJjhgp58aOhvHHgpaxoQYsCUfDS6BECMEoVxFGEFPdk3y8lbzIsq9eUyeizFleMacYwoscCir8nQLlW34lxfRmirkNpD9vU1XnmjnZ5hGdnor1qIDqz3KJ040dVQ617MwyG97xxYLT0FsH907vBXgdc4RCHwKd1~9siagA5CSMaA~wM8ymKXLypiZGYexENLmim7nMzJTQYoOM~fVS99UaGJleDBN3pgZ2EvRYDQV2VqKH7Gee07R3y7b~c0tAKVHS0IbPQfTVJigrIHjTl~ZczxpaeTM04T8IgxKnO~lSmR1w7Ik8TpEkETwT9PDwUqQsjmlSY8E~WwwGMRJVyIRZUkHeRZ0aFq7us8W9EKzYtjjiU1z0QFpZrTfJE8oqCbnH5Lqv5Q86UdTPpriJC1N99E77TpCTnNzcBnpp6ko2JCy2IJUveaigKxS6EmS9KarkkkBRsckOKZZ6UNTOqPZsBCsx0Q9WvDF-Uc3dtouXWyenxRptaQsdkZyYlEQv");
    emailPacket1 = new EncryptedEmailPacket(unencryptedPacket1, destination1);
    emailPacket2 = new EncryptedEmailPacket(unencryptedPacket2, destination2);
}
Also used : UniqueId(i2p.bote.UniqueId) ByteArrayInputStream(java.io.ByteArrayInputStream) EncryptedEmailPacket(i2p.bote.packet.dht.EncryptedEmailPacket) EmailDestination(i2p.bote.email.EmailDestination) UnencryptedEmailPacket(i2p.bote.packet.dht.UnencryptedEmailPacket) File(java.io.File) Before(org.junit.Before)

Example 8 with UniqueId

use of i2p.bote.UniqueId in project i2p.i2p-bote by i2p.

the class ResponsePacketTest method setUp.

@Before
public void setUp() throws Exception {
    byte[] packetIdBytes = new byte[] { 120, 120, -8, -88, 21, 126, 46, -61, 18, -101, 15, 53, 20, -44, -112, 42, 86, -117, 30, -96, -66, 33, 71, -55, -102, -78, 78, -82, -105, 66, -116, 43 };
    UniqueId packetId = new UniqueId(packetIdBytes, 0);
    Collection<ResponsePacket> responsePackets = ResponsePacket.create(createDataPacket(), StatusCode.OK, packetId);
    assertEquals(1, responsePackets.size());
    responsePacket = responsePackets.iterator().next();
}
Also used : UniqueId(i2p.bote.UniqueId) Before(org.junit.Before)

Example 9 with UniqueId

use of i2p.bote.UniqueId in project i2p.i2p-bote by i2p.

the class EmailPacketDeleteRequestTest method setUp.

@Before
public void setUp() throws Exception {
    Hash dhtKey = new Hash(new byte[] { -48, 78, 66, 58, -79, 87, 38, -103, -60, -27, 108, 55, 117, 37, -99, 93, -23, -102, -83, 20, 44, -80, 65, 89, -68, -73, 69, 51, 115, 79, 24, 127 });
    byte[] packetIdBytes = new byte[] { 120, 120, -8, -88, 21, 126, 46, -61, 18, -101, 15, 53, 20, -44, -112, 42, 86, -117, 30, -96, -66, 33, 71, -55, -102, -78, 78, -82, -105, 66, -116, 43 };
    UniqueId deleteAuthorization = new UniqueId(packetIdBytes, 0);
    delRequest = new EmailPacketDeleteRequest(dhtKey, deleteAuthorization);
}
Also used : UniqueId(i2p.bote.UniqueId) Hash(net.i2p.data.Hash) Before(org.junit.Before)

Example 10 with UniqueId

use of i2p.bote.UniqueId in project i2p.i2p-bote by i2p.

the class EncryptedEmailPacketTest method setUp.

@Before
public void setUp() throws Exception {
    // make an UnencryptedEmailPacket
    byte[] content = message.getBytes();
    byte[] messageIdBytes = new byte[] { -69, -24, -109, 1, 69, -122, -69, 113, -68, -90, 55, -28, 105, 97, 125, 70, 51, 58, 14, 2, -13, -53, 90, -29, 36, 67, 36, -94, -108, -125, 11, 123 };
    UniqueId messageId = new UniqueId(messageIdBytes, 0);
    int fragmentIndex = 0;
    plaintextPacket = new UnencryptedEmailPacket(new ByteArrayInputStream(content), messageId, fragmentIndex, I2PBotePacket.MAX_DATAGRAM_SIZE);
    plaintextPacket.setNumFragments(1);
    encryptedPackets = new EncryptedEmailPacket[2];
    identities = new EmailIdentity[2];
    // make a ElGamal/DSA identity
    String elGamalBase64 = "piYT1uJ3O8~bBPZmTvehMbp3-Zksg5enhvIlp2X8txqL25l0WdQMWwyt30UAOVQqxGdnMPTqqjh~-zoa~rCQORo~J1gRxLwCX9LlHQqaIimJilrbN-rhKy4Xlft054wbgQjLSC-WICE4W64KDfitwRzdr7lV6lz~0KFiZ8erZ-~WPMG1CgWEku9lILQUdUHyFBguPcK9oPDq7oGBuFGy8w0CvAq7ex3nmbL7zQVA~VqILtOGeGK2fidCuuofj4AQsTcXmH9O0nxZGCIJBhf~4EWmazvxu8XVB8pabNQvRDbmFu6q85JTwmxC45lCjqNw30hp8q2zoqP-zchjWOrxFUhSumpBdD0xXJR~qmhejh4WnuRnnam9j3fcxH5i~T7xWgmvIbpZEI4kyc9VEbXbLI7k-bU2A6sdP-AGt5~TjGLcxpdsPnOLRXO-Dsi7E9-3Kc84s4TmdpEJdtHn1dxYyeeT-ysVOqXjv5w5Cuk0XJpUIJG8n7aXHpNb-QLxPD3yAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADWF3qnAX-p41Po~VNmOUzS-Yt~noD8-e~L3P5rZXBWf-XtB4hkloo6m1jwqphEdf1";
    identities[0] = new EmailIdentity(elGamalBase64);
    EmailDestination elGamalDestination = new EmailDestination(identities[0].getKey());
    // make an ElGamal encrypted packet
    assertTrue(identities[0].getCryptoImpl() instanceof ElGamal2048_DSA1024);
    encryptedPackets[0] = new EncryptedEmailPacket(plaintextPacket, elGamalDestination);
    // make a ECDH/ECDSA identity
    String ecdhBase64 = "m-5~1dZ0MrGdyAWu-C2ecNAB5LCCsHQpeSfjn-r~mqMfNvroR98~BRmReUDmb0la-r-pBHLMtflrJE7aTrGwDTBm5~AJFEm-9SJPZnyGs-ed5pOj4Db65yJml1y1n77qr1~mM4GITl6KuIoxg8YwvPrCIlXe2hiiDCoC-uY9-np9UYYujtjOOwCqXPH9PIbcZeFRkegbOxw5G6I7M4-TZBFbxYDtaew6HX9hnQEGWHkaapq2kTTB3Hmv0Uyo64jvcfMmSRcPng3J1Ho5mHgnzsH0qxQemnBcw7Lfc9fU8xRz858uyiQ8J8XH3T8S7k2~8L7awSgaT7uHQgpV~Rs0p1ofJ70g";
    identities[1] = new EmailIdentity(ecdhBase64);
    EmailDestination ecdhDestination = new EmailDestination(identities[1].getKey());
    // make an ECDH encrypted packet
    assertTrue(identities[1].getCryptoImpl() instanceof ECDH521_ECDSA521);
    encryptedPackets[1] = new EncryptedEmailPacket(plaintextPacket, ecdhDestination);
}
Also used : UniqueId(i2p.bote.UniqueId) ByteArrayInputStream(java.io.ByteArrayInputStream) EmailIdentity(i2p.bote.email.EmailIdentity) EmailDestination(i2p.bote.email.EmailDestination) ElGamal2048_DSA1024(i2p.bote.crypto.ElGamal2048_DSA1024) ECDH521_ECDSA521(i2p.bote.crypto.ECDH521_ECDSA521) Before(org.junit.Before)

Aggregations

UniqueId (i2p.bote.UniqueId)25 ByteArrayInputStream (java.io.ByteArrayInputStream)9 Before (org.junit.Before)9 EncryptedEmailPacket (i2p.bote.packet.dht.EncryptedEmailPacket)7 EmailDestination (i2p.bote.email.EmailDestination)6 Hash (net.i2p.data.Hash)6 UnencryptedEmailPacket (i2p.bote.packet.dht.UnencryptedEmailPacket)5 File (java.io.File)5 DataPacket (i2p.bote.packet.DataPacket)3 DeletionInfoPacket (i2p.bote.packet.dht.DeletionInfoPacket)3 DhtStorablePacket (i2p.bote.packet.dht.DhtStorablePacket)3 EmailPacketDeleteRequest (i2p.bote.packet.dht.EmailPacketDeleteRequest)3 IOException (java.io.IOException)3 Destination (net.i2p.data.Destination)3 EmailIdentity (i2p.bote.email.EmailIdentity)2 DeletionAwareDhtFolder (i2p.bote.folder.DeletionAwareDhtFolder)2 DhtStorageHandler (i2p.bote.network.DhtStorageHandler)2 ResponsePacket (i2p.bote.packet.ResponsePacket)2 DeleteRequest (i2p.bote.packet.dht.DeleteRequest)2 DeletionQuery (i2p.bote.packet.dht.DeletionQuery)2