Skip to content

Commit d64a90f

Browse files
committed
reverted some rsa items
1 parent 26db381 commit d64a90f

File tree

3 files changed

+77
-69
lines changed

3 files changed

+77
-69
lines changed

keeperapi/src/browser/platform.ts

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -214,17 +214,17 @@ export const browserPlatform: Platform = class {
214214
await this.importKeyRSA(keyId, keyBytes, storage)
215215
break
216216
// TODO: add something like this, need to find pub/priv key pair
217-
case 'ecc':
218-
// gonna figure this out
219-
try {
220-
debugger
221-
const privkey = keyBytes.slice(ECC_PUB_KEY_LENGTH)
222-
const pubKey = keyBytes.slice(0, ECC_PUB_KEY_LENGTH)
223-
await this.importKeyEC(keyId, privkey, pubKey, storage)
224-
} catch(e){
225-
console.error('ecc error in unwrapKeys: ', e)
226-
}
227-
break
217+
// case 'ecc':
218+
// // gonna figure this out
219+
// try {
220+
// debugger
221+
// const privkey = keyBytes.slice(ECC_PUB_KEY_LENGTH)
222+
// const pubKey = keyBytes.slice(0, ECC_PUB_KEY_LENGTH)
223+
// await this.importKeyEC(keyId, privkey, pubKey, storage)
224+
// } catch(e){
225+
// console.error('ecc error in unwrapKeys: ', e)
226+
// }
227+
// break
228228
default:
229229
throw new Error(`unable to import ${unwrappedType} key`)
230230
}
@@ -275,23 +275,23 @@ export const browserPlatform: Platform = class {
275275
await this.unwrapAesKey(key, keyId, unwrappingKeyId, encryptionType, storage, canExport)
276276
break
277277
// TODO: add something like this, need to find pub/priv key pair
278-
case 'ecc':
279-
if (cryptoKeysCache['gcm'][keyId]) {
280-
return
281-
}
282-
283-
try {
284-
debugger
285-
// maybe this priv key?
286-
// const eccPrivateKey = await this.loadKey(unwrappingKeyId, 'ecc', storage)
287-
const privkey = key.slice(ECC_PUB_KEY_LENGTH)
288-
const pubKey = key.slice(0, ECC_PUB_KEY_LENGTH)
278+
// case 'ecc':
279+
// if (cryptoKeysCache['gcm'][keyId]) {
280+
// return
281+
// }
282+
283+
// try {
284+
// debugger
285+
// // maybe this priv key?
286+
// // const eccPrivateKey = await this.loadKey(unwrappingKeyId, 'ecc', storage)
287+
// const privkey = key.slice(ECC_PUB_KEY_LENGTH)
288+
// const pubKey = key.slice(0, ECC_PUB_KEY_LENGTH)
289289

290-
await this.unwrapECCKey(privkey, pubKey, keyId, unwrappingKeyId, encryptionType, storage)
291-
} catch(e){
292-
console.error('ecc error in unwrapKey: ', e)
293-
}
294-
break
290+
// await this.unwrapECCKey(privkey, pubKey, keyId, unwrappingKeyId, encryptionType, storage)
291+
// } catch(e){
292+
// console.error('ecc error in unwrapKey: ', e)
293+
// }
294+
// break
295295
default:
296296
throw new Error('Unable to unwrap key type ' + unwrappedKeyType)
297297
}

keeperapi/src/endpoint.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -288,17 +288,17 @@ export class KeeperEndpoint {
288288
// RSA TAGGED - done, add ecOnly check to only make ec keys if ec only is true
289289
public async getOnsitePublicKey(ecOnly:boolean): Promise<string> {
290290
if (!this.onsitePublicKey || !this.onsitePrivateKey) {
291-
if(ecOnly){
292-
const {privateKey, publicKey} = await platform.generateECKeyPair()
291+
// if(ecOnly){
292+
// const {privateKey, publicKey} = await platform.generateECKeyPair()
293293

294-
this.onsitePrivateKey = privateKey
295-
this.onsitePublicKey = publicKey
296-
} else {
297-
const {privateKey, publicKey} = await platform.generateRSAKeyPair()
298-
299-
this.onsitePrivateKey = privateKey
300-
this.onsitePublicKey = publicKey
301-
}
294+
// this.onsitePrivateKey = privateKey
295+
// this.onsitePublicKey = publicKey
296+
// } else {
297+
// }
298+
const {privateKey, publicKey} = await platform.generateRSAKeyPair()
299+
300+
this.onsitePrivateKey = privateKey
301+
this.onsitePublicKey = publicKey
302302
}
303303

304304
return webSafe64FromBytes(this.onsitePublicKey)

keeperapi/src/vaultx.ts

Lines changed: 40 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -292,31 +292,39 @@ export const processTeams = async (teams: NN<ITeam>[], storage: VaultStorage, de
292292
}
293293
}
294294

295-
switch (team.teamKeyType) {
296-
case Records.RecordKeyType.ENCRYPTED_BY_DATA_KEY:
297-
teamPrivateKeys[teamUid + '_priv'] = {
298-
data: team.teamPrivateKey,
299-
dataId: teamUid + '_priv',
300-
keyId: teamUid,
301-
encryptionType: 'cbc',
302-
unwrappedType: 'rsa',
303-
}
304-
break
305-
// RSA TAGGED - this essentially changes the unwrapped type to ecc. make sure this is fine
306-
case Records.RecordKeyType.ENCRYPTED_BY_PUBLIC_KEY_ECC:
307-
teamPrivateKeys[teamUid + '_priv'] = {
308-
data: team.teamPrivateKey,
309-
dataId: teamUid + '_priv',
310-
keyId: 'pk_ecc',
311-
encryptionType: 'ecc',
312-
unwrappedType: 'aes',
313-
}
314-
break
315-
default:
316-
console.error(`Key ${team.teamKeyType} type for team folder private key ${teamUid} is not supported for team folder decryption`)
317-
break
295+
teamPrivateKeys[teamUid + '_priv'] = {
296+
data: team.teamPrivateKey,
297+
dataId: teamUid + '_priv',
298+
keyId: teamUid,
299+
encryptionType: 'cbc',
300+
unwrappedType: 'rsa',
318301
}
319302

303+
// switch (team.teamKeyType) {
304+
// case Records.RecordKeyType.ENCRYPTED_BY_DATA_KEY:
305+
// teamPrivateKeys[teamUid + '_priv'] = {
306+
// data: team.teamPrivateKey,
307+
// dataId: teamUid + '_priv',
308+
// keyId: teamUid,
309+
// encryptionType: 'cbc',
310+
// unwrappedType: 'rsa',
311+
// }
312+
// break
313+
// // RSA TAGGED - this essentially changes the unwrapped type to ecc. make sure this is fine
314+
// case Records.RecordKeyType.ENCRYPTED_BY_PUBLIC_KEY_ECC:
315+
// teamPrivateKeys[teamUid + '_priv'] = {
316+
// data: team.teamPrivateKey,
317+
// dataId: teamUid + '_priv',
318+
// keyId: 'pk_ecc',
319+
// encryptionType: 'ecc',
320+
// unwrappedType: 'aes',
321+
// }
322+
// break
323+
// default:
324+
// console.error(`Key ${team.teamKeyType} type for team folder private key ${teamUid} is not supported for team folder decryption`)
325+
// break
326+
// }
327+
320328
// RSA TAGGED - fix is the switch case above. need to confirm the encryptionType and unwrappedType are correct
321329
// teamPrivateKeys[teamUid + '_priv'] = {
322330
// data: team.teamPrivateKey,
@@ -354,15 +362,15 @@ export const processTeams = async (teams: NN<ITeam>[], storage: VaultStorage, de
354362
unwrappedType: 'aes',
355363
}
356364
break
357-
case Records.RecordKeyType.ENCRYPTED_BY_PUBLIC_KEY_ECC:
358-
teamSharedFolderKeys[folderUid] = {
359-
data: folderKey.sharedFolderKey,
360-
dataId: folderUid,
361-
keyId: 'pk_ecc',
362-
encryptionType: 'ecc',
363-
unwrappedType: 'aes',
364-
}
365-
break
365+
// case Records.RecordKeyType.ENCRYPTED_BY_PUBLIC_KEY_ECC:
366+
// teamSharedFolderKeys[folderUid] = {
367+
// data: folderKey.sharedFolderKey,
368+
// dataId: folderUid,
369+
// keyId: 'pk_ecc',
370+
// encryptionType: 'ecc',
371+
// unwrappedType: 'aes',
372+
// }
373+
// break
366374
default:
367375
console.error(`Key ${folderKey.keyType} type for team folder key ${teamUid}/${folderUid} is not supported for team folder decryption`)
368376
break

0 commit comments

Comments
 (0)