mirror of
https://github.com/qrtc/ffmpeg-dev-go.git
synced 2025-09-26 20:01:22 +08:00
33 lines
884 B
Go
33 lines
884 B
Go
// Copyright (c) 2023 QRTC. All rights reserved.
|
|
// Use of this source code is governed by a MIT
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package ffmpeg
|
|
|
|
/*
|
|
#include <libavutil/tea.h>
|
|
*/
|
|
import "C"
|
|
|
|
// AVTEA
|
|
type AVTEA C.struct_AVTEA
|
|
|
|
// AvTeaAlloc allocates an AVTEA context.
|
|
func AvTeaAlloc() *AVTEA {
|
|
return (*AVTEA)(C.av_tea_alloc())
|
|
}
|
|
|
|
// AvTeaInit initializes an AVTEA context.
|
|
func AvTeaInit(ctx *AVTEA, key []uint8, rounds int32) {
|
|
if len(key) < 16 {
|
|
panic("key len < 16")
|
|
}
|
|
C.av_tea_init((*C.struct_AVTEA)(ctx), (*C.uint8_t)(&key[0]), (C.int)(rounds))
|
|
}
|
|
|
|
// AvTeaCrypt encrypts or decrypts a buffer using a previously initialized context.
|
|
func AvTeaCrypt(ctx *AVTEA, dst, src *uint8, count int32, iv *uint8, decrypt int32) {
|
|
C.av_tea_crypt((*C.struct_AVTEA)(ctx), (*C.uint8_t)(dst), (*C.uint8_t)(src),
|
|
(C.int)(count), (*C.uint8_t)(iv), (C.int)(decrypt))
|
|
}
|