Documentation
¶
Index ¶
- Constants
- Variables
- func BodyParser(c *fiber.Ctx, data interface{}) error
- func DecryptAES(key, ciphertext []byte) ([]byte, error)
- func DecryptRSA(privateKey *rsa.PrivateKey, ciphertext []byte) ([]byte, error)
- func EncryptAES(key, plaintext []byte) ([]byte, error)
- func EncryptRSA(publicKey *rsa.PublicKey, message []byte) ([]byte, error)
- func FailedRequest(c *fiber.Ctx, message string, err error) error
- func GenerateRSAKey(keySize int) (*rsa.PrivateKey, *rsa.PublicKey, error)
- func GenerateToken(tkLength int32) string
- func GetCurrent() (id int64, token string, app uint, domain string)
- func InvalidRequest(c *fiber.Ctx, message string) error
- func NewAESKey() ([]byte, error)
- func PackageRSAPrivateKey(privateKey *rsa.PrivateKey) string
- func PackageRSAPublicKey(publicKey *rsa.PublicKey) string
- func PostRequest(url string, body map[string]interface{}) (map[string]interface{}, error)
- func PostRequestNoTC(url string, body map[string]interface{}) (map[string]interface{}, error)
- func ReportOffline(node pipes.Node)
- func ReturnJSON(c *fiber.Ctx, data interface{}) error
- func SetOnline() map[string]interface{}
- func Setup() bool
- func SignRSA(privateKey *rsa.PrivateKey, message string) (string, error)
- func SuccessfulRequest(c *fiber.Ctx) error
- func TestAES()
- func UnpackageRSAPrivateKey(priv string) (*rsa.PrivateKey, error)
- func UnpackageRSAPublicKey(pub string) (*rsa.PublicKey, error)
- func VerifyRSASignature(signature string, publicKey *rsa.PublicKey, message string) error
- type NormalResponse
Constants ¶
const ApiVersion = "v1"
* Important
const ErrorServer = "server.error"
const StandardKeySize = 2048
const StatusError = 2
const StatusOffline = 1
const StatusOnline = 0
Variables ¶
var BasePath = "http://localhost:3000"
var ClusterID uint = 0
var FilePath = ""
var JwtSecret = ""
var NODE_ID uint = 0
var NODE_TOKEN = ""
var NodePrivateKey *rsa.PrivateKey // Private key for current node
* Credentials for this node
var NodePublicKey *rsa.PublicKey // Public key for current node
var Protocol = "http://"
var ServerPublicKey *rsa.PublicKey // Public key from the backend server
var Testing = false
var TestingToken = ""
Functions ¶
func DecryptAES ¶
Decrypt decrypts the given ciphertext using AES-GCM.
func DecryptRSA ¶
func DecryptRSA(privateKey *rsa.PrivateKey, ciphertext []byte) ([]byte, error)
Decrypt a message with a private key. (can't be infinitely long)
func EncryptAES ¶
Encrypt encrypts the given plaintext using AES-GCM.
func EncryptRSA ¶
Encrypt a message with a public key. (can't be infinitely long)
func GenerateRSAKey ¶
Generate a new RSA key pair.
func GenerateToken ¶
func PackageRSAPrivateKey ¶
func PackageRSAPrivateKey(privateKey *rsa.PrivateKey) string
PackageRSAPrivateKey packages a private key into our own format. Packaging order: modulus, public exponent, private exponent, p, q
func PackageRSAPublicKey ¶
PackageRSAPublicKey packages a public key into our own format. Packaging order: modulus, public exponent
func PostRequest ¶
Send a post request (with TC protection encryption)
func PostRequestNoTC ¶
Send a post request (without TC encryption and custom URL)
func ReportOffline ¶
func SignRSA ¶
func SignRSA(privateKey *rsa.PrivateKey, message string) (string, error)
Sign a message with a private key.
func SuccessfulRequest ¶
func UnpackageRSAPrivateKey ¶
func UnpackageRSAPrivateKey(priv string) (*rsa.PrivateKey, error)
Unpackage private key (in our own format that is kinda crappy but who cares)
func UnpackageRSAPublicKey ¶
Unpackage public key (in our own format that is kinda crappy but who cares)