From acf44f2f60abcb3f705efded5a01c66feea95609 Mon Sep 17 00:00:00 2001 From: Jason Wright Date: Fri, 10 May 2002 15:25:40 +0000 Subject: - Add a set length insn for the result (length gets zotted by the shift right) - Use length to determine how much to copy out, and bzero the rest --- sys/dev/pci/lofn.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'sys/dev/pci') diff --git a/sys/dev/pci/lofn.c b/sys/dev/pci/lofn.c index 3d82e667e03..37f90f48122 100644 --- a/sys/dev/pci/lofn.c +++ b/sys/dev/pci/lofn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lofn.c,v 1.17 2002/05/09 21:43:17 jason Exp $ */ +/* $OpenBSD: lofn.c,v 1.18 2002/05/10 15:25:39 jason Exp $ */ /* * Copyright (c) 2001-2002 Jason L. Wright (jason@thought.net) @@ -437,7 +437,11 @@ lofn_modexp_start(sc, q) ip += 4; WRITE_REG(sc, LOFN_REL_INSTR + ip, - LOFN_INSTR2(OP_DONE, OP_CODE_SR, 3, 3, nshift)); + LOFN_INSTR2(0, OP_CODE_SR, 3, 3, nshift)); + ip += 4; + + WRITE_REG(sc, LOFN_REL_INSTR + ip, + LOFN_INSTR2(OP_DONE, OP_CODE_TAG, 3, 3, bits)); ip += 4; } @@ -463,10 +467,23 @@ lofn_modexp_finish(sc, q) struct lofn_q *q; { struct cryptkop *krp = q->q_krp; + int reglen, crplen; lofn_read_reg(sc, 3, &sc->sc_tmp); - bcopy(sc->sc_tmp.b, krp->krp_param[LOFN_MODEXP_PAR_C].crp_p, - (krp->krp_param[LOFN_MODEXP_PAR_C].crp_nbits + 7) / 8); + + reglen = ((READ_REG(sc, LOFN_LENADDR(LOFN_WIN_2, 3)) & LOFN_LENMASK) + + 7) / 8; + crplen = (krp->krp_param[LOFN_MODEXP_PAR_C].crp_nbits + 7) / 8; + + if (crplen <= reglen) + bcopy(sc->sc_tmp.b, krp->krp_param[LOFN_MODEXP_PAR_C].crp_p, + reglen); + else { + bcopy(sc->sc_tmp.b, krp->krp_param[LOFN_MODEXP_PAR_C].crp_p, + reglen); + bzero(krp->krp_param[LOFN_MODEXP_PAR_C].crp_p + reglen, + crplen - reglen); + } bzero(&sc->sc_tmp, sizeof(sc->sc_tmp)); lofn_zero_reg(sc, 0); lofn_zero_reg(sc, 1); -- cgit v1.2.3