From owner-freebsd-questions@FreeBSD.ORG Wed Dec 22 16:21:18 2010 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2E85C106566B for ; Wed, 22 Dec 2010 16:21:18 +0000 (UTC) (envelope-from hedayati.mo@gmail.com) Received: from mail-ww0-f50.google.com (mail-ww0-f50.google.com [74.125.82.50]) by mx1.freebsd.org (Postfix) with ESMTP id B76AF8FC0A for ; Wed, 22 Dec 2010 16:21:17 +0000 (UTC) Received: by wwf26 with SMTP id 26so4985690wwf.31 for ; Wed, 22 Dec 2010 08:21:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:content-type :content-transfer-encoding; bh=WKSZWTN8zoHjH8hm9Ffb9Os23561b2FqnNtoFnZ+BcM=; b=fQaIdB0sp2dvdXDcZpbXiqkzQP+cpWHzuIMTf08pw1CmCjtFBSeqIw6JmnTac8Nnie mzSISNJKDod5fnM4dnWeeRn5Ol9Ra3z1euG7hQ6a6XFeuu7LnwAj4ODrrb9g7VqxshCf Rvg371NCdCJ7rd1UU/SqrDfuED4v7AK+Cwkh0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; b=aJZgonX4vJNvitWF8yfidmY3Lxx1GKvn/tqPQYYaAWeFeYdpLGWeT4ojvb6im9deAR xIEBroO3ld4d/ws2BjZGbhsUyPh/BbGVYOCc6A3wELuaglJV95K7u9UYKyvzY5s1AEze IGrnNeUjtC4wPRo9iZCixeSA6aAbahFci2KYM= Received: by 10.227.132.200 with SMTP id c8mr4340515wbt.31.1293034876568; Wed, 22 Dec 2010 08:21:16 -0800 (PST) MIME-Version: 1.0 Received: by 10.227.143.202 with HTTP; Wed, 22 Dec 2010 08:20:36 -0800 (PST) In-Reply-To: <201012221603.oBMG3AnT016020@mail.r-bonomi.com> References: <201012221603.oBMG3AnT016020@mail.r-bonomi.com> From: Mohammad Hedayati Date: Wed, 22 Dec 2010 19:50:36 +0330 Message-ID: To: freebsd-questions@freebsd.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: DES Cipher X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Dec 2010 16:21:18 -0000 On Wed, Dec 22, 2010 at 7:33 PM, Robert Bonomi w= rote: > >> From owner-freebsd-questions@freebsd.org =C2=A0Wed Dec 22 08:22:15 2010 >> From: Mohammad Hedayati >> Date: Wed, 22 Dec 2010 17:50:19 +0330 >> To: freebsd-questions@freebsd.org >> Subject: DES Cipher >> >> Can anyone please show me a sample code for ciphering using DES in FreeB= SD? > > I hate to say it, but RTFM applies. > 'apropos encryption' gives, among other things (and first), a cite to bde= s(1). > > 'bdes' is a program that comes with the FreeBSD distribution. > You have access to the source code of all of the distribution. > > 'Use the Souce, Luke" applies, and will bring the mountain to Mohammad. := ) > > > Thanks Robert, I haven't seen a cite to bdes in the FM of des(3), but the problem is solved using the source of bdes(1) [thanks to Antone]. The code would be as easy as: #include int main(int argc, char *argv[]) { DES_key_schedule schedule; DES_cblock key; strncpy(key, "somekey", 8); =09 DES_set_key(&key, &schedule); =09 DES_cblock buf; strncpy(buf, "sometxt", 8); =09 // Encrypting DES_ecb_encrypt(&buf, &buf, &schedule, 0);=09 =09 // Decrypting DES_ecb_encrypt(&buf, &buf, &schedule, 1);=09 printf("Text Is: %s\n", buf); =09 return(0); }