Skip to content

Commit

Permalink
Add Spake parameter plumbing to Conscrypt
Browse files Browse the repository at this point in the history
This cl:
- Adds Key/TrustManagerFactories and Key/TrustManagers for Spake
- Modifies OpenSSLParameters to accept Spake
- Adds Spake setup within NativeSSL
- Includes miscellaneous changes to make the above work
- Adds tests for the above.

TEST=atest SSLSocketTest/SpakeManagerFactoriesTest/SpakeKeyManagerParametersTest
BUG=382233100

Change-Id: I5203a651fa74fe90cabd234bc2b1a94cfc9d3e88
  • Loading branch information
miguelaranda0 committed Jan 16, 2025
1 parent 310dabb commit cd3da0c
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,27 @@ public final class PakeClientKeyManagerParameters implements ManagerFactoryParam
*
* @return The client identifier.
*/
public @Nullable byte[] getClientId();
public @Nullable byte[] getClientId() {
throw new RuntimeException("Stub!");
}

/**
* Returns the server identifier.
*
* @return The server identifier.
*/
public @Nullable byte[] getServerId();
public @Nullable byte[] getServerId() {
throw new RuntimeException("Stub!");
}

/**
* Returns a copy of the list of available PAKE options.
*
* @return A copy of the list of available PAKE options.
*/
public @NonNull List<PakeOption> getOptions();
public @NonNull List<PakeOption> getOptions() {
throw new RuntimeException("Stub!");
}

/**
* A builder for creating {@link PakeClientKeyManagerParameters} instances.
Expand All @@ -75,15 +81,19 @@ public static final class Builder {
* @param clientId The ID of the client involved in the PAKE exchange.
* @return This builder.
*/
public @NonNull Builder setClientId(@Nullable byte[] clientId);
public @NonNull Builder setClientId(@Nullable byte[] clientId) {
throw new RuntimeException("Stub!");
}

/**
* Sets the ID of the server involved in the PAKE exchange.
*
* @param serverId The ID of the server involved in the PAKE exchange.
* @return This builder.
*/
public @NonNull Builder setServerId(@Nullable byte[] serverId);
public @NonNull Builder setServerId(@Nullable byte[] serverId) {
throw new RuntimeException("Stub!");
}

/**
* Adds a PAKE option.
Expand All @@ -92,14 +102,18 @@ public static final class Builder {
* @return This builder.
* @throws InvalidParameterException If an option with the same algorithm already exists.
*/
public @NonNull Builder addOption(@NonNull PakeOption option);
public @NonNull Builder addOption(@NonNull PakeOption option) {
throw new RuntimeException("Stub!");
}

/**
* Builds a new {@link PakeClientKeyManagerParameters} instance.
*
* @return A new {@link PakeClientKeyManagerParameters} instance.
* @throws InvalidParameterException If no PAKE options are provided.
*/
public @NonNull PakeClientKeyManagerParameters build();
public @NonNull PakeClientKeyManagerParameters build() {
throw new RuntimeException("Stub!");
}
}
}
20 changes: 15 additions & 5 deletions android-stub/src/main/java/android/pake/PakeOption.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ public final class PakeOption {
*
* @return The algorithm of the PAKE algorithm.
*/
public @NonNull String getAlgorithm();
public @NonNull String getAlgorithm() {
throw new RuntimeException("Stub!");
}

/**
* Returns the message component with the given key.
Expand All @@ -48,7 +50,9 @@ public final class PakeOption {
* @return The component data, or {@code null} if no component with the given
* key exists.
*/
public @Nullable byte[] getMessageComponent(@NonNull String key);
public @Nullable byte[] getMessageComponent(@NonNull String key) {
throw new RuntimeException("Stub!");
}

/**
* A builder for creating {@link PakeOption} instances.
Expand All @@ -62,7 +66,9 @@ public static final class Builder {
* @param algorithm The algorithm of the PAKE algorithm.
* @throws InvalidParameterException If the algorithm is invalid.
*/
public Builder(@NonNull String algorithm);
public Builder(@NonNull String algorithm) {
throw new RuntimeException("Stub!");
}

/**
* Adds a message component.
Expand All @@ -72,7 +78,9 @@ public static final class Builder {
* @return This builder.
* @throws InvalidParameterException If the key is invalid.
*/
public @NonNull Builder addMessageComponent(@NonNull String key, @Nullable byte[] value);
public @NonNull Builder addMessageComponent(@NonNull String key, @Nullable byte[] value) {
throw new RuntimeException("Stub!");
}

/**
* Builds a new {@link PakeOption} instance.
Expand All @@ -83,6 +91,8 @@ public static final class Builder {
* @return A new {@link PakeOption} instance.
* @throws InvalidParameterException If the message components are invalid.
*/
public @NonNull PakeOption build();
public @NonNull PakeOption build() {
throw new RuntimeException("Stub!");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ public final class PakeServerKeyManagerParameters implements ManagerFactoryParam
*
* @return The known links.
*/
public @NonNull Set<Link> getLinks();
public @NonNull Set<Link> getLinks() {
throw new RuntimeException("Stub!");
}

/**
* Returns an unmodifiable list of PAKE options for the given {@link Link}.
Expand All @@ -59,7 +61,9 @@ public final class PakeServerKeyManagerParameters implements ManagerFactoryParam
* {@link #getLinks}.
* @return An unmodifiable list of PAKE options for the given link.
*/
public @NonNull List<PakeOption> getOptions(@NonNull Link link);
public @NonNull List<PakeOption> getOptions(@NonNull Link link) {
throw new RuntimeException("Stub!");
}

/**
* Returns an unmodifiable list of PAKE options for the given client-server pair.
Expand All @@ -69,7 +73,9 @@ public final class PakeServerKeyManagerParameters implements ManagerFactoryParam
* @return An unmodifiable list of PAKE options for the given link.
*/
public @NonNull List<PakeOption> getOptions(
@Nullable byte[] clientId, @Nullable byte[] serverId);
@Nullable byte[] clientId, @Nullable byte[] serverId) {
throw new RuntimeException("Stub!");
}

/**
* A PAKE link class combining the client and server IDs.
Expand All @@ -83,25 +89,37 @@ public static final class Link {
* @param clientId The client identifier for the link.
* @param serverId The server identifier for the link.
*/
private Link(@Nullable byte[] clientId, @Nullable byte[] serverId);
private Link(@Nullable byte[] clientId, @Nullable byte[] serverId) {
throw new RuntimeException("Stub!");
}

/**
* Returns the client identifier for the link.
*
* @return The client identifier for the link.
*/
public @Nullable byte[] getClientId();
public @Nullable byte[] getClientId() {
throw new RuntimeException("Stub!");
}

/**
* Returns the server identifier for the link.
*
* @return The server identifier for the link.
*/
public @Nullable byte[] getServerId();
public @Nullable byte[] getServerId() {
throw new RuntimeException("Stub!");
}

@Override public boolean equals(Object o);
@Override
public boolean equals(Object o) {
throw new RuntimeException("Stub!");
}

@Override public int hashCode();
@Override
public int hashCode() {
throw new RuntimeException("Stub!");
}
}

/**
Expand All @@ -121,14 +139,18 @@ public static final class Builder {
* @throws InvalidParameterException If the provided options are invalid.
*/
public @NonNull Builder setOptions(@Nullable byte[] clientId, @Nullable byte[] serverId,
@NonNull List<PakeOption> options);
@NonNull List<PakeOption> options) {
throw new RuntimeException("Stub!");
}

/**
* Builds a new {@link PakeServerKeyManagerParameters} instance.
*
* @return A new {@link PakeServerKeyManagerParameters} instance.
* @throws InvalidParameterException If no links are provided.
*/
public @NonNull PakeServerKeyManagerParameters build();
public @NonNull PakeServerKeyManagerParameters build() {
throw new RuntimeException("Stub!");
}
}
}

0 comments on commit cd3da0c

Please sign in to comment.