Skip to content

Commit b9f0358

Browse files
committed
Project import generated by Copybara.
PiperOrigin-RevId: 874012482
1 parent 5255c88 commit b9f0358

File tree

8 files changed

+144
-39
lines changed

8 files changed

+144
-39
lines changed

android-stub/src/main/java/android/crypto/hpke/HpkeSpi.java

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ public interface HpkeSpi {
6464
* @throws UnsupportedOperationException if the mode is not supported by this implementation
6565
* @throws IllegalStateException if this SPI has already been initialised
6666
*/
67-
void engineInitSender(@NonNull PublicKey recipientKey, @Nullable byte[] info,
68-
@Nullable PrivateKey senderKey, @Nullable byte[] psk,
69-
@Nullable byte[] psk_id) throws InvalidKeyException;
67+
void engineInitSender(@NonNull PublicKey recipientKey, byte @Nullable[] info,
68+
@Nullable PrivateKey senderKey, byte @Nullable[] psk,
69+
byte @Nullable[] psk_id) throws InvalidKeyException;
7070

7171
/**
7272
* Initialises an HPKE SPI in one of the sender modes described in RFC 9180 with
@@ -105,9 +105,9 @@ void engineInitSender(@NonNull PublicKey recipientKey, @Nullable byte[] info,
105105
* @throws UnsupportedOperationException if the mode is not supported by this implementation
106106
* @throws IllegalStateException if this SPI has already been initialised
107107
*/
108-
void engineInitSenderWithSeed(@NonNull PublicKey recipientKey, @Nullable byte[] info,
109-
@Nullable PrivateKey senderKey, @Nullable byte[] psk,
110-
@Nullable byte[] psk_id, @NonNull byte[] sKe)
108+
void engineInitSenderWithSeed(@NonNull PublicKey recipientKey, byte @Nullable[] info,
109+
@Nullable PrivateKey senderKey, byte @Nullable[] psk,
110+
byte @Nullable[] psk_id, byte @NonNull[] sKe)
111111
throws InvalidKeyException;
112112

113113
/**
@@ -141,9 +141,9 @@ void engineInitSenderWithSeed(@NonNull PublicKey recipientKey, @Nullable byte[]
141141
* @throws UnsupportedOperationException if the mode is not supported by this implementation
142142
* @throws IllegalStateException if this SPI has already been initialised
143143
*/
144-
void engineInitRecipient(@NonNull byte[] encapsulated, @NonNull PrivateKey recipientKey,
145-
@Nullable byte[] info, @Nullable PublicKey senderKey,
146-
@Nullable byte[] psk, @Nullable byte[] psk_id)
144+
void engineInitRecipient(byte @NonNull[] encapsulated, @NonNull PrivateKey recipientKey,
145+
byte @Nullable[] info, @Nullable PublicKey senderKey,
146+
byte @Nullable[] psk, byte @Nullable[] psk_id)
147147
throws InvalidKeyException;
148148

149149
/**
@@ -156,7 +156,7 @@ void engineInitRecipient(@NonNull byte[] encapsulated, @NonNull PrivateKey recip
156156
* @throws IllegalStateException if this SPI has not been initialised or if it was initialised
157157
* as a recipient
158158
*/
159-
@NonNull byte[] engineSeal(@NonNull byte[] plaintext, @Nullable byte[] aad);
159+
byte @NonNull[] engineSeal(byte @NonNull[] plaintext, byte @Nullable[] aad);
160160

161161
/**
162162
* Opens a message, using the internal key schedule maintained by an HPKE recipient SPI.
@@ -168,8 +168,7 @@ void engineInitRecipient(@NonNull byte[] encapsulated, @NonNull PrivateKey recip
168168
* as a sender
169169
* @throws GeneralSecurityException on decryption failures
170170
*/
171-
@NonNull
172-
byte[] engineOpen(@NonNull byte[] ciphertext, @Nullable byte[] aad)
171+
byte @NonNull[] engineOpen(byte @NonNull[] ciphertext, byte @Nullable[] aad)
173172
throws GeneralSecurityException;
174173

175174
/**
@@ -182,7 +181,7 @@ byte[] engineOpen(@NonNull byte[] ciphertext, @Nullable byte[] aad)
182181
* @throws IllegalStateException if this SPI has not been initialised
183182
*
184183
*/
185-
@NonNull byte[] engineExport(int length, @Nullable byte[] context);
184+
byte @NonNull[] engineExport(int length, byte @Nullable[] context);
186185

187186
/**
188187
* Returns the encapsulated key material for an HPKE sender.
@@ -191,5 +190,5 @@ byte[] engineOpen(@NonNull byte[] ciphertext, @Nullable byte[] aad)
191190
* @throws IllegalStateException if this SPI has not been initialised or if it was initialised
192191
* as a recipient
193192
*/
194-
@NonNull byte[] getEncapsulated();
193+
byte @NonNull[] getEncapsulated();
195194
}

android-stub/src/main/java/android/pake/PakeClientKeyManagerParameters.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public final class PakeClientKeyManagerParameters implements ManagerFactoryParam
4747
*
4848
* @return The client identifier.
4949
*/
50-
public @Nullable byte[] getClientId() {
50+
public byte @Nullable[] getClientId() {
5151
throw new RuntimeException("Stub!");
5252
}
5353

@@ -56,7 +56,7 @@ public final class PakeClientKeyManagerParameters implements ManagerFactoryParam
5656
*
5757
* @return The server identifier.
5858
*/
59-
public @Nullable byte[] getServerId() {
59+
public byte @Nullable[] getServerId() {
6060
throw new RuntimeException("Stub!");
6161
}
6262

@@ -81,7 +81,7 @@ public static final class Builder {
8181
* @param clientId The ID of the client involved in the PAKE exchange.
8282
* @return This builder.
8383
*/
84-
public @NonNull Builder setClientId(@Nullable byte[] clientId) {
84+
public @NonNull Builder setClientId(byte @Nullable[] clientId) {
8585
throw new RuntimeException("Stub!");
8686
}
8787

@@ -91,7 +91,7 @@ public static final class Builder {
9191
* @param serverId The ID of the server involved in the PAKE exchange.
9292
* @return This builder.
9393
*/
94-
public @NonNull Builder setServerId(@Nullable byte[] serverId) {
94+
public @NonNull Builder setServerId(byte @Nullable[] serverId) {
9595
throw new RuntimeException("Stub!");
9696
}
9797

android-stub/src/main/java/android/pake/PakeOption.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public final class PakeOption {
5050
* @return The component data, or {@code null} if no component with the given
5151
* key exists.
5252
*/
53-
public @Nullable byte[] getMessageComponent(@NonNull String key) {
53+
public byte @Nullable[] getMessageComponent(@NonNull String key) {
5454
throw new RuntimeException("Stub!");
5555
}
5656

@@ -78,7 +78,7 @@ public Builder(@NonNull String algorithm) {
7878
* @return This builder.
7979
* @throws InvalidParameterException If the key is invalid.
8080
*/
81-
public @NonNull Builder addMessageComponent(@NonNull String key, @Nullable byte[] value) {
81+
public @NonNull Builder addMessageComponent(@NonNull String key, byte @Nullable[] value) {
8282
throw new RuntimeException("Stub!");
8383
}
8484

android-stub/src/main/java/android/pake/PakeServerKeyManagerParameters.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ public final class PakeServerKeyManagerParameters implements ManagerFactoryParam
7272
* @param serverId The server identifier for the link.
7373
* @return An unmodifiable list of PAKE options for the given link.
7474
*/
75-
public @NonNull List<PakeOption> getOptions(@Nullable byte[] clientId,
76-
@Nullable byte[] serverId) {
75+
public @NonNull List<PakeOption> getOptions(byte @Nullable[] clientId,
76+
byte @Nullable[] serverId) {
7777
throw new RuntimeException("Stub!");
7878
}
7979

@@ -89,7 +89,7 @@ public static final class Link {
8989
* @param clientId The client identifier for the link.
9090
* @param serverId The server identifier for the link.
9191
*/
92-
private Link(@Nullable byte[] clientId, @Nullable byte[] serverId) {
92+
private Link(byte @Nullable[] clientId, byte @Nullable[] serverId) {
9393
throw new RuntimeException("Stub!");
9494
}
9595

@@ -98,7 +98,7 @@ private Link(@Nullable byte[] clientId, @Nullable byte[] serverId) {
9898
*
9999
* @return The client identifier for the link.
100100
*/
101-
public @Nullable byte[] getClientId() {
101+
public byte @Nullable[] getClientId() {
102102
throw new RuntimeException("Stub!");
103103
}
104104

@@ -107,7 +107,7 @@ private Link(@Nullable byte[] clientId, @Nullable byte[] serverId) {
107107
*
108108
* @return The server identifier for the link.
109109
*/
110-
public @Nullable byte[] getServerId() {
110+
public byte @Nullable[] getServerId() {
111111
throw new RuntimeException("Stub!");
112112
}
113113

@@ -138,7 +138,7 @@ public static final class Builder {
138138
* @return This builder.
139139
* @throws InvalidParameterException If the provided options are invalid.
140140
*/
141-
public @NonNull Builder setOptions(@Nullable byte[] clientId, @Nullable byte[] serverId,
141+
public @NonNull Builder setOptions(byte @Nullable[] clientId, byte @Nullable[] serverId,
142142
@NonNull List<PakeOption> options) {
143143
throw new RuntimeException("Stub!");
144144
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright 2020 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.conscrypt;
18+
19+
/**
20+
* Stub class for logging statistics events.
21+
*/
22+
public class ConscryptStatsLog {
23+
public static final int TLS_HANDSHAKE_REPORTED = 0;
24+
25+
public static void write(int code, boolean arg1, int arg2, int arg3, int arg4) {}
26+
}

common/src/main/java/org/conscrypt/ConscryptEngineSocket.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ public void onHandshakeFinished() {
142142
// references to the given ConscryptEngineSocket. Our internal engine will call
143143
// the SSLEngine-receiving methods, but our callers expect the SSLSocket-receiving
144144
// methods to get called.
145+
@SuppressWarnings("CustomX509TrustManager")
145146
private static X509TrustManager getDelegatingTrustManager(final X509TrustManager delegate,
146147
final ConscryptEngineSocket socket) {
147148
if (delegate instanceof X509ExtendedTrustManager) {

fix_format.py

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#!/usr/bin/env python3
2+
import shutil
3+
import subprocess
4+
import sys
5+
from pathlib import Path
6+
from typing import List, FrozenSet
7+
8+
CLANG_FORMAT_BIN: str = "clang-format"
9+
PROJECT_PREFIX: str = "//depot/google3/third_party/java_src/conscrypt/"
10+
VALID_EXTENSIONS: FrozenSet[str] = frozenset({".java", ".cc", ".h", ".cpp", ".c"})
11+
12+
def get_g4_output() -> str:
13+
"""Runs g4 opened and returns the stdout."""
14+
try:
15+
return subprocess.check_output(["g4", "opened"], text=True)
16+
except subprocess.CalledProcessError as e:
17+
sys.exit(f"ERROR: Failed to run 'g4 opened'.\nDetails: {e}")
18+
19+
def parse_files(g4_output: str, project_prefix: str, root_dir: Path) -> List[str]:
20+
"""Parses g4 output and returns a list of absolute file paths to format."""
21+
files_to_format: List[str] = []
22+
23+
for line in g4_output.splitlines():
24+
line = line.strip()
25+
if not line:
26+
continue
27+
28+
depot_path = line.split('#')[0]
29+
30+
if not depot_path.endswith(tuple(VALID_EXTENSIONS)):
31+
continue
32+
33+
if not depot_path.startswith(project_prefix):
34+
continue
35+
36+
relative_path = depot_path[len(project_prefix):]
37+
38+
abs_path = root_dir / relative_path
39+
files_to_format.append(str(abs_path))
40+
41+
return files_to_format
42+
43+
def main() -> None:
44+
script_dir = Path(__file__).resolve().parent
45+
config_path = script_dir / ".clang-format"
46+
47+
try:
48+
if not config_path.is_file():
49+
raise FileNotFoundError(f"Config file missing at {config_path}")
50+
except OSError as e:
51+
sys.exit(f"ERROR: Could not access config file.\nDetails: {e}")
52+
53+
if not shutil.which(CLANG_FORMAT_BIN):
54+
sys.exit(f"ERROR: '{CLANG_FORMAT_BIN}' not found in PATH.")
55+
56+
print("Querying opened files...")
57+
g4_output = get_g4_output()
58+
files_to_format = parse_files(g4_output, PROJECT_PREFIX, script_dir)
59+
60+
if not files_to_format:
61+
print(f"No source files under {PROJECT_PREFIX} are currently open.")
62+
sys.exit(0)
63+
64+
print(f"Formatting {len(files_to_format)} file(s) with config: {config_path}")
65+
66+
cmd = [
67+
CLANG_FORMAT_BIN,
68+
"-i",
69+
f"-style=file:{config_path}",
70+
] + files_to_format
71+
72+
try:
73+
subprocess.run(cmd, check=True)
74+
print("Done.")
75+
except subprocess.CalledProcessError as e:
76+
sys.exit(f"ERROR: clang-format failed.\nDetails: {e}")
77+
78+
if __name__ == "__main__":
79+
main()

platform/src/main/java/org/conscrypt/AndroidHpkeSpi.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ public AndroidHpkeSpi(org.conscrypt.HpkeSpi delegate) {
3737
}
3838

3939
@Override
40-
public void engineInitSender(PublicKey recipientKey, @Nullable byte[] info,
41-
PrivateKey senderKey, @Nullable byte[] psk,
42-
@Nullable byte[] psk_id) throws InvalidKeyException {
40+
public void engineInitSender(PublicKey recipientKey, byte @Nullable[] info,
41+
PrivateKey senderKey, byte @Nullable[] psk,
42+
byte @Nullable[] psk_id) throws InvalidKeyException {
4343
delegate.engineInitSender(recipientKey, info, senderKey, psk, psk_id);
4444
}
4545

@@ -51,39 +51,39 @@ public void engineInitSenderForTesting(PublicKey recipientKey, byte[] info,
5151
}
5252

5353
@Override
54-
public void engineInitSenderWithSeed(PublicKey recipientKey, @Nullable byte[] info,
55-
PrivateKey senderKey, @Nullable byte[] psk,
56-
@Nullable byte[] psk_id, @NonNull byte[] sKe)
54+
public void engineInitSenderWithSeed(PublicKey recipientKey, byte @Nullable[] info,
55+
PrivateKey senderKey, byte @Nullable[] psk,
56+
byte @Nullable[] psk_id, byte @NonNull[] sKe)
5757
throws InvalidKeyException {
5858
delegate.engineInitSenderForTesting(recipientKey, info, senderKey, psk, psk_id, sKe);
5959
}
6060

6161
@Override
62-
public void engineInitRecipient(@NonNull byte[] encapsulated, PrivateKey recipientKey,
63-
@Nullable byte[] info, PublicKey senderKey,
64-
@Nullable byte[] psk, @Nullable byte[] psk_id)
62+
public void engineInitRecipient(byte @NonNull[] encapsulated, PrivateKey recipientKey,
63+
byte @Nullable[] info, PublicKey senderKey,
64+
byte @Nullable[] psk, byte @Nullable[] psk_id)
6565
throws InvalidKeyException {
6666
delegate.engineInitRecipient(encapsulated, recipientKey, info, senderKey, psk, psk_id);
6767
}
6868

6969
@Override
70-
public @NonNull byte[] engineSeal(@NonNull byte[] plaintext, @Nullable byte[] aad) {
70+
public byte @NonNull[] engineSeal(byte @NonNull[] plaintext, byte @Nullable[] aad) {
7171
return delegate.engineSeal(plaintext, aad);
7272
}
7373

7474
@Override
75-
public @NonNull byte[] engineOpen(@NonNull byte[] ciphertext, @Nullable byte[] aad)
75+
public byte @NonNull[] engineOpen(byte @NonNull[] ciphertext, byte @Nullable[] aad)
7676
throws GeneralSecurityException {
7777
return delegate.engineOpen(ciphertext, aad);
7878
}
7979

8080
@Override
81-
public @NonNull byte[] engineExport(int length, @Nullable byte[] context) {
81+
public byte @NonNull[] engineExport(int length, byte @Nullable[] context) {
8282
return delegate.engineExport(length, context);
8383
}
8484

8585
@Override
86-
public @NonNull byte[] getEncapsulated() {
86+
public byte @NonNull[] getEncapsulated() {
8787
return delegate.getEncapsulated();
8888
}
8989

0 commit comments

Comments
 (0)