1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 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 * http://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 16 #ifndef HKS_OPENSSL_ED25519TOX25519_H 17 #define HKS_OPENSSL_ED25519TOX25519_H 18 19 #include <openssl/ossl_typ.h> 20 #include <stdint.h> 21 22 #include "hks_type.h" 23 24 struct Curve25519Structure { 25 BIGNUM *p; // Curve25519 prime 26 BIGNUM *d; // A non-zero element in the finite filed 27 BIGNUM *negativeTwo; 28 BIGNUM *negativeOne; 29 BIGNUM *negativeOneDivideTwo; 30 BIGNUM *ed25519Pubkey; 31 }; 32 struct Curve25519Var { 33 BIGNUM *a; 34 BIGNUM *b; 35 BIGNUM *c; 36 }; 37 38 #ifdef __cplusplus 39 extern "C" { 40 #endif 41 42 int32_t ConvertPubkeyX25519FromED25519(const struct HksBlob *keyIn, struct HksBlob *keyOut); 43 44 int32_t ConvertPrivX25519FromED25519(const struct HksBlob *keyIn, struct HksBlob *keyOut); 45 46 #ifdef __cplusplus 47 } 48 #endif 49 50 #endif /* HKS_OPENSSL_ED25519TOX25519_H */ 51