1 /*
2 * Copyright 2022 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 #include "verify_native.h"
18
19 #include <compos_key.h>
20
21 using rust::Slice;
22
verify(Slice<const uint8_t> public_key,Slice<const uint8_t> signature,Slice<const uint8_t> data)23 bool verify(Slice<const uint8_t> public_key, Slice<const uint8_t> signature,
24 Slice<const uint8_t> data) {
25 compos_key::PublicKey public_key_array;
26 compos_key::Signature signature_array;
27
28 if (public_key.size() != public_key_array.size() ||
29 signature.size() != signature_array.size()) {
30 return false;
31 }
32
33 std::copy(public_key.begin(), public_key.end(), public_key_array.begin());
34 std::copy(signature.begin(), signature.end(), signature_array.begin());
35
36 return compos_key::verify(public_key_array, signature_array, data.data(), data.size());
37 }
38