Skip to content

Conversation

@ic0ns
Copy link
Contributor

@ic0ns ic0ns commented Jun 11, 2025

Summary

  • Redesigned the ModifiableVariableProperty annotation to be more generic and informative
  • Replaced Type enum with Purpose enum for protocol-agnostic semantic classification
  • Replaced Format enum with Encoding enum with comprehensive data encoding formats
  • Added length constraint parameters: minLength, maxLength, expectedLength for better field specification
  • Removed protocol-specific parameters to improve generalization across different protocols
  • Enhanced ModifiableVariableAnalyzer with new methods for length constraint analysis
  • Updated test suite with comprehensive coverage of new features

Key Improvements

Better Length Information: The annotation now supports specifying minimum, maximum, and expected length constraints for fields, providing crucial structural information.

Protocol Agnostic: Removed TLS-specific elements and made the annotation suitable for any protocol or data structure.

Enhanced Encoding Support: Added comprehensive encoding format options including ASN.1, PKCS formats, PEM, DER, Base64, endianness options, and more.

Improved Analysis: New utility methods for grouping fields by length constraints and finding fields with specific length requirements.

Usage Examples

// Length field with constraints  
@ModifiableVariableProperty(purpose = Purpose.LENGTH, minLength = 1, maxLength = 4)
private ModifiableInteger messageLength;

// Fixed-length random value
@ModifiableVariableProperty(purpose = Purpose.RANDOM, expectedLength = 32)
private ModifiableByteArray nonce;

// Variable-length signature with encoding
@ModifiableVariableProperty(
    purpose = Purpose.SIGNATURE,
    encoding = Encoding.ASN1_DER,
    minLength = 64,
    maxLength = 256,
    critical = true)
private ModifiableByteArray digitalSignature;

Resolves #203

… constraints

- Replaced Type enum with Purpose enum for protocol-agnostic semantic classification
- Replaced Format enum with Encoding enum for comprehensive data encoding formats
- Added length constraint parameters: minLength, maxLength, expectedLength
- Removed protocol-specific fields for better generalization
- Updated ModifiableVariableAnalyzer with new analysis methods for length constraints
- Enhanced test suite to cover new features and length validation capabilities
- Improved documentation with comprehensive usage examples

This design provides more structural information about fields while being
applicable across different protocols and data formats, not just TLS-specific.

Resolves: #203
Copy link
Contributor Author

@ic0ns ic0ns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the code that is not needed anymore

Comment on lines 305 to 316
/**
* Finds all fields marked as critical.
*
* @param clazz The class to analyze
* @return A list of fields marked as critical
*/
public static List<Field> getCriticalFields(Class<?> clazz) {
return getAnnotatedFields(clazz).stream()
.filter(field -> field.getAnnotation(ModifiableVariableProperty.class).critical())
.collect(Collectors.toList());
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this

ic0ns and others added 6 commits June 11, 2025 14:01
- Simplify verbose JavaDoc descriptions
- Update signature example with plausible length values (70-73 bytes)
- Remove critical parameter from annotation and all related usage
- Remove "or credential" from CERTIFICATE documentation
- Clarify expectedLength as hint for typical length
- Update example comments for clarity

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Remove expectedLength usage from random value example in JavaDoc to address
reviewer feedback about its semantics.
VERSION was too protocol-specific. Replace with existing CONSTANT purpose
to maintain protocol-agnostic design.
Remove EXTENSION, CONTROL, and PAYLOAD purposes to make the annotation
more protocol-agnostic. Updated JavaDoc example to use PLAINTEXT instead.
@ic0ns ic0ns merged commit 4e048bd into main Jun 11, 2025
12 checks passed
@ic0ns ic0ns deleted the refactor-modifiable-variable-property-203 branch June 12, 2025 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor ModifiableVariableProperty class

2 participants