• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2010-2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
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  * A copy of the License is located at
7  *
8  *  http://aws.amazon.com/apache2.0
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 package software.amazon.awssdk.crt.auth.signing;
16 
17 import software.amazon.awssdk.crt.http.HttpRequest;
18 
19 /**
20  * Internal utility/testing functions for verifying sigv4a signatures.
21  */
22 public class AwsSigningUtils {
23 
verifySigv4aEcdsaSignature(HttpRequest request, String expectedCanonicalRequest, AwsSigningConfig config, byte[] hexEncodedSignature, String verifierPubX, String verifierPubY)24     public static boolean verifySigv4aEcdsaSignature(HttpRequest request, String expectedCanonicalRequest, AwsSigningConfig config, byte[] hexEncodedSignature, String verifierPubX, String verifierPubY) {
25         return awsSigningUtilsVerifyEcdsaSignature(request, request.marshalForJni(), expectedCanonicalRequest, config, hexEncodedSignature, verifierPubX, verifierPubY);
26     }
27 
verifyRawSha256EcdsaSignature(byte[] stringToSign, byte[] hexEncodedSignature, String verifierPubX, String verifierPubY)28     public static boolean verifyRawSha256EcdsaSignature(byte[] stringToSign, byte[] hexEncodedSignature, String verifierPubX, String verifierPubY) {
29         return awsSigningUtilsVerifyRawSha256EcdsaSignature(stringToSign, hexEncodedSignature, verifierPubX, verifierPubY);
30     }
31 
32     /*******************************************************************************
33      * native methods
34      ******************************************************************************/
awsSigningUtilsVerifyEcdsaSignature( HttpRequest request, byte[] marshalledRequest, String expectedCanonicalRequest, AwsSigningConfig config, byte[] hexEncodedSignature, String verifierPubX, String verifiedPubY)35     private static native boolean awsSigningUtilsVerifyEcdsaSignature(
36             HttpRequest request,
37             byte[] marshalledRequest,
38             String expectedCanonicalRequest,
39             AwsSigningConfig config,
40             byte[] hexEncodedSignature,
41             String verifierPubX,
42             String verifiedPubY);
43 
awsSigningUtilsVerifyRawSha256EcdsaSignature( byte[] stringToSign, byte[] hexEncodedSignature, String verifierPubX, String verifiedPubY)44     private static native boolean awsSigningUtilsVerifyRawSha256EcdsaSignature(
45             byte[] stringToSign,
46             byte[] hexEncodedSignature,
47             String verifierPubX,
48             String verifiedPubY);
49 }
50