BigEndianConversions.smali

.class public final Lorg/spongycastle/pqc/math/linearalgebra/BigEndianConversions;
.super Ljava/lang/Object;
.source "BigEndianConversions.java"


# direct methods
.method private constructor <init>()V
    .registers 1

    .prologue
    .line 17
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 19
    return-void
.end method

.method public static I2OSP(I[BI)V
    .registers 6

    .prologue
    .line 81
    add-int/lit8 v0, p2, 0x1

    shr-int/lit8 v1, p0, 0x18

    aput-byte v1, p1, p2

    .line 82
    add-int/lit8 v1, v0, 0x1

    ushr-int/lit8 v2, p0, 0x10

    int-to-byte v2, v2

    aput-byte v2, p1, v0

    .line 83
    add-int/lit8 v0, v1, 0x1

    ushr-int/lit8 v2, p0, 0x8

    int-to-byte v2, v2

    aput-byte v2, p1, v1

    .line 84
    int-to-byte v1, p0

    aput-byte v1, p1, v0

    .line 85
    return-void
.end method

.method public static I2OSP(I[BII)V
    .registers 7

    .prologue
    .line 141
    add-int/lit8 v0, p3, -0x1

    :goto_2
    if-ltz v0, :cond_13

    .line 143
    add-int v1, p2, v0

    add-int/lit8 v2, p3, -0x1

    sub-int/2addr v2, v0

    mul-int/lit8 v2, v2, 0x8

    ushr-int v2, p0, v2

    int-to-byte v2, v2

    aput-byte v2, p1, v1

    .line 141
    add-int/lit8 v0, v0, -0x1

    goto :goto_2

    .line 145
    :cond_13
    return-void
.end method

.method public static I2OSP(J[BI)V
    .registers 8

    .prologue
    .line 118
    add-int/lit8 v0, p3, 0x1

    const/16 v1, 0x38

    ushr-long v2, p0, v1

    long-to-int v1, v2

    int-to-byte v1, v1

    aput-byte v1, p2, p3

    .line 119
    add-int/lit8 v1, v0, 0x1

    const/16 v2, 0x30

    ushr-long v2, p0, v2

    long-to-int v2, v2

    int-to-byte v2, v2

    aput-byte v2, p2, v0

    .line 120
    add-int/lit8 v0, v1, 0x1

    const/16 v2, 0x28

    ushr-long v2, p0, v2

    long-to-int v2, v2

    int-to-byte v2, v2

    aput-byte v2, p2, v1

    .line 121
    add-int/lit8 v1, v0, 0x1

    const/16 v2, 0x20

    ushr-long v2, p0, v2

    long-to-int v2, v2

    int-to-byte v2, v2

    aput-byte v2, p2, v0

    .line 122
    add-int/lit8 v0, v1, 0x1

    const/16 v2, 0x18

    ushr-long v2, p0, v2

    long-to-int v2, v2

    int-to-byte v2, v2

    aput-byte v2, p2, v1

    .line 123
    add-int/lit8 v1, v0, 0x1

    const/16 v2, 0x10

    ushr-long v2, p0, v2

    long-to-int v2, v2

    int-to-byte v2, v2

    aput-byte v2, p2, v0

    .line 124
    add-int/lit8 v0, v1, 0x1

    const/16 v2, 0x8

    ushr-long v2, p0, v2

    long-to-int v2, v2

    int-to-byte v2, v2

    aput-byte v2, p2, v1

    .line 125
    long-to-int v1, p0

    int-to-byte v1, v1

    aput-byte v1, p2, v0

    .line 126
    return-void
.end method

.method public static I2OSP(I)[B
    .registers 4

    .prologue
    .line 30
    const/4 v0, 0x4

    new-array v0, v0, [B

    .line 31
    const/4 v1, 0x0

    shr-int/lit8 v2, p0, 0x18

    aput-byte v2, v0, v1

    .line 32
    const/4 v1, 0x1

    ushr-int/lit8 v2, p0, 0x10

    int-to-byte v2, v2

    aput-byte v2, v0, v1

    .line 33
    const/4 v1, 0x2

    ushr-int/lit8 v2, p0, 0x8

    int-to-byte v2, v2

    aput-byte v2, v0, v1

    .line 34
    const/4 v1, 0x3

    int-to-byte v2, p0

    aput-byte v2, v0, v1

    .line 35
    return-object v0
.end method

.method public static I2OSP(II)[B
    .registers 6

    .prologue
    .line 53
    if-gez p0, :cond_4

    .line 55
    const/4 v0, 0x0

    .line 68
    :cond_3
    return-object v0

    .line 57
    :cond_4
    invoke-static {p0}, Lorg/spongycastle/pqc/math/linearalgebra/IntegerFunctions;->ceilLog256(I)I

    move-result v2

    .line 58
    if-le v2, p1, :cond_12

    .line 60
    new-instance v0, Ljava/lang/ArithmeticException;

    const-string v1, "Cannot encode given integer into specified number of octets."

    invoke-direct {v0, v1}, Ljava/lang/ArithmeticException;-><init>(Ljava/lang/String;)V

    throw v0

    .line 63
    :cond_12
    new-array v0, p1, [B

    .line 64
    add-int/lit8 v1, p1, -0x1

    :goto_16
    sub-int v3, p1, v2

    if-lt v1, v3, :cond_3

    .line 66
    add-int/lit8 v3, p1, -0x1

    sub-int/2addr v3, v1

    mul-int/lit8 v3, v3, 0x8

    ushr-int v3, p0, v3

    int-to-byte v3, v3

    aput-byte v3, v0, v1

    .line 64
    add-int/lit8 v1, v1, -0x1

    goto :goto_16
.end method

.method public static I2OSP(J)[B
    .registers 8

    .prologue
    const/16 v4, 0x8

    .line 96
    new-array v0, v4, [B

    .line 97
    const/4 v1, 0x0

    const/16 v2, 0x38

    ushr-long v2, p0, v2

    long-to-int v2, v2

    int-to-byte v2, v2

    aput-byte v2, v0, v1

    .line 98
    const/4 v1, 0x1

    const/16 v2, 0x30

    ushr-long v2, p0, v2

    long-to-int v2, v2

    int-to-byte v2, v2

    aput-byte v2, v0, v1

    .line 99
    const/4 v1, 0x2

    const/16 v2, 0x28

    ushr-long v2, p0, v2

    long-to-int v2, v2

    int-to-byte v2, v2

    aput-byte v2, v0, v1

    .line 100
    const/4 v1, 0x3

    const/16 v2, 0x20

    ushr-long v2, p0, v2

    long-to-int v2, v2

    int-to-byte v2, v2

    aput-byte v2, v0, v1

    .line 101
    const/4 v1, 0x4

    const/16 v2, 0x18

    ushr-long v2, p0, v2

    long-to-int v2, v2

    int-to-byte v2, v2

    aput-byte v2, v0, v1

    .line 102
    const/4 v1, 0x5

    const/16 v2, 0x10

    ushr-long v2, p0, v2

    long-to-int v2, v2

    int-to-byte v2, v2

    aput-byte v2, v0, v1

    .line 103
    const/4 v1, 0x6

    ushr-long v2, p0, v4

    long-to-int v2, v2

    int-to-byte v2, v2

    aput-byte v2, v0, v1

    .line 104
    const/4 v1, 0x7

    long-to-int v2, p0

    int-to-byte v2, v2

    aput-byte v2, v0, v1

    .line 105
    return-object v0
.end method

.method public static OS2IP([B)I
    .registers 5

    .prologue
    const/4 v0, 0x0

    .line 159
    array-length v1, p0

    const/4 v2, 0x4

    if-le v1, v2, :cond_d

    .line 161
    new-instance v0, Ljava/lang/ArithmeticException;

    const-string v1, "invalid input length"

    invoke-direct {v0, v1}, Ljava/lang/ArithmeticException;-><init>(Ljava/lang/String;)V

    throw v0

    .line 163
    :cond_d
    array-length v1, p0

    if-nez v1, :cond_11

    .line 172
    :goto_10
    return v0

    :cond_11
    move v1, v0

    .line 168
    :goto_12
    array-length v2, p0

    if-ge v0, v2, :cond_24

    .line 170
    aget-byte v2, p0, v0

    and-int/lit16 v2, v2, 0xff

    array-length v3, p0

    add-int/lit8 v3, v3, -0x1

    sub-int/2addr v3, v0

    mul-int/lit8 v3, v3, 0x8

    shl-int/2addr v2, v3

    or-int/2addr v1, v2

    .line 168
    add-int/lit8 v0, v0, 0x1

    goto :goto_12

    :cond_24
    move v0, v1

    .line 172
    goto :goto_10
.end method

.method public static OS2IP([BI)I
    .registers 5

    .prologue
    .line 185
    add-int/lit8 v0, p1, 0x1

    aget-byte v1, p0, p1

    and-int/lit16 v1, v1, 0xff

    shl-int/lit8 v1, v1, 0x18

    .line 186
    add-int/lit8 v2, v0, 0x1

    aget-byte v0, p0, v0

    and-int/lit16 v0, v0, 0xff

    shl-int/lit8 v0, v0, 0x10

    or-int/2addr v0, v1

    .line 187
    add-int/lit8 v1, v2, 0x1

    aget-byte v2, p0, v2

    and-int/lit16 v2, v2, 0xff

    shl-int/lit8 v2, v2, 0x8

    or-int/2addr v0, v2

    .line 188
    aget-byte v1, p0, v1

    and-int/lit16 v1, v1, 0xff

    or-int/2addr v0, v1

    .line 189
    return v0
.end method

.method public static OS2IP([BII)I
    .registers 7

    .prologue
    const/4 v0, 0x0

    .line 206
    array-length v1, p0

    if-eqz v1, :cond_b

    array-length v1, p0

    add-int v2, p1, p2

    add-int/lit8 v2, v2, -0x1

    if-ge v1, v2, :cond_c

    .line 215
    :cond_b
    return v0

    :cond_c
    move v1, v0

    .line 211
    :goto_d
    if-ge v1, p2, :cond_b

    .line 213
    add-int v2, p1, v1

    aget-byte v2, p0, v2

    and-int/lit16 v2, v2, 0xff

    sub-int v3, p2, v1

    add-int/lit8 v3, v3, -0x1

    mul-int/lit8 v3, v3, 0x8

    shl-int/2addr v2, v3

    or-int/2addr v2, v0

    .line 211
    add-int/lit8 v0, v1, 0x1

    move v1, v0

    move v0, v2

    goto :goto_d
.end method

.method public static OS2LIP([BI)J
    .registers 10

    .prologue
    const-wide/16 v6, 0xff

    .line 228
    add-int/lit8 v0, p1, 0x1

    aget-byte v1, p0, p1

    int-to-long v2, v1

    and-long/2addr v2, v6

    const/16 v1, 0x38

    shl-long/2addr v2, v1

    .line 229
    add-int/lit8 v1, v0, 0x1

    aget-byte v0, p0, v0

    int-to-long v4, v0

    and-long/2addr v4, v6

    const/16 v0, 0x30

    shl-long/2addr v4, v0

    or-long/2addr v2, v4

    .line 230
    add-int/lit8 v0, v1, 0x1

    aget-byte v1, p0, v1

    int-to-long v4, v1

    and-long/2addr v4, v6

    const/16 v1, 0x28

    shl-long/2addr v4, v1

    or-long/2addr v2, v4

    .line 231
    add-int/lit8 v1, v0, 0x1

    aget-byte v0, p0, v0

    int-to-long v4, v0

    and-long/2addr v4, v6

    const/16 v0, 0x20

    shl-long/2addr v4, v0

    or-long/2addr v2, v4

    .line 232
    add-int/lit8 v0, v1, 0x1

    aget-byte v1, p0, v1

    int-to-long v4, v1

    and-long/2addr v4, v6

    const/16 v1, 0x18

    shl-long/2addr v4, v1

    or-long/2addr v2, v4

    .line 233
    add-int/lit8 v1, v0, 0x1

    aget-byte v0, p0, v0

    and-int/lit16 v0, v0, 0xff

    shl-int/lit8 v0, v0, 0x10

    int-to-long v4, v0

    or-long/2addr v2, v4

    .line 234
    add-int/lit8 v0, v1, 0x1

    aget-byte v1, p0, v1

    and-int/lit16 v1, v1, 0xff

    shl-int/lit8 v1, v1, 0x8

    int-to-long v4, v1

    or-long/2addr v2, v4

    .line 235
    aget-byte v0, p0, v0

    and-int/lit16 v0, v0, 0xff

    int-to-long v0, v0

    or-long/2addr v0, v2

    .line 236
    return-wide v0
.end method

.method public static toByteArray([I)[B
    .registers 5

    .prologue
    .line 247
    array-length v0, p0

    shl-int/lit8 v0, v0, 0x2

    new-array v1, v0, [B

    .line 248
    const/4 v0, 0x0

    :goto_6
    array-length v2, p0

    if-ge v0, v2, :cond_13

    .line 250
    aget v2, p0, v0

    shl-int/lit8 v3, v0, 0x2

    invoke-static {v2, v1, v3}, Lorg/spongycastle/pqc/math/linearalgebra/BigEndianConversions;->I2OSP(I[BI)V

    .line 248
    add-int/lit8 v0, v0, 0x1

    goto :goto_6

    .line 252
    :cond_13
    return-object v1
.end method

.method public static toByteArray([II)[B
    .registers 7

    .prologue
    const/4 v0, 0x0

    .line 266
    array-length v2, p0

    .line 267
    new-array v3, p1, [B

    move v1, v0

    .line 269
    :goto_5
    add-int/lit8 v4, v2, -0x2

    if-gt v0, v4, :cond_13

    .line 271
    aget v4, p0, v0

    invoke-static {v4, v3, v1}, Lorg/spongycastle/pqc/math/linearalgebra/BigEndianConversions;->I2OSP(I[BI)V

    .line 269
    add-int/lit8 v0, v0, 0x1

    add-int/lit8 v1, v1, 0x4

    goto :goto_5

    .line 273
    :cond_13
    add-int/lit8 v0, v2, -0x1

    aget v0, p0, v0

    sub-int v2, p1, v1

    invoke-static {v0, v3, v1, v2}, Lorg/spongycastle/pqc/math/linearalgebra/BigEndianConversions;->I2OSP(I[BII)V

    .line 274
    return-object v3
.end method

.method public static toIntArray([B)[I
    .registers 7

    .prologue
    const/4 v0, 0x0

    .line 285
    array-length v1, p0

    add-int/lit8 v1, v1, 0x3

    div-int/lit8 v2, v1, 0x4

    .line 286
    array-length v1, p0

    and-int/lit8 v3, v1, 0x3

    .line 287
    new-array v4, v2, [I

    move v1, v0

    .line 290
    :goto_c
    add-int/lit8 v5, v2, -0x2

    if-gt v0, v5, :cond_1b

    .line 292
    invoke-static {p0, v1}, Lorg/spongycastle/pqc/math/linearalgebra/BigEndianConversions;->OS2IP([BI)I

    move-result v5

    aput v5, v4, v0

    .line 290
    add-int/lit8 v0, v0, 0x1

    add-int/lit8 v1, v1, 0x4

    goto :goto_c

    .line 294
    :cond_1b
    if-eqz v3, :cond_26

    .line 296
    add-int/lit8 v0, v2, -0x1

    invoke-static {p0, v1, v3}, Lorg/spongycastle/pqc/math/linearalgebra/BigEndianConversions;->OS2IP([BII)I

    move-result v1

    aput v1, v4, v0

    .line 303
    :goto_25
    return-object v4

    .line 300
    :cond_26
    add-int/lit8 v0, v2, -0x1

    invoke-static {p0, v1}, Lorg/spongycastle/pqc/math/linearalgebra/BigEndianConversions;->OS2IP([BI)I

    move-result v1

    aput v1, v4, v0

    goto :goto_25
.end method