Skip to content

CryptoKey algorithm/usages getters return internal slots instead of cached copies #59534

@panva

Description

@panva

Subsystem

Web Cryptography API

What steps will reproduce the bug?

const kp = await crypto.subtle.generateKey('Ed25519', true, ['sign', 'verify']);
kp.privateKey.usages.pop()

const sig = await crypto.subtle.sign('Ed25519', kp.privateKey, new Uint8Array())

// DOMException [InvalidAccessError]: Unable to use this key to sign
//    at signVerify (node:internal/crypto/webcrypto:765:11)
//    at SubtleCrypto.sign (node:internal/crypto/webcrypto:811:10)

What is the expected behavior? Why is that the expected behavior?

per the spec, cached copies of the internal slots are returned from these getters and only internal slots are used in the SubtleCrypto operations

What do you see instead?

the actual internal slots are returned, modifying them results in observable changes in behaviour when using the modified CryptoKey

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions