• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang support.CheckSize函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/redragonx/GoSodium/sodium/support.CheckSize函数的典型用法代码示例。如果您正苦于以下问题:Golang CheckSize函数的具体用法?Golang CheckSize怎么用?Golang CheckSize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了CheckSize函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: BoxBeforeNm

// BoxBeforeNm is the first have of the box operation and generates a unique key per
// public, secret key pair (recipient, sender). The key is returned in KeyOut which can
// then be pssed to BoxAfterNm or BoxOpenAfterNm. The same key can be used for all messages between
// the same recipient/sender (same key pairs) provided that a unique nonce is used each time.
// This function is an optimization as it allows the shared key to be generated once for
// multiple messages.
//
// Returns 0 on sucess, non-zero result on error.
func BoxBeforeNm(keyOut []byte, pk, sk []byte) int {
	support.CheckSize(keyOut, BoxBeforeNmBytes(), "key output")
	support.CheckSize(pk, BoxPublicKeyBytes(), "public key")
	support.CheckSize(sk, BoxSecretKeyBytes(), "secret key")

	return int(C.crypto_box_beforenm((*C.uchar)(&keyOut[0]), (*C.uchar)(&pk[0]), (*C.uchar)(&sk[0])))
}
开发者ID:alanfairless,项目名称:GoSodium,代码行数:15,代码来源:cryptobox.go


示例2: BoxSeedKeyPair

func BoxSeedKeyPair(pkOut []byte, skOut []byte, seed []byte) int {
	support.CheckSize(pkOut, BoxPublicKeyBytes(), "public key")
	support.CheckSize(skOut, BoxSecretKeyBytes(), "secret key")
	support.CheckSize(seed, BoxSeedBytes(), "seed")

	return int(C.crypto_box_seed_keypair((*C.uchar)(&pkOut[0]), (*C.uchar)(&skOut[0]), (*C.uchar)(&seed[0])))
}
开发者ID:alanfairless,项目名称:GoSodium,代码行数:7,代码来源:cryptobox.go


示例3: SignEd25519SKToCurve25519

func SignEd25519SKToCurve25519(curve25519SK []byte, ed25519SK []byte) int {
	support.CheckSize(curve25519SK, scalarmult.ScalarMultBytes(), "curve25519 secret key output")
	support.CheckSize(ed25519SK, SignSecretKeyBytes(), "ed25519 secret key")

	return int(C.crypto_sign_ed25519_sk_to_curve25519(
		(*C.uchar)(&curve25519SK[0]), (*C.uchar)(&ed25519SK[0])))
}
开发者ID:alanfairless,项目名称:GoSodium,代码行数:7,代码来源:cryptosign.go


示例4: SignEd25519PKToCurve25519

func SignEd25519PKToCurve25519(curve25519PK []byte, ed25519PK []byte) int {
	support.CheckSize(curve25519PK, scalarmult.ScalarMultBytes(), "curve25519 public key output")
	support.CheckSize(ed25519PK, SignPublicKeyBytes(), "ed25519 public key")

	return int(C.crypto_sign_ed25519_pk_to_curve25519(
		(*C.uchar)(&curve25519PK[0]), (*C.uchar)(&ed25519PK[0])))
}
开发者ID:alanfairless,项目名称:GoSodium,代码行数:7,代码来源:cryptosign.go


示例5: SignEd25519SKToSeed

func SignEd25519SKToSeed(seed []byte, sk []byte) int {
	support.CheckSize(seed, SignSeedBytes(), "seed output")
	support.CheckSize(sk, SignSecretKeyBytes(), "secret key")

	return int(C.crypto_sign_ed25519_sk_to_seed(
		(*C.uchar)(&seed[0]), (*C.uchar)(&sk[0])))
}
开发者ID:alanfairless,项目名称:GoSodium,代码行数:7,代码来源:cryptosign.go


示例6: SignEd25519SKToPK

func SignEd25519SKToPK(pkOut []byte, sk []byte) int {
	support.CheckSize(pkOut, SignPublicKeyBytes(), "public key output")
	support.CheckSize(sk, SignSecretKeyBytes(), "secret key")

	return int(C.crypto_sign_ed25519_sk_to_pk(
		(*C.uchar)(&pkOut[0]), (*C.uchar)(&sk[0])))
}
开发者ID:alanfairless,项目名称:GoSodium,代码行数:7,代码来源:cryptosign.go


示例7: OneTimeAuth

// OneTimeAuth computes a message authentication code (MAC) for the given input buffer and writes
// it to 'out'. 'out' must be a []byte of OneTimeAuthBytes() bytes. 'key' must not be used with
// any other messages.
//
// Returns: 0
// TODO: Can this ever return non-zero? If not should not return a value.
func OneTimeAuth(macOut []byte, message []byte, key []byte) int {
	support.CheckSize(macOut, OneTimeAuthBytes(), "MAC output buffer")
	support.CheckSize(key, OneTimeAuthKeyBytes(), "key")

	return int(C.crypto_onetimeauth(
		(*C.uchar)(&macOut[0]),
		(*C.uchar)(&message[0]), (C.ulonglong)(len(message)),
		(*C.uchar)(&key[0])))
}
开发者ID:alanfairless,项目名称:GoSodium,代码行数:15,代码来源:onetimeauth.go


示例8: OneTimeAuthVerify

// OneTimeAuthVerify verifies a message authentication code (MAC) for a given message and key.
//
// Returns: 0 if the MAC authenticates the message, -1 if not.
func OneTimeAuthVerify(mac, message, key []byte) int {
	support.CheckSize(mac, OneTimeAuthBytes(), "MAC")
	support.CheckSize(key, OneTimeAuthKeyBytes(), "key")

	return int(C.crypto_onetimeauth_verify(
		(*C.uchar)(&mac[0]),
		(*C.uchar)(&message[0]), (C.ulonglong)(len(message)),
		(*C.uchar)(&key[0])))
}
开发者ID:alanfairless,项目名称:GoSodium,代码行数:12,代码来源:onetimeauth.go


示例9: BoxAfterNm

func BoxAfterNm(cypherTextOut []byte, message []byte, nonce, key []byte) int {
	support.CheckSize(cypherTextOut, len(message), "cypher text output")
	support.CheckSize(nonce, BoxNonceBytes(), "nonce")
	support.CheckSize(key, BoxBeforeNmBytes(), "intermediate key")

	return int(C.crypto_box_afternm((*C.uchar)(&cypherTextOut[0]),
		(*C.uchar)(&message[0]), (C.ulonglong)(len(message)),
		(*C.uchar)(&nonce[0]),
		(*C.uchar)(&key[0])))
}
开发者ID:alanfairless,项目名称:GoSodium,代码行数:10,代码来源:cryptobox.go


示例10: SignOpen

func SignOpen(messageOut []byte, sealedMessage []byte, pk []byte) int {
	support.CheckSize(messageOut, len(sealedMessage)-SignBytes(), "message output")
	support.CheckSize(pk, SignPublicKeyBytes(), "public key")

	lenMessageOut := (C.ulonglong)(len(messageOut))

	return int(C.crypto_sign_open(
		(*C.uchar)(&messageOut[0]), (*C.ulonglong)(&lenMessageOut),
		(*C.uchar)(&sealedMessage[0]), (C.ulonglong)(len(sealedMessage)),
		(*C.uchar)(&pk[0])))
}
开发者ID:alanfairless,项目名称:GoSodium,代码行数:11,代码来源:cryptosign.go


示例11: boxSeal

func boxSeal(cipherTextOut []byte, message []byte, pk []byte) int {
	support.CheckSize(cipherTextOut, BoxMacBytes()+len(message), "cypher text output")
	support.CheckSize(pk, BoxPublicKeyBytes(), "public key")

	return int(C.crypto_box_seal(
		(*C.uchar)(&cipherTextOut[0]),
		(*C.uchar)(&message[0]),
		(C.ulonglong)(len(message)),
		(*C.uchar)(&pk[0])))

}
开发者ID:alanfairless,项目名称:GoSodium,代码行数:11,代码来源:cryptoboxseal.go


示例12: SecretBoxOpen

// SecretBoxOpen opens the authenticated cypher text produced by SecretBox and returns the original
// message plain text. The cypher text is authenticated prior to decryption to ensure it has not
// been modified from the original. The messageOut buffer must be the same size as the cypherText
// buffer and will be padded with SecretBoxZeroBytes() worth of leading zero bytes.
//
// Returns: 0 on success, non-zero on failure
func SecretBoxOpen(messageOut, cypherText, nonce, key []byte) int {
	support.CheckSize(messageOut, len(cypherText), "message output")
	support.CheckSize(nonce, SecretBoxNonceBytes(), "nonce")
	support.CheckSize(key, SecretBoxKeyBytes(), "key")

	return int(C.crypto_secretbox_open(
		(*C.uchar)(&messageOut[0]),
		(*C.uchar)(&cypherText[0]), (C.ulonglong)(len(cypherText)),
		(*C.uchar)(&nonce[0]),
		(*C.uchar)(&key[0])))
}
开发者ID:alanfairless,项目名称:GoSodium,代码行数:17,代码来源:secretbox.go


示例13: SecretBox

// SecretBox takes a message buffer, a random nonce, and a key and writes the encrypted, authenticated
// cypher text into the cypherTextOut buffer. The message buffer must have SecretBoxZeroBytes() worth
// of zero-padding at the start of it. The key may be reused across messages, but the nonce must be
// used only once for a given key. \
//
// Returns: 0 on success, non-zero on failure.
func SecretBox(cypherTextOut, message, nonce, key []byte) int {
	support.CheckSize(cypherTextOut, len(message), "cypher text output")
	support.CheckSize(nonce, SecretBoxNonceBytes(), "nonce")
	support.CheckSize(key, SecretBoxKeyBytes(), "key")

	return int(C.crypto_secretbox(
		(*C.uchar)(&cypherTextOut[0]),
		(*C.uchar)(&message[0]), (C.ulonglong)(len(message)),
		(*C.uchar)(&nonce[0]),
		(*C.uchar)(&key[0])))
}
开发者ID:alanfairless,项目名称:GoSodium,代码行数:17,代码来源:secretbox.go


示例14: Sign

func Sign(sealedMessageOut []byte, message []byte, sk []byte) int {
	support.CheckSize(sealedMessageOut, SignBytes()+len(message), "sealed message output")
	support.CheckSize(sk, SignSecretKeyBytes(), "secret key")

	lenSealedMessageOut := (C.ulonglong)(len(sealedMessageOut))

	return int(C.crypto_sign(
		(*C.uchar)(&sealedMessageOut[0]), (*C.ulonglong)(&lenSealedMessageOut),
		(*C.uchar)(&message[0]), (C.ulonglong)(len(message)),
		(*C.uchar)(&sk[0])))
}
开发者ID:alanfairless,项目名称:GoSodium,代码行数:11,代码来源:cryptosign.go


示例15: BoxOpenAfterNm

func BoxOpenAfterNm(messageOut []byte, cypherText []byte, nonce, key []byte) int {
	support.CheckSize(messageOut, len(cypherText), "message output")
	support.CheckSize(nonce, BoxNonceBytes(), "nonce")
	support.CheckSize(key, BoxBeforeNmBytes(), "key")

	return int(C.crypto_box_open_afternm(
		(*C.uchar)(&messageOut[0]),
		(*C.uchar)(&cypherText[0]), (C.ulonglong)(len(cypherText)),
		(*C.uchar)(&nonce[0]),
		(*C.uchar)(&key[0])))
}
开发者ID:alanfairless,项目名称:GoSodium,代码行数:11,代码来源:cryptobox.go


示例16: boxSealOpen

func boxSealOpen(messageOut []byte, cypherText []byte, pk, sk []byte) int {
	support.CheckSize(messageOut, BoxMacBytes()+len(cypherText), "message output")
	support.CheckSize(pk, BoxPublicKeyBytes(), "public key")
	support.CheckSize(sk, BoxSecretKeyBytes(), "secret key")

	return int(C.crypto_box_seal_open(
		(*C.uchar)(&messageOut[0]),
		(*C.uchar)(&cypherText[0]),
		(C.ulonglong)(len(cypherText)),
		(*C.uchar)(&pk[0]),
		(*C.uchar)(&sk[0])))
}
开发者ID:alanfairless,项目名称:GoSodium,代码行数:12,代码来源:cryptoboxseal.go


示例17: Box

func Box(cypherTextOut []byte, message []byte, nonce, pk, sk []byte) int {
	support.CheckSize(cypherTextOut, len(message), "cypher text output")
	support.CheckSize(nonce, BoxNonceBytes(), "nonce")
	support.CheckSize(pk, BoxPublicKeyBytes(), "public key")
	support.CheckSize(sk, BoxSecretKeyBytes(), "secret key")

	return int(C.crypto_box((*C.uchar)(&cypherTextOut[0]),
		(*C.uchar)(&message[0]), (C.ulonglong)(len(message)),
		(*C.uchar)(&nonce[0]),
		(*C.uchar)(&pk[0]),
		(*C.uchar)(&sk[0])))
}
开发者ID:alanfairless,项目名称:GoSodium,代码行数:12,代码来源:cryptobox.go


示例18: BoxEasyDetachedAfterNm

func BoxEasyDetachedAfterNm(cipherTextOut []byte, message []byte, nonce, key []byte) int {
	support.CheckSize(cipherTextOut, BoxMacBytes()+len(message), "cypher text output")
	support.CheckSize(nonce, BoxNonceBytes(), "nonce")
	support.CheckSize(key, BoxBeforeNmBytes(), "key")

	return int(C.crypto_box_easy_afternm(
		(*C.uchar)(&cipherTextOut[0]),
		(*C.uchar)(&message[0]),
		(C.ulonglong)(len(message)),
		(*C.uchar)(&nonce[0]),
		(*C.uchar)(&key[0])))
}
开发者ID:alanfairless,项目名称:GoSodium,代码行数:12,代码来源:cryptoboxeasy.go


示例19: BoxOpenEasy

func BoxOpenEasy(messageOut []byte, cypherText []byte, nonce, pk, sk []byte) int {
	support.CheckSize(messageOut, BoxMacBytes()+len(cypherText), "message output")
	support.CheckSize(nonce, BoxNonceBytes(), "nonce")
	support.CheckSize(pk, BoxPublicKeyBytes(), "public key")
	support.CheckSize(sk, BoxSecretKeyBytes(), "secret key")

	return int(C.crypto_box_open_easy(
		(*C.uchar)(&messageOut[0]),
		(*C.uchar)(&cypherText[0]),
		(C.ulonglong)(len(cypherText)),
		(*C.uchar)(&nonce[0]),
		(*C.uchar)(&pk[0]),
		(*C.uchar)(&sk[0])))
}
开发者ID:alanfairless,项目名称:GoSodium,代码行数:14,代码来源:cryptoboxeasy.go


示例20: boxOpenDetached

func boxOpenDetached(messageOut []byte, message []byte, mac, nonce, pk, sk []byte) int {
	support.CheckSize(messageOut, BoxMacBytes()+len(message), "cipher text output")
	support.CheckSize(mac, BoxMacBytes(), "mac")
	support.CheckSize(nonce, BoxNonceBytes(), "nonce")
	support.CheckSize(pk, BoxPublicKeyBytes(), "public key")
	support.CheckSize(sk, BoxSecretKeyBytes(), "secret key")

	return int(C.crypto_box_detached(
		(*C.uchar)(&messageOut[0]),
		(*C.uchar)(&message[0]),
		(*C.uchar)(&mac[0]),
		(C.ulonglong)(len(message)),
		(*C.uchar)(&nonce[0]),
		(*C.uchar)(&pk[0]),
		(*C.uchar)(&sk[0])))
}
开发者ID:alanfairless,项目名称:GoSodium,代码行数:16,代码来源:cryptoboxeasy.go



注:本文中的github.com/redragonx/GoSodium/sodium/support.CheckSize函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang cursor.Cursor类代码示例发布时间:2022-05-28
下一篇:
Golang redis.Int函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap