1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

chore(tools): remove from qTox repo tools for creating updates

They were moved into a separate repo.
This commit is contained in:
Zetok Zalbavar 2017-01-08 14:25:35 +00:00
parent c584685db3
commit 3b56a6ec2a
No known key found for this signature in database
GPG Key ID: C953D3880212068A
16 changed files with 0 additions and 906 deletions

View File

@ -10,9 +10,6 @@ branches:
matrix:
fast_finish: true
allow_failures:
- rust: beta
- rust: nightly
include:
- os: linux
env: JOB=verify-commit-format
@ -27,18 +24,6 @@ matrix:
# the actual compilin'
- os: linux
env: JOB=build-ubuntu-14-04
- os: linux
env: JOB=build-rust
language: rust
rust: stable
- os: linux
env: JOB=build-rust
language: rust
rust: beta
- os: linux
env: JOB=build-rust
language: rust
rust: nightly
- os: osx
osx_image: xcode7.3
env: JOB=build-osx

View File

@ -1,71 +0,0 @@
#!/bin/bash
#
# Copyright © 2016 by The qTox Project Contributors
#
# This program is libre software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# used in travis to:
# - pull in dependencies for building libsodium
# - build required libsodium
# Fail out on error
set -eu -o pipefail
readonly LIBSODIUM_VER="1.0.11"
build_libsodium() {
sudo apt-get update -qq
sudo apt-get install -y \
build-essential \
libtool \
autotools-dev \
automake \
checkinstall \
check \
git \
yasm \
pkg-config || yes
git clone https://github.com/jedisct1/libsodium.git libsodium \
--branch $LIBSODIUM_VER \
--depth 1
cd libsodium
./autogen.sh
./configure
make -j$(nproc)
sudo checkinstall \
--install \
--pkgname libsodium \
--pkgversion $LIBSODIUM_VER \
--nodoc \
-y
sudo ldconfig
cd ..
}
build_rust_bits() {
# TODO: make it a loop over paths once there are more rust bits
cd tools/update-server/qtox-updater-sign
cargo build --verbose
cargo test --verbose
# add `cargo doc` once it's needed?
}
main() {
build_libsodium
build_rust_bits
}
main

View File

@ -1,35 +0,0 @@
#!/usr/bin/python2.7
# This script deploys a qTox update to an FTP server.
# Pass the path to the root of the local update server as argument, no spaces allowed
import sys
import os
target = 'win32'
prefix = '/qtox/'+target+'/'
uploadcmd1 = "bash -c '"+'ftp -n tux3-dev.tox.chat 0<<<"`echo -ne "user qtox-win-update-upload INSERT-PASSWORD-HERE\ncd '+target+'\nsend '
uploadcmd2 = '\n"`"'+"'"
def upload(file, rfile):
#print(uploadcmd1+file+' '+rfile+uploadcmd2)
os.system(uploadcmd1+file+' '+rfile+uploadcmd2)
# Check our local folders
if (len(sys.argv) < 2):
print("ERROR: Needs the path to the local update server in argument")
sys.exit(1)
localpath = sys.argv[1];
# Upload files/
filenames = next(os.walk(localpath+prefix+'/files/'))[2]
for filename in filenames:
print("Uploading files/"+filename+'...')
upload(localpath+prefix+'/files/'+filename, 'files/'+filename)
# Upload version and flist
print("Uploading flist...")
upload(localpath+prefix+'flist', 'flist')
print("Uploading version...")
upload(localpath+prefix+'version', 'version')

View File

@ -1,35 +0,0 @@
#!/usr/bin/python2.7
# This script deploys a qTox update to an FTP server.
# Pass the path to the root of the local update server as argument, no spaces allowed
import sys
import os
target = 'win64'
prefix = '/qtox/'+target+'/'
uploadcmd1 = "bash -c '"+'ftp -n tux3-dev.tox.chat 0<<<"`echo -ne "user qtox-win-update-upload INSERT-PASSWORD-HERE\ncd '+target+'\nsend '
uploadcmd2 = '\n"`"'+"'"
def upload(file, rfile):
#print(uploadcmd1+file+' '+rfile+uploadcmd2)
os.system(uploadcmd1+file+' '+rfile+uploadcmd2)
# Check our local folders
if (len(sys.argv) < 2):
print("ERROR: Needs the path to the local update server in argument")
sys.exit(1)
localpath = sys.argv[1];
# Upload files/
filenames = next(os.walk(localpath+prefix+'/files/'))[2]
for filename in filenames:
print("Uploading files/"+filename+'...')
upload(localpath+prefix+'/files/'+filename, 'files/'+filename)
# Upload version and flist
print("Uploading flist...")
upload(localpath+prefix+'flist', 'flist')
print("Uploading version...")
upload(localpath+prefix+'version', 'version')

View File

@ -1,56 +0,0 @@
#!/usr/bin/python2.7
# This script deploys a qTox update to Amazon S3: It will upload ./qtox/win32/version, ./qtox/win32/flist, and ./qtox/win32/files/*
# Pass the path to the root of the local update server as argument, no spaces allowed
import sys
import os
import boto
from boto.s3.key import Key
# Check our local folders
if (len(sys.argv) < 2):
print("ERROR: Needs the path to the local update server in argument")
sys.exit(1)
localpath = sys.argv[1];
prefix = "/qtox/win32/" # We only support Windows for now
# Connect to S3
conn = boto.connect_s3()
bucket = conn.get_bucket('qtox-updater')
print("Connected to S3")
sys.stdout.flush()
# Delete the old version, so nobody downloads a half-uploaded update
print("Deleting version ...")
sys.stdout.flush()
oldversion = Key(bucket)
oldversion.key = prefix+'version'
bucket.delete_key(oldversion)
# Upload files/
filenames = next(os.walk(localpath+prefix+'/files/'))[2]
for filename in filenames:
print("Uploading files/"+filename+'...')
sys.stdout.flush()
k = Key(bucket)
k.key = prefix+'files/'+filename
k.set_contents_from_filename(localpath+prefix+'/files/'+filename)
k.make_public()
# Upload version and flist
print("Uploading flist...")
sys.stdout.flush()
flist = Key(bucket)
flist.key = prefix+'flist'
flist.set_contents_from_filename(localpath+prefix+'flist')
flist.make_public()
print("Uploading version...")
sys.stdout.flush()
version = Key(bucket)
version.key = prefix+'version'
version.set_contents_from_filename(localpath+prefix+'version')
version.make_public()

View File

@ -1,37 +0,0 @@
#!/bin/bash
# win64 update
rm -f *.zip*
rm -f gitversion
rm -rf win64/*
mkdir -p win64
wget https://build.tox.chat/view/qtox/job/qTox-stable_build_windows_x86-64_release/lastSuccessfulBuild/artifact/qTox-stable_build_windows_x86-64_release.zip
wget https://build.tox.chat/view/qtox/job/qTox-stable_build_windows_x86-64_release/lastSuccessfulBuild/artifact/version -O gitversion
unzip -o qTox-stable_build_windows_x86-64_release.zip -d win64/source
echo -n 3 > win64/version
qtox-updater-sign `date +%s`!`cat gitversion` >> win64/version
qtox-updater-genflist win64
rm -rf win64/source
rm -f /var/www/html/qtox/win64/version
rm -rf /var/www/html/qtox/win64/*
cp -r win64/* /var/www/html/qtox/win64/
# win32 update, I don't feel like writing bash functions edition
rm -f *.zip*
rm -f gitversion
rm -rf win32/*
mkdir -p win32
wget https://build.tox.chat/view/qtox/job/qTox-stable_build_windows_x86_release/lastSuccessfulBuild/artifact/qTox-stable_build_windows_x86_release.zip
wget https://build.tox.chat/view/qtox/job/qTox-stable_build_windows_x86_release/lastSuccessfulBuild/artifact/version -O gitversion
unzip -o qTox-stable_build_windows_x86_release.zip -d win32/source
echo -n 3 > win32/version
qtox-updater-sign `date +%s`!`cat gitversion` >> win32/version
qtox-updater-genflist win32
rm -rf win32/source
rm -f /var/www/html/qtox/win32/version
rm -rf /var/www/html/qtox/win32/*
cp -r win32/* /var/www/html/qtox/win32/

View File

@ -1,154 +0,0 @@
/*
Copyright © 2014 by The qTox Project Contributors
This file is part of qTox, a Qt-based graphical interface for Tox.
qTox is libre software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
qTox is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with qTox. If not, see <http://www.gnu.org/licenses/>
*/
#include <iostream>
#include <QFile>
#include <QByteArray>
#include <QDir>
#include <QStack>
#include <QCryptographicHash>
#include <sodium.h>
#include "serialize.h"
using namespace std;
/// Pass the target folder as first argument, no spaces allowed. We'll call that dir $TARGET
/// Update the content of $TARGET/source/ before calling this tool
/// We'll generate $TARGET/flist and $TARGET/files/ then exit
/// We need qtox-updater-skey in our working directory to sign the flist
///
/// The generated flist is very simple and just installs everything in the working directory ...
QList<QString> scanDir(QDir dir)
{
QList<QString> files;
QStack<QString> stack;
stack.push(dir.absolutePath());
while (!stack.isEmpty())
{
QString sSubdir = stack.pop();
QDir subdir(sSubdir);
// Check for the files.
QList<QString> sublist = subdir.entryList(QDir::Files);
for (QString& file : sublist)
file = dir.relativeFilePath(sSubdir + '/' + file);
files += sublist;
QFileInfoList infoEntries = subdir.entryInfoList(QStringList(),
QDir::AllDirs | QDir::NoSymLinks | QDir::NoDotAndDotDot);
for (int i = 0; i < infoEntries.size(); i++)
{
QFileInfo& item = infoEntries[i];
stack.push(item.absoluteFilePath());
}
}
return files;
}
int main(int argc, char* argv[])
{
cout << "qTox updater flist generator" << endl;
/// First some basic error handling, prepare our handles, ...
if (argc != 2)
{
cout << "ERROR: qtox-updater-genflist takes the target path in argument" << endl;
return 1;
}
QFile skeyFile("qtox-updater-skey");
if (!skeyFile.open(QIODevice::ReadOnly))
{
cout << "ERROR: qtox-updater-genflist can't open the secret (private) key file" << endl;
return 1;
}
QByteArray skeyData = skeyFile.readAll();
skeyFile.close();
QString target(argv[1]);
QFile flistFile(target+"/flist");
if (!flistFile.open(QIODevice::Truncate | QIODevice::WriteOnly))
{
cout << "ERROR: qtox-updater-genflist can't open the target flist" << endl;
return 1;
}
// Wipe the /files/ folder
QDir(target+"/files/").removeRecursively();
QDir(target).mkdir("files");
QDir sdir(target+"/source/");
if (!sdir.isReadable())
{
cout << "ERROR: qtox-updater-genflist can't open the target source directory" << endl;
return 1;
}
QStringList filesListStr = scanDir(sdir);
/// Serialize the flist data
QByteArray flistData;
for (QString fileStr : filesListStr)
{
cout << "Adding "<<fileStr.toStdString()<<"..."<<endl;
QFile file(target+"/source/"+fileStr);
if (!file.open(QIODevice::ReadOnly))
{
cout << "ERROR: qtox-updater-genflist couldn't open a target file to sign it" << endl;
return 1;
}
QByteArray fileData = file.readAll();
unsigned char sig[crypto_sign_BYTES];
crypto_sign_detached(sig, nullptr, (unsigned char*)fileData.data(), fileData.size(), (unsigned char*)skeyData.data());
QString id = QCryptographicHash::hash(fileStr.toUtf8(), QCryptographicHash::Sha3_224).toHex();
flistData += QByteArray::fromRawData((char*)sig, crypto_sign_BYTES);
flistData += stringToData(id);
flistData += stringToData("./"+fileStr); ///< Always install in the working directory for now
flistData += uint64ToData(fileData.size());
file.close();
if (!file.copy(target+"/files/"+id))
{
cout << "ERROR: qtox-updater-genflist couldn't copy target file to /files/" << endl;
return 1;
}
}
cout << "Signing and writing the flist..."<<endl;
/// Sign our flist
unsigned char sig[crypto_sign_BYTES];
crypto_sign_detached(sig, nullptr, (unsigned char*)flistData.data(), flistData.size(), (unsigned char*)skeyData.data());
/// Write the flist
flistFile.write("1");
flistFile.write((char*)sig, crypto_sign_BYTES);
flistFile.write(flistData);
flistFile.close();
return 0;
}

View File

@ -1,10 +0,0 @@
TEMPLATE = app
CONFIG += console c++11
QT += core
LIBS += -lsodium
SOURCES += main.cpp \
serialize.cpp
HEADERS += \
serialize.h

View File

@ -1,257 +0,0 @@
/*
Copyright © 2014 by The qTox Project Contributors
This file is part of qTox, a Qt-based graphical interface for Tox.
qTox is libre software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
qTox is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with qTox. If not, see <http://www.gnu.org/licenses/>
*/
#include "serialize.h"
QByteArray doubleToData(double num)
{
union
{
char tab[8];
double n;
} castUnion;
//char n[8];
//*((double*) n) = num;
castUnion.n=num;
return QByteArray(castUnion.tab,8);
}
QByteArray floatToData(float num)
{
union
{
char tab[4];
float n;
} castUnion;
castUnion.n=num;
return QByteArray(castUnion.tab,4);
}
float dataToFloat(QByteArray data)
{
union
{
char tab[4];
float n;
} castUnion;
castUnion.tab[0]=data.data()[0];
castUnion.tab[1]=data.data()[1];
castUnion.tab[2]=data.data()[2];
castUnion.tab[3]=data.data()[3];
return castUnion.n;
}
// Converts a string into PNet string data
QByteArray stringToData(QString str)
{
QByteArray data(4,0);
// Write the size in a Uint of variable lenght (8-32 bits)
int i=0;
uint num1 = (uint)str.toUtf8().size();
while (num1 >= 0x80)
{
data[i] = (unsigned char)(num1 | 0x80); i++;
num1 = num1 >> 7;
}
data[i]=num1;
data.resize(i+1);
data+=str.toUtf8();
return data;
}
QString dataToString(QByteArray data)
{
// Variable UInt32
unsigned char num3;
int num = 0;
int num2 = 0;
int i=0;
do
{
num3 = data[i]; i++;
num |= (num3 & 0x7f) << num2;
num2 += 7;
} while ((num3 & 0x80) != 0);
unsigned int strlen = (uint) num;
if (!strlen)
return QString();
data = data.right(data.size()-i); // Remove the strlen
data.truncate(strlen);
return QString(data);
}
float dataToRangedSingle(float min, float max, int numberOfBits, QByteArray data)
{
uint endvalue=0;
uint value=0;
if (numberOfBits <= 8)
{
endvalue = (uchar)data[0];
goto done;
}
value = (uchar)data[0];
numberOfBits -= 8;
if (numberOfBits <= 8)
{
endvalue = (value | ((uint) ((uchar)data[1]) << 8));
goto done;
}
value |= (uint) (((uchar)data[1]) << 8);
numberOfBits -= 8;
if (numberOfBits <= 8)
{
uint num2 = (uint) (((uchar)data[2]) << 0x10);
endvalue = (value | num2);
goto done;
}
value |= (uint) (((uchar)data[2]) << 0x10);
numberOfBits -= 8;
endvalue = (value | ((uint) (((uchar)data[3]) << 0x18)));
goto done;
done:
float num = max - min;
int num2 = (((int) 1) << numberOfBits) - 1;
float num3 = endvalue;
float num4 = num3 / ((float) num2);
return (min + (num4 * num));
}
QByteArray rangedSingleToData(float value, float min, float max, int numberOfBits)
{
QByteArray data;
float num = max - min;
float num2 = (value - min) / num;
int num3 = (((int) 1) << numberOfBits) - 1;
uint source = num3 * num2;
if (numberOfBits <= 8)
{
data += (unsigned char)source;
return data;
}
data += (unsigned char)source;
numberOfBits -= 8;
if (numberOfBits <= 8)
{
data += (unsigned char)(source>>8);
return data;
}
data += (unsigned char)(source>>8);
numberOfBits -= 8;
if (numberOfBits <= 8)
{
data += (unsigned char)(source>>16);
return data;
}
data += (unsigned char)(source>>16);
data += (unsigned char)(source>>24);
return data;
}
uint8_t dataToUint8(QByteArray data)
{
return (uint8_t)data[0];
}
uint16_t dataToUint16(QByteArray data)
{
return ((uint16_t)(uint8_t)data[0])
+(((uint16_t)(uint8_t)data[1])<<8);
}
uint32_t dataToUint32(QByteArray data)
{
return ((uint32_t)(uint8_t)data[0])
+(((uint32_t)(uint8_t)data[1])<<8)
+(((uint32_t)(uint8_t)data[2])<<16)
+(((uint32_t)(uint8_t)data[3])<<24);
}
uint64_t dataToUint64(QByteArray data)
{
return ((uint64_t)(uint8_t)data[0])
+(((uint64_t)(uint8_t)data[1])<<8)
+(((uint64_t)(uint8_t)data[2])<<16)
+(((uint64_t)(uint8_t)data[3])<<24)
+(((uint64_t)(uint8_t)data[4])<<32)
+(((uint64_t)(uint8_t)data[5])<<40)
+(((uint64_t)(uint8_t)data[6])<<48)
+(((uint64_t)(uint8_t)data[7])<<56);
}
unsigned getVUint32Size(QByteArray data)
{
unsigned lensize=0;
{
unsigned char num3;
do {
num3 = data[lensize];
lensize++;
} while ((num3 & 0x80) != 0);
}
return lensize;
}
QByteArray uint8ToData(uint8_t num)
{
QByteArray data(1,0);
data[0] = (uint8_t)num;
return data;
}
QByteArray uint16ToData(uint16_t num)
{
QByteArray data(2,0);
data[0] = (uint8_t)(num & 0xFF);
data[1] = (uint8_t)((num>>8) & 0xFF);
return data;
}
QByteArray uint32ToData(uint32_t num)
{
QByteArray data(4,0);
data[0] = (uint8_t)(num & 0xFF);
data[1] = (uint8_t)((num>>8) & 0xFF);
data[2] = (uint8_t)((num>>16) & 0xFF);
data[3] = (uint8_t)((num>>24) & 0xFF);
return data;
}
QByteArray uint64ToData(uint64_t num)
{
QByteArray data(8,0);
data[0] = (uint8_t)(num & 0xFF);
data[1] = (uint8_t)((num>>8) & 0xFF);
data[2] = (uint8_t)((num>>16) & 0xFF);
data[3] = (uint8_t)((num>>24) & 0xFF);
data[4] = (uint8_t)((num>>32) & 0xFF);
data[5] = (uint8_t)((num>>40) & 0xFF);
data[6] = (uint8_t)((num>>48) & 0xFF);
data[7] = (uint8_t)((num>>56) & 0xFF);
return data;
}

View File

@ -1,48 +0,0 @@
/*
Copyright © 2014 by The qTox Project Contributors
This file is part of qTox, a Qt-based graphical interface for Tox.
qTox is libre software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
qTox is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with qTox. If not, see <http://www.gnu.org/licenses/>
*/
#ifndef SERIALIZE_H
#define SERIALIZE_H
#include <cstdint>
#include <QByteArray>
#include <QString>
/// Most of those functions are unsafe unless otherwise specified
/// Do not use them on untrusted data (e.g. check a signature first)
QByteArray doubleToData(double num);
QByteArray floatToData(float num);
float dataToFloat(QByteArray data);
QByteArray stringToData(QString str);
QString dataToString(QByteArray data);
float dataToRangedSingle(float min, float max, int numberOfBits, QByteArray data);
QByteArray rangedSingleToData(float value, float min, float max, int numberOfBits);
uint8_t dataToUint8(QByteArray data);
uint16_t dataToUint16(QByteArray data);
uint32_t dataToUint32(QByteArray data);
uint64_t dataToUint64(QByteArray data);
unsigned getVUint32Size(QByteArray data);
QByteArray uint8ToData(uint8_t num);
QByteArray uint16ToData(uint16_t num);
QByteArray uint32ToData(uint32_t num);
QByteArray uint64ToData(uint64_t num);
#endif // SERIALIZE_H

View File

@ -1,35 +0,0 @@
#include <sodium.h>
#include <QCoreApplication>
#include <QByteArray>
#include <QFile>
#include <QDebug>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
(void) a;
QByteArray skey(crypto_sign_SECRETKEYBYTES, 0);
QFile skeyFile("qtox-updater-skey");
if (!skeyFile.open(QIODevice::WriteOnly))
{
qCritical() << "Failed to open qtox-updater-skey";
return 1;
}
QByteArray pkey(crypto_sign_PUBLICKEYBYTES, 0);
QFile pkeyFile("qtox-updater-pkey");
if (!pkeyFile.open(QIODevice::WriteOnly))
{
qCritical() << "Failed to open qtox-updater-pkey";
return 1;
}
crypto_sign_keypair((uint8_t*)pkey.data(), (uint8_t*)skey.data());
skeyFile.write(skey);
pkeyFile.write(pkey);
qDebug() << "Wrote new keys to disk";
return 0;
}

View File

@ -1,13 +0,0 @@
QT += core
QT -= gui
TARGET = qtox-updater-genkeys
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
LIBS += -lsodium

View File

@ -1,41 +0,0 @@
[root]
name = "qtox-updater-sign"
version = "0.1.0"
dependencies = [
"sodiumoxide 0.0.12 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "libc"
version = "0.2.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "libsodium-sys"
version = "0.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "pkg-config"
version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "serde"
version = "0.7.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "sodiumoxide"
version = "0.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
"libsodium-sys 0.0.12 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 0.7.15 (registry+https://github.com/rust-lang/crates.io-index)",
]

View File

@ -1,7 +0,0 @@
[package]
name = "qtox-updater-sign"
version = "0.1.0"
authors = ["Zetok Zalbavar <zetok@openmailbox.org>"]
[dependencies]
sodiumoxide = "0.0.12"

View File

@ -1,26 +0,0 @@
# qtox-updater-sign
Simple program for signing releases.
Requires a file named `qtox-updater-skey` in the working directory that
contains the secret key.
To sign a release, either supply the name of the file to be signed as an
argument, or pipe data via stdin.
```bash
./qtox-updater-sign sign-this-binary > signature_file
# or
./qtox-updater-sign < sign-this-binary > signature_file
```
# Compiling
Requires `libsodium` and Rust.
To build a debug version: `cargo build`
To build a release version: `cargo build --release`
This will produce `qtox-updater-sign` binary in `target/debug` or
`target/release` directory respectively.

View File

@ -1,66 +0,0 @@
/*
Copyright © 2016 by The qTox Project Contributors
This file is part of qTox, a Qt-based graphical interface for Tox.
qTox is libre software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
qTox is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with qTox. If not, see <http://www.gnu.org/licenses/>.
*/
extern crate sodiumoxide;
use std::io::prelude::*;
use std::io;
use std::fs::File;
use sodiumoxide::crypto::sign::*;
/// file that contains secret key
const SKEY_FNAME: &'static str = "qtox-updater-skey";
/// if there is more than just the program name in args, treat "1st" arg as the
/// data to sign
/// otherwise just read bytes from stdin
fn read_from_file_or_stdin(buf: &mut Vec<u8>) {
if std::env::args().count() > 1 {
let data = std::env::args().nth(1).expect("Failed to get fname");
buf.extend_from_slice(&data.into_bytes());
} else {
io::stdin().read_to_end(buf).expect("Failed to read stdin");
}
}
/// get SecretKey from `SKEY_FNAME` file
fn get_secret_key() -> SecretKey {
let mut skey_file = File::open(SKEY_FNAME)
.expect(&format!("ERROR: {} can't open the secret (private) key file\n",
std::env::args().next().unwrap()));
let mut skey_bytes = Vec::with_capacity(SECRETKEYBYTES);
skey_file.read_to_end(&mut skey_bytes)
.expect(&format!("Failed to read {}", SKEY_FNAME));
SecretKey::from_slice(&skey_bytes[..SECRETKEYBYTES])
.expect("Failed to get right amount of bytes for SecretKey")
}
fn main() {
let mut plaintext = Vec::new();
read_from_file_or_stdin(&mut plaintext);
let sk = get_secret_key();
let signed = sign(&plaintext, &sk);
io::stdout().write_all(&signed).expect("Failed to write signature");
}