blob: fcdb22b26d8f8075ab5a796ad1583ac2918b7aff [file] [log] [blame]
Elly4046edf2024-10-10 20:51:361// Copyright 2024 The Chromium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CRYPTO_SUBTLE_PASSKEY_H_
6#define CRYPTO_SUBTLE_PASSKEY_H_
7
8#include "crypto/crypto_export.h"
9
Elly11005ea2024-12-11 16:39:2510namespace ash {
11class CryptohomeTokenEncryptor;
Elly7f0b5a872025-02-13 01:51:1312class Key;
Elly11005ea2024-12-11 16:39:2513}
14
Elly5be8ea02024-10-29 15:00:5415namespace syncer {
16class Nigori;
17}
18
Elly4046edf2024-10-10 20:51:3619namespace crypto {
Elly28e72c262024-12-03 01:06:3520class SubtlePassKey;
21} // namespace crypto
22
23namespace chromeos::onc {
24crypto::SubtlePassKey MakeCryptoPassKey();
25}
26
Tom Andersonc4f709722025-01-11 01:49:1927namespace os_crypt_async {
28class FreedesktopSecretKeyProvider;
29}
30
Ellyc4eea4e2024-12-10 19:34:3131class OSCryptImpl;
32
Elly28e72c262024-12-03 01:06:3533namespace crypto {
Elly4046edf2024-10-10 20:51:3634
35// A crypto::SubtlePassKey allows you to call subtle, difficult-to-get-right, or
36// mistake-prone APIs, or APIs that allow you to make detailed cryptographic
37// choices for yourself. See //docs/patterns/passkey.md for details.
38//
39// Note: this has no relation at all to the "passkey" WebAuthN mechanism.
40class CRYPTO_EXPORT SubtlePassKey final {
41 public:
42 ~SubtlePassKey();
43
44 // Test code is always allowed to use these APIs.
45 static SubtlePassKey ForTesting();
46
47 private:
48 SubtlePassKey();
49
50 // Deprecated: remove this once the DeriveKey*() methods are deleted from
51 // SymmetricKey.
52 friend class SymmetricKey;
Elly5be8ea02024-10-29 15:00:5453
Elly11005ea2024-12-11 16:39:2554 // This class uses custom PBKDF2 parameters, and has to keep doing so for
55 // compatibility with persisted data on disk.
56 friend class ash::CryptohomeTokenEncryptor;
57
Elly5be8ea02024-10-29 15:00:5458 // This class uses custom PBKDF2 parameters - the Nigori spec requires this.
59 friend class syncer::Nigori;
Elly28e72c262024-12-03 01:06:3560
61 // ONC EncryptedConfiguration objects can contain and require us to use
62 // arbitrary (possibly attacker-supplied) PBKDF2 parameters.
63 friend SubtlePassKey chromeos::onc::MakeCryptoPassKey();
Ellyc4eea4e2024-12-10 19:34:3164
Tom Andersonc4f709722025-01-11 01:49:1965 // These classes use custom PBKDF2 parameters and have to keep doing so for
Ellyc4eea4e2024-12-10 19:34:3166 // compatibility with existing persisted data.
67 friend class ::OSCryptImpl;
Tom Andersonc4f709722025-01-11 01:49:1968 friend class os_crypt_async::FreedesktopSecretKeyProvider;
Elly7f0b5a872025-02-13 01:51:1369
70 // This class uses custom PBKDF2 parameters which cannot be changed for
71 // compatibility with persisted data.
72 friend class ash::Key;
Elly4046edf2024-10-10 20:51:3673};
74
75} // namespace crypto
76
77#endif // CRYPTO_SUBTLE_PASSKEY_H_