-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial commit of source and other project files
- Loading branch information
1 parent
03b47e8
commit e32a070
Showing
18 changed files
with
4,132 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# OSCORE for Californium | ||
|
||
This project was created as a part of a master thesis by Luka Dschaak. The Title was 'Developement and Implementation of Object Security in Californium using OSCOAP'. As you can see, the implementation is based on the old Version OSCOAP. The exact Version is https://tools.ietf.org/html/draft-ietf-core-object-security-03. | ||
|
||
The Object Security Option number was selected to 52225. It is placed as constant in OscoapEndpoint. To change it, you have to rebuild the project. | ||
|
||
|
||
## use oscoap-0.1.jar | ||
Currently the library is not available via repository. To use it, it must be included manually, as well the the following dependencies: | ||
|
||
group: 'com.augustcellars.cose', name: 'cose-java', version:'0.9.6' | ||
group: 'org.eclipse.californium', name: 'californium-core', version:'1.0.6' | ||
group: 'org.eclipse.californium', name: 'element-connector', version:'1.0.6' | ||
|
||
Examplecode of how Server and Client can be used, is found in the source files OscoapTestClient and OscoapTestServer | ||
|
||
|
||
## Build with gradle | ||
There are some different gradle tasks defined. For the the usual library, which can be included in an existing project, use `gradle jar`. There are two test classes for a standalone use. With `gradle fatJarTestServer` a standalone version of the OscoapTestServer will be compiled. With `gradle fatJarTestClient` get the same for the client. | ||
|
||
All Jars are placed under build/libs/. | ||
|
||
|
||
## Run TestServer and TestClient | ||
`java -jar build/libs/oscoap-test-server_standalone-0.1.jar` or `java -jar build/libs/oscoap-test-client_standalone-0.1.jar`. Start server first! | ||
|
||
There must be a first parameter! It should be the address (e.g. ip address) for the other endpoint. This is important for the security context. | ||
|
||
For example: | ||
Server: 192.168.0.20 | ||
Client: 192.168.0.30 | ||
|
||
$ java -jar build/libs/oscoap-test-server_standalone-0.1.jar 192.168.0.30 | ||
$ java -jar build/libs/oscoap-test-client_standalone-0.1.jar 192.168.0.20 | ||
|
||
Both try to find out the own address and display that on the console. If it is the wrong address, just pass it as second parameter to the call. | ||
|
||
$ java -jar build/libs/oscoap-test-server_standalone-0.1.jar 192.168.0.30 192.168.0.20 | ||
$ java -jar build/libs/oscoap-test-client_standalone-0.1.jar 192.168.0.20 192.168.0.30 | ||
|
||
The Server starts an OscoapEndpoint and provides several resources. The client has a small test routine. After starting the client a ping check will be done first. If it fails once, just try starting the client again. | ||
|
||
After ping you can choose between 'n' for next test (starts with 0), 'all' fo running all 16 tests, 'exit' for closing the client or type a [number] for selecting a specific test. | ||
|
||
Examples on localhost with different ports and IPv6 use (only server): | ||
Please use '127.0.0.1' instead of 'localhost' and '0:0:0:0:0:0:0:1' instead of '::1' | ||
|
||
$ java -jar build/libs/oscoap-test-server_standalone-0.1.jar 127.0.0.1:27332 127.0.0.1:27331 | ||
$ java -jar build/libs/oscoap-test-server_standalone-0.1.jar [0:0:0:0:0:0:0:1]:27332 [0:0:0:0:0:0:0:1]:27331 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
group 'de.uni-bremen.agrn' | ||
version '0.1' | ||
|
||
apply plugin: 'java' | ||
apply plugin: 'maven' | ||
|
||
sourceCompatibility = 1.8 | ||
targetCompatibility = 1.8 | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
compile group: 'com.augustcellars.cose', name: 'cose-java', version:'0.9.6' | ||
compile group: 'org.eclipse.californium', name: 'californium-core', version:'1.0.6' | ||
compile group: 'org.eclipse.californium', name: 'element-connector', version:'1.0.6' | ||
} | ||
|
||
jar { | ||
manifest { | ||
attributes 'Implementation-Title': 'OSCOAP for Californium', | ||
'Implementation-Version': version | ||
} | ||
} | ||
|
||
task fatJarTestClient(type: Jar) { | ||
manifest { | ||
attributes 'Implementation-Title': 'OSCOAP Californium Test Client', | ||
'Implementation-Version': version, | ||
'Main-Class': 'OscoapTestClient' | ||
} | ||
baseName = project.name + '-test-client_standalone' | ||
from { configurations.testCompile.collect { it.isDirectory() ? it : zipTree(it) } } | ||
from sourceSets.test.output | ||
with jar | ||
exclude 'META-INF/*.RSA', 'META-INF/*.SF','META-INF/*.DSA' | ||
} | ||
|
||
task fatJarTestServer(type: Jar) { | ||
manifest { | ||
attributes 'Implementation-Title': 'OSCOAP Californium Test Server', | ||
'Implementation-Version': version, | ||
'Main-Class': 'OscoapTestServer' | ||
} | ||
baseName = project.name + '-test-server_standalone' | ||
from { configurations.testCompile.collect { it.isDirectory() ? it : zipTree(it) } } | ||
from sourceSets.test.output | ||
with jar | ||
exclude 'META-INF/*.RSA', 'META-INF/*.SF','META-INF/*.DSA' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>org.dschaak</groupId> | ||
<artifactId>oscoap</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<source>1.8</source> | ||
<target>1.8</target> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.augustcellars.cose</groupId> | ||
<artifactId>cose-java</artifactId> | ||
<version>0.9.6</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.eclipse.californium</groupId> | ||
<artifactId>californium-core</artifactId> | ||
<version>1.0.6</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.californium</groupId> | ||
<artifactId>element-connector</artifactId> | ||
<version>1.0.6</version> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
rootProject.name = 'oscoap' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import COSE.AlgorithmID; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
|
||
import static javax.xml.bind.DatatypeConverter.printHexBinary; | ||
|
||
/** | ||
* Common Context build the context for an endpoint for communication with another endpoint. | ||
* Reference a SenderContext and a RecipientContext | ||
* Created by Luka Dschaak on 23.03.2017. | ||
*/ | ||
public class CommonContext { | ||
|
||
// All final, because they are immutable values | ||
private final AlgorithmID algorithm; // "AES-CCM-64-64-128" is mandatory 26 in COSE | ||
private final byte[] masterSecret; | ||
private final byte[] masterSalt; | ||
|
||
private SenderContext senderContext; | ||
private RecipientContext recipientContext; | ||
|
||
private final String targetResourceHost; | ||
|
||
// String = Token, OscoapRequest = (sequnceNumber, senderID) | ||
private HashMap<String, OscoapRequestParameter> requestList; | ||
|
||
|
||
CommonContext(AlgorithmID algorithm, byte[] masterSecret, byte[] masterSalt, String targetResourceHost){ | ||
this.algorithm = algorithm; | ||
this.masterSecret = masterSecret; | ||
this.masterSalt = masterSalt; | ||
this.targetResourceHost = OscoapHelper.reducedIPv6Host(targetResourceHost); | ||
this.requestList = new HashMap<>(); | ||
} | ||
|
||
public AlgorithmID getAlgorithm() { | ||
return algorithm; | ||
} | ||
|
||
public byte[] getMasterSecret() { | ||
return masterSecret; | ||
} | ||
|
||
public byte[] getMasterSalt() { | ||
return masterSalt; | ||
} | ||
|
||
public SenderContext getSenderContext() { | ||
return senderContext; | ||
} | ||
|
||
void setSenderContext(SenderContext senderContext) { | ||
this.senderContext = senderContext; | ||
} | ||
|
||
public RecipientContext getRecipientContext() { | ||
return recipientContext; | ||
} | ||
|
||
void setRecipientContext(RecipientContext recipientContext) { | ||
this.recipientContext = recipientContext; | ||
} | ||
|
||
public String getTargetResourceHost() { | ||
return targetResourceHost; | ||
} | ||
|
||
public boolean hasCurrentToken(byte[] requestToken) { | ||
String tokenString = printHexBinary(requestToken); | ||
return this.requestList.containsKey(tokenString); | ||
} | ||
|
||
public void addRequestParameters(byte[] token, OscoapRequestParameter params) { | ||
String tokenString = printHexBinary(token); | ||
this.requestList.put(tokenString, params); | ||
} | ||
|
||
public OscoapRequestParameter getAndRemoveRequestParameters(byte[] token) { | ||
String tokenString = printHexBinary(token); | ||
return requestList.remove(tokenString); | ||
} | ||
} |
Oops, something went wrong.