Unexport low-level key functions (#1188)
This commit is contained in:
parent
c5aa647e31
commit
4efeac3ad1
14
openpgp.d.ts
vendored
14
openpgp.d.ts
vendored
|
@ -629,20 +629,6 @@ export interface KeyOptions {
|
|||
subkeys?: KeyOptions[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Intended for internal use with openpgp.generate()
|
||||
* It's recommended that users choose openpgp.generateKey() that requires KeyOptions instead
|
||||
*/
|
||||
export interface FullKeyOptions {
|
||||
userIds: UserId[];
|
||||
passphrase?: string;
|
||||
numBits?: number;
|
||||
keyExpirationTime?: number;
|
||||
curve?: EllipticCurveName;
|
||||
date?: Date;
|
||||
subkeys: KeyOptions[]; // required unlike KeyOptions.subkeys
|
||||
}
|
||||
|
||||
export interface Keyid {
|
||||
bytes: string;
|
||||
}
|
||||
|
|
|
@ -17,7 +17,11 @@ export {
|
|||
* @see module:key
|
||||
* @name module:openpgp.key
|
||||
*/
|
||||
export * from './key';
|
||||
export {
|
||||
readKey, readArmoredKey,
|
||||
readKeys, readArmoredKeys,
|
||||
Key
|
||||
} from './key';
|
||||
|
||||
/**
|
||||
* @see module:signature
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../..');
|
||||
const util = require('../../src/util');
|
||||
const key = require('../../src/key');
|
||||
|
||||
const chai = require('chai');
|
||||
chai.use(require('chai-as-promised'));
|
||||
|
@ -3122,7 +3123,7 @@ module.exports = () => describe('Key', function() {
|
|||
|
||||
it("getPreferredAlgo('symmetric') - one key - AES256", async function() {
|
||||
const [key1] = await openpgp.readArmoredKeys(twoKeys);
|
||||
const prefAlgo = await openpgp.getPreferredAlgo('symmetric', [key1]);
|
||||
const prefAlgo = await key.getPreferredAlgo('symmetric', [key1]);
|
||||
expect(prefAlgo).to.equal(openpgp.enums.symmetric.aes256);
|
||||
});
|
||||
|
||||
|
@ -3132,7 +3133,7 @@ module.exports = () => describe('Key', function() {
|
|||
const key2 = keys[1];
|
||||
const primaryUser = await key2.getPrimaryUser();
|
||||
primaryUser.selfCertification.preferredSymmetricAlgorithms = [6,8,3];
|
||||
const prefAlgo = await openpgp.getPreferredAlgo('symmetric', [key1, key2]);
|
||||
const prefAlgo = await key.getPreferredAlgo('symmetric', [key1, key2]);
|
||||
expect(prefAlgo).to.equal(openpgp.enums.symmetric.aes192);
|
||||
});
|
||||
|
||||
|
@ -3142,7 +3143,7 @@ module.exports = () => describe('Key', function() {
|
|||
const key2 = keys[1];
|
||||
const primaryUser = await key2.getPrimaryUser();
|
||||
primaryUser.selfCertification.preferredSymmetricAlgorithms = null;
|
||||
const prefAlgo = await openpgp.getPreferredAlgo('symmetric', [key1, key2]);
|
||||
const prefAlgo = await key.getPreferredAlgo('symmetric', [key1, key2]);
|
||||
expect(prefAlgo).to.equal(openpgp.enums.symmetric.aes128);
|
||||
});
|
||||
|
||||
|
@ -3151,9 +3152,9 @@ module.exports = () => describe('Key', function() {
|
|||
const primaryUser = await key1.getPrimaryUser();
|
||||
primaryUser.selfCertification.features = [7]; // Monkey-patch AEAD feature flag
|
||||
primaryUser.selfCertification.preferredAeadAlgorithms = [2,1];
|
||||
const prefAlgo = await openpgp.getPreferredAlgo('aead', [key1]);
|
||||
const prefAlgo = await key.getPreferredAlgo('aead', [key1]);
|
||||
expect(prefAlgo).to.equal(openpgp.enums.aead.ocb);
|
||||
const supported = await openpgp.isAeadSupported([key1]);
|
||||
const supported = await key.isAeadSupported([key1]);
|
||||
expect(supported).to.be.true;
|
||||
});
|
||||
|
||||
|
@ -3166,9 +3167,9 @@ module.exports = () => describe('Key', function() {
|
|||
primaryUser.selfCertification.preferredAeadAlgorithms = [2,1];
|
||||
const primaryUser2 = await key2.getPrimaryUser();
|
||||
primaryUser2.selfCertification.features = [7]; // Monkey-patch AEAD feature flag
|
||||
const prefAlgo = await openpgp.getPreferredAlgo('aead', [key1, key2]);
|
||||
const prefAlgo = await key.getPreferredAlgo('aead', [key1, key2]);
|
||||
expect(prefAlgo).to.equal(openpgp.enums.aead.eax);
|
||||
const supported = await openpgp.isAeadSupported([key1, key2]);
|
||||
const supported = await key.isAeadSupported([key1, key2]);
|
||||
expect(supported).to.be.true;
|
||||
});
|
||||
|
||||
|
@ -3179,9 +3180,9 @@ module.exports = () => describe('Key', function() {
|
|||
const primaryUser = await key1.getPrimaryUser();
|
||||
primaryUser.selfCertification.features = [7]; // Monkey-patch AEAD feature flag
|
||||
primaryUser.selfCertification.preferredAeadAlgorithms = [2,1];
|
||||
const prefAlgo = await openpgp.getPreferredAlgo('aead', [key1, key2]);
|
||||
const prefAlgo = await key.getPreferredAlgo('aead', [key1, key2]);
|
||||
expect(prefAlgo).to.equal(openpgp.enums.aead.eax);
|
||||
const supported = await openpgp.isAeadSupported([key1, key2]);
|
||||
const supported = await key.isAeadSupported([key1, key2]);
|
||||
expect(supported).to.be.false;
|
||||
});
|
||||
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../..');
|
||||
const util = require('../../src/util');
|
||||
|
||||
const { readArmoredKey, generate, Key, readArmoredCleartextMessage, CleartextMessage, enums, PacketList, SignaturePacket } = openpgp;
|
||||
const { readArmoredKey, Key, readArmoredCleartextMessage, CleartextMessage, enums, PacketList, SignaturePacket } = openpgp;
|
||||
const key = require('../../src/key');
|
||||
|
||||
const chai = require('chai');
|
||||
chai.use(require('chai-as-promised'));
|
||||
|
@ -9,7 +10,7 @@ chai.use(require('chai-as-promised'));
|
|||
const expect = chai.expect;
|
||||
|
||||
async function generateTestData() {
|
||||
const victimPrivKey = await generate({
|
||||
const victimPrivKey = await key.generate({
|
||||
userIds: ['Victim <victim@example.com>'],
|
||||
rsaBits: util.getWebCryptoAll() ? 2048 : 1024,
|
||||
subkeys: [{
|
||||
|
@ -18,7 +19,7 @@ async function generateTestData() {
|
|||
});
|
||||
victimPrivKey.revocationSignatures = [];
|
||||
|
||||
const attackerPrivKey = await generate({
|
||||
const attackerPrivKey = await key.generate({
|
||||
userIds: ['Attacker <attacker@example.com>'],
|
||||
rsaBits: util.getWebCryptoAll() ? 2048 : 1024,
|
||||
subkeys: [],
|
||||
|
|
Loading…
Reference in New Issue
Block a user