compiler: build separation runtime with clite
This commit is contained in:
5
runtime/internal/clite/openssl/_wrap/openssl.c
Normal file
5
runtime/internal/clite/openssl/_wrap/openssl.c
Normal file
@@ -0,0 +1,5 @@
|
||||
#include <openssl/crypto.h>
|
||||
|
||||
void opensslFree(void *ptr) {
|
||||
OPENSSL_free(ptr);
|
||||
}
|
||||
61
runtime/internal/clite/openssl/bio.go
Normal file
61
runtime/internal/clite/openssl/bio.go
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 2024 The GoPlus Authors (goplus.org). All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package openssl
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
c "github.com/goplus/llgo/runtime/internal/clite"
|
||||
)
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
type BIO struct {
|
||||
Unused [0]byte
|
||||
}
|
||||
|
||||
// BIO *BIO_new_mem_buf(const void *buf, int len);
|
||||
//
|
||||
//go:linkname BIONewMemBuf C.BIO_new_mem_buf
|
||||
func BIONewMemBuf(buf unsafe.Pointer, len c.Int) *BIO
|
||||
|
||||
// int BIO_free(BIO *a);
|
||||
//
|
||||
// llgo:link (*BIO).Free C.BIO_free
|
||||
func (*BIO) Free() c.Int { return 0 }
|
||||
|
||||
// int BIO_up_ref(BIO *a);
|
||||
//
|
||||
// llgo:link (*BIO).UpRef C.BIO_up_ref
|
||||
func (*BIO) UpRef() c.Int { return 0 }
|
||||
|
||||
// int BIO_read_ex(BIO *b, void *data, size_t dlen, size_t *readbytes);
|
||||
//
|
||||
// llgo:link (*BIO).ReadEx C.BIO_read_ex
|
||||
func (*BIO) ReadEx(data unsafe.Pointer, dlen uintptr, readbytes *uintptr) c.Int { return 0 }
|
||||
|
||||
// int BIO_write(BIO *b, const void *data, int dlen);
|
||||
//
|
||||
// llgo:link (*BIO).Write C.BIO_write
|
||||
func (*BIO) Write(data unsafe.Pointer, dlen c.Int) c.Int { return 0 }
|
||||
|
||||
// int BIO_write_ex(BIO *b, const void *data, size_t dlen, size_t *written);
|
||||
//
|
||||
// llgo:link (*BIO).WriteEx C.BIO_write_ex
|
||||
func (*BIO) WriteEx(data unsafe.Pointer, dlen uintptr, written *uintptr) c.Int { return 0 }
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
409
runtime/internal/clite/openssl/bn.go
Normal file
409
runtime/internal/clite/openssl/bn.go
Normal file
@@ -0,0 +1,409 @@
|
||||
/*
|
||||
* Copyright (c) 2024 The GoPlus Authors (goplus.org). All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package openssl
|
||||
|
||||
import (
|
||||
_ "unsafe"
|
||||
|
||||
c "github.com/goplus/llgo/runtime/internal/clite"
|
||||
)
|
||||
|
||||
type BN_ULONG = uint64
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
type BN_CTX struct {
|
||||
Unused [0]byte
|
||||
}
|
||||
|
||||
// BN_CTX *BN_CTX_new(void);
|
||||
//
|
||||
//go:linkname BN_CTXNew C.BN_CTX_new
|
||||
func BN_CTXNew() *BN_CTX
|
||||
|
||||
// BN_CTX *BN_CTX_secure_new(void);
|
||||
//
|
||||
//go:linkname BN_CTXSecureNew C.BN_CTX_secure_new
|
||||
func BN_CTXSecureNew() *BN_CTX
|
||||
|
||||
// BN_CTX *BN_CTX_new_ex(OSSL_LIB_CTX *ctx);
|
||||
// BN_CTX *BN_CTX_secure_new_ex(OSSL_LIB_CTX *ctx);
|
||||
|
||||
// void BN_CTX_free(BN_CTX *c);
|
||||
//
|
||||
// llgo:link (*BN_CTX).Free C.BN_CTX_free
|
||||
func (*BN_CTX) Free() {}
|
||||
|
||||
// void BN_CTX_start(BN_CTX *ctx);
|
||||
//
|
||||
// llgo:link (*BN_CTX).Start C.BN_CTX_start
|
||||
func (*BN_CTX) Start() {}
|
||||
|
||||
// BIGNUM *BN_CTX_get(BN_CTX *ctx);
|
||||
//
|
||||
// llgo:link (*BN_CTX).Get C.BN_CTX_get
|
||||
func (*BN_CTX) Get() *BIGNUM { return nil }
|
||||
|
||||
// void BN_CTX_end(BN_CTX *ctx);
|
||||
//
|
||||
// llgo:link (*BN_CTX).End C.BN_CTX_end
|
||||
func (*BN_CTX) End() {}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
type BIGNUM struct {
|
||||
Unused [0]byte
|
||||
}
|
||||
|
||||
// BIGNUM *BN_new(void);
|
||||
//
|
||||
//go:linkname BNNew C.BN_new
|
||||
func BNNew() *BIGNUM
|
||||
|
||||
// BIGNUM *BN_secure_new(void);
|
||||
//
|
||||
//go:linkname BNSecureNew C.BN_secure_new
|
||||
func BNSecureNew() *BIGNUM
|
||||
|
||||
// void BN_free(BIGNUM *a);
|
||||
//
|
||||
// llgo:link (*BIGNUM).Free C.BN_free
|
||||
func (*BIGNUM) Free() {}
|
||||
|
||||
// void BN_clear_free(BIGNUM *a);
|
||||
//
|
||||
// llgo:link (*BIGNUM).ClearFree C.BN_clear_free
|
||||
func (*BIGNUM) ClearFree() {}
|
||||
|
||||
// void BN_clear(BIGNUM *a);
|
||||
//
|
||||
// llgo:link (*BIGNUM).Clear C.BN_clear
|
||||
func (*BIGNUM) Clear() {}
|
||||
|
||||
// BIGNUM *BN_dup(const BIGNUM *a);
|
||||
//
|
||||
// llgo:link (*BIGNUM).Dup C.BN_dup
|
||||
func (*BIGNUM) Dup() *BIGNUM { return nil }
|
||||
|
||||
// BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b);
|
||||
//
|
||||
// llgo:link (*BIGNUM).Copy C.BN_copy
|
||||
func (*BIGNUM) Copy(b *BIGNUM) *BIGNUM { return nil }
|
||||
|
||||
// void BN_swap(BIGNUM *a, BIGNUM *b);
|
||||
//
|
||||
// llgo:link (*BIGNUM).Swap C.BN_swap
|
||||
func (*BIGNUM) Swap(b *BIGNUM) {}
|
||||
|
||||
// int BN_is_zero(const BIGNUM *a);
|
||||
//
|
||||
// llgo:link (*BIGNUM).IsZero C.BN_is_zero
|
||||
func (*BIGNUM) IsZero() c.Int { return 0 }
|
||||
|
||||
// void BN_zero_ex(BIGNUM *a);
|
||||
//
|
||||
// llgo:link (*BIGNUM).SetZero C.BN_zero_ex
|
||||
func (*BIGNUM) SetZero() {}
|
||||
|
||||
// int BN_is_one(const BIGNUM *a);
|
||||
//
|
||||
// llgo:link (*BIGNUM).IsOne C.BN_is_one
|
||||
func (*BIGNUM) IsOne() c.Int { return 0 }
|
||||
|
||||
// int BN_is_odd(const BIGNUM *a);
|
||||
//
|
||||
// llgo:link (*BIGNUM).IsOdd C.BN_is_odd
|
||||
func (*BIGNUM) IsOdd() c.Int { return 0 }
|
||||
|
||||
// int BN_abs_is_word(const BIGNUM *a, const BN_ULONG w);
|
||||
//
|
||||
// llgo:link (*BIGNUM).AbsIsWord C.BN_abs_is_word
|
||||
func (*BIGNUM) AbsIsWord(w BN_ULONG) c.Int { return 0 }
|
||||
|
||||
// int BN_is_word(const BIGNUM *a, const BN_ULONG w);
|
||||
//
|
||||
// llgo:link (*BIGNUM).IsWord C.BN_is_word
|
||||
func (*BIGNUM) IsWord(w BN_ULONG) c.Int { return 0 }
|
||||
|
||||
// int BN_set_word(BIGNUM *a, BN_ULONG w);
|
||||
//
|
||||
// llgo:link (*BIGNUM).SetWord C.BN_set_word
|
||||
func (*BIGNUM) SetWord(w BN_ULONG) c.Int { return 0 }
|
||||
|
||||
// BN_ULONG BN_get_word(const BIGNUM *a);
|
||||
//
|
||||
// llgo:link (*BIGNUM).GetWord C.BN_get_word
|
||||
func (*BIGNUM) GetWord() BN_ULONG { return 0 }
|
||||
|
||||
// BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w);
|
||||
//
|
||||
// llgo:link (*BIGNUM).ModWord C.BN_mod_word
|
||||
func (*BIGNUM) ModWord(w BN_ULONG) BN_ULONG { return 0 }
|
||||
|
||||
// BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w);
|
||||
//
|
||||
// llgo:link (*BIGNUM).DivWord C.BN_div_word
|
||||
func (*BIGNUM) DivWord(w BN_ULONG) BN_ULONG { return 0 }
|
||||
|
||||
// int BN_mul_word(BIGNUM *a, BN_ULONG w);
|
||||
//
|
||||
// llgo:link (*BIGNUM).MulWord C.BN_mul_word
|
||||
func (*BIGNUM) MulWord(w BN_ULONG) c.Int { return 0 }
|
||||
|
||||
// int BN_add_word(BIGNUM *a, BN_ULONG w);
|
||||
//
|
||||
// llgo:link (*BIGNUM).AddWord C.BN_add_word
|
||||
func (*BIGNUM) AddWord(w BN_ULONG) c.Int { return 0 }
|
||||
|
||||
// int BN_sub_word(BIGNUM *a, BN_ULONG w);
|
||||
//
|
||||
// llgo:link (*BIGNUM).SubWord C.BN_sub_word
|
||||
func (*BIGNUM) SubWord(w BN_ULONG) c.Int { return 0 }
|
||||
|
||||
// char *BN_bn2hex(const BIGNUM *a);
|
||||
//
|
||||
// llgo:link (*BIGNUM).Bn2hex C.BN_bn2hex
|
||||
func (*BIGNUM) Bn2hex() *c.Char { return nil }
|
||||
|
||||
// char *BN_bn2dec(const BIGNUM *a);
|
||||
//
|
||||
// llgo:link (*BIGNUM).Bn2dec C.BN_bn2dec
|
||||
func (*BIGNUM) Bn2dec() *c.Char { return nil }
|
||||
|
||||
// llgo:link (*BIGNUM).CStr C.BN_bn2dec
|
||||
func (*BIGNUM) CStr() *c.Char { return nil }
|
||||
|
||||
// int BN_hex2bn(BIGNUM **a, const char *str);
|
||||
//
|
||||
//go:linkname BNHex2bn C.BN_hex2bn
|
||||
func BNHex2bn(a **BIGNUM, str *c.Char) c.Int
|
||||
|
||||
// int BN_dec2bn(BIGNUM **a, const char *str);
|
||||
//
|
||||
//go:linkname BNDec2bn C.BN_dec2bn
|
||||
func BNDec2bn(a **BIGNUM, str *c.Char) c.Int
|
||||
|
||||
// int BN_asc2bn(BIGNUM **a, const char *str);
|
||||
//
|
||||
//go:linkname BNAsc2bn C.BN_asc2bn
|
||||
func BNAsc2bn(a **BIGNUM, str *c.Char) c.Int
|
||||
|
||||
// BIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret);
|
||||
//
|
||||
//go:linkname BNBin2bn C.BN_bin2bn
|
||||
func BNBin2bn(s *byte, len c.Int, ret *BIGNUM) *BIGNUM
|
||||
|
||||
// BIGNUM *BN_signed_bin2bn(const unsigned char *s, int len, BIGNUM *ret);
|
||||
//
|
||||
//go:linkname BNSignedBin2bn C.BN_signed_bin2bn
|
||||
func BNSignedBin2bn(s *byte, len c.Int, ret *BIGNUM) *BIGNUM
|
||||
|
||||
// int BN_bn2bin(const BIGNUM *a, unsigned char *to);
|
||||
//
|
||||
// llgo:link (*BIGNUM).Bn2bin C.BN_bn2bin
|
||||
func (bn *BIGNUM) Bn2bin(to *byte) c.Int { return 0 }
|
||||
|
||||
// int BN_bn2binpad(const BIGNUM *a, unsigned char *to, int tolen);
|
||||
//
|
||||
// llgo:link (*BIGNUM).Bn2binpad C.BN_bn2binpad
|
||||
func (bn *BIGNUM) Bn2binpad(to *byte, tolen c.Int) c.Int { return 0 }
|
||||
|
||||
// int BN_signed_bn2bin(const BIGNUM *a, unsigned char *to, int tolen);
|
||||
//
|
||||
// llgo:link (*BIGNUM).SignedBn2bin C.BN_signed_bn2bin
|
||||
func (bn *BIGNUM) SignedBn2bin(to *byte, tolen c.Int) c.Int { return 0 }
|
||||
|
||||
// BIGNUM *BN_lebin2bn(const unsigned char *s, int len, BIGNUM *ret);
|
||||
//
|
||||
//go:linkname BNLebin2bn C.BN_lebin2bn
|
||||
func BNLebin2bn(s *byte, len c.Int, ret *BIGNUM) *BIGNUM
|
||||
|
||||
// BIGNUM *BN_signed_lebin2bn(const unsigned char *s, int len, BIGNUM *ret);
|
||||
//
|
||||
//go:linkname BNSignedLebin2bn C.BN_signed_lebin2bn
|
||||
func BNSignedLebin2bn(s *byte, len c.Int, ret *BIGNUM) *BIGNUM
|
||||
|
||||
// int BN_bn2lebinpad(const BIGNUM *a, unsigned char *to, int tolen);
|
||||
//
|
||||
// llgo:link (*BIGNUM).Bn2lebinpad C.BN_bn2lebinpad
|
||||
func (bn *BIGNUM) Bn2lebinpad(to *byte, tolen c.Int) c.Int { return 0 }
|
||||
|
||||
// int BN_signed_bn2lebin(const BIGNUM *a, unsigned char *to, int tolen);
|
||||
//
|
||||
// llgo:link (*BIGNUM).SignedBn2lebin C.BN_signed_bn2lebin
|
||||
func (bn *BIGNUM) SignedBn2lebin(to *byte, tolen c.Int) c.Int { return 0 }
|
||||
|
||||
// BIGNUM *BN_native2bn(const unsigned char *s, int len, BIGNUM *ret);
|
||||
//
|
||||
//go:linkname BNNative2bn C.BN_native2bn
|
||||
func BNNative2bn(s *byte, len c.Int, ret *BIGNUM) *BIGNUM
|
||||
|
||||
// BIGNUM *BN_signed_native2bn(const unsigned char *s, int len, BIGNUM *ret);
|
||||
//
|
||||
//go:linkname BNSignedNative2bn C.BN_signed_native2bn
|
||||
func BNSignedNative2bn(s *byte, len c.Int, ret *BIGNUM) *BIGNUM
|
||||
|
||||
// int BN_bn2nativepad(const BIGNUM *a, unsigned char *to, int tolen);
|
||||
//
|
||||
// llgo:link (*BIGNUM).Bn2nativepad C.BN_bn2nativepad
|
||||
func (bn *BIGNUM) Bn2nativepad(to *byte, tolen c.Int) c.Int { return 0 }
|
||||
|
||||
// int BN_signed_bn2native(const BIGNUM *a, unsigned char *to, int tolen);
|
||||
//
|
||||
// llgo:link (*BIGNUM).SignedBn2native C.BN_signed_bn2native
|
||||
func (bn *BIGNUM) SignedBn2native(to *byte, tolen c.Int) c.Int { return 0 }
|
||||
|
||||
// BIGNUM *BN_mpi2bn(const unsigned char *s, int len, BIGNUM *ret);
|
||||
//
|
||||
//go:linkname BNMpi2bn C.BN_mpi2bn
|
||||
func BNMpi2bn(s *byte, len c.Int, ret *BIGNUM) *BIGNUM
|
||||
|
||||
// int BN_bn2mpi(const BIGNUM *a, unsigned char *to);
|
||||
//
|
||||
// llgo:link (*BIGNUM).Bn2mpi C.BN_bn2mpi
|
||||
func (bn *BIGNUM) Bn2mpi(to *byte) c.Int { return 0 }
|
||||
|
||||
// int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
|
||||
//
|
||||
// llgo:link (*BIGNUM).Sub C.BN_sub
|
||||
func (*BIGNUM) Sub(a, b *BIGNUM) c.Int { return 0 }
|
||||
|
||||
// int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
|
||||
//
|
||||
// llgo:link (*BIGNUM).Add C.BN_add
|
||||
func (*BIGNUM) Add(a, b *BIGNUM) c.Int { return 0 }
|
||||
|
||||
// int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
|
||||
//
|
||||
// llgo:link (*BIGNUM).Usub C.BN_usub
|
||||
func (*BIGNUM) Usub(a, b *BIGNUM) c.Int { return 0 }
|
||||
|
||||
// int BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
|
||||
//
|
||||
// llgo:link (*BIGNUM).Uadd C.BN_uadd
|
||||
func (*BIGNUM) Uadd(a, b *BIGNUM) c.Int { return 0 }
|
||||
|
||||
// int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
|
||||
//
|
||||
// llgo:link (*BIGNUM).Mul C.BN_mul
|
||||
func (*BIGNUM) Mul(r, a, b *BIGNUM, ctx *BN_CTX) c.Int { return 0 }
|
||||
|
||||
// int BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx);
|
||||
//
|
||||
// llgo:link (*BIGNUM).Sqr C.BN_sqr
|
||||
func (*BIGNUM) Sqr(r, a *BIGNUM, ctx *BN_CTX) c.Int { return 0 }
|
||||
|
||||
/** BN_set_negative sets sign of a BIGNUM
|
||||
* \param b pointer to the BIGNUM object
|
||||
* \param n 0 if the BIGNUM b should be positive and a value != 0 otherwise
|
||||
*/
|
||||
// void BN_set_negative(BIGNUM *b, int n);
|
||||
//
|
||||
// llgo:link (*BIGNUM).SetNegative C.BN_set_negative
|
||||
func (*BIGNUM) SetNegative(n c.Int) {}
|
||||
|
||||
/** BN_is_negative returns 1 if the BIGNUM is negative
|
||||
* \param b pointer to the BIGNUM object
|
||||
* \return 1 if a < 0 and 0 otherwise
|
||||
*/
|
||||
// int BN_is_negative(const BIGNUM *b);
|
||||
//
|
||||
// llgo:link (*BIGNUM).IsNegative C.BN_is_negative
|
||||
func (*BIGNUM) IsNegative() c.Int { return 0 }
|
||||
|
||||
// int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx);
|
||||
//
|
||||
// llgo:link (*BIGNUM).Div C.BN_div
|
||||
func (*BIGNUM) Div(rem, m, d *BIGNUM, ctx *BN_CTX) c.Int { return 0 }
|
||||
|
||||
// int BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx);
|
||||
//
|
||||
// llgo:link (*BIGNUM).Nnmod C.BN_nnmod
|
||||
func (*BIGNUM) Nnmod(r, m, d *BIGNUM, ctx *BN_CTX) c.Int { return 0 }
|
||||
|
||||
// int BN_cmp(const BIGNUM *a, const BIGNUM *b);
|
||||
//
|
||||
// llgo:link (*BIGNUM).Cmp C.BN_cmp
|
||||
func (*BIGNUM) Cmp(b *BIGNUM) c.Int { return 0 }
|
||||
|
||||
// int BN_ucmp(const BIGNUM *a, const BIGNUM *b);
|
||||
//
|
||||
// llgo:link (*BIGNUM).Ucmp C.BN_ucmp
|
||||
func (*BIGNUM) Ucmp(b *BIGNUM) c.Int { return 0 }
|
||||
|
||||
// int BN_is_bit_set(const BIGNUM *a, int n);
|
||||
//
|
||||
// llgo:link (*BIGNUM).IsBitSet C.BN_is_bit_set
|
||||
func (*BIGNUM) IsBitSet(n c.Int) c.Int { return 0 }
|
||||
|
||||
// int BN_set_bit(BIGNUM *a, int n);
|
||||
//
|
||||
// llgo:link (*BIGNUM).SetBit C.BN_set_bit
|
||||
func (*BIGNUM) SetBit(n c.Int) c.Int { return 0 }
|
||||
|
||||
// int BN_clear_bit(BIGNUM *a, int n);
|
||||
//
|
||||
// llgo:link (*BIGNUM).ClearBit C.BN_clear_bit
|
||||
func (*BIGNUM) ClearBit(n c.Int) c.Int { return 0 }
|
||||
|
||||
// int BN_lshift(BIGNUM *r, const BIGNUM *a, int n);
|
||||
//
|
||||
// llgo:link (*BIGNUM).Lshift C.BN_lshift
|
||||
func (*BIGNUM) Lshift(a *BIGNUM, n c.Int) c.Int { return 0 }
|
||||
|
||||
// int BN_lshift1(BIGNUM *r, const BIGNUM *a);
|
||||
//
|
||||
// llgo:link (*BIGNUM).Lshift1 C.BN_lshift1
|
||||
func (*BIGNUM) Lshift1(a *BIGNUM) c.Int { return 0 }
|
||||
|
||||
// int BN_rshift(BIGNUM *r, const BIGNUM *a, int n);
|
||||
//
|
||||
// llgo:link (*BIGNUM).Rshift C.BN_rshift
|
||||
func (*BIGNUM) Rshift(a *BIGNUM, n c.Int) c.Int { return 0 }
|
||||
|
||||
// int BN_rshift1(BIGNUM *r, const BIGNUM *a);
|
||||
//
|
||||
// llgo:link (*BIGNUM).Rshift1 C.BN_rshift1
|
||||
func (*BIGNUM) Rshift1(a *BIGNUM) c.Int { return 0 }
|
||||
|
||||
// int BN_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
|
||||
//
|
||||
// llgo:link (*BIGNUM).Exp C.BN_exp
|
||||
func (*BIGNUM) Exp(a, p *BIGNUM, ctx *BN_CTX) c.Int { return 0 }
|
||||
|
||||
// int BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx);
|
||||
//
|
||||
// llgo:link (*BIGNUM).ModExp C.BN_mod_exp
|
||||
func (*BIGNUM) ModExp(a, p, m *BIGNUM, ctx *BN_CTX) c.Int { return 0 }
|
||||
|
||||
// int BN_gcd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
|
||||
//
|
||||
// llgo:link (*BIGNUM).Gcd C.BN_gcd
|
||||
func (*BIGNUM) Gcd(a, b *BIGNUM, ctx *BN_CTX) c.Int { return 0 }
|
||||
|
||||
// int BN_are_coprime(const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
|
||||
//
|
||||
// llgo:link (*BIGNUM).AreCoprime C.BN_are_coprime
|
||||
func (*BIGNUM) AreCoprime(b *BIGNUM, ctx *BN_CTX) c.Int { return 0 }
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
type BN_GENCB struct {
|
||||
Unused [0]byte
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
156
runtime/internal/clite/openssl/err.go
Normal file
156
runtime/internal/clite/openssl/err.go
Normal file
@@ -0,0 +1,156 @@
|
||||
/*
|
||||
* Copyright (c) 2024 The GoPlus Authors (goplus.org). All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package openssl
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
c "github.com/goplus/llgo/runtime/internal/clite"
|
||||
)
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/*-
|
||||
* The error code packs differently depending on if it records a system
|
||||
* error or an OpenSSL error.
|
||||
*
|
||||
* A system error packs like this (we follow POSIX and only allow positive
|
||||
* numbers that fit in an |int|):
|
||||
*
|
||||
* +-+-------------------------------------------------------------+
|
||||
* |1| system error number |
|
||||
* +-+-------------------------------------------------------------+
|
||||
*
|
||||
* An OpenSSL error packs like this:
|
||||
*
|
||||
* <---------------------------- 32 bits -------------------------->
|
||||
* <--- 8 bits ---><------------------ 23 bits ----------------->
|
||||
* +-+---------------+---------------------------------------------+
|
||||
* |0| library | reason |
|
||||
* +-+---------------+---------------------------------------------+
|
||||
*
|
||||
* A few of the reason bits are reserved as flags with special meaning:
|
||||
*
|
||||
* <5 bits-<>--------- 19 bits ----------------->
|
||||
* +-------+-+-----------------------------------+
|
||||
* | rflags| | reason |
|
||||
* +-------+-+-----------------------------------+
|
||||
* ^
|
||||
* |
|
||||
* ERR_RFLAG_FATAL = ERR_R_FATAL
|
||||
*
|
||||
* The reason flags are part of the overall reason code for practical
|
||||
* reasons, as they provide an easy way to place different types of
|
||||
* reason codes in different numeric ranges.
|
||||
*
|
||||
* The currently known reason flags are:
|
||||
*
|
||||
* ERR_RFLAG_FATAL Flags that the reason code is considered fatal.
|
||||
* For backward compatibility reasons, this flag
|
||||
* is also the code for ERR_R_FATAL (that reason
|
||||
* code served the dual purpose of flag and reason
|
||||
* code in one in pre-3.0 OpenSSL).
|
||||
* ERR_RFLAG_COMMON Flags that the reason code is common to all
|
||||
* libraries. All ERR_R_ macros must use this flag,
|
||||
* and no other _R_ macro is allowed to use it.
|
||||
*/
|
||||
type Errno c.Ulong
|
||||
|
||||
// ERR_get_error returns the earliest error code from the thread's error queue and
|
||||
// removes the entry. This function can be called repeatedly until there are no more
|
||||
// error codes to return.
|
||||
//
|
||||
// unsigned long ERR_get_error(void);
|
||||
//
|
||||
//go:linkname ERRGetError C.ERR_get_error
|
||||
func ERRGetError() Errno
|
||||
|
||||
// ERR_get_error_all() is the same as ERR_get_error(), but on success it additionally
|
||||
// stores the filename, line number and function where the error occurred in *file,
|
||||
// *line and *func, and also extra text and flags in *data, *flags. If any of those
|
||||
// parameters are NULL, it will not be changed.
|
||||
//
|
||||
// unsigned long ERR_get_error_all(
|
||||
// const char **file, int *line, const char **func, const char **data, int *flags);
|
||||
//
|
||||
//go:linkname ERRGetErrorAll C.ERR_get_error_all
|
||||
func ERRGetErrorAll(
|
||||
file **c.Char, line *c.Int, function **c.Char, data **c.Char, flags *c.Int) Errno
|
||||
|
||||
// unsigned long ERR_peek_error(void);
|
||||
//
|
||||
//go:linkname ERRPeekError C.ERR_peek_error
|
||||
func ERRPeekError() Errno
|
||||
|
||||
// unsigned long ERR_peek_error_all(
|
||||
// const char **file, int *line, const char **func, const char **data, int *flags);
|
||||
//
|
||||
//go:linkname ERRPeekErrorAll C.ERR_peek_error_all
|
||||
func ERRPeekErrorAll(
|
||||
file **c.Char, line *c.Int, function **c.Char, data **c.Char, flags *c.Int) Errno
|
||||
|
||||
// unsigned long ERR_peek_last_error(void);
|
||||
//
|
||||
//go:linkname ERRPeekLastError C.ERR_peek_last_error
|
||||
func ERRPeekLastError() Errno
|
||||
|
||||
// unsigned long ERR_peek_last_error_all(
|
||||
// const char **file, int *line, const char **func, const char **data, int *flags);
|
||||
//
|
||||
//go:linkname ERRPeekLastErrorAll C.ERR_peek_last_error_all
|
||||
func ERRPeekLastErrorAll(
|
||||
file **c.Char, line *c.Int, function **c.Char, data **c.Char, flags *c.Int) Errno
|
||||
|
||||
// void ERR_clear_error(void);
|
||||
//
|
||||
//go:linkname ERRClearError C.ERR_clear_error
|
||||
func ERRClearError()
|
||||
|
||||
// ERR_error_string() generates a human-readable string representing the error code e,
|
||||
// and places it at buf. buf must be at least 256 bytes long.
|
||||
//
|
||||
// char *ERR_error_string(unsigned long e, char *buf);
|
||||
//
|
||||
//go:linkname ERRErrorString C.ERR_error_string
|
||||
func ERRErrorString(e Errno, buf *c.Char) *c.Char
|
||||
|
||||
// ERR_lib_error_string() and ERR_reason_error_string() return the library name and
|
||||
// reason string respectively.
|
||||
//
|
||||
// const char *ERR_lib_error_string(unsigned long e);
|
||||
//
|
||||
//go:linkname ERRLibErrorString C.ERR_lib_error_string
|
||||
func ERRLibErrorString(e Errno) *c.Char
|
||||
|
||||
// const char *ERR_reason_error_string(unsigned long e);
|
||||
//
|
||||
//go:linkname ERRReasonErrorString C.ERR_reason_error_string
|
||||
func ERRReasonErrorString(e Errno) *c.Char
|
||||
|
||||
// void ERR_print_errors_cb(int (*cb) (const char *str, size_t len, void *u), void *u);
|
||||
//
|
||||
// [pid]:error:[error code]:[library name]:[function name]:[reason string]:[filename]:[line]:[optional text message]
|
||||
//
|
||||
//go:linkname ERRPrintErrorsCb C.ERR_print_errors_cb
|
||||
func ERRPrintErrorsCb(cb func(str *c.Char, len uintptr, u unsafe.Pointer) c.Int, u unsafe.Pointer)
|
||||
|
||||
// void ERR_print_errors_fp(FILE *fp);
|
||||
//
|
||||
//go:linkname ERRPrintErrorsFp C.ERR_print_errors_fp
|
||||
func ERRPrintErrorsFp(fp c.FilePtr)
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
133
runtime/internal/clite/openssl/hmac.go
Normal file
133
runtime/internal/clite/openssl/hmac.go
Normal file
@@ -0,0 +1,133 @@
|
||||
package openssl
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
c "github.com/goplus/llgo/runtime/internal/clite"
|
||||
)
|
||||
|
||||
const (
|
||||
EVP_MAX_MD_SIZE = 64 /* longest known is SHA512 */
|
||||
)
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
type EVP_MD struct {
|
||||
Unused [0]byte
|
||||
}
|
||||
|
||||
// const EVP_MD *EVP_sha1(void)
|
||||
//
|
||||
//go:linkname EVP_sha1 C.EVP_sha1
|
||||
func EVP_sha1() *EVP_MD
|
||||
|
||||
// const EVP_MD *EVP_sha224(void)
|
||||
//
|
||||
//go:linkname EVP_sha224 C.EVP_sha224
|
||||
func EVP_sha224() *EVP_MD
|
||||
|
||||
// func EVP_sha256() *EVP_MD
|
||||
//
|
||||
//go:linkname EVP_sha256 C.EVP_sha256
|
||||
func EVP_sha256() *EVP_MD
|
||||
|
||||
// const EVP_MD *EVP_sha512_224(void)
|
||||
//
|
||||
//go:linkname EVP_sha512_224 C.EVP_sha512_224
|
||||
func EVP_sha512_224() *EVP_MD
|
||||
|
||||
// const EVP_MD *EVP_sha512_256(void)
|
||||
//
|
||||
//go:linkname EVP_sha512_256 C.EVP_sha512_256
|
||||
func EVP_sha512_256() *EVP_MD
|
||||
|
||||
// const EVP_MD *EVP_sha384(void)
|
||||
//
|
||||
//go:linkname EVP_sha384 C.EVP_sha384
|
||||
func EVP_sha384() *EVP_MD
|
||||
|
||||
// const EVP_MD *EVP_sha512(void)
|
||||
//
|
||||
//go:linkname EVP_sha512 C.EVP_sha512
|
||||
func EVP_sha512() *EVP_MD
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
type HMAC_CTX struct {
|
||||
Unused [0]byte
|
||||
}
|
||||
|
||||
// OSSL_DEPRECATEDIN_3_0 HMAC_CTX *HMAC_CTX_new(void);
|
||||
//
|
||||
//go:linkname NewHMAC_CTX C.HMAC_CTX_new
|
||||
func NewHMAC_CTX() *HMAC_CTX
|
||||
|
||||
// OSSL_DEPRECATEDIN_3_0 void HMAC_CTX_free(HMAC_CTX *ctx);
|
||||
//
|
||||
// llgo:link (*HMAC_CTX).Free C.HMAC_CTX_free
|
||||
func (ctx *HMAC_CTX) Free() {}
|
||||
|
||||
// OSSL_DEPRECATEDIN_3_0 size_t HMAC_size(const HMAC_CTX *e);
|
||||
//
|
||||
// llgo:link (*HMAC_CTX).Size C.HMAC_size
|
||||
func (ctx *HMAC_CTX) Size() uintptr { return 0 }
|
||||
|
||||
// OSSL_DEPRECATEDIN_3_0 int HMAC_CTX_reset(HMAC_CTX *ctx);
|
||||
//
|
||||
// llgo:link (*HMAC_CTX).Reset C.HMAC_CTX_reset
|
||||
func (ctx *HMAC_CTX) Reset() c.Int { return 0 }
|
||||
|
||||
// OSSL_DEPRECATEDIN_1_1_0 __owur int HMAC_Init(HMAC_CTX *ctx,
|
||||
// const void *key, int len,
|
||||
// const EVP_MD *md);
|
||||
//
|
||||
// llgo:link (*HMAC_CTX).Init C.HMAC_Init
|
||||
func (ctx *HMAC_CTX) Init(key unsafe.Pointer, len c.Int, md *EVP_MD) c.Int { return 0 }
|
||||
|
||||
func (ctx *HMAC_CTX) InitBytes(key []byte, md *EVP_MD) c.Int {
|
||||
return ctx.Init(unsafe.Pointer(unsafe.SliceData(key)), c.Int(len(key)), md)
|
||||
}
|
||||
|
||||
func (ctx *HMAC_CTX) InitString(key string, md *EVP_MD) c.Int {
|
||||
return ctx.Init(unsafe.Pointer(unsafe.StringData(key)), c.Int(len(key)), md)
|
||||
}
|
||||
|
||||
// OSSL_DEPRECATEDIN_3_0 int HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len,
|
||||
// const EVP_MD *md, ENGINE *impl);
|
||||
//
|
||||
// llgo:link (*HMAC_CTX).InitEx C.HMAC_Init_ex
|
||||
func (ctx *HMAC_CTX) InitEx(key unsafe.Pointer, len c.Int, md *EVP_MD, impl unsafe.Pointer) c.Int {
|
||||
return 0
|
||||
}
|
||||
|
||||
// OSSL_DEPRECATEDIN_3_0 int HMAC_Update(HMAC_CTX *ctx, const unsigned char *data,
|
||||
// size_t len);
|
||||
//
|
||||
// llgo:link (*HMAC_CTX).Update C.HMAC_Update
|
||||
func (ctx *HMAC_CTX) Update(data unsafe.Pointer, len uintptr) c.Int { return 0 }
|
||||
|
||||
func (ctx *HMAC_CTX) UpdateBytes(data []byte) c.Int {
|
||||
return ctx.Update(unsafe.Pointer(unsafe.SliceData(data)), uintptr(len(data)))
|
||||
}
|
||||
|
||||
func (ctx *HMAC_CTX) UpdateString(data string) c.Int {
|
||||
return ctx.Update(unsafe.Pointer(unsafe.StringData(data)), uintptr(len(data)))
|
||||
}
|
||||
|
||||
// OSSL_DEPRECATEDIN_3_0 int HMAC_Final(HMAC_CTX *ctx, unsigned char *md,
|
||||
// unsigned int *len);
|
||||
//
|
||||
// llgo:link (*HMAC_CTX).Final C.HMAC_Final
|
||||
func (ctx *HMAC_CTX) Final(md *byte, len *c.Uint) c.Int { return 0 }
|
||||
|
||||
// OSSL_DEPRECATEDIN_3_0 __owur int HMAC_CTX_copy(HMAC_CTX *dctx, HMAC_CTX *sctx);
|
||||
//
|
||||
// llgo:link (*HMAC_CTX).Copy C.HMAC_CTX_copy
|
||||
func (ctx *HMAC_CTX) Copy(sctx *HMAC_CTX) c.Int { return 0 }
|
||||
|
||||
// OSSL_DEPRECATEDIN_3_0 void HMAC_CTX_set_flags(HMAC_CTX *ctx, unsigned long flags);
|
||||
//
|
||||
// llgo:link (*HMAC_CTX).SetFlags C.HMAC_CTX_set_flags
|
||||
func (ctx *HMAC_CTX) SetFlags(flags c.Ulong) {}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
85
runtime/internal/clite/openssl/md5.go
Normal file
85
runtime/internal/clite/openssl/md5.go
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright (c) 2024 The GoPlus Authors (goplus.org). All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package openssl
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
c "github.com/goplus/llgo/runtime/internal/clite"
|
||||
)
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
const (
|
||||
MD5_CBLOCK = 64
|
||||
MD5_LBLOCK = MD5_CBLOCK / 4
|
||||
)
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
type MD5_LONG = c.Uint
|
||||
|
||||
type MD5_CTX struct {
|
||||
A, B, C, D MD5_LONG
|
||||
Nl, Nh MD5_LONG
|
||||
Data [MD5_LBLOCK]MD5_LONG
|
||||
Num c.Uint
|
||||
}
|
||||
|
||||
// OSSL_DEPRECATEDIN_3_0 int MD5_Init(MD5_CTX *c);
|
||||
//
|
||||
// llgo:link (*MD5_CTX).Init C.MD5_Init
|
||||
func (c *MD5_CTX) Init() c.Int { return 0 }
|
||||
|
||||
// OSSL_DEPRECATEDIN_3_0 int MD5_Update(MD5_CTX *c, const void *data, size_t len);
|
||||
//
|
||||
// llgo:link (*MD5_CTX).Update C.MD5_Update
|
||||
func (c *MD5_CTX) Update(data unsafe.Pointer, n uintptr) c.Int { return 0 }
|
||||
|
||||
func (c *MD5_CTX) UpdateBytes(data []byte) c.Int {
|
||||
return c.Update(unsafe.Pointer(unsafe.SliceData(data)), uintptr(len(data)))
|
||||
}
|
||||
|
||||
func (c *MD5_CTX) UpdateString(data string) c.Int {
|
||||
return c.Update(unsafe.Pointer(unsafe.StringData(data)), uintptr(len(data)))
|
||||
}
|
||||
|
||||
// OSSL_DEPRECATEDIN_3_0 int MD5_Final(unsigned char *md, MD5_CTX *c);
|
||||
//
|
||||
//go:linkname md5Final C.MD5_Final
|
||||
func md5Final(md *byte, c *MD5_CTX) c.Int
|
||||
|
||||
func (c *MD5_CTX) Final(md *byte) c.Int {
|
||||
return md5Final(md, c)
|
||||
}
|
||||
|
||||
// OSSL_DEPRECATEDIN_3_0 unsigned char *MD5(const unsigned char *d, size_t n, unsigned char *md);
|
||||
//
|
||||
//go:linkname MD5 C.MD5
|
||||
func MD5(data unsafe.Pointer, n uintptr, md *byte) *byte
|
||||
|
||||
func MD5Bytes(data []byte, md *byte) *byte {
|
||||
return MD5(unsafe.Pointer(unsafe.SliceData(data)), uintptr(len(data)), md)
|
||||
}
|
||||
|
||||
func MD5String(data string, md *byte) *byte {
|
||||
return MD5(unsafe.Pointer(unsafe.StringData(data)), uintptr(len(data)), md)
|
||||
}
|
||||
|
||||
// OSSL_DEPRECATEDIN_3_0 void MD5_Transform(MD5_CTX *c, const unsigned char *b);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
38
runtime/internal/clite/openssl/openssl.go
Normal file
38
runtime/internal/clite/openssl/openssl.go
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2024 The GoPlus Authors (goplus.org). All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package openssl
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
c "github.com/goplus/llgo/runtime/internal/clite"
|
||||
)
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
const (
|
||||
LLGoFiles = "$(pkg-config --cflags openssl): _wrap/openssl.c"
|
||||
LLGoPackage = "link: $(pkg-config --libs openssl); -lssl -lcrypto"
|
||||
)
|
||||
|
||||
//go:linkname Free C.opensslFree
|
||||
func Free(ptr unsafe.Pointer)
|
||||
|
||||
//go:linkname FreeCStr C.opensslFree
|
||||
func FreeCStr(ptr *c.Char)
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
37
runtime/internal/clite/openssl/pem.go
Normal file
37
runtime/internal/clite/openssl/pem.go
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (c) 2024 The GoPlus Authors (goplus.org). All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package openssl
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
c "github.com/goplus/llgo/runtime/internal/clite"
|
||||
)
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
// typedef int (*pem_password_cb)(char *buf, int size, int rwflag, void *userdata);
|
||||
//
|
||||
// llgo:type C
|
||||
type PemPasswordCb func(buf *c.Char, size, rwflag c.Int, userdata unsafe.Pointer) c.Int
|
||||
|
||||
// RSA *PEM_read_bio_RSAPrivateKey(BIO *bp, RSA **x, pem_password_cb *cb, void *u);
|
||||
//
|
||||
//go:linkname PEMReadBioRSAPrivateKey C.PEM_read_bio_RSAPrivateKey
|
||||
func PEMReadBioRSAPrivateKey(bp *BIO, x **RSA, cb PemPasswordCb, u unsafe.Pointer) *RSA
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
80
runtime/internal/clite/openssl/rand.go
Normal file
80
runtime/internal/clite/openssl/rand.go
Normal file
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (c) 2024 The GoPlus Authors (goplus.org). All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package openssl
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
c "github.com/goplus/llgo/runtime/internal/clite"
|
||||
)
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
// int RAND_bytes(unsigned char *buf, int num);
|
||||
//
|
||||
//go:linkname RANDBufferWithLen C.RAND_bytes
|
||||
func RANDBufferWithLen(buf *byte, num c.Int) c.Int
|
||||
|
||||
func RANDBytes(buf []byte) c.Int {
|
||||
return RANDBufferWithLen(unsafe.SliceData(buf), c.Int(len(buf)))
|
||||
}
|
||||
|
||||
// int RAND_priv_bytes(unsigned char *buf, int num);
|
||||
//
|
||||
//go:linkname RANDPrivBufferWithLen C.RAND_priv_bytes
|
||||
func RANDPrivBufferWithLen(buf *byte, num c.Int) c.Int
|
||||
|
||||
func RANDPrivBytes(buf []byte) c.Int {
|
||||
return RANDPrivBufferWithLen(unsafe.SliceData(buf), c.Int(len(buf)))
|
||||
}
|
||||
|
||||
// void RAND_seed(const void *buf, int num);
|
||||
//
|
||||
//go:linkname RANDSeed C.RAND_seed
|
||||
func RANDSeed(buf unsafe.Pointer, num c.Int)
|
||||
|
||||
// void RAND_keep_random_devices_open(int keep);
|
||||
//
|
||||
//go:linkname RANDKeepRandomDevicesOpen C.RAND_keep_random_devices_open
|
||||
func RANDKeepRandomDevicesOpen(keep c.Int)
|
||||
|
||||
// int RAND_load_file(const char *file, long max_bytes);
|
||||
//
|
||||
//go:linkname RANDLoadFile C.RAND_load_file
|
||||
func RANDLoadFile(file *c.Char, maxBytes c.Long) c.Int
|
||||
|
||||
// int RAND_write_file(const char *file);
|
||||
//
|
||||
//go:linkname RANDWriteFile C.RAND_write_file
|
||||
func RANDWriteFile(file *c.Char) c.Int
|
||||
|
||||
// const char *RAND_file_name(char *file, size_t num);
|
||||
//
|
||||
//go:linkname RANDFileName C.RAND_file_name
|
||||
func RANDFileName(file *c.Char, num uintptr) *c.Char
|
||||
|
||||
// int RAND_status(void);
|
||||
//
|
||||
//go:linkname RANDStatus C.RAND_status
|
||||
func RANDStatus() c.Int
|
||||
|
||||
// int RAND_poll(void);
|
||||
//
|
||||
//go:linkname RANDPoll C.RAND_poll
|
||||
func RANDPoll() c.Int
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
305
runtime/internal/clite/openssl/rsa.go
Normal file
305
runtime/internal/clite/openssl/rsa.go
Normal file
@@ -0,0 +1,305 @@
|
||||
/*
|
||||
* Copyright (c) 2024 The GoPlus Authors (goplus.org). All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package openssl
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
c "github.com/goplus/llgo/runtime/internal/clite"
|
||||
)
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
type RSA_METHOD struct {
|
||||
Unused [0]byte
|
||||
}
|
||||
|
||||
// OSSL_DEPRECATEDIN_3_0 RSA_METHOD *RSA_meth_new(const char *name, int flags);
|
||||
//
|
||||
//go:linkname RSAMethNew C.RSA_meth_new
|
||||
func RSAMethNew(name *byte, flags c.Int) *RSA_METHOD
|
||||
|
||||
// OSSL_DEPRECATEDIN_3_0 void RSA_meth_free(RSA_METHOD *meth);
|
||||
//
|
||||
// llgo:link (*RSA_METHOD).Free C.RSA_meth_free
|
||||
func (*RSA_METHOD) Free() {}
|
||||
|
||||
// OSSL_DEPRECATEDIN_3_0
|
||||
// int RSA_meth_set_init(RSA_METHOD *rsa, int (*init) (RSA *rsa));
|
||||
//
|
||||
// llgo:link (*RSA_METHOD).SetInit C.RSA_meth_set_init
|
||||
func (*RSA_METHOD) SetInit(init func(rsa *RSA) c.Int) c.Int { return 0 }
|
||||
|
||||
// OSSL_DEPRECATEDIN_3_0
|
||||
// int RSA_meth_set_finish(RSA_METHOD *rsa, int (*finish) (RSA *rsa));
|
||||
//
|
||||
// llgo:link (*RSA_METHOD).SetFinish C.RSA_meth_set_finish
|
||||
func (*RSA_METHOD) SetFinish(finish func(rsa *RSA) c.Int) c.Int { return 0 }
|
||||
|
||||
/*
|
||||
OSSL_DEPRECATEDIN_3_0
|
||||
int RSA_meth_set_mod_exp(RSA_METHOD *rsa,
|
||||
int (*mod_exp) (BIGNUM *r0, const BIGNUM *i, RSA *rsa,
|
||||
BN_CTX *ctx));
|
||||
*/
|
||||
// llgo:link (*RSA_METHOD).SetModExp C.RSA_meth_set_mod_exp
|
||||
func (*RSA_METHOD) SetModExp(modExp func(
|
||||
r0 *BIGNUM, i *BIGNUM, rsa *RSA, ctx *BN_CTX) c.Int) c.Int {
|
||||
return 0
|
||||
}
|
||||
|
||||
/*
|
||||
OSSL_DEPRECATEDIN_3_0
|
||||
int RSA_meth_set_bn_mod_exp(RSA_METHOD *rsa,
|
||||
int (*bn_mod_exp) (BIGNUM *r,
|
||||
const BIGNUM *a,
|
||||
const BIGNUM *p,
|
||||
const BIGNUM *m,
|
||||
BN_CTX *ctx,
|
||||
BN_MONT_CTX *m_ctx));
|
||||
//-llgo:link (*RSA_METHOD).SetBnModExp C.RSA_meth_set_bn_mod_exp
|
||||
func (*RSA_METHOD) SetBnModExp(bnModExp func(
|
||||
r *BIGNUM, a *BIGNUM, p *BIGNUM, m *BIGNUM, ctx *BN_CTX, mCtx *BN_MONT_CTX) c.Int) c.Int {
|
||||
return 0
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
OSSL_DEPRECATEDIN_3_0
|
||||
int RSA_meth_set_pub_enc(RSA_METHOD *rsa,
|
||||
int (*pub_enc) (int flen, const unsigned char *from,
|
||||
unsigned char *to, RSA *rsa,
|
||||
int padding));
|
||||
*/
|
||||
// llgo:link (*RSA_METHOD).SetPubEnc C.RSA_meth_set_pub_enc
|
||||
func (*RSA_METHOD) SetPubEnc(pubEnc func(
|
||||
flen c.Int, from *byte, to *byte, rsa *RSA, padding c.Int) c.Int) c.Int {
|
||||
return 0
|
||||
}
|
||||
|
||||
/*
|
||||
OSSL_DEPRECATEDIN_3_0
|
||||
int RSA_meth_set_pub_dec(RSA_METHOD *rsa,
|
||||
int (*pub_dec) (int flen, const unsigned char *from,
|
||||
unsigned char *to, RSA *rsa,
|
||||
int padding));
|
||||
*/
|
||||
// llgo:link (*RSA_METHOD).SetPubDec C.RSA_meth_set_pub_dec
|
||||
func (*RSA_METHOD) SetPubDec(pubDec func(
|
||||
flen c.Int, from *byte, to *byte, rsa *RSA, padding c.Int) c.Int) c.Int {
|
||||
return 0
|
||||
}
|
||||
|
||||
/*
|
||||
OSSL_DEPRECATEDIN_3_0
|
||||
int RSA_meth_set_priv_enc(RSA_METHOD *rsa,
|
||||
int (*priv_enc) (int flen, const unsigned char *from,
|
||||
unsigned char *to, RSA *rsa,
|
||||
int padding));
|
||||
*/
|
||||
// llgo:link (*RSA_METHOD).SetPrivEnc C.RSA_meth_set_priv_enc
|
||||
func (*RSA_METHOD) SetPrivEnc(privEnc func(
|
||||
flen c.Int, from *byte, to *byte, rsa *RSA, padding c.Int) c.Int) c.Int {
|
||||
return 0
|
||||
}
|
||||
|
||||
/*
|
||||
OSSL_DEPRECATEDIN_3_0
|
||||
int RSA_meth_set_priv_dec(RSA_METHOD *rsa,
|
||||
int (*priv_dec) (int flen, const unsigned char *from,
|
||||
unsigned char *to, RSA *rsa,
|
||||
int padding));
|
||||
*/
|
||||
// llgo:link (*RSA_METHOD).SetPrivDec C.RSA_meth_set_priv_dec
|
||||
func (*RSA_METHOD) SetPrivDec(privDec func(
|
||||
flen c.Int, from *byte, to *byte, rsa *RSA, padding c.Int) c.Int) c.Int {
|
||||
return 0
|
||||
}
|
||||
|
||||
/*
|
||||
OSSL_DEPRECATEDIN_3_0
|
||||
int RSA_meth_set_sign(RSA_METHOD *rsa,
|
||||
int (*sign) (int type, const unsigned char *m,
|
||||
unsigned int m_length,
|
||||
unsigned char *sigret, unsigned int *siglen,
|
||||
const RSA *rsa));
|
||||
*/
|
||||
// llgo:link (*RSA_METHOD).SetSign C.RSA_meth_set_sign
|
||||
func (*RSA_METHOD) SetSign(sign func(
|
||||
typ c.Int, msg *byte, mlen c.Uint,
|
||||
sigret *byte, siglen *c.Uint, rsa *RSA) c.Int) c.Int {
|
||||
return 0
|
||||
}
|
||||
|
||||
/*
|
||||
OSSL_DEPRECATEDIN_3_0
|
||||
int RSA_meth_set_verify(RSA_METHOD *rsa,
|
||||
int (*verify) (int dtype, const unsigned char *m,
|
||||
unsigned int m_length,
|
||||
const unsigned char *sigbuf,
|
||||
unsigned int siglen, const RSA *rsa));
|
||||
*/
|
||||
// llgo:link (*RSA_METHOD).SetVerify C.RSA_meth_set_verify
|
||||
func (*RSA_METHOD) SetVerify(verify func(
|
||||
dtype c.Int, msg *byte, mlen c.Uint,
|
||||
sigbuf *byte, siglen c.Uint, rsa *RSA) c.Int) c.Int {
|
||||
return 0
|
||||
}
|
||||
|
||||
/*
|
||||
OSSL_DEPRECATEDIN_3_0
|
||||
int RSA_meth_set_keygen(RSA_METHOD *rsa,
|
||||
int (*keygen) (RSA *rsa, int bits, BIGNUM *e,
|
||||
BN_GENCB *cb));
|
||||
|
||||
OSSL_DEPRECATEDIN_3_0
|
||||
int RSA_meth_set_multi_prime_keygen(RSA_METHOD *meth,
|
||||
int (*keygen) (RSA *rsa, int bits,
|
||||
int primes, BIGNUM *e,
|
||||
BN_GENCB *cb));
|
||||
*/
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
type RSA struct {
|
||||
Unused [0]byte
|
||||
}
|
||||
|
||||
// OSSL_DEPRECATEDIN_3_0 RSA *RSA_new(void);
|
||||
//
|
||||
//go:linkname RSANew C.RSA_new
|
||||
func RSANew() *RSA
|
||||
|
||||
// OSSL_DEPRECATEDIN_3_0 RSA *RSA_new_method(ENGINE *engine);
|
||||
|
||||
// OSSL_DEPRECATEDIN_3_0 void RSA_free(RSA *r);
|
||||
//
|
||||
// llgo:link (*RSA).Free C.RSA_free
|
||||
func (*RSA) Free() {}
|
||||
|
||||
// "up" the RSA object's reference count
|
||||
// OSSL_DEPRECATEDIN_3_0 int RSA_up_ref(RSA *r);
|
||||
//
|
||||
// llgo:link (*RSA).UpRef C.RSA_up_ref
|
||||
func (*RSA) UpRef() c.Int { return 0 }
|
||||
|
||||
// OSSL_DEPRECATEDIN_3_0 int RSA_bits(const RSA *rsa);
|
||||
//
|
||||
// llgo:link (*RSA).Bits C.RSA_bits
|
||||
func (*RSA) Bits() c.Int { return 0 }
|
||||
|
||||
// OSSL_DEPRECATEDIN_3_0 int RSA_size(const RSA *rsa);
|
||||
//
|
||||
// llgo:link (*RSA).Size C.RSA_size
|
||||
func (*RSA) Size() c.Int { return 0 }
|
||||
|
||||
// OSSL_DEPRECATEDIN_3_0 int RSA_security_bits(const RSA *rsa);
|
||||
//
|
||||
// llgo:link (*RSA).SecurityBits C.RSA_security_bits
|
||||
func (*RSA) SecurityBits() c.Int { return 0 }
|
||||
|
||||
// OSSL_DEPRECATEDIN_3_0 int RSA_flags(const RSA *r);
|
||||
//
|
||||
// llgo:link (*RSA).Flags C.RSA_flags
|
||||
func (*RSA) Flags() c.Int { return 0 }
|
||||
|
||||
// OSSL_DEPRECATEDIN_3_0 void RSA_set_flags(RSA *r, int flags);
|
||||
//
|
||||
// llgo:link (*RSA).SetFlags C.RSA_set_flags
|
||||
func (*RSA) SetFlags(flags c.Int) {}
|
||||
|
||||
// OSSL_DEPRECATEDIN_3_0 void RSA_clear_flags(RSA *r, int flags);
|
||||
//
|
||||
// llgo:link (*RSA).ClearFlags C.RSA_clear_flags
|
||||
func (*RSA) ClearFlags(flags c.Int) {}
|
||||
|
||||
// OSSL_DEPRECATEDIN_3_0 int RSA_test_flags(const RSA *r, int flags);
|
||||
//
|
||||
// llgo:link (*RSA).TestFlags C.RSA_test_flags
|
||||
func (*RSA) TestFlags(flags c.Int) c.Int { return 0 }
|
||||
|
||||
// OSSL_DEPRECATEDIN_3_0 int RSA_get_version(RSA *r);
|
||||
//
|
||||
// llgo:link (*RSA).GetVersion C.RSA_get_version
|
||||
func (*RSA) GetVersion() c.Int { return 0 }
|
||||
|
||||
// OSSL_DEPRECATEDIN_3_0 int RSA_set_ex_data(RSA *r, int idx, void *arg);
|
||||
//
|
||||
// llgo:link (*RSA).SetExData C.RSA_set_ex_data
|
||||
func (*RSA) SetExData(idx c.Int, arg unsafe.Pointer) c.Int { return 0 }
|
||||
|
||||
// OSSL_DEPRECATEDIN_3_0 void *RSA_get_ex_data(const RSA *r, int idx);
|
||||
//
|
||||
// llgo:link (*RSA).GetExData C.RSA_get_ex_data
|
||||
func (*RSA) GetExData(idx c.Int) unsafe.Pointer { return nil }
|
||||
|
||||
// OSSL_DEPRECATEDIN_3_0 int RSA_set_method(RSA *rsa, const RSA_METHOD *meth);
|
||||
//
|
||||
// llgo:link (*RSA).SetMethod C.RSA_set_method
|
||||
func (*RSA) SetMethod(meth *RSA_METHOD) c.Int { return 0 }
|
||||
|
||||
// OSSL_DEPRECATEDIN_3_0 int RSA_generate_key_ex(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb);
|
||||
//
|
||||
// llgo:link (*RSA).GenerateKeyEx C.RSA_generate_key_ex
|
||||
func (*RSA) GenerateKeyEx(bits c.Int, e *BIGNUM, cb *BN_GENCB) c.Int { return 0 }
|
||||
|
||||
// OSSL_DEPRECATEDIN_3_0 int RSA_generate_multi_prime_key(RSA *rsa, int bits, int primes, BIGNUM *e, BN_GENCB *cb);
|
||||
//
|
||||
// llgo:link (*RSA).GenerateMultiPrimeKey C.RSA_generate_multi_prime_key
|
||||
func (*RSA) GenerateMultiPrimeKey(bits, primes c.Int, e *BIGNUM, cb *BN_GENCB) c.Int { return 0 }
|
||||
|
||||
/*
|
||||
// next 4 return -1 on error
|
||||
|
||||
OSSL_DEPRECATEDIN_3_0
|
||||
int RSA_public_encrypt(int flen, const unsigned char *from, unsigned char *to,
|
||||
RSA *rsa, int padding);
|
||||
OSSL_DEPRECATEDIN_3_0
|
||||
int RSA_private_encrypt(int flen, const unsigned char *from, unsigned char *to,
|
||||
RSA *rsa, int padding);
|
||||
OSSL_DEPRECATEDIN_3_0
|
||||
int RSA_public_decrypt(int flen, const unsigned char *from, unsigned char *to,
|
||||
RSA *rsa, int padding);
|
||||
OSSL_DEPRECATEDIN_3_0
|
||||
int RSA_private_decrypt(int flen, const unsigned char *from, unsigned char *to,
|
||||
RSA *rsa, int padding);
|
||||
*/
|
||||
//go:linkname RSAPublicEncrypt C.RSA_public_encrypt
|
||||
func RSAPublicEncrypt(flen c.Int, from *byte, to *byte, rsa *RSA, padding c.Int) c.Int
|
||||
|
||||
//go:linkname RSAPrivateEncrypt C.RSA_private_encrypt
|
||||
func RSAPrivateEncrypt(flen c.Int, from *byte, to *byte, rsa *RSA, padding c.Int) c.Int
|
||||
|
||||
//go:linkname RSAPublicDecrypt C.RSA_public_decrypt
|
||||
func RSAPublicDecrypt(flen c.Int, from *byte, to *byte, rsa *RSA, padding c.Int) c.Int
|
||||
|
||||
//go:linkname RSAPrivateDecrypt C.RSA_private_decrypt
|
||||
func RSAPrivateDecrypt(flen c.Int, from *byte, to *byte, rsa *RSA, padding c.Int) c.Int
|
||||
|
||||
// OSSL_DEPRECATEDIN_3_0 int RSA_sign(
|
||||
// int type, const unsigned char *m, unsigned int m_length,
|
||||
// unsigned char *sigret, unsigned int *siglen, RSA *rsa);
|
||||
//
|
||||
//go:linkname RSASign C.RSA_sign
|
||||
func RSASign(typ c.Int, msg *byte, mlen c.Uint, sigret *byte, siglen *c.Uint, rsa *RSA) c.Int
|
||||
|
||||
// OSSL_DEPRECATEDIN_3_0 int RSA_verify(int type, const unsigned char *m,
|
||||
// unsigned int m_length,
|
||||
// const unsigned char *sigbuf,
|
||||
// unsigned int siglen, RSA *rsa);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
94
runtime/internal/clite/openssl/sha1.go
Normal file
94
runtime/internal/clite/openssl/sha1.go
Normal file
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Copyright (c) 2024 The GoPlus Authors (goplus.org). All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package openssl
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
c "github.com/goplus/llgo/runtime/internal/clite"
|
||||
)
|
||||
|
||||
const (
|
||||
SHA_DIGEST_LENGTH = 20
|
||||
SHA_LBLOCK = 16
|
||||
SHA_CBLOCK = (SHA_LBLOCK * 4)
|
||||
SHA_LAST_BLOCK = (SHA_CBLOCK - 8)
|
||||
|
||||
SHA256_CBLOCK = (SHA_LBLOCK * 4)
|
||||
SHA256_192_DIGEST_LENGTH = 24
|
||||
SHA224_DIGEST_LENGTH = 28
|
||||
SHA256_DIGEST_LENGTH = 32
|
||||
SHA384_DIGEST_LENGTH = 48
|
||||
SHA512_DIGEST_LENGTH = 64
|
||||
SHA512_CBLOCK = (SHA_LBLOCK * 8)
|
||||
)
|
||||
|
||||
type SHA_LONG64 = c.UlongLong
|
||||
|
||||
type SHA_LONG = c.Uint
|
||||
|
||||
type SHA_CTX struct {
|
||||
H0, H1, H2, H3, H4 SHA_LONG
|
||||
Nl, Nh SHA_LONG
|
||||
Data [SHA_LBLOCK]SHA_LONG
|
||||
Num c.Uint
|
||||
}
|
||||
|
||||
// OSSL_DEPRECATEDIN_3_0 int SHA1_Init(SHA_CTX *c);
|
||||
//
|
||||
// llgo:link (*SHA_CTX).Init C.SHA1_Init
|
||||
func (c *SHA_CTX) Init() c.Int { return 0 }
|
||||
|
||||
// OSSL_DEPRECATEDIN_3_0 int SHA1_Update(SHA_CTX *c, const void *data, size_t len);
|
||||
//
|
||||
// llgo:link (*SHA_CTX).Update C.SHA1_Update
|
||||
func (c *SHA_CTX) Update(data unsafe.Pointer, n uintptr) c.Int { return 0 }
|
||||
|
||||
func (c *SHA_CTX) UpdateBytes(data []byte) c.Int {
|
||||
return c.Update(unsafe.Pointer(unsafe.SliceData(data)), uintptr(len(data)))
|
||||
}
|
||||
|
||||
func (c *SHA_CTX) UpdateString(data string) c.Int {
|
||||
return c.Update(unsafe.Pointer(unsafe.StringData(data)), uintptr(len(data)))
|
||||
}
|
||||
|
||||
// OSSL_DEPRECATEDIN_3_0 int SHA1_Final(unsigned char *md, SHA_CTX *c);
|
||||
//
|
||||
//go:linkname sha1Final C.SHA1_Final
|
||||
func sha1Final(md *byte, c *SHA_CTX) c.Int
|
||||
|
||||
func (c *SHA_CTX) Final(md *byte) c.Int {
|
||||
return sha1Final(md, c)
|
||||
}
|
||||
|
||||
// OSSL_DEPRECATEDIN_3_0 void SHA1_Transform(SHA_CTX *c, const unsigned char *data);
|
||||
//
|
||||
// llgo:link (*SHA_CTX).Transform C.SHA1_Transform
|
||||
func (c *SHA_CTX) Transform(data *byte) {}
|
||||
|
||||
// unsigned char *SHA1(const unsigned char *d, size_t n, unsigned char *md);
|
||||
//
|
||||
//go:linkname SHA1 C.SHA1
|
||||
func SHA1(data unsafe.Pointer, n uintptr, md *byte) *byte
|
||||
|
||||
func SHA1Bytes(data []byte, md *byte) *byte {
|
||||
return SHA1(unsafe.Pointer(unsafe.SliceData(data)), uintptr(len(data)), md)
|
||||
}
|
||||
|
||||
func SHA1String(data string, md *byte) *byte {
|
||||
return SHA1(unsafe.Pointer(unsafe.StringData(data)), uintptr(len(data)), md)
|
||||
}
|
||||
117
runtime/internal/clite/openssl/sha256.go
Normal file
117
runtime/internal/clite/openssl/sha256.go
Normal file
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* Copyright (c) 2024 The GoPlus Authors (goplus.org). All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package openssl
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
c "github.com/goplus/llgo/runtime/internal/clite"
|
||||
)
|
||||
|
||||
type SHA256_CTX struct {
|
||||
H [8]SHA_LONG
|
||||
Nl, Nh SHA_LONG
|
||||
Data [SHA_LBLOCK]SHA_LONG
|
||||
Num, MdLen c.Uint
|
||||
}
|
||||
|
||||
type SHA224_CTX SHA256_CTX
|
||||
|
||||
// OSSL_DEPRECATEDIN_3_0 int SHA224_Init(SHA256_CTX *c);
|
||||
//
|
||||
// llgo:link (*SHA224_CTX).Init C.SHA224_Init
|
||||
func (c *SHA224_CTX) Init() c.Int { return 0 }
|
||||
|
||||
// OSSL_DEPRECATEDIN_3_0 int SHA224_Update(SHA256_CTX *c, const void *data, size_t len);
|
||||
//
|
||||
// llgo:link (*SHA224_CTX).Update C.SHA224_Update
|
||||
func (c *SHA224_CTX) Update(data unsafe.Pointer, n uintptr) c.Int { return 0 }
|
||||
|
||||
func (c *SHA224_CTX) UpdateBytes(data []byte) c.Int {
|
||||
return c.Update(unsafe.Pointer(unsafe.SliceData(data)), uintptr(len(data)))
|
||||
}
|
||||
|
||||
func (c *SHA224_CTX) UpdateString(data string) c.Int {
|
||||
return c.Update(unsafe.Pointer(unsafe.StringData(data)), uintptr(len(data)))
|
||||
}
|
||||
|
||||
// OSSL_DEPRECATEDIN_3_0 int SHA224_Final(unsigned char *md, SHA256_CTX *c);
|
||||
//
|
||||
//go:linkname sha224Final C.SHA224_Final
|
||||
func sha224Final(md *byte, c *SHA224_CTX) c.Int
|
||||
|
||||
func (c *SHA224_CTX) Final(md *byte) c.Int {
|
||||
return sha224Final(md, c)
|
||||
}
|
||||
|
||||
// OSSL_DEPRECATEDIN_3_0 int SHA256_Init(SHA256_CTX *c);
|
||||
//
|
||||
// llgo:link (*SHA256_CTX).Init C.SHA256_Init
|
||||
func (c *SHA256_CTX) Init() c.Int { return 0 }
|
||||
|
||||
// OSSL_DEPRECATEDIN_3_0 int SHA256_Update(SHA256_CTX *c, const void *data, size_t len);
|
||||
//
|
||||
// llgo:link (*SHA256_CTX).Update C.SHA256_Update
|
||||
func (c *SHA256_CTX) Update(data unsafe.Pointer, n uintptr) c.Int { return 0 }
|
||||
|
||||
func (c *SHA256_CTX) UpdateBytes(data []byte) c.Int {
|
||||
return c.Update(unsafe.Pointer(unsafe.SliceData(data)), uintptr(len(data)))
|
||||
}
|
||||
|
||||
func (c *SHA256_CTX) UpdateString(data string) c.Int {
|
||||
return c.Update(unsafe.Pointer(unsafe.StringData(data)), uintptr(len(data)))
|
||||
}
|
||||
|
||||
// OSSL_DEPRECATEDIN_3_0 int SHA256_Final(unsigned char *md, SHA256_CTX *c);
|
||||
//
|
||||
//go:linkname sha256Final C.SHA256_Final
|
||||
func sha256Final(md *byte, c *SHA256_CTX) c.Int
|
||||
|
||||
func (c *SHA256_CTX) Final(md *byte) c.Int {
|
||||
return sha256Final(md, c)
|
||||
}
|
||||
|
||||
// OSSL_DEPRECATEDIN_3_0 void SHA256_Transform(SHA256_CTX *c, const unsigned char *data);
|
||||
//
|
||||
// llgo:link (*SHA256_CTX).Transform C.SHA256_Transform
|
||||
func (c *SHA256_CTX) Transform(data *byte) {}
|
||||
|
||||
// unsigned char *SHA224(const unsigned char *d, size_t n, unsigned char *md);
|
||||
//
|
||||
//go:linkname SHA224 C.SHA224
|
||||
func SHA224(data unsafe.Pointer, n uintptr, md *byte) *byte
|
||||
|
||||
func SHA224Bytes(data []byte, md *byte) *byte {
|
||||
return SHA224(unsafe.Pointer(unsafe.SliceData(data)), uintptr(len(data)), md)
|
||||
}
|
||||
|
||||
func SHA224String(data string, md *byte) *byte {
|
||||
return SHA224(unsafe.Pointer(unsafe.StringData(data)), uintptr(len(data)), md)
|
||||
}
|
||||
|
||||
// unsigned char *SHA256(const unsigned char *d, size_t n, unsigned char *md);
|
||||
//
|
||||
//go:linkname SHA256 C.SHA256
|
||||
func SHA256(data unsafe.Pointer, n uintptr, md *byte) *byte
|
||||
|
||||
func SHA256Bytes(data []byte, md *byte) *byte {
|
||||
return SHA256(unsafe.Pointer(unsafe.SliceData(data)), uintptr(len(data)), md)
|
||||
}
|
||||
|
||||
func SHA256String(data string, md *byte) *byte {
|
||||
return SHA256(unsafe.Pointer(unsafe.StringData(data)), uintptr(len(data)), md)
|
||||
}
|
||||
115
runtime/internal/clite/openssl/sha512.go
Normal file
115
runtime/internal/clite/openssl/sha512.go
Normal file
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* Copyright (c) 2024 The GoPlus Authors (goplus.org). All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package openssl
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
c "github.com/goplus/llgo/runtime/internal/clite"
|
||||
)
|
||||
|
||||
type SHA512_CTX struct {
|
||||
H [8]SHA_LONG64
|
||||
N1, Nh SHA_LONG64
|
||||
D [SHA_LBLOCK]SHA_LONG64
|
||||
Num, MdLen c.Uint
|
||||
}
|
||||
|
||||
type SHA384_CTX SHA512_CTX
|
||||
|
||||
// OSSL_DEPRECATEDIN_3_0 int SHA384_Init(SHA512_CTX *c);
|
||||
//
|
||||
// llgo:link (*SHA384_CTX).Init C.SHA384_Init
|
||||
func (c *SHA384_CTX) Init() c.Int { return 0 }
|
||||
|
||||
// OSSL_DEPRECATEDIN_3_0 int SHA384_Update(SHA512_CTX *c, const void *data, size_t len);
|
||||
//
|
||||
// llgo:link (*SHA384_CTX).Update C.SHA384_Update
|
||||
func (c *SHA384_CTX) Update(data unsafe.Pointer, n uintptr) c.Int { return 0 }
|
||||
|
||||
func (c *SHA384_CTX) UpdateBytes(data []byte) c.Int {
|
||||
return c.Update(unsafe.Pointer(unsafe.SliceData(data)), uintptr(len(data)))
|
||||
}
|
||||
|
||||
func (c *SHA384_CTX) UpdateString(data string) c.Int {
|
||||
return c.Update(unsafe.Pointer(unsafe.StringData(data)), uintptr(len(data)))
|
||||
}
|
||||
|
||||
// OSSL_DEPRECATEDIN_3_0 int SHA384_Final(unsigned char *md, SHA512_CTX *c);
|
||||
//
|
||||
//go:linkname sha384Final C.SHA384_Final
|
||||
func sha384Final(md *byte, c *SHA384_CTX) c.Int
|
||||
|
||||
func (c *SHA384_CTX) Final(md *byte) c.Int {
|
||||
return sha384Final(md, c)
|
||||
}
|
||||
|
||||
// OSSL_DEPRECATEDIN_3_0 int SHA512_Init(SHA512_CTX *c);
|
||||
//
|
||||
// llgo:link (*SHA512_CTX).Init C.SHA512_Init
|
||||
func (c *SHA512_CTX) Init() c.Int { return 0 }
|
||||
|
||||
// OSSL_DEPRECATEDIN_3_0 int SHA512_Update(SHA512_CTX *c, const void *data, size_t len);
|
||||
//
|
||||
// llgo:link (*SHA512_CTX).Update C.SHA512_Update
|
||||
func (c *SHA512_CTX) Update(data unsafe.Pointer, n uintptr) c.Int { return 0 }
|
||||
func (c *SHA512_CTX) UpdateBytes(data []byte) c.Int {
|
||||
return c.Update(unsafe.Pointer(unsafe.SliceData(data)), uintptr(len(data)))
|
||||
}
|
||||
func (c *SHA512_CTX) UpdateString(data string) c.Int {
|
||||
return c.Update(unsafe.Pointer(unsafe.StringData(data)), uintptr(len(data)))
|
||||
}
|
||||
|
||||
// OSSL_DEPRECATEDIN_3_0 int SHA512_Final(unsigned char *md, SHA512_CTX *c);
|
||||
//
|
||||
//go:linkname sha512Final C.SHA512_Final
|
||||
func sha512Final(md *byte, c *SHA512_CTX) c.Int
|
||||
|
||||
func (c *SHA512_CTX) Final(md *byte) c.Int {
|
||||
return sha512Final(md, c)
|
||||
}
|
||||
|
||||
// OSSL_DEPRECATEDIN_3_0 void SHA512_Transform(SHA512_CTX *c, const unsigned char *data);
|
||||
//
|
||||
// llgo:link (*SHA512_CTX).Transform C.SHA512_Transform
|
||||
func (c *SHA512_CTX) Transform(data *byte) {}
|
||||
|
||||
// unsigned char *SHA384(const unsigned char *d, size_t n, unsigned char *md);
|
||||
//
|
||||
//go:linkname SHA384 C.SHA384
|
||||
func SHA384(data unsafe.Pointer, n uintptr, md *byte) *byte
|
||||
|
||||
func SHA384Bytes(data []byte, md *byte) *byte {
|
||||
return SHA384(unsafe.Pointer(unsafe.SliceData(data)), uintptr(len(data)), md)
|
||||
}
|
||||
|
||||
func SHA384String(data string, md *byte) *byte {
|
||||
return SHA384(unsafe.Pointer(unsafe.StringData(data)), uintptr(len(data)), md)
|
||||
}
|
||||
|
||||
// unsigned char *SHA512(const unsigned char *d, size_t n, unsigned char *md);
|
||||
//
|
||||
//go:linkname SHA512 C.SHA512
|
||||
func SHA512(data unsafe.Pointer, n uintptr, md *byte) *byte
|
||||
|
||||
func SHA512Bytes(data []byte, md *byte) *byte {
|
||||
return SHA512(unsafe.Pointer(unsafe.SliceData(data)), uintptr(len(data)), md)
|
||||
}
|
||||
|
||||
func SHA512String(data string, md *byte) *byte {
|
||||
return SHA512(unsafe.Pointer(unsafe.StringData(data)), uintptr(len(data)), md)
|
||||
}
|
||||
Reference in New Issue
Block a user