mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-06-16 09:53:39 +08:00
Add license text
This commit is contained in:
@@ -1,3 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2017 - 2018 The GmSSL Project. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* 3. All advertising materials mentioning features or use of this
|
||||||
|
* software must display the following acknowledgment:
|
||||||
|
* "This product includes software developed by the GmSSL Project.
|
||||||
|
* (http://gmssl.org/)"
|
||||||
|
*
|
||||||
|
* 4. The name "GmSSL Project" must not be used to endorse or promote
|
||||||
|
* products derived from this software without prior written
|
||||||
|
* permission. For written permission, please contact
|
||||||
|
* guanzhi1980@gmail.com.
|
||||||
|
*
|
||||||
|
* 5. Products derived from this software may not be called "GmSSL"
|
||||||
|
* nor may "GmSSL" appear in their names without prior written
|
||||||
|
* permission of the GmSSL Project.
|
||||||
|
*
|
||||||
|
* 6. Redistributions of any form whatsoever must retain the following
|
||||||
|
* acknowledgment:
|
||||||
|
* "This product includes software developed by the GmSSL Project
|
||||||
|
* (http://gmssl.org/)"
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE GmSSL PROJECT ``AS IS'' AND ANY
|
||||||
|
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE GmSSL PROJECT OR
|
||||||
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||||
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||||
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
/* +build cgo */
|
/* +build cgo */
|
||||||
|
|
||||||
package gmssl
|
package gmssl
|
||||||
|
|||||||
@@ -1,3 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2017 - 2018 The GmSSL Project. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* 3. All advertising materials mentioning features or use of this
|
||||||
|
* software must display the following acknowledgment:
|
||||||
|
* "This product includes software developed by the GmSSL Project.
|
||||||
|
* (http://gmssl.org/)"
|
||||||
|
*
|
||||||
|
* 4. The name "GmSSL Project" must not be used to endorse or promote
|
||||||
|
* products derived from this software without prior written
|
||||||
|
* permission. For written permission, please contact
|
||||||
|
* guanzhi1980@gmail.com.
|
||||||
|
*
|
||||||
|
* 5. Products derived from this software may not be called "GmSSL"
|
||||||
|
* nor may "GmSSL" appear in their names without prior written
|
||||||
|
* permission of the GmSSL Project.
|
||||||
|
*
|
||||||
|
* 6. Redistributions of any form whatsoever must retain the following
|
||||||
|
* acknowledgment:
|
||||||
|
* "This product includes software developed by the GmSSL Project
|
||||||
|
* (http://gmssl.org/)"
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE GmSSL PROJECT ``AS IS'' AND ANY
|
||||||
|
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE GmSSL PROJECT OR
|
||||||
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||||
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||||
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
/* +build cgo */
|
/* +build cgo */
|
||||||
package gmssl
|
package gmssl
|
||||||
|
|
||||||
@@ -110,7 +158,20 @@ func (cert *Certificate) GetPublicKey() (*PublicKey, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (cert *Certificate) GetText() (string, error) {
|
func (cert *Certificate) GetText() (string, error) {
|
||||||
return "", nil
|
bio := C.BIO_new(C.BIO_s_mem())
|
||||||
|
if bio == nil {
|
||||||
|
return "", GetErrors()
|
||||||
|
}
|
||||||
|
defer C.BIO_free(bio)
|
||||||
|
if 0 >= C.X509_print(bio, cert.x509) {
|
||||||
|
return "", GetErrors()
|
||||||
|
}
|
||||||
|
var p *C.char
|
||||||
|
len := C._BIO_get_mem_data(bio, &p)
|
||||||
|
if len <= 0 {
|
||||||
|
return "", GetErrors()
|
||||||
|
}
|
||||||
|
return C.GoString(p)[:len], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cert *Certificate) CheckPrivateKey(skey *PrivateKey) error {
|
func (cert *Certificate) CheckPrivateKey(skey *PrivateKey) error {
|
||||||
|
|||||||
@@ -1,3 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2017 - 2018 The GmSSL Project. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* 3. All advertising materials mentioning features or use of this
|
||||||
|
* software must display the following acknowledgment:
|
||||||
|
* "This product includes software developed by the GmSSL Project.
|
||||||
|
* (http://gmssl.org/)"
|
||||||
|
*
|
||||||
|
* 4. The name "GmSSL Project" must not be used to endorse or promote
|
||||||
|
* products derived from this software without prior written
|
||||||
|
* permission. For written permission, please contact
|
||||||
|
* guanzhi1980@gmail.com.
|
||||||
|
*
|
||||||
|
* 5. Products derived from this software may not be called "GmSSL"
|
||||||
|
* nor may "GmSSL" appear in their names without prior written
|
||||||
|
* permission of the GmSSL Project.
|
||||||
|
*
|
||||||
|
* 6. Redistributions of any form whatsoever must retain the following
|
||||||
|
* acknowledgment:
|
||||||
|
* "This product includes software developed by the GmSSL Project
|
||||||
|
* (http://gmssl.org/)"
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE GmSSL PROJECT ``AS IS'' AND ANY
|
||||||
|
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE GmSSL PROJECT OR
|
||||||
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||||
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||||
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
/* +build cgo */
|
/* +build cgo */
|
||||||
package gmssl
|
package gmssl
|
||||||
|
|
||||||
@@ -87,22 +135,18 @@ type CipherContext struct {
|
|||||||
|
|
||||||
func NewCipherContext(name string, key, iv []byte, encrypt bool) (
|
func NewCipherContext(name string, key, iv []byte, encrypt bool) (
|
||||||
*CipherContext, error) {
|
*CipherContext, error) {
|
||||||
|
|
||||||
cname := C.CString(name)
|
cname := C.CString(name)
|
||||||
defer C.free(unsafe.Pointer(cname))
|
defer C.free(unsafe.Pointer(cname))
|
||||||
|
|
||||||
cipher := C.EVP_get_cipherbyname(cname)
|
cipher := C.EVP_get_cipherbyname(cname)
|
||||||
if cipher == nil {
|
if cipher == nil {
|
||||||
return nil, GetErrors()
|
return nil, GetErrors()
|
||||||
}
|
}
|
||||||
|
|
||||||
if key == nil {
|
if key == nil {
|
||||||
return nil, errors.New("No key")
|
return nil, errors.New("No key")
|
||||||
}
|
}
|
||||||
if len(key) != int(C.EVP_CIPHER_key_length(cipher)) {
|
if len(key) != int(C.EVP_CIPHER_key_length(cipher)) {
|
||||||
return nil, errors.New("Invalid key length")
|
return nil, errors.New("Invalid key length")
|
||||||
}
|
}
|
||||||
|
|
||||||
if 0 != int(C.EVP_CIPHER_iv_length(cipher)) {
|
if 0 != int(C.EVP_CIPHER_iv_length(cipher)) {
|
||||||
if iv == nil {
|
if iv == nil {
|
||||||
return nil, errors.New("No IV")
|
return nil, errors.New("No IV")
|
||||||
@@ -111,27 +155,22 @@ func NewCipherContext(name string, key, iv []byte, encrypt bool) (
|
|||||||
return nil, errors.New("Invalid IV")
|
return nil, errors.New("Invalid IV")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx := C.EVP_CIPHER_CTX_new()
|
ctx := C.EVP_CIPHER_CTX_new()
|
||||||
if ctx == nil {
|
if ctx == nil {
|
||||||
return nil, GetErrors()
|
return nil, GetErrors()
|
||||||
}
|
}
|
||||||
|
|
||||||
ret := &CipherContext{ctx}
|
ret := &CipherContext{ctx}
|
||||||
runtime.SetFinalizer(ret, func(ret *CipherContext) {
|
runtime.SetFinalizer(ret, func(ret *CipherContext) {
|
||||||
C.EVP_CIPHER_CTX_free(ret.ctx)
|
C.EVP_CIPHER_CTX_free(ret.ctx)
|
||||||
})
|
})
|
||||||
|
|
||||||
enc := 1
|
enc := 1
|
||||||
if encrypt == false {
|
if encrypt == false {
|
||||||
enc = 0
|
enc = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
if 1 != C.EVP_CipherInit(ctx, cipher, (*C.uchar)(&key[0]),
|
if 1 != C.EVP_CipherInit(ctx, cipher, (*C.uchar)(&key[0]),
|
||||||
(*C.uchar)(&iv[0]), C.int(enc)) {
|
(*C.uchar)(&iv[0]), C.int(enc)) {
|
||||||
return nil, GetErrors()
|
return nil, GetErrors()
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2017 - 2018 The GmSSL Project. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* 3. All advertising materials mentioning features or use of this
|
||||||
|
* software must display the following acknowledgment:
|
||||||
|
* "This product includes software developed by the GmSSL Project.
|
||||||
|
* (http://gmssl.org/)"
|
||||||
|
*
|
||||||
|
* 4. The name "GmSSL Project" must not be used to endorse or promote
|
||||||
|
* products derived from this software without prior written
|
||||||
|
* permission. For written permission, please contact
|
||||||
|
* guanzhi1980@gmail.com.
|
||||||
|
*
|
||||||
|
* 5. Products derived from this software may not be called "GmSSL"
|
||||||
|
* nor may "GmSSL" appear in their names without prior written
|
||||||
|
* permission of the GmSSL Project.
|
||||||
|
*
|
||||||
|
* 6. Redistributions of any form whatsoever must retain the following
|
||||||
|
* acknowledgment:
|
||||||
|
* "This product includes software developed by the GmSSL Project
|
||||||
|
* (http://gmssl.org/)"
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE GmSSL PROJECT ``AS IS'' AND ANY
|
||||||
|
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE GmSSL PROJECT OR
|
||||||
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||||
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||||
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
/* +build cgo */
|
/* +build cgo */
|
||||||
|
|
||||||
package gmssl
|
package gmssl
|
||||||
@@ -102,7 +150,8 @@ func (ctx *DigestContext) Update(data []byte) error {
|
|||||||
if len(data) == 0 {
|
if len(data) == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if 1 != C.EVP_DigestUpdate(ctx.ctx, unsafe.Pointer(&data[0]), C.size_t(len(data))) {
|
if 1 != C.EVP_DigestUpdate(ctx.ctx, unsafe.Pointer(&data[0]),
|
||||||
|
C.size_t(len(data))) {
|
||||||
return GetErrors()
|
return GetErrors()
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@@ -111,7 +160,8 @@ func (ctx *DigestContext) Update(data []byte) error {
|
|||||||
func (ctx *DigestContext) Final() ([]byte, error) {
|
func (ctx *DigestContext) Final() ([]byte, error) {
|
||||||
outbuf := make([]byte, 64)
|
outbuf := make([]byte, 64)
|
||||||
outlen := C.uint(len(outbuf))
|
outlen := C.uint(len(outbuf))
|
||||||
if 1 != C.EVP_DigestFinal_ex(ctx.ctx, (*C.uchar)(unsafe.Pointer(&outbuf[0])), &outlen) {
|
if 1 != C.EVP_DigestFinal_ex(ctx.ctx,
|
||||||
|
(*C.uchar)(unsafe.Pointer(&outbuf[0])), &outlen) {
|
||||||
return nil, GetErrors()
|
return nil, GetErrors()
|
||||||
}
|
}
|
||||||
return outbuf[:outlen], nil
|
return outbuf[:outlen], nil
|
||||||
@@ -120,7 +170,7 @@ func (ctx *DigestContext) Final() ([]byte, error) {
|
|||||||
func (ctx *DigestContext) Reset() error {
|
func (ctx *DigestContext) Reset() error {
|
||||||
md := C.EVP_MD_CTX_md(ctx.ctx)
|
md := C.EVP_MD_CTX_md(ctx.ctx)
|
||||||
if md == nil {
|
if md == nil {
|
||||||
return GetErrors()
|
return GetErrors() //FIXME: return some errors
|
||||||
}
|
}
|
||||||
if 1 != C.EVP_DigestInit_ex(ctx.ctx, md, nil) {
|
if 1 != C.EVP_DigestInit_ex(ctx.ctx, md, nil) {
|
||||||
return GetErrors()
|
return GetErrors()
|
||||||
|
|||||||
@@ -1,3 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2017 - 2018 The GmSSL Project. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* 3. All advertising materials mentioning features or use of this
|
||||||
|
* software must display the following acknowledgment:
|
||||||
|
* "This product includes software developed by the GmSSL Project.
|
||||||
|
* (http://gmssl.org/)"
|
||||||
|
*
|
||||||
|
* 4. The name "GmSSL Project" must not be used to endorse or promote
|
||||||
|
* products derived from this software without prior written
|
||||||
|
* permission. For written permission, please contact
|
||||||
|
* guanzhi1980@gmail.com.
|
||||||
|
*
|
||||||
|
* 5. Products derived from this software may not be called "GmSSL"
|
||||||
|
* nor may "GmSSL" appear in their names without prior written
|
||||||
|
* permission of the GmSSL Project.
|
||||||
|
*
|
||||||
|
* 6. Redistributions of any form whatsoever must retain the following
|
||||||
|
* acknowledgment:
|
||||||
|
* "This product includes software developed by the GmSSL Project
|
||||||
|
* (http://gmssl.org/)"
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE GmSSL PROJECT ``AS IS'' AND ANY
|
||||||
|
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE GmSSL PROJECT OR
|
||||||
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||||
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||||
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
/* +build cgo */
|
/* +build cgo */
|
||||||
package gmssl
|
package gmssl
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2017 - 2018 The GmSSL Project. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* 3. All advertising materials mentioning features or use of this
|
||||||
|
* software must display the following acknowledgment:
|
||||||
|
* "This product includes software developed by the GmSSL Project.
|
||||||
|
* (http://gmssl.org/)"
|
||||||
|
*
|
||||||
|
* 4. The name "GmSSL Project" must not be used to endorse or promote
|
||||||
|
* products derived from this software without prior written
|
||||||
|
* permission. For written permission, please contact
|
||||||
|
* guanzhi1980@gmail.com.
|
||||||
|
*
|
||||||
|
* 5. Products derived from this software may not be called "GmSSL"
|
||||||
|
* nor may "GmSSL" appear in their names without prior written
|
||||||
|
* permission of the GmSSL Project.
|
||||||
|
*
|
||||||
|
* 6. Redistributions of any form whatsoever must retain the following
|
||||||
|
* acknowledgment:
|
||||||
|
* "This product includes software developed by the GmSSL Project
|
||||||
|
* (http://gmssl.org/)"
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE GmSSL PROJECT ``AS IS'' AND ANY
|
||||||
|
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE GmSSL PROJECT OR
|
||||||
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||||
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||||
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
/* +build cgo */
|
/* +build cgo */
|
||||||
package gmssl
|
package gmssl
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2017 - 2018 The GmSSL Project. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* 3. All advertising materials mentioning features or use of this
|
||||||
|
* software must display the following acknowledgment:
|
||||||
|
* "This product includes software developed by the GmSSL Project.
|
||||||
|
* (http://gmssl.org/)"
|
||||||
|
*
|
||||||
|
* 4. The name "GmSSL Project" must not be used to endorse or promote
|
||||||
|
* products derived from this software without prior written
|
||||||
|
* permission. For written permission, please contact
|
||||||
|
* guanzhi1980@gmail.com.
|
||||||
|
*
|
||||||
|
* 5. Products derived from this software may not be called "GmSSL"
|
||||||
|
* nor may "GmSSL" appear in their names without prior written
|
||||||
|
* permission of the GmSSL Project.
|
||||||
|
*
|
||||||
|
* 6. Redistributions of any form whatsoever must retain the following
|
||||||
|
* acknowledgment:
|
||||||
|
* "This product includes software developed by the GmSSL Project
|
||||||
|
* (http://gmssl.org/)"
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE GmSSL PROJECT ``AS IS'' AND ANY
|
||||||
|
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE GmSSL PROJECT OR
|
||||||
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||||
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||||
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
/* +build cgo */
|
/* +build cgo */
|
||||||
|
|
||||||
package gmssl
|
package gmssl
|
||||||
|
|||||||
@@ -1,3 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2017 - 2018 The GmSSL Project. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* 3. All advertising materials mentioning features or use of this
|
||||||
|
* software must display the following acknowledgment:
|
||||||
|
* "This product includes software developed by the GmSSL Project.
|
||||||
|
* (http://gmssl.org/)"
|
||||||
|
*
|
||||||
|
* 4. The name "GmSSL Project" must not be used to endorse or promote
|
||||||
|
* products derived from this software without prior written
|
||||||
|
* permission. For written permission, please contact
|
||||||
|
* guanzhi1980@gmail.com.
|
||||||
|
*
|
||||||
|
* 5. Products derived from this software may not be called "GmSSL"
|
||||||
|
* nor may "GmSSL" appear in their names without prior written
|
||||||
|
* permission of the GmSSL Project.
|
||||||
|
*
|
||||||
|
* 6. Redistributions of any form whatsoever must retain the following
|
||||||
|
* acknowledgment:
|
||||||
|
* "This product includes software developed by the GmSSL Project
|
||||||
|
* (http://gmssl.org/)"
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE GmSSL PROJECT ``AS IS'' AND ANY
|
||||||
|
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE GmSSL PROJECT OR
|
||||||
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||||
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||||
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
/* +build cgo */
|
/* +build cgo */
|
||||||
package gmssl
|
package gmssl
|
||||||
|
|
||||||
@@ -764,6 +812,7 @@ func (sk *PrivateKey) GetText() (string, error) {
|
|||||||
return "", GetErrors()
|
return "", GetErrors()
|
||||||
}
|
}
|
||||||
defer C.BIO_free(bio)
|
defer C.BIO_free(bio)
|
||||||
|
/* FIMME: some times this will failed */
|
||||||
if 1 != C.EVP_PKEY_print_private(bio, sk.pkey, 0, nil) {
|
if 1 != C.EVP_PKEY_print_private(bio, sk.pkey, 0, nil) {
|
||||||
return "", GetErrors()
|
return "", GetErrors()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2017 - 2018 The GmSSL Project. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* 3. All advertising materials mentioning features or use of this
|
||||||
|
* software must display the following acknowledgment:
|
||||||
|
* "This product includes software developed by the GmSSL Project.
|
||||||
|
* (http://gmssl.org/)"
|
||||||
|
*
|
||||||
|
* 4. The name "GmSSL Project" must not be used to endorse or promote
|
||||||
|
* products derived from this software without prior written
|
||||||
|
* permission. For written permission, please contact
|
||||||
|
* guanzhi1980@gmail.com.
|
||||||
|
*
|
||||||
|
* 5. Products derived from this software may not be called "GmSSL"
|
||||||
|
* nor may "GmSSL" appear in their names without prior written
|
||||||
|
* permission of the GmSSL Project.
|
||||||
|
*
|
||||||
|
* 6. Redistributions of any form whatsoever must retain the following
|
||||||
|
* acknowledgment:
|
||||||
|
* "This product includes software developed by the GmSSL Project
|
||||||
|
* (http://gmssl.org/)"
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE GmSSL PROJECT ``AS IS'' AND ANY
|
||||||
|
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE GmSSL PROJECT OR
|
||||||
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||||
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||||
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
/* +build cgo */
|
/* +build cgo */
|
||||||
package gmssl
|
package gmssl
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2017 - 2018 The GmSSL Project. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* 3. All advertising materials mentioning features or use of this
|
||||||
|
* software must display the following acknowledgment:
|
||||||
|
* "This product includes software developed by the GmSSL Project.
|
||||||
|
* (http://gmssl.org/)"
|
||||||
|
*
|
||||||
|
* 4. The name "GmSSL Project" must not be used to endorse or promote
|
||||||
|
* products derived from this software without prior written
|
||||||
|
* permission. For written permission, please contact
|
||||||
|
* guanzhi1980@gmail.com.
|
||||||
|
*
|
||||||
|
* 5. Products derived from this software may not be called "GmSSL"
|
||||||
|
* nor may "GmSSL" appear in their names without prior written
|
||||||
|
* permission of the GmSSL Project.
|
||||||
|
*
|
||||||
|
* 6. Redistributions of any form whatsoever must retain the following
|
||||||
|
* acknowledgment:
|
||||||
|
* "This product includes software developed by the GmSSL Project
|
||||||
|
* (http://gmssl.org/)"
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE GmSSL PROJECT ``AS IS'' AND ANY
|
||||||
|
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE GmSSL PROJECT OR
|
||||||
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||||
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||||
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
package sm3
|
package sm3
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -1,3 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2017 - 2018 The GmSSL Project. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* 3. All advertising materials mentioning features or use of this
|
||||||
|
* software must display the following acknowledgment:
|
||||||
|
* "This product includes software developed by the GmSSL Project.
|
||||||
|
* (http://gmssl.org/)"
|
||||||
|
*
|
||||||
|
* 4. The name "GmSSL Project" must not be used to endorse or promote
|
||||||
|
* products derived from this software without prior written
|
||||||
|
* permission. For written permission, please contact
|
||||||
|
* guanzhi1980@gmail.com.
|
||||||
|
*
|
||||||
|
* 5. Products derived from this software may not be called "GmSSL"
|
||||||
|
* nor may "GmSSL" appear in their names without prior written
|
||||||
|
* permission of the GmSSL Project.
|
||||||
|
*
|
||||||
|
* 6. Redistributions of any form whatsoever must retain the following
|
||||||
|
* acknowledgment:
|
||||||
|
* "This product includes software developed by the GmSSL Project
|
||||||
|
* (http://gmssl.org/)"
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE GmSSL PROJECT ``AS IS'' AND ANY
|
||||||
|
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE GmSSL PROJECT OR
|
||||||
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||||
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||||
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
/* +build cgo */
|
/* +build cgo */
|
||||||
package gmssl
|
package gmssl
|
||||||
|
|
||||||
@@ -8,7 +56,7 @@ import "C"
|
|||||||
|
|
||||||
func GetVersions() []string {
|
func GetVersions() []string {
|
||||||
versions := []string {
|
versions := []string {
|
||||||
"GmSSL Go API 1.3 Aug 6 2018",
|
"GmSSL Go API 1.4 Aug 7 2018",
|
||||||
C.GoString(C.OpenSSL_version(C.OPENSSL_VERSION)),
|
C.GoString(C.OpenSSL_version(C.OPENSSL_VERSION)),
|
||||||
C.GoString(C.OpenSSL_version(C.OPENSSL_BUILT_ON)),
|
C.GoString(C.OpenSSL_version(C.OPENSSL_BUILT_ON)),
|
||||||
C.GoString(C.OpenSSL_version(C.OPENSSL_CFLAGS)),
|
C.GoString(C.OpenSSL_version(C.OPENSSL_CFLAGS)),
|
||||||
|
|||||||
@@ -1,3 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2017 - 2018 The GmSSL Project. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* 3. All advertising materials mentioning features or use of this
|
||||||
|
* software must display the following acknowledgment:
|
||||||
|
* "This product includes software developed by the GmSSL Project.
|
||||||
|
* (http://gmssl.org/)"
|
||||||
|
*
|
||||||
|
* 4. The name "GmSSL Project" must not be used to endorse or promote
|
||||||
|
* products derived from this software without prior written
|
||||||
|
* permission. For written permission, please contact
|
||||||
|
* guanzhi1980@gmail.com.
|
||||||
|
*
|
||||||
|
* 5. Products derived from this software may not be called "GmSSL"
|
||||||
|
* nor may "GmSSL" appear in their names without prior written
|
||||||
|
* permission of the GmSSL Project.
|
||||||
|
*
|
||||||
|
* 6. Redistributions of any form whatsoever must retain the following
|
||||||
|
* acknowledgment:
|
||||||
|
* "This product includes software developed by the GmSSL Project
|
||||||
|
* (http://gmssl.org/)"
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE GmSSL PROJECT ``AS IS'' AND ANY
|
||||||
|
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE GmSSL PROJECT OR
|
||||||
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||||
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||||
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -171,4 +219,33 @@ func main() {
|
|||||||
fmt.Println("SM2 encryption/decryption failure")
|
fmt.Println("SM2 encryption/decryption failure")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Certificate */
|
||||||
|
certpem := `-----BEGIN CERTIFICATE-----
|
||||||
|
MIICAjCCAaigAwIBAgIBATAKBggqgRzPVQGDdTBSMQswCQYDVQQGEwJDTjELMAkG
|
||||||
|
A1UECAwCQkoxCzAJBgNVBAcMAkJKMQwwCgYDVQQKDANQS1UxCzAJBgNVBAsMAkNB
|
||||||
|
MQ4wDAYDVQQDDAVQS1VDQTAeFw0xNzA2MDEwMDAwMDBaFw0yMDA2MDEwMDAwMDBa
|
||||||
|
MEYxCzAJBgNVBAYTAkNOMQswCQYDVQQIDAJCSjEMMAoGA1UECgwDUEtVMQswCQYD
|
||||||
|
VQQLDAJDQTEPMA0GA1UEAwwGYW50c3NzMFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0D
|
||||||
|
QgAEHpXtrYNlwesl7IyPuaHKKHqn4rHBk+tCU0l0T+zuBNMHAOJzKNDbobno6gOI
|
||||||
|
EQlVfC9q9uk9lO174GJsMLWJJqN7MHkwCQYDVR0TBAIwADAsBglghkgBhvhCAQ0E
|
||||||
|
HxYdT3BlblNTTCBHZW5lcmF0ZWQgQ2VydGlmaWNhdGUwHQYDVR0OBBYEFJsrRYOA
|
||||||
|
J8gpNq0KK6yuh/Dv9SjaMB8GA1UdIwQYMBaAFH1Dhf9CqQQYHF/8euzcPROIzn0r
|
||||||
|
MAoGCCqBHM9VAYN1A0gAMEUCIQCjrQ2nyiPqod/gZdj5X1+WW4fGtyqXvXLL3lOF
|
||||||
|
31nA/gIgZOpHLnvkyggY9VFfEQVp+8t6kewSfxb4eOImSu+dZcE=
|
||||||
|
-----END CERTIFICATE-----`
|
||||||
|
|
||||||
|
cert, _ := gmssl.NewCertificateFromPEM(certpem, "")
|
||||||
|
subject, _ := cert.GetSubject()
|
||||||
|
issuer, _ := cert.GetIssuer()
|
||||||
|
serial, _ := cert.GetSerialNumber()
|
||||||
|
certpk, _ := cert.GetPublicKey()
|
||||||
|
certpktxt, _ := certpk.GetText()
|
||||||
|
certtxt, _ := cert.GetText()
|
||||||
|
|
||||||
|
fmt.Println("Certificate:")
|
||||||
|
fmt.Printf(" Subject = %s\n", subject)
|
||||||
|
fmt.Printf(" Issuer = %s \n", issuer)
|
||||||
|
fmt.Printf(" Serial Number = %s\n", serial)
|
||||||
|
fmt.Println(certpktxt)
|
||||||
|
fmt.Println(certtxt)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user