Skip to content

Commit

Permalink
Commit of latest release
Browse files Browse the repository at this point in the history
Source for release 2.4.1
  • Loading branch information
r3-gabriel committed Sep 20, 2021
0 parents commit 6c32789
Show file tree
Hide file tree
Showing 467 changed files with 198,634 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
r3.exe
r3
resource.syso
7 changes: 7 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright (c) 2019-2021 Gabriel Victor Herbert

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# r3
REI3 business application platform
111 changes: 111 additions & 0 deletions activation/activation.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
package activation

import (
"crypto"
"crypto/rsa"
"crypto/sha256"
"crypto/x509"
"encoding/base64"
"encoding/json"
"encoding/pem"
"errors"
"r3/config"
"r3/log"
"r3/types"
)

// public key of OC2020_license_key, created 2020-10-05
var publicKey = `-----BEGIN RSA PUBLIC KEY-----
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UDbC+yG+80Q
SdthJUjKqXXNWkFkWTxIOpesF9Fmw6Wa7ttBQnB8exNbciYI4orgUiW0ZV/jNoWB
8Hu1/OSZ9x9x8/s39d4/O3YyMtlgyzcuLY2HmgIU55VPMe8LlQ2/HQnytEGDKywo
LxJmmk6ANsKZSl1aZSvRGOG34pNurXETrIpfkk7SL/1gUuHWi3JLc5nyJS9SXxRA
ROqxKPBfyYvvjts3K+llbbw6HJNXtxhTdyxwuNKSadrM1a2B7AtO4Y43OevE8rMw
u9DrmnzjhTNa/lOu0icNEX0P9R9wsqUZ7hrHPrnMoa8puC8spj1KRSR/ImZT9ZO/
4gfolmEtgZ5ROc9LVFdozTi7YTdLfUp2SZwb9dkmN7sb5ex3bRnGrnOKMxq1kdTq
85TB/RpHnzfwY5yvCArrQS5w0nG7tQwoK1v71V6ew6MDc68PYD2ePOAjwKQ0ehAG
uy3b3xhDHk+UmSAkCK9qXIzXKmylOqdWarqVKkz6rR7v+/ZtbeIjwiCp9TXbxyzc
vCPF8QXc4V/wgJZtn6vdSXGR5W0dByItU5TLOlk6kLX4Aj6G8T+J//7NX5InD5Q/
7YPTU7NMcyC54h7EbTSPO8dQu0mQuo/dHEONCFaVEpaKVGYMY3Au8tUCAwEAAQ==
-----END RSA PUBLIC KEY-----`

func SetLicense() {
if config.GetString("licenseFile") == "" {
log.Info("server", "skipping activation check, no license installed")
return
}

var licFile types.LicenseFile

if err := json.Unmarshal([]byte(config.GetString("licenseFile")), &licFile); err != nil {
log.Error("server", "could not unmarshal license from config", err)
return
}

licenseJson, err := json.Marshal(licFile.License)
if err != nil {
log.Error("server", "could not marshal license data", err)
return
}
hashed := sha256.Sum256(licenseJson)

// get license signature
signature, err := base64.URLEncoding.DecodeString(licFile.Signature)
if err != nil {
log.Error("server", "could not decode license signature", err)
return
}

// verify signature
data, _ := pem.Decode([]byte(publicKey))
if data == nil {
log.Error("server", "could not decode public key", errors.New(""))
return
}
key, err := x509.ParsePKCS1PublicKey(data.Bytes)
if err != nil {
log.Error("server", "could not parse public key", errors.New(""))
return
}

if err := rsa.VerifyPKCS1v15(key, crypto.SHA256, hashed[:], signature); err != nil {
log.Error("server", "failed to verify license", err)
return
}

// set license
log.Info("server", "setting license")
config.License = licFile.License
}
Loading

0 comments on commit 6c32789

Please sign in to comment.