diff options
Diffstat (limited to 'bcprov/src/main/java/org/bouncycastle/asn1/x9/X9IntegerConverter.java')
-rw-r--r-- | bcprov/src/main/java/org/bouncycastle/asn1/x9/X9IntegerConverter.java | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/bcprov/src/main/java/org/bouncycastle/asn1/x9/X9IntegerConverter.java b/bcprov/src/main/java/org/bouncycastle/asn1/x9/X9IntegerConverter.java index 16a803cc..2851bcae 100644 --- a/bcprov/src/main/java/org/bouncycastle/asn1/x9/X9IntegerConverter.java +++ b/bcprov/src/main/java/org/bouncycastle/asn1/x9/X9IntegerConverter.java @@ -5,20 +5,43 @@ import java.math.BigInteger; import org.bouncycastle.math.ec.ECCurve; import org.bouncycastle.math.ec.ECFieldElement; +/** + * A class which converts integers to byte arrays, allowing padding and calculations + * to be done according the the filed size of the curve or field element involved. + */ public class X9IntegerConverter { + /** + * Return the curve's field size in bytes. + * + * @param c the curve of interest. + * @return the field size in bytes (rounded up). + */ public int getByteLength( ECCurve c) { return (c.getFieldSize() + 7) / 8; } + /** + * Return the field element's field size in bytes. + * + * @param fe the field element of interest. + * @return the field size in bytes (rounded up). + */ public int getByteLength( ECFieldElement fe) { return (fe.getFieldSize() + 7) / 8; } + /** + * Convert an integer to a byte array, ensuring it is exactly qLength long. + * + * @param s the integer to be converted. + * @param qLength the length + * @return the resulting byte array. + */ public byte[] integerToBytes( BigInteger s, int qLength) |