MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- $Id$
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "system.h"
gcry_error_t err = 0;
err = gcry_mpi_scan(&rsa->n, GCRYMPI_FMT_HEX, n, 0, NULL)
- ?: gcry_mpi_scan(&rsa->e, GCRYMPI_FMT_HEX, n, 0, NULL);
+ ?: gcry_mpi_scan(&rsa->e, GCRYMPI_FMT_HEX, e, 0, NULL);
if(err) {
- logger(LOG_ERR, _("Error while reading RSA public key: %s"), gcry_strerror(errno));
+ logger(LOG_ERR, "Error while reading RSA public key: %s", gcry_strerror(errno));
return false;
}
gcry_error_t err = 0;
err = gcry_mpi_scan(&rsa->n, GCRYMPI_FMT_HEX, n, 0, NULL)
- ?: gcry_mpi_scan(&rsa->e, GCRYMPI_FMT_HEX, n, 0, NULL)
- ?: gcry_mpi_scan(&rsa->d, GCRYMPI_FMT_HEX, n, 0, NULL);
+ ?: gcry_mpi_scan(&rsa->e, GCRYMPI_FMT_HEX, e, 0, NULL)
+ ?: gcry_mpi_scan(&rsa->d, GCRYMPI_FMT_HEX, d, 0, NULL);
if(err) {
- logger(LOG_ERR, _("Error while reading RSA public key: %s"), gcry_strerror(errno));
+ logger(LOG_ERR, "Error while reading RSA public key: %s", gcry_strerror(errno));
return false;
}
size_t derlen;
if(!pem_decode(fp, "RSA PUBLIC KEY", derbuf, sizeof derbuf, &derlen)) {
- logger(LOG_ERR, _("Unable to read RSA public key: %s"), strerror(errno));
+ logger(LOG_ERR, "Unable to read RSA public key: %s", strerror(errno));
return NULL;
}
|| !ber_read_mpi(&derp, &derlen, &rsa->n)
|| !ber_read_mpi(&derp, &derlen, &rsa->e)
|| derlen) {
- logger(LOG_ERR, _("Error while decoding RSA public key"));
+ logger(LOG_ERR, "Error while decoding RSA public key");
return NULL;
}
size_t derlen;
if(!pem_decode(fp, "RSA PRIVATE KEY", derbuf, sizeof derbuf, &derlen)) {
- logger(LOG_ERR, _("Unable to read RSA private key: %s"), strerror(errno));
+ logger(LOG_ERR, "Unable to read RSA private key: %s", strerror(errno));
return NULL;
}
|| !ber_read_mpi(&derp, &derlen, NULL)
|| !ber_read_mpi(&derp, &derlen, NULL) // u
|| derlen) {
- logger(LOG_ERR, _("Error while decoding RSA private key"));
+ logger(LOG_ERR, "Error while decoding RSA private key");
return NULL;
}
gcry_mpi_t outmpi = gcry_mpi_new(len * 8);
gcry_mpi_powm(outmpi, inmpi, rsa->e, rsa->n);
+ int pad = len - (gcry_mpi_get_nbits(outmpi) + 7) / 8;
+ while(pad--)
+ *(char *)out++ = 0;
+
check(gcry_mpi_print(GCRYMPI_FMT_USG, out,len, NULL, outmpi));
return true;
gcry_mpi_t outmpi = gcry_mpi_new(len * 8);
gcry_mpi_powm(outmpi, inmpi, rsa->d, rsa->n);
+ int pad = len - (gcry_mpi_get_nbits(outmpi) + 7) / 8;
+ while(pad--)
+ *(char *)out++ = 0;
+
check(gcry_mpi_print(GCRYMPI_FMT_USG, out,len, NULL, outmpi));
return true;