xref: /aosp_15_r20/external/cronet/third_party/anonymous_tokens/src/anonymous_tokens/cpp/crypto/constants.h (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2023 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //    https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef ANONYMOUS_TOKENS_CPP_CRYPTO_CONSTANTS_H_
16 #define ANONYMOUS_TOKENS_CPP_CRYPTO_CONSTANTS_H_
17 
18 #include <cstdint>
19 
20 #include "absl/strings/string_view.h"
21 
22 namespace anonymous_tokens {
23 
24 // Returned integer on successful execution of BoringSSL methods
25 constexpr int kBsslSuccess = 1;
26 
27 // RSA modulus size, 4096 bits
28 //
29 // Our recommended size.
30 constexpr int kRsaModulusSizeInBits4096 = 4096;
31 
32 // RSA modulus size, 512 bytes
33 constexpr int kRsaModulusSizeInBytes512 = 512;
34 
35 // RSA modulus size, 2048 bits
36 //
37 // Recommended size for RSA Blind Signatures without Public Metadata.
38 //
39 // https://www.ietf.org/archive/id/draft-ietf-privacypass-protocol-08.html#name-token-type-blind-rsa-2048-b.
40 constexpr int kRsaModulusSizeInBits2048 = 2048;
41 
42 // RSA modulus size, 256 bytes
43 constexpr int kRsaModulusSizeInBytes256 = 256;
44 
45 // Salt length, 48 bytes
46 //
47 // Recommended size. The convention is to use hLen, the length of the output of
48 // the hash function in bytes. A salt length of zero will result in a
49 // deterministic signature value.
50 //
51 // https://datatracker.ietf.org/doc/draft-irtf-cfrg-rsa-blind-signatures/
52 constexpr int kSaltLengthInBytes48 = 48;
53 
54 // Length of message mask, 32 bytes.
55 //
56 // https://datatracker.ietf.org/doc/draft-irtf-cfrg-rsa-blind-signatures/
57 constexpr size_t kRsaMessageMaskSizeInBytes32 = 32;
58 
59 // Info used in HKDF for Public Metadata Hash.
60 constexpr absl::string_view kHkdfPublicMetadataInfo = "PBRSA";
61 
62 constexpr int kHkdfPublicMetadataInfoSizeInBytes = 5;
63 
64 // Object identifier for Rivest, Shamir, Adleman (RSA) Signature Scheme with
65 // Appendix - Probabilistic Signature Scheme (RSASSA-PSS) defined here:
66 // https://oidref.com/1.2.840.113549.1.1.10
67 constexpr char kRsaSsaPssOid[] = "1.2.840.113549.1.1.10";
68 
69 // Object identifier for SHA384 defined here:
70 // https://oidref.com/2.16.840.1.101.3.4.2.2
71 constexpr char kSha384Oid[] = "2.16.840.1.101.3.4.2.2";
72 
73 // Object identifier for RSA algorithm that uses the Mask Generator Function 1
74 // (MGF1) defined here:
75 // https://oidref.com/1.2.840.113549.1.1.8
76 constexpr char kRsaSsaPssMgf1Oid[] = "1.2.840.113549.1.1.8";
77 
78 }  // namespace anonymous_tokens
79 
80 #endif  // ANONYMOUS_TOKENS_CPP_CRYPTO_CONSTANTS_H_
81