本文整理匯總了Golang中github.com/redragonx/GoSodium/sodium/support.CheckSize函數的典型用法代碼示例。如果您正苦於以下問題:Golang CheckSize函數的具體用法?Golang CheckSize怎麽用?Golang CheckSize使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了CheckSize函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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])))
}
示例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])))
}
示例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])))
}
示例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])))
}
示例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])))
}
示例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])))
}
示例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])))
}
示例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])))
}
示例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])))
}
示例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])))
}
示例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])))
}
示例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])))
}
示例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])))
}
示例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])))
}
示例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])))
}