From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.help Subject: Re: Let us see how to encrypt with Emacs? Date: Fri, 09 Jul 2021 13:39:31 +0300 Message-ID: <83mtqvdb4s.fsf@gnu.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34924"; mail-complaints-to="usenet@ciao.gmane.io" To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jul 09 12:40:09 2021 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m1nvV-0008sU-2O for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 09 Jul 2021 12:40:09 +0200 Original-Received: from localhost ([::1]:35660 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m1nvT-0008Kl-Vt for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 09 Jul 2021 06:40:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:32894) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1nv9-0008KN-Rm for help-gnu-emacs@gnu.org; Fri, 09 Jul 2021 06:39:47 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:55186) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m1nv9-0006ES-LZ for help-gnu-emacs@gnu.org; Fri, 09 Jul 2021 06:39:47 -0400 Original-Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:3291 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1nv9-0002Pq-6u for help-gnu-emacs@gnu.org; Fri, 09 Jul 2021 06:39:47 -0400 In-Reply-To: (message from Jean Louis on Fri, 09 Jul 2021 10:38:41 +0300) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:131632 Archived-At: > Date: Fri, 09 Jul 2021 10:38:41 +0300 > From: Jean Louis > > (gnutls-symmetric-encrypt "CHACHA20-64" "MyPassword987" (make-string 16 (random 100)) "Text to encrypt") > > but error is: > > (error "GnuTLS cipher CHACHA20-64/encrypt key length 13 is not equal to the required 32") > > which is somehow clear, so maybe I could use the function `string-pad': > > (gnutls-symmetric-encrypt "CHACHA20-64" (string-pad "MyPassword987" 32) (make-string 16 (random 100)) "Text to encrypt") > > then I get error: > > (error "GnuTLS cipher CHACHA20-64/encrypt input block length 15 is not a multiple of the required 64") > > and try to remedy it with some result, that is vague, as text > longer than 64 I would not know how to chunk and what is expected > from me: > > (gnutls-symmetric-encrypt "CHACHA20-64" (string-pad "MyPassword987" 32) (make-string 16 (random 100)) (string-pad "Text to encrypt" 64)) ⇒ ("woEB\351Qe\2626Hn\360\211\332g\336\331@\357\327\246n\326XL\344\334=\305\307\232\360\277\301\253\215\3108\202'\232\301\234\373\234\364\344\276ws\355YJQ" "****************") > > (setq encrypted (gnutls-symmetric-encrypt "CHACHA20-64" (string-pad "MyPassword987" 32) (make-string 16 (random 100)) (string-pad "Text to encrypt" 64))) > > And I can decrypt it: > > (car (gnutls-symmetric-decrypt "CHACHA20-64" (string-pad "MyPassword987" 32) (cadr encrypted) (car encrypted))) ⇒ "Text to encrypt " > > but that is not well integrated for practical encryption as I > have to employ padding even for string to be encrypted, and > chunking of string to 64 bytes. No, you don't need to chunk, you just need to pad to a multiple of 64 bytes. > So I would like to use this input, but I do not understand and > cannot get example how to usei t, and I did review md5 and > secure-hash functions and still... I need help. What kind of help? To use these functions, you need to learn about the various ciphers and what they require. This is something the Emacs Lisp reference manual cannot teach you. > ‘STRING’ > A string as input will be used directly. It may be modified by the > function (unlike most other Emacs Lisp functions) to reduce the > chance of exposing sensitive data after the function does its work. > > I am trying to use list with STRING as following and that does not work: > > (gnutls-symmetric-encrypt "CHACHA20-64" (string-pad "MyPassword987" 32) (make-string 16 (random 100)) '(STRING "Text to encrypt")) What do you mean by "does not work"?