Skip to content

Commit

Permalink
removed private key upload from encryption feature. use of public key…
Browse files Browse the repository at this point in the history
… only.
  • Loading branch information
odds-get-evened committed Jan 3, 2023
1 parent 8faf26b commit ace908f
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 32 deletions.
18 changes: 7 additions & 11 deletions src/elements/encrypting/egenerate.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@ const EGenerate = () => {

const [displayLoading, setDisplayLoading] = useState(false);

const [keyData, setKeyData] = useState({
username: '',
email: '',
thepasswd: ''
});
const [keyData, setKeyData] = useState({});

const [disabledGenerate, setDisabledGenerate] = useState(true);

const keySchema = Joi.object({
Expand Down Expand Up @@ -60,8 +57,6 @@ const EGenerate = () => {
const clickGenerate = (e) => {
e.preventDefault();

setKeyData({...keyData, thetag: randomBytes(4).toString('hex')});

/**
* disable the genreate button, until key has
* completed generating
Expand All @@ -77,13 +72,14 @@ const EGenerate = () => {
passphrase: keyData.thepasswd,
format: 'armored'
}).then((keyPair) => {
let zip = new JSZip();
zip.file("handshake-enc-" + keyData.thetag + ".pem", keyPair.privateKey);
zip.file("handshake-enc-" + keyData.thetag + ".pub", keyPair.publicKey);
const theTag = randomBytes(4).toString('hex');

const zip = new JSZip();
zip.file("handshake-enc-" + theTag + ".pem", keyPair.privateKey);

if(JSZip.support.uint8array) {
zip.generateAsync({type: 'blob'}).then((blob) => {
saveAs(blob, "handshake-enc-" + keyData.thetag + ".zip");
saveAs(blob, "handshake-enc-" + theTag + ".zip");
});
}

Expand Down
5 changes: 3 additions & 2 deletions src/elements/encrypting/encrypt.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,9 @@ const Encrypt = () => {
};

useEffect(() => {
console.log(encData);
setDisplayErrorMsg(!(errorMessage === ""));
}, [errorMessage]);
}, [errorMessage, encData]);

return (
<>
Expand All @@ -138,7 +139,7 @@ const Encrypt = () => {
<input type='file' ref={refUploadKey} multiple={false} onChange={changeUploadKey} style={{display: 'none'}} />
<ButtonGroup>
<Button onClick={e => {refUploadMsg.current.click();}}>add signed message</Button>
<Button disabled={disableUploadKey} onClick={e => {refUploadKey.current.click();}}>add encrpytion key</Button>
<Button disabled={disableUploadKey} onClick={e => {refUploadKey.current.click();}}>add public key</Button>
<Button disabled={disableEncryptIt} onClick={clickEncryptIt}>encrypt!</Button>
</ButtonGroup>
</Stack>
Expand Down
15 changes: 8 additions & 7 deletions src/elements/signing.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ const Signing = () => {
<Nav.Link eventKey="generate">generate</Nav.Link>
</Nav.Item>
<Nav.Item>
<Nav.Link eventKey="encrypt">encrypt</Nav.Link>
<Nav.Link eventKey="pubkey">public key</Nav.Link>
</Nav.Item>
<Nav.Item>
<Nav.Link eventKey="decrypt">decrypt</Nav.Link>
<Nav.Link eventKey="encrypt">encrypt</Nav.Link>
</Nav.Item>
<Nav.Item>
<Nav.Link eventKey="pubkey">public key</Nav.Link>
<Nav.Link eventKey="decrypt">decrypt</Nav.Link>
</Nav.Item>
</Nav>
</Col>
Expand All @@ -94,15 +94,15 @@ const Signing = () => {
<Tab.Pane eventKey="generate">
<EGenerate />
</Tab.Pane>
<Tab.Pane eventKey="pubkey">
<PubKey />
</Tab.Pane>
<Tab.Pane eventKey="encrypt">
<Encrypt />
</Tab.Pane>
<Tab.Pane eventKey="decrypt">
<Decrypt />
</Tab.Pane>
<Tab.Pane eventKey="pubkey">
<PubKey />
</Tab.Pane>
</Tab.Content>
</Col>
<Col lg={3}>
Expand All @@ -114,7 +114,8 @@ const Signing = () => {
<span className='small fw-semibold'>example: handshake-enc-&lt;tag id&gt;.zip</span>
</Alert>
<Alert variant='warning'>
<span className='fs-3 text'>2.</span> use your signed packet, to encrypt the clear text message from the signing process.
<span className='fs-3 text'>2.</span>
use your signed packet, to encrypt the clear text message from the signing process.
<br />
<span className='small fw-semibold'>example: handshake-secret-&lt;enc id tag&gt;.zip</span>
</Alert>
Expand Down
19 changes: 8 additions & 11 deletions src/elements/signing/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ const Generate = (props) => {

const [clickGenerateDisabled, setClickGenerateDisabled] = useState(true);

const [signingData, setSigningData] = useState({
thename: '',
theemail: '',
thepasswd: ''
});
const [signingData, setSigningData] = useState({});

const signingSchema = Joi.object({
thename: Joi.string().min(3).max(30).required(),
Expand All @@ -26,7 +22,7 @@ const Generate = (props) => {
});

const cleanUp = () => {
setSigningData({ theemail: "", thename: "", thepasswd: "" });
setSigningData({});
refTheEmail.current.value = "";
refTheName.current.value = "";
refThePasswd.current.value = "";
Expand All @@ -35,8 +31,6 @@ const Generate = (props) => {
const clickGenerate = (e) => {
e.preventDefault();

setSigningData({...signingData, thetag: randomBytes(4).toString('hex')});

generateKey({
type: 'ecc',
curve: 'curve25519',
Expand All @@ -51,19 +45,22 @@ const Generate = (props) => {
}).then((kee) => {
cleanUp();

const theTag = randomBytes(4).toString('hex');

let zip = new JSZip();
zip.file("handshake-sign-" + signingData.thetag + ".priv", kee.privateKey);
zip.file("handshake-sign-" + signingData.thetag + ".pub", kee.publicKey);
zip.file("handshake-sign-" + theTag + ".priv", kee.privateKey);
zip.file("handshake-sign-" + theTag + ".pub", kee.publicKey);

if(JSZip.support.uint8array) {
zip.generateAsync({type: 'blob'}).then((blob) => {
saveAs(blob, "handshake-sign-" + signingData.thetag + ".zip");
saveAs(blob, "handshake-sign-" + theTag + ".zip");
});
}
});
};

useEffect(() => {
console.log(signingData);
let val1 = signingSchema.validate(signingData);
setClickGenerateDisabled(val1.error);
}, [signingData]);
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const Main = (props) => {
<Container>
<Row>
<Col lg={12}>
<h1>handshake <Badge bg='dark'>v0.0.3</Badge></h1>
<h1>handshake <Badge bg='dark'>v0.0.4</Badge></h1>
</Col>
</Row>
<Row>
Expand Down

0 comments on commit ace908f

Please sign in to comment.