本文整理匯總了Golang中github.com/GoKillers/libsodium-go/support.CheckSize函數的典型用法代碼示例。如果您正苦於以下問題:Golang CheckSize函數的具體用法?Golang CheckSize怎麽用?Golang CheckSize使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了CheckSize函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: CryptoSignVerifyDetached
func CryptoSignVerifyDetached(sig []byte, m []byte, pk []byte) int {
support.CheckSize(sig, CryptoSignBytes(), "signature")
support.CheckSize(pk, CryptoSignPublicKeyBytes(), "public key")
return int(C.crypto_sign_verify_detached(
(*C.uchar)(&sig[0]),
(*C.uchar)(&m[0]),
(C.ulonglong)(len(m)),
(*C.uchar)(&pk[0])))
}
示例2: CryptoBoxBeforeNm
func CryptoBoxBeforeNm(pk []byte, sk []byte) ([]byte, int) {
support.CheckSize(pk, CryptoBoxPublicKeyBytes(), "public key")
support.CheckSize(sk, CryptoBoxSecretKeyBytes(), "sender's secret key")
k := make([]byte, CryptoBoxBeforeNmBytes())
exit := int(C.crypto_box_beforenm(
(*C.uchar)(&k[0]),
(*C.uchar)(&pk[0]),
(*C.uchar)(&sk[0])))
return k, exit
}
示例3: CryptoBoxEasyAfterNm
func CryptoBoxEasyAfterNm(m []byte, n []byte, k []byte) ([]byte, int) {
support.CheckSize(n, CryptoBoxNonceBytes(), "nonce")
support.CheckSize(k, CryptoBoxBeforeNmBytes(), "shared secret key")
c := make([]byte, len(m)+CryptoBoxMacBytes())
exit := int(C.crypto_box_easy_afternm(
(*C.uchar)(&c[0]),
(*C.uchar)(&m[0]),
(C.ulonglong)(len(m)),
(*C.uchar)(&n[0]),
(*C.uchar)(&k[0])))
return c, exit
}
示例4: CryptoBoxOpenAfteNm
func CryptoBoxOpenAfteNm(c []byte, n []byte, k []byte) ([]byte, int) {
support.CheckSize(n, CryptoBoxNonceBytes(), "nonce")
support.CheckSize(k, CryptoBoxBeforeNmBytes(), "shared secret key")
m := make([]byte, len(c))
exit := int(C.crypto_box_afternm(
(*C.uchar)(&m[0]),
(*C.uchar)(&c[0]),
(C.ulonglong)(len(c)),
(*C.uchar)(&n[0]),
(*C.uchar)(&k[0])))
return m, exit
}
示例5: CryptoScalarMult
func CryptoScalarMult(n []byte, p []byte) ([]byte, int) {
support.CheckSize(n, CryptoScalarmultScalarBytes(), "secret key")
support.CheckSize(p, CryptoScalarmultScalarBytes(), "public key")
q := make([]byte, CryptoScalarmultBytes())
var exit C.int
exit = C.crypto_scalarmult(
(*C.uchar)(&q[0]),
(*C.uchar)(&n[0]),
(*C.uchar)(&p[0]))
return q, int(exit)
}
示例6: CryptoSecretBoxOpen
func CryptoSecretBoxOpen(c []byte, n []byte, k []byte) ([]byte, int) {
support.CheckSize(n, CryptoSecretBoxNonceBytes(), "nonce")
support.CheckSize(k, CryptoSecretBoxKeyBytes(), "key")
m := make([]byte, len(c)-CryptoSecretBoxMacBytes())
exit := int(C.crypto_secretbox_open(
(*C.uchar)(&m[0]),
(*C.uchar)(&c[0]),
(C.ulonglong)(len(c)),
(*C.uchar)(&n[0]),
(*C.uchar)(&k[0])))
return m, exit
}
示例7: CryptoSecretBoxEasy
func CryptoSecretBoxEasy(m []byte, n []byte, k []byte) ([]byte, int) {
support.CheckSize(n, CryptoSecretBoxNonceBytes(), "nonce")
support.CheckSize(k, CryptoSecretBoxKeyBytes(), "key")
c := make([]byte, len(m)+CryptoSecretBoxMacBytes())
exit := int(C.crypto_secretbox_easy(
(*C.uchar)(&c[0]),
(*C.uchar)(&m[0]),
(C.ulonglong)(len(m)),
(*C.uchar)(&n[0]),
(*C.uchar)(&k[0])))
return c, exit
}
示例8: CryptoBoxSealOpen
func CryptoBoxSealOpen(c []byte, pk []byte, sk []byte) ([]byte, int) {
support.CheckSize(pk, CryptoBoxPublicKeyBytes(), "public key")
support.CheckSize(sk, CryptoBoxSecretKeyBytes(), "secret key")
m := make([]byte, len(c)-CryptoBoxMacBytes())
exit := int(C.crypto_box_seal_open(
(*C.uchar)(&m[0]),
(*C.uchar)(&c[0]),
(C.ulonglong)(len(c)),
(*C.uchar)(&pk[0]),
(*C.uchar)(&sk[0])))
return m, exit
}
示例9: CryptoBoxEasy
func CryptoBoxEasy(m []byte, n []byte, pk []byte, sk []byte) ([]byte, int) {
support.CheckSize(n, CryptoBoxNonceBytes(), "nonce")
support.CheckSize(pk, CryptoBoxPublicKeyBytes(), "public key")
support.CheckSize(sk, CryptoBoxSecretKeyBytes(), "secret key")
c := make([]byte, len(m)+CryptoBoxMacBytes())
exit := int(C.crypto_box_easy(
(*C.uchar)(&c[0]),
(*C.uchar)(&m[0]),
(C.ulonglong)(len(m)),
(*C.uchar)(&n[0]),
(*C.uchar)(&pk[0]),
(*C.uchar)(&sk[0])))
return c, exit
}
示例10: CryptoBoxOpen
func CryptoBoxOpen(c []byte, n []byte, pk []byte, sk []byte) ([]byte, int) {
support.CheckSize(n, CryptoBoxNonceBytes(), "nonce")
support.CheckSize(pk, CryptoBoxPublicKeyBytes(), "public key")
support.CheckSize(sk, CryptoBoxPublicKeyBytes(), "secret key")
m := make([]byte, len(c))
exit := int(C.crypto_box_open(
(*C.uchar)(&m[0]),
(*C.uchar)(&c[0]),
(C.ulonglong)(len(c)),
(*C.uchar)(&n[0]),
(*C.uchar)(&pk[0]),
(*C.uchar)(&sk[0])))
return m, exit
}
示例11: CryptoBoxSeedKeyPair
func CryptoBoxSeedKeyPair(seed []byte) ([]byte, []byte, int) {
support.CheckSize(seed, CryptoBoxSeedBytes(), "seed")
sk := make([]byte, CryptoBoxSecretKeyBytes())
pk := make([]byte, CryptoBoxPublicKeyBytes())
exit := int(C.crypto_box_seed_keypair(
(*C.uchar)(&pk[0]),
(*C.uchar)(&sk[0]),
(*C.uchar)(&seed[0])))
return sk, pk, exit
}
示例12: CryptoBoxSeal
func CryptoBoxSeal(m []byte, pk []byte) ([]byte, int) {
support.CheckSize(pk, CryptoBoxPublicKeyBytes(), "public key")
c := make([]byte, len(m)+CryptoBoxMacBytes())
exit := int(C.crypto_box_seal(
(*C.uchar)(&c[0]),
(*C.uchar)(&m[0]),
(C.ulonglong)(len(m)),
(*C.uchar)(&pk[0])))
return c, exit
}
示例13: CryptoAuthVerify
func CryptoAuthVerify(hmac []byte, in []byte, key []byte) int {
support.CheckSize(key, CryptoAuthKeyBytes(), "key")
inlen := len(in)
exit := int(C.crypto_auth_verify(
(*C.uchar)(&hmac[0]),
(*C.uchar)(&in[0]),
(C.ulonglong)(inlen),
(*C.uchar)(&key[0])))
return exit
}
示例14: CryptoAuth
func CryptoAuth(in []byte, key []byte) ([]byte, int) {
support.CheckSize(key, CryptoAuthKeyBytes(), "key")
inlen := len(in)
out := make([]byte, inlen+CryptoAuthBytes())
exit := int(C.crypto_auth(
(*C.uchar)(&out[0]),
(*C.uchar)(&in[0]),
(C.ulonglong)(inlen),
(*C.uchar)(&key[0])))
return out, exit
}
示例15: CryptoSignDetached
func CryptoSignDetached(m []byte, sk []byte) ([]byte, int) {
support.CheckSize(sk, CryptoSignSecretKeyBytes(), "secret key")
sig := make([]byte, CryptoSignBytes())
var actualSigSize C.ulonglong
exit := int(C.crypto_sign_detached(
(*C.uchar)(&sig[0]),
(&actualSigSize),
(*C.uchar)(&m[0]),
(C.ulonglong)(len(m)),
(*C.uchar)(&sk[0])))
return sig[:actualSigSize], exit
}