Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support requiring auth for keys generated outside of TEE on Android #2283

Merged
merged 1 commit into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/tabris/Crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,8 @@ class SubtleCrypto {
if ('usageRequiresAuth' in options) {
checkType(options.usageRequiresAuth, Boolean, {name: 'options.usageRequiresAuth'});
}
if (options.usageRequiresAuth && !options.inTee) {
throw new TypeError('options.usageRequiresAuth is only supported for keys in TEE');
if (options.usageRequiresAuth && !options.inTee && (tabris as any).device.platform !== 'Android') {
throw new TypeError('options.usageRequiresAuth is only supported for keys not in TEE on Android');
}
}
const inTee = options?.inTee;
Expand Down
13 changes: 11 additions & 2 deletions test/tabris/Crypto.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1124,13 +1124,22 @@ describe('Crypto', function() {
expect(client.calls({op: 'create', type: 'tabris.CryptoKey'}).length).to.equal(0);
});

it('rejects options.usageRequiresAuth when options.inTee is not set', async function() {
it('rejects options.usageRequiresAuth when options.inTee is not set and platform is not Android', async function() {
(tabris as any).device.platform = 'iOS';
params[3] = {usageRequiresAuth: true};
await expect(generateKey())
.rejectedWith(TypeError, 'options.usageRequiresAuth is only supported for keys in TEE');
.rejectedWith(TypeError, 'options.usageRequiresAuth is only supported for keys not in TEE on Android');
expect(client.calls({op: 'create', type: 'tabris.CryptoKey'}).length).to.equal(0);
});

it('does not reject options.usageRequiresAuth when options.inTee is not set and platform is Android',
async function() {
(tabris as any).device.platform = 'Android';
params[3] = {usageRequiresAuth: true};
await generateKey(param => param.onSuccess());
expect(client.calls({op: 'create', type: 'tabris.CryptoKey'}).length).to.be.greaterThan(0);
});

});

describe('subtle.sign()', function() {
Expand Down