Skip to content

Commit

Permalink
Importing sysutils/gzsig from pfPorts
Browse files Browse the repository at this point in the history
  • Loading branch information
rbgarga committed Aug 20, 2015
1 parent b4c24bb commit 7478966
Show file tree
Hide file tree
Showing 20 changed files with 2,117 additions and 0 deletions.
21 changes: 21 additions & 0 deletions sysutils/gzsig/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
PORTNAME= gzsig
PORTVERSION= 0.0.2
CATEGORIES= sysutils
MASTER_SITES= # empty
DISTFILES= # none
EXTRACT_ONLY= # empty

MAINTAINER= [email protected]
COMMENT= reinits ata channel 0

WHERE= sbin
PLIST_FILES= ${WHERE}/${PORTNAME}

do-extract:
mkdir -p ${WRKSRC}
cp -r ${FILESDIR}/* ${WRKSRC}

do-install:
${INSTALL_PROGRAM} ${WRKSRC}/${PORTNAME} ${STAGEDIR}${PREFIX}/${WHERE}

.include <bsd.port.mk>
10 changes: 10 additions & 0 deletions sysutils/gzsig/files/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# $OpenBSD: Makefile,v 1.2 2005/05/29 02:41:42 marius Exp $

PROG = gzsig
SRCS = gzsig.c key.c sign.c ssh.c util.c verify.c x509.c ssh2.c

LDADD = -lcrypto -lm -lc

CLEANFILES += TAGS *~

.include <bsd.prog.mk>
45 changes: 45 additions & 0 deletions sysutils/gzsig/files/extern.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* extern.h
*
* Copyright (c) 2001 Dug Song <[email protected]>
* Copyright (c) 2001 Arbor Networks, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The names of the copyright holders may not be used to endorse or
* promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Vendor: extern.h,v 1.2 2005/04/01 16:47:31 dugsong Exp $
*/

#ifndef EXTERN_H
#define EXTERN_H

void sign(int argc, char *argv[]);
void verify(int argc, char *argv[]);

int sign_passwd_cb(char *buf, int size, int rwflag, void *u);

void sign_usage(void);
void verify_usage(void);

#endif /* EXTERN_H */
107 changes: 107 additions & 0 deletions sysutils/gzsig/files/gzip.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
/*
* gzip.h
*
* Copyright (c) 2001 Dug Song <[email protected]>
* Copyright (c) 2001 Arbor Networks, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The names of the copyright holders may not be used to endorse or
* promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Vendor: gzip.h,v 1.2 2005/04/01 16:47:31 dugsong Exp $
*/

#ifndef GZIP_H
#define GZIP_H

/* RFC 1952 is b0rked! This is from gzip-1.2.4's algorithm.doc... */

/* Magic header */
#define GZIP_MAGIC "\037\213"

/* Compression methods */
#define GZIP_MSTORED 0
#define GZIP_MCOMPRESS 1
#define GZIP_MPACKED 2
#define GZIP_MLZHED 3
#define GZIP_MDEFLATE 8

/* Flags */
#define GZIP_FTEXT 0x01
#define GZIP_FCONT 0x02 /* never set by gzip-1.2.4 */
#define GZIP_FEXTRA 0x04
#define GZIP_FNAME 0x08
#define GZIP_FCOMMENT 0x10
#define GZIP_FENCRYPT 0x20
#define GZIP_FRESERVED 0xC0

#define GZIP_FENCRYPT_LEN 12

#define GZSIG_ID "GS"
#define GZSIG_VERSION 1

struct gzsig_data {
u_char version;
#ifdef COMMENT_ONLY
u_char signature[];
#endif
};

/*
* Note: all number fields below are in little-endian byte order.
*/

struct gzip_xfield {
u_short len;
struct gzip_subfield {
u_char id[2];
u_short len;
#ifdef COMMENT_ONLY
u_char data[];
#endif
} subfield;
};

struct gzip_header {
u_char magic[2];
u_char method;
u_char flags;
u_char mtime[4];
u_char xflags;
u_char os;
#if COMMENT_ONLY
/* Optional fields */
u_char part[2]; /* flags & GZIP_FCONT */
struct gzip_xfield xfield; /* flags & GZIP_FEXTRA */
char filename[]; /* flags & GZIP_FNAME */
char comment[]; /* flags & GZIP_FCOMMENT */
u_char encrypt_hdr[12]; /* flags & GZIP_FENCRYPT */
#endif
};

struct gzip_trailer {
u_int32_t crc32[4];
u_int32_t size[4];
};

#endif /* GZIP_H */
117 changes: 117 additions & 0 deletions sysutils/gzsig/files/gzsig.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
.\" $OpenBSD: gzsig.1,v 1.8 2005/08/05 14:17:55 jmc Exp $
.\" $Id$
.\"
.\" Copyright (c) 2001 Dug Song <[email protected]>
.\" Copyright (c) 2001 Arbor Networks, Inc.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\"
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. The names of the copyright holders may not be used to endorse or
.\" promote products derived from this software without specific
.\" prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
.\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
.\" AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
.\" THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
.\" EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
.\" PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
.\" OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
.\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd July 6, 2001
.Dt GZSIG 1
.Sh NAME
.Nm gzsig
.Nd gzip signing utility
.Sh SYNOPSIS
.Nm gzsig
.Ic sign
.Op Fl q
.Op Fl f Ar secret_file
.Ar privkey
.Op Ar
.Nm gzsig
.Ic verify
.Op Fl q
.Op Fl f Ar secret_file
.Ar pubkey
.Op Ar
.Sh DESCRIPTION
.Nm
embeds or verifies RSA PKCS #1 v2.0 or DSA SHA1 signatures in
.Xr gzip 1
compressed files using SSH identity keys or X509 certificates.
.Pp
The
.Ar file
operands are processed in command-line order.
If
.Ar file
is a single dash
.Pq Sq -
or absent,
.Nm
reads from the standard input.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl f Ar secret_file
Indicates that the passphrase for the key should be read from
.Ar secret_file
instead of being supplied manually.
.It Fl q
Enable quiet mode.
.It Ic sign
Sign the input using the private key in
.Ar privkey .
.It Ic verify
Verify the signature using the public key in
.Ar pubkey .
.El
.Pp
The
.Nm
utility exits 0 on success or \*(Gt0 if an error occurred.
.Sh EXAMPLES
Sign
.Ar file1
and
.Ar file2
with the SSH2 identity key in
.Ar ~/.ssh/id_rsa :
.Pp
.Dl $ gzsig sign ~/.ssh/id_rsa file1 file2
.Pp
Sign
.Ar file1
with the SSH2 identity key, saving the signed file in
.Ar file2 :
.Pp
.Dl $ gzsig sign ~/.ssh/id_rsa \*(Ltfile1 \*(Gtfile2
.Pp
Verify the signature on
.Ar file1
using the SSL certificate in
.Ar /etc/ssl/server.crt :
.Pp
.Dl $ gzsig verify /etc/ssl/server.crt \*(Ltfile1
.Sh SEE ALSO
.Xr gzip 1 ,
.Xr ssh-keygen 1 ,
.Xr ssl 8
.Sh AUTHORS
Dug Song
.Aq [email protected] .
SSH2 support by
Marius Eriksen
.Aq [email protected] .
65 changes: 65 additions & 0 deletions sysutils/gzsig/files/gzsig.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/* $OpenBSD: gzsig.c,v 1.3 2005/05/29 09:10:23 djm Exp $ */

/*
* gzsig.c
*
* Copyright (c) 2001 Dug Song <[email protected]>
* Copyright (c) 2001 Arbor Networks, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The names of the copyright holders may not be used to endorse or
* promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Vendor: gzsig.c,v 1.2 2005/04/01 16:47:31 dugsong Exp $
*/

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#include "extern.h"

static void
usage(void)
{
sign_usage();
verify_usage();
exit(1);
}

int
main(int argc, char *argv[])
{
if (argc < 2)
usage();

if (strcmp(argv[1], "sign") == 0) {
sign(argc - 1, argv + 1);
} else if (strcmp(argv[1], "verify") == 0) {
verify(argc - 1, argv + 1);
} else {
usage();
}

exit(0);
}
Loading

0 comments on commit 7478966

Please sign in to comment.