Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
ghewgill committed Feb 8, 2024
1 parent 8d4c229 commit bdf54a8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 17 deletions.
10 changes: 5 additions & 5 deletions samples/otp/otp.neon
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ FUNCTION b32decode(s: String): Bytes
IF "A" <= s[i] <= "Z" THEN
x := string.toCodePoint(s[i]) - string.toCodePoint("A")
ELSIF "0" <= s[i] <= "7" THEN
x := string.toCodePoint(s[i]) - string.toCodePoint("2") + 26
x := (string.toCodePoint(s[i]) - string.toCodePoint("2")) + 26
ELSE
PANIC "Invalid base64 character"
END IF
b[5*i INTDIV 8] := binary.and32(0xff, binary.or32(b[5*i INTDIV 8], binary.shiftRight32(binary.shiftLeft32(x, 3), 5*i MOD 8)))
IF 5*i MOD 8 >= 4 THEN
b[5*i INTDIV 8 + 1] := binary.and32(0xff, binary.or32(b[5*i INTDIV 8 + 1], binary.shiftLeft32(x, 3 + 8 - (5*i MOD 8))))
b[(5*i) INTDIV 8] := binary.and32(0xff, binary.or32(b[(5*i) INTDIV 8], binary.shiftRight32(binary.shiftLeft32(x, 3), (5*i) MOD 8)))
IF (5*i) MOD 8 >= 4 THEN
b[((5*i) INTDIV 8) + 1] := binary.and32(0xff, binary.or32(b[((5*i) INTDIV 8) + 1], binary.shiftLeft32(x, 3 + 8 - ((5*i) MOD 8))))
END IF
END FOR
RETURN b.toBytes()
Expand All @@ -45,7 +45,7 @@ TESTCASE hmac_sha1(kk.encodeUTF8(), mm.encodeUTF8()) = HEXBYTES "de7c9b85b8b78
FUNCTION hotp(sbytes: Bytes, movingFactor: Number): String
VAR data: Array<Number> := [0,0,0,0]
FOR i := 4 TO 7 DO
data.append(binary.and32(0xff, binary.shiftRight32(movingFactor, 56 - 8*i)))
data.append(binary.and32(0xff, binary.shiftRight32(movingFactor, 56 - (8*i))))
END FOR
LET r: Bytes := hmac_sha1(sbytes, data.toBytes())
LET a: Array<Number> := r.toArray()
Expand Down
12 changes: 0 additions & 12 deletions src/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -828,18 +828,6 @@ std::unique_ptr<Expression> Parser::parseArithmetic()
left.reset(new DivisionExpression(tok_op, std::move(left), std::move(right)));
break;
}
case INTDIV: {
++i;
std::unique_ptr<Expression> right = parseCompoundExpression();
left.reset(new IntegerDivisionExpression(tok_op, std::move(left), std::move(right)));
break;
}
case MOD: {
++i;
std::unique_ptr<Expression> right = parseCompoundExpression();
left.reset(new ModuloExpression(tok_op, std::move(left), std::move(right)));
break;
}
default:
break;
}
Expand Down

0 comments on commit bdf54a8

Please sign in to comment.