# Security and Testing Scripts

This directory contains scripts for security testing and verification of the clock-bigint library.

## Scripts

### `verify_constant_time.sh`

Verifies constant-time properties of cryptographic operations.

**Usage:**
```bash
./scripts/verify_constant_time.sh
```

**What it does:**
- Runs basic test suite
- Executes constant-time specific tests
- Performs fuzz testing for timing verification
- Checks code for timing-dependent patterns
- Analyzes performance for anomalies
- Looks for branch-free implementation patterns

### `security_test.sh`

Comprehensive security testing suite covering all security aspects.

**Usage:**
```bash
./scripts/security_test.sh
```

**What it does:**
- Unit tests
- Integration tests
- Compliance/property-based tests
- Constant-time verification
- No-std compatibility testing
- Fuzz testing (short runs)
- Security vulnerability scanning
- Code linting
- Memory safety testing
- Documentation coverage
- Benchmark execution
- Cross-platform compatibility

## Continuous Integration

These scripts are designed to be used in CI/CD pipelines:

### GitHub Actions

The scripts are automatically run in the following workflows:
- `ci.yml`: Basic testing and linting
- `fuzz.yml`: Extended fuzz testing
- `bench.yml`: Performance verification

### Local Development

Run these scripts locally during development:

```bash
# Quick security check
./scripts/verify_constant_time.sh

# Full security test suite
./scripts/security_test.sh
```

## Test Results

Both scripts provide detailed output with:
- ✅ Passed tests
- ⚠️ Warnings (non-blocking issues)
- ✗ Failed tests (blocking issues)

## Dependencies

The scripts require:
- `cargo` and `rustc`
- `cargo-fuzz` (optional, for fuzz testing)
- `cargo-audit` (optional, for vulnerability scanning)
- `cross` (optional, for cross-platform testing)

Install optional dependencies:
```bash
cargo install cargo-fuzz
cargo install cargo-audit
cargo install cross
```

## Adding New Tests

When adding new security-related functionality:

1. Update the relevant test functions in the scripts
2. Add new test cases to the existing test suites
3. Update this README with new script capabilities
4. Ensure CI workflows are updated if needed

## Security Considerations

These scripts help verify:
- **Constant-time execution**: No timing leaks
- **Mathematical correctness**: Correct cryptographic results
- **Memory safety**: No buffer overflows or corruption
- **Code quality**: Linting and documentation
- **Performance**: No regressions in critical operations

Always review script output carefully and address any warnings or failures before releasing code.