Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iHXRE-0007t8-1W for pgsql-general@arkaria.postgresql.org; Mon, 07 Oct 2019 18:08:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iHXRC-0001z6-Ek for pgsql-general@arkaria.postgresql.org; Mon, 07 Oct 2019 18:08:50 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iHXRC-0001yv-0x for pgsql-general@lists.postgresql.org; Mon, 07 Oct 2019 18:08:50 +0000 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iHXR8-0000n9-JH for pgsql-general@postgresql.org; Mon, 07 Oct 2019 18:08:49 +0000 Received: by mail-wr1-x443.google.com with SMTP id w12so16440806wro.5 for ; Mon, 07 Oct 2019 11:08:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=7Qpbc+a+SbC74UZyzK22LzcPtSFlj2psRsGnoOWArk4=; b=nj1ZtVMrFCpxiMktUSH7cs2igNQwKA2B7pbGg6z7jYpv9f2peBjwOEFdpIX+b2cCy2 bpB+tpToi8x0RXXYFtOb3AKt5uLuPkkZGKCk7lDML5W+7Nd3lt7hfPW9oAMxxS2XbSls p2448ffwzzuF2bmUfsPmIYOLxBZKZdXBajwUYhLQZthWwFnjS5I76dpbAYQN2mG9Q3Rn LFXcd9/aGadWi3WTA6TvSWuGZ7euw2baAgQu4YSAxzuoLyr5IiOzWmFjwmNlZ4dMGicc iYPbkDOhPtihQQ2eHz/6+qs11fkGZpy2smsQcwmVUCN52hzyjJiq4jXEoyPxjA34wzL5 T4yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=7Qpbc+a+SbC74UZyzK22LzcPtSFlj2psRsGnoOWArk4=; b=jLvM5Lyc6sWqZPTBOSltTAS7fdNl60Y7hluL1KsQJGnLmMYMCNy4owuUiPnzP6YzpR 3lWpwvS5NHFsh4h29IUAEl76RYr3crnwEMoi4rWgY04e5NDyICnihLFiJXMCCTPlIZO1 Zxc8sqqzbjMnzCPNucwbRHZ3fjFWW5IlbOu7sVQ7a+sGy1Z7gNDkuTd1HOqoqkQtz6Ta 9YdS6yKItf6LJbYT4zlth4EDnbOzWbwoPlmk3gQOux5WQEE5Bs1hmeZorliGV281L8Kr /pWAdFfARbsLsISOy+6aLeU6/lHM95KiUv5+QHksydoXLOss5ssnsjEA18CpwVflDsdK cf6w== X-Gm-Message-State: APjAAAUNOAY5AimAXwKyYimTNX/Nn4oGkUYtWfM8L3I5ZfSXxDcQTgW5 twfsycOwuUEidIaielEZ4YPaTg== X-Google-Smtp-Source: APXvYqzh1QARd+HMT9XmMuGCJPB9xV6VBMTkMgdnnA9QsmRVbwRg5mWTX8l6WxIOR3ZYtLLyjqtBhA== X-Received: by 2002:a5d:4c52:: with SMTP id n18mr9751846wrt.258.1570471725450; Mon, 07 Oct 2019 11:08:45 -0700 (PDT) Received: from localhost (ip-86-49-253-183.net.upcbroadband.cz. [86.49.253.183]) by smtp.gmail.com with ESMTPSA id r13sm27118004wrn.0.2019.10.07.11.08.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2019 11:08:44 -0700 (PDT) Date: Mon, 7 Oct 2019 20:08:42 +0200 From: Tomas Vondra To: erik@q32.com Cc: pgsql-general@postgresql.org Subject: Re: pgcrypto question Message-ID: <20191007180842.j6jqgcirhsnbqp2x@development> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Mon, Oct 07, 2019 at 12:05:16PM -0400, Erik Aronesty wrote: >Currently, it is my understanding that the pgcrypto library requires >the user to send a password or private key up to the server for >decryption. > Correct. In the naive case the key is included in each SQL query, which does have various issues. Bruce Momjian has a nice extension that allows you to fix that by loading the key into backend memory: http://momjian.us/download/pgcryptokey/ >Is there a notion of a client-side encrypt/decrypt plugin when doing a >postgres query? > >For example, a user could query postgres, get back data of type >"encrypted", and a "libpq" plugin could decode/decrypt those columns >that are of data type "encrypted".... in a manner transparent to the >user of the client.... > >Obviously I could write this by intercepting the relevant libpq calls >using LD_PRELOAD or Microsoft's "Detours" ... but it there a better >way to do that? > AFAIk that's usually done at the application level, i.e. the application is sending/receiving encrypted data, and the database simply sees bytea columns. I'm not aware of a driver doing that transparently, but it seems like an interesting idea - I wonder if it could be done e.g. in psycopg as an extension, or something like that. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services