pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Matching pgp_sym_encrypt() and gpg2 output
3+ messages / 2 participants
[nested] [flat]

* Matching pgp_sym_encrypt() and gpg2 output
@ 2019-08-27 17:33  Bruce Momjian <bruce@momjian.us>
  0 siblings, 1 reply; 3+ messages in thread

From: Bruce Momjian @ 2019-08-27 17:33 UTC (permalink / raw)
  To: pgsql-general

I am trying to generate output from the command-line program gpg2 that
matches the output of pgp_sym_encrypt().  gpg2 outputs:

	$ echo 'my access password' | tr -d '\n' | gpg2 --symmetric --batch
	> --cipher-algo AES256 --passphrase 'abc' | xxd -p | tr -d '\n'

	8c0d0409030248b24f9d2bc91287f5d24701...

while pgp_sym_encrypt() outputs:

	SELECT pgp_sym_encrypt('my access password', 'abc', 'cipher-algo=aes256');
	                                                                        
	     pgp_sym_encrypt
	----------------------------------------
	 \xc30d0409030282dbcc61c149fd4b67d24...

I realize the \x is from the bytea output function, but the hex digits
don't match, and the gpg2 output is slightly longer than the
pgp_sym_encrypt() output.  What gpg2 options will allow it to match?
Thanks.

-- 
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

+ As you are, so once was I.  As I am, so you will be. +
+                      Ancient Roman grave inscription +





^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Matching pgp_sym_encrypt() and gpg2 output
@ 2019-08-27 18:05  Jeff Janes <jeff.janes@gmail.com>
  parent: Bruce Momjian <bruce@momjian.us>
  0 siblings, 1 reply; 3+ messages in thread

From: Jeff Janes @ 2019-08-27 18:05 UTC (permalink / raw)
  To: Bruce Momjian <bruce@momjian.us>; +Cc: pgsql-general

On Tue, Aug 27, 2019 at 1:33 PM Bruce Momjian <bruce@momjian.us> wrote:

> I am trying to generate output from the command-line program gpg2 that
> matches the output of pgp_sym_encrypt().  gpg2 outputs:
>
>         $ echo 'my access password' | tr -d '\n' | gpg2 --symmetric --batch
>         > --cipher-algo AES256 --passphrase 'abc' | xxd -p | tr -d '\n'
>

I don't even get the same output on repeated execution of this same
command, so I think you are pursuing a lost cause.

Cheers,

Jeff

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Matching pgp_sym_encrypt() and gpg2 output
@ 2019-08-27 18:35  Bruce Momjian <bruce@momjian.us>
  parent: Jeff Janes <jeff.janes@gmail.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Bruce Momjian @ 2019-08-27 18:35 UTC (permalink / raw)
  To: Jeff Janes <jeff.janes@gmail.com>; +Cc: pgsql-general

On Tue, Aug 27, 2019 at 02:05:28PM -0400, Jeff Janes wrote:
> On Tue, Aug 27, 2019 at 1:33 PM Bruce Momjian <bruce@momjian.us> wrote:
> 
>     I am trying to generate output from the command-line program gpg2 that
>     matches the output of pgp_sym_encrypt().  gpg2 outputs:
> 
>             $ echo 'my access password' | tr -d '\n' | gpg2 --symmetric --batch
>             > --cipher-algo AES256 --passphrase 'abc' | xxd -p | tr -d '\n'
> 
> 
> I don't even get the same output on repeated execution of this same command, so
> I think you are pursuing a lost cause.

Ah, very good point.  I at least get the same first few bytes and same
length each time, so I never even looked at the trailing bytes, and you
are right that it isn't surprising they differ each time.

Anyway, I figured it out.  I was originally trying to use openssl to
match pgp_sym_encrypt(), and that wasn't working, and then when I
couldn't get the gpg2 bytes to match, I asked here.  Seems I got it
working with the attached SQL file.  Thanks.

-- 
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

+ As you are, so once was I.  As I am, so you will be. +
+                      Ancient Roman grave inscription +

Attachments:

  key-pass-test.sql (application/x-sql, 510B) download

^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2019-08-27 18:35 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-08-27 17:33 Matching pgp_sym_encrypt() and gpg2 output Bruce Momjian <bruce@momjian.us>
2019-08-27 18:05 ` Jeff Janes <jeff.janes@gmail.com>
2019-08-27 18:35   ` Bruce Momjian <bruce@momjian.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox