Description
RSA key generator, use greatest common divisor, Euler's phi, coprime numbers (no Maven etc.)
- Comand-Line manager in edu.awieclawski.cmd.rsa.MainManager;
- Web-App in edu.awieclawski.web.* (servlets,jsp,css,jstl);
- API Rest in edu.awieclawski.web.rest;
instruction:
- Install Tomcat 8.0 in <$ECLIPSE_WORKSSPACE>/tomcat80
- Add <$ECLIPSE_WORKSSPACE>/tomcat80/lib/servlet-api.jar to the Project Java BuildPath libraries
- Add the Project to the Server in the Server Eclipse tab
- Deploy & visit at http://localhost:8080/edu.awieclawski.rsa/welcome
example data:
- p=11,q=23,e=29->d=129
- p=113,q=241,e=827->d=5363
requirements:
- Download from: https://eclipse-ee4j.github.io/jersey/download.html the archive 'jaxrs-ri-2.25.1.zip' described as 'Jersey JAX-RS 2.0 RI bundle bundle contains the JAX-RS 2.0 API jar, all the core Jersey module jars as well as all the required 3rd-party dependencies.'
- Extract the archive and add all the jars (by mouse right click on the Project):
- to the 'BuildPath' > 'Libraries' tab
- to the 'Properties' > 'Deployment Assembly'
- Deploy, by 'Run on Server' in Eclipse.
- Put in section of 'server.xml' (Tomcat instance) following line:
<Valve className="org.apache.catalina.valves.ErrorReportValve"
showReport="false" showServerInfo="false" />
to avoid html report as error responses.
examples:
- visit Hello page at:
http://localhost:8080/edu.awieclawski.rsa/rest/api
- get client Agent:
http://localhost:8080/edu.awieclawski.rsa/rest/api/agent
- get client Host:
http://localhost:8080/edu.awieclawski.rsa/rest/api/host
- get client Headers:
http://localhost:8080/edu.awieclawski.rsa/rest/api/headers
- check if prime number:
http://localhost:8080/edu.awieclawski.rsa/rest/api/isprime/29
-> returns '29';
http://localhost:8080/edu.awieclawski.rsa/rest/api/isprime/22
-> returns 'HTTP Status 417 - Expectation Failed';
http://localhost:8080/edu.awieclawski.rsa/rest/api/isprime/aa
-> returns 'HTTP Status 406 - Not Acceptable';
JSON requirements:
- Download jars from Maven repos:
- jackson-annotations-2.2.3.jar
- jackson-core-2.2.3.jar
- jackson-databind-2.2.3.jar
- jackson-jaxrs-base-2.2.3.jar
- jackson-jaxrs-json-provider-2.2.3.jar
- jackson-jaxrs-xml-provider-2.2.3.jar
- jackson-module-jaxb-annotations-2.2.3.jar
- add mentioned above jars (by right click on the Project)
- to the 'BuildPath' > 'Libraries' of the Project
- to the 'Properties' > 'Deployment Assembly'
examples:
- type in http browser:
http://localhost:8080/edu.awieclawski.rsa/rest/api/isprime_rj/29
-> returns {"value":29,"reqid":"20210504182903794"} as JSON;
- type in cmdl:
curl --header "Content-Type: application/json"
--request POST
--data '{"modulusn":253,"pubkey":29}'
http://localhost:8080/edu.awieclawski.rsa/rest/api/coprimes_rj
-> returns {"modulusn":253,"pubkey":29,"phin":220,"reqid":"20210504222925995"} as JSON;
curl --header "Content-Type: application/json"
--request POST
--data '{"phin":244,"pubkey":29}'
http://localhost:8080/edu.awieclawski.rsa/rest/api/coprimes_rj
-> returns HTTP Status 417 - Expectation Failed
curl --header "Content-Type: application/json"
--request POST
--data '{"modulusn":253,"key":29,"message":"ala ma kotA"}'
http://localhost:8080/edu.awieclawski.rsa/rest/api/encode_rj
-> returns {"modulusn":253,"key":29,"message":"ala ma kotA","encoded":[247,225,247,142,43,247,142,172,199,24,153],"reqid":"20210506202116153"}
curl --header "Content-Type: application/json" --request POST --data '{"modulusn":266,"key":22,"message":"ala ma kotA"}' \http://localhost:8080/edu.awieclawski.rsa/rest/api/encode_rj
-> returns HTTP Status 406 - Not Acceptable